📄 displaymain.java
字号:
connect_fail_screen(); } } } private void display_Image(boolean ready){ // StringItem ImageString; Image preview_image; if (ready){ String preview_url = "http://" + ip + "/remote_temp/thumbnail_" + CurrentUser +".jpg"; System.out.println(preview_url); DataInputStream is = null; StringBuffer sb = new StringBuffer(); preview_image = null; try{ HttpConnection c = (HttpConnection) Connector.open(preview_url); int len = (int)c.getLength(); if (len > 0) { is = c.openDataInputStream(); byte[] data = new byte[len]; is.readFully(data); preview_image = Image.createImage(data, 0, len); } is.close(); c.close(); } catch (Exception e) { e.printStackTrace(); } preview_image_screen =new Message (preview_image,5); display.setCurrent(preview_image_screen); preview_image_screen.addCommand(okCommand); preview_image_screen.addCommand(backCommand); preview_image_screen.setCommandListener(new CommandListener() { public void commandAction (Command c, Displayable d) { if (c==okCommand) { currentpath=back_folder; file_selected(); } if (c==backCommand) { currentpath = back_folder; display.setCurrent(file_list_screen); file_list_screen.draw_choice(); } } }); /*(ImageItem imgItem = new ImageItem("", preview_image, ImageItem.LAYOUT_NEWLINE_AFTER | ImageItem.LAYOUT_LEFT, null); display_Image.append(imgItem);*/ } else{ preview_image_fail_screen =new Message ("Cannot preview the image.",0,this); display.setCurrent(preview_image_fail_screen); preview_image_fail_screen.addCommand(exitCommand); preview_image_fail_screen.addCommand(backCommand); preview_image_fail_screen.setCommandListener(new CommandListener() { public void commandAction (Command c, Displayable d) { if (c==exitCommand) { destroyApp(false); notifyDestroyed(); } if (c==backCommand) { currentpath = back_folder; display.setCurrent(file_list_screen); file_list_screen.draw_choice(); } } }); /* ImageString = new StringItem ("","Cannot preview the image."); display_Image.append(ImageString); */ } /* display_Image.addCommand(backCommand); display_Image.setCommandListener(this); display.setCurrent(display_Image); currentScreen ="display_Image"; */ } public class sendEmail implements Runnable{ public void run(){ try{ boolean sent = false; file_toSend = encode_char(file_toSend); title = encode_char(title); content =encode_char(content); sent = service.sendEmail(CurrentUser,email,title,content,file_toSend,"remote5"); if(sent) send_sucess_screen(); else send_fail_screen(); } catch (Exception e){ connect_fail_screen(); } } } private void verify_send() { Thread th = new Thread(new sendEmail()); th.start(); email_waiting_screen=new Animation(display, this,3); display.setCurrent(email_waiting_screen); } private boolean verify_email() { if (title.equals("")) { title="(no subject)"; return true; }else{ return true; } } private void start_screen() { if (sound_setting) { try { success=getClass().getResourceAsStream("/start.mp3"); p=Manager.createPlayer(success,"audio/mpeg"); p.realize(); p.setLoopCount(1); VolumeControl volume =(VolumeControl) p.getControl ("VolumeControl"); volume.setLevel(100); p.start(); }catch (Exception e) {System.out.println(e);} } display.vibrate(500); start_screen = new Animation(display, this,0); display.setCurrent(start_screen); long displayTime = 2000; //start the timer timer.schedule (new TimerTask() { public void run() { start_screen_disappear(); } }, displayTime); } private void start_screen_disappear() { timer.cancel(); ip=default_ip; login_screen(ip,ln,pw); } public void function_screen() { function_screen = new Function(this); display.setCurrent(function_screen); } public void file_list_screen() { file_list_screen = new FileList(this); file_list_screen.addCommand(backCommand); file_list_screen.addCommand(okCommand); file_list_screen.setCommandListener(new CommandListener() { public void commandAction (Command c, Displayable d) { String filename; if (c==backCommand) { for (int i =0; i <file_selected.length; i++){ file_selected[i] =null; } currentpath=""; file_list_screen.select_pressed=true; function_screen(); } if (c==okCommand) { file_selected(); } if (c==mycomputerCommand) { file_list_screen.progress_h = file_list_screen.screenHeight/8+1; file_list_screen.removeCommand(previewCommand); file_list_screen.removeCommand(detailCommand); currentpath=""; file_list_screen.choice =0; file_list_screen.display_choice =0; file_list_screen.type=0; file_list_screen.removeCommand(parentCommand); file_list_screen.removeCommand(mycomputerCommand); update_filelist(0); } if (c==parentCommand) { file_list_screen.progress_h = file_list_screen.screenHeight/8+1; file_list_screen.removeCommand(previewCommand); file_list_screen.removeCommand(detailCommand); if (currentpath.indexOf('\\') == currentpath.lastIndexOf('\\')) { currentpath=""; file_list_screen.choice =0; file_list_screen.display_choice =0; file_list_screen.type=0; file_list_screen.removeCommand(parentCommand); file_list_screen.removeCommand(mycomputerCommand); update_filelist(0); }else { currentpath = currentpath.substring(0,currentpath.lastIndexOf('\\')); currentpath = currentpath.substring(0,currentpath.lastIndexOf('\\')+1); //update the name of drive ,dir,name if (currentpath.indexOf('\\') == currentpath.lastIndexOf('\\')) { file_list_screen.selected_text=currentpath.substring(0,currentpath.lastIndexOf('\\')); file_list_screen.choice =0; file_list_screen.display_choice =0; file_list_screen.type=1; update_filelist(1); }else { file_list_screen.selected_text=currentpath.substring(0,currentpath.lastIndexOf('\\')); file_list_screen.selected_text=file_list_screen.selected_text.substring(file_list_screen.selected_text.lastIndexOf('\\')+1,file_list_screen.selected_text.length()); file_list_screen.choice =0; file_list_screen.display_choice =0; file_list_screen.type=2; update_filelist(1); } } } if ( c == detailCommand || c == previewCommand){ back_folder = currentpath; filename = file_name[file_list_screen.choice-dir_name.length]; currentpath+=filename; int name_length = filename.length(); String temp; int name_start = name_length; for (int i = name_length-1; i >=0 ; i--){ temp = filename.substring(i,i+1); if (temp.equals(".")){ name_start = i + 1; break; } } if (name_start == name_length){ file_type = "Unknown"; } else{ file_type = filename.substring(name_start,name_length); file_type = file_type.toUpperCase(); } if (c==previewCommand) { if ( file_type.compareTo("JPG") == 0 || file_type.compareTo("PNG") == 0 || file_type.compareTo("GIF") == 0 ) { Thread th = new Thread(new previewImage()); th.start(); display.setCurrent(files_waiting_screen); } else{ // fail to display image //display_image(false); preview_image_fail_screen(); } } else if (c== detailCommand) { Thread th = new Thread(new displayDetails()); th.start(); display.setCurrent(files_waiting_screen); } } } }); display.setCurrent(file_list_screen); }public void confirm_file_screen() { display.vibrate(500); confirm_file_screen =new Message ("Confirm to select this file? ",1 , this); display.setCurrent(confirm_file_screen); confirm_file_screen.addCommand(yesCommand); confirm_file_screen.addCommand(noCommand); confirm_file_screen.setCommandListener(new CommandListener() { public void commandAction (Command c, Displayable d) { if (c==yesCommand) { String temp_path=currentpath; currentpath +=file_name[file_list_screen.choice-dir_name.length]; for (int i =0; i <file_selected.length; i++){ if (file_selected[i] ==null){ file_selected[i] = currentpath; file_list_screen.no_file_selected++; break; } } currentpath=""; file_list_screen.select_pressed=true; if (file_list_screen.no_file_selected==file_selected.length) { transfer_screen("","",""); }else { file_more_screen(); currentpath=temp_path; } } if (c==noCommand) { display.setCurrent(file_list_screen); file_list_screen.draw_choice(); } } });}public void preview_image_fail_screen() { display.vibrate(500); preview_image_fail_screen =new Message ("It is not a valid image file. ",0 , this); display.setCurrent(preview_image_fail_screen); preview_image_fail_screen.addCommand(backCommand); preview_image_fail_screen.addCommand(exitCommand); preview_image_fail_screen.setCommandListener(new CommandListener() { public void commandAction (Command c, Displayable d) { if (c==exitCommand) { destroyApp(false); notifyDestroyed(); } if (c==backCommand) { currentpath = back_folder; display.setCurrent(file_list_screen); file_list_screen.draw_choice(); } } });} public void file_selected() { file_list_screen.progress_h = file_list_screen.screenHeight/8+1; if (file_list_screen.type==0) { file_list_screen.addCommand(parentCommand); file_list_screen.addCommand(mycomputerCommand); file_list_screen.selected_text =drive_name[file_list_screen.choice].substring(0,drive_name[file_list_screen.choice].length()-1); currentpath +=drive_name[file_list_screen.choice]; //update the name of drive, dir, name file_list_screen.type=1; file_list_screen.choice=0; file_list_screen.display_choice=0; update_filelist(1); }else{ if (file_list_screen.choice < dir_name.length) { file_list_screen.selected_text = dir_name[file_list_screen.choice]; currentpath += dir_name[file_list_screen.choice]; currentpath += "\\"; //update the name of drive, dir, name file_list_screen.type=2; file_list_screen.choice =0; file_list_screen.display_choice=0; update_filelist(1); } if (file_list_screen.choice >=dir_name.length) { confirm_file_screen(); } } } public void file_detail_screen(String date,long size,boolean hidden) { file_detail_screen = new Message(currentpath,file_type,date,size,hidden,3); display.setCurrent(file_detail_screen); file_detail_screen.addCommand(backCommand); file_detail_screen.addCommand(okCommand); file_detail_screen.setCommandListener(new CommandListener() { public void commandAction (Command c, Displayable d) { if (c==okCommand) { currentpath=back_folder; file_selected(); } if (c==backCommand) { currentpath = back_folder; display.setCurrent(file_list_screen); file_list_screen.draw_choice(); } } }); } public void help_screen() { help_screen =new Message ("Select File Transfer for sending files in remote computer by email. Select Setting to change the sound setting and default IP address. In the File Transfer function, select the file you wanted. By pressing Details, the file details will be shown. By pressing Preview, the preview image will be shown. By pressing Parent folder, the parent directory will be shown. Press okay to confirm file(s) for sending. After selecting the files, the email screen is displayed. Input Email, Title and Content. Press OK to transfer the file(s). ",4, this); display.setCurrent(help_screen); help_screen.addCommand(backCommand); help_screen.addCommand(exitCommand); help_screen.setCommandListener(new CommandListener() { public void commandAction (Command c, Displayable d) { if (c==exitCommand) { destroyApp(false); notifyDestroyed(); } if (c==backCommand) { help_screen.select_pressed=true; function_screen();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -