⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mailform.java

📁 手机邮箱撒的方式方式方式的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
        private static class MultimediaMode extends ViewingModesWithActions {            private MultimediaMode(String viewingModeString) {                super(viewingModeString);            }            protected boolean displayBodyPart(Graphics g, MailForm mailForm) {                mailForm.displayMultimediaBodyPart(g);                return true;            }            protected String getBodyPartContent(MessageHeader msgHeader, byte currAttachmentID) {                // multimedia content is raw data, so does not return anything.                return "";            }        }        /**         * Class with actions of viewing mode NO_VIEW_MODE.         */        private static class NoViewMode extends ViewingModesWithActions {            private NoViewMode(String viewingModeString) {                super(viewingModeString);            }            protected boolean prepareForViewingBP(BodyPart actBodyPart, byte ID, MailForm mailForm) {                MujMail.mujmail.alert.setAlert(mailForm, mailForm.attchList, Lang.get(Lang.ALRT_MF_UNSUPPORTED_FORMAT), MyAlert.DEFAULT, AlertType.ERROR);                return false;            }            protected boolean isViewable(BodyPart actBodyPart, Displayable attchList) {                MujMail.mujmail.alert.setAlert(this, attchList, Lang.get(Lang.ALRT_MF_UNSUPPORTED_FORMAT), MyAlert.DEFAULT, AlertType.ERROR);                return false;            }        }        /**         * Class represents mode for viewing HMTL content.         *          * @author Betlista         */        private static class HTMLMode extends PlainTextMode {        	public HTMLMode(String viewingModeString) {				super(viewingModeString);			}        	        	protected boolean displayBodyPart(Graphics g, MailForm mailForm) {        		  if (DEBUG) System.out.println("DEBUG HTMLMode.displayBodyPart(Graphics, MailForm) - start");        		try {                                //#ifdef MUJMAIL_HTML                                mailForm.displayHTMLBodyPart( g );                                //#else//#                                 mailForm.displayPlainTextBodyPart( g );                                //#endif                                mailForm.displayPlainTextBodyPart(g); // TODO remove tags                                        		} catch (Throwable t) {        			System.err.println("Problem displaying HTML:");        			System.out.println("--- HTML START ---");        			System.out.println( mailForm.textBodyString );        			System.out.println("--- HTML END ---");        			t.printStackTrace();        		}        		return true;        	}            protected String preprocessBodyPartBeforeDisplaying(MailForm mailFrom) {                //#ifdef MUJMAIL_HTML                return mailFrom.textBodyString;                //#else//#                 return Functions.removeTags(mailFrom.textBodyString);                //#endif            }        }    }    private void updateEditButton() {        removeCommand(edit);        if (callBox instanceof InBox) {            edit = new Command("Bounce", Command.ITEM, 10);        } else {            edit = new Command(Lang.get(Lang.BTN_EDIT), Command.ITEM, 10);        }        addCommand(edit);    }        private void displayMultimediaBodyPart(Graphics g) {        String extension = msgHeader.getBpExtension(currAttachmentID).toLowerCase();        if (extension.equals("jpg") || extension.equals("jpeg") || extension.equals("gif") || extension.equals("png")) {            drawImage(g);        }    }    private void displayPlainTextBodyPart(Graphics g) throws MyException {        if (newConvertedTextSelected || newTextSelected)         {            prepareNewText(g);            // TODO: on some slow phones repaint was needed: test on more phones            // now and eventually uncomment it            repaint();        }        // draw the body part, which has been already parsed and stored to "textBodyDisplays" variable        drawText(textBodyString, textBodyDisplays, g);    }    //#ifdef MUJMAIL_HTML    private void displayHTMLBodyPart( final Graphics g ) {          if (DEBUG) System.out.println("DEBUG MailForm.displayHTMLBodyPart(Graphics)");        BPViewingModes.ViewingModesWithActions viewingMode = getBPViewingModeWithActions();     	textBodyString = viewingMode.getBodyPartContent(msgHeader, currAttachmentID);        if (DEBUG) System.out.println("text:\n" + textBodyString );        Parser parser = new Parser( textBodyString );              Vector elements = parser.parse();        prevScreen = mujMail.getDisplay().getCurrent();        Browser browser = new Browser( elements );        mujMail.getDisplay().setCurrent( browser );    }    //#endif    /**     * Gets body part viewing mode with actions.     * @return body part viewing mode with actions.     */    private ViewingModesWithActions getBPViewingModeWithActions() {        return bpViewingMode.getViewingModeWithActions(msgHeader.getBodyPart(currAttachmentID));    }    /**     * Loads the text of the message to be displayed and prepares textBodyString      * and textBodyDisplays to displaying.     * @param g     * @throws mujmail.MyException if loading of text was not successful     */    private void prepareNewText(Graphics g) throws MyException {        //DebugConsole.println("Prepare new text");        BPViewingModes.ViewingModesWithActions viewingMode = getBPViewingModeWithActions();        try {            if (DEBUG) System.out.println("DEBUG - MailForm.prepareNewText - getting body part content, Viewing mode = " + viewingMode);            textBodyString = viewingMode.getBodyPartContent(msgHeader, currAttachmentID);            if (textBodyString == null) {                throw new MyException(MyException.DB_CANNOT_LOAD_BODY);            }            textBodyString = viewingMode.preprocessBodyPartBeforeDisplaying(this);            if (Settings.replaceTabs) {                textBodyString = textBodyString.replace('\t', ' ');            }        } catch (OutOfMemoryError e) {        	e.printStackTrace();            back();            mujMail.alert.setAlert(this, callBox, Lang.get(Lang.ALRT_MF_VIEW_ATT) + Lang.get(Lang.FAILED) + " " + Lang.get(Lang.ALRT_SYS_LOW_MEMORY), MyAlert.DEFAULT, AlertType.ERROR);        } catch (MyException ignored) {        	ignored.printStackTrace();        }        if (textBodyString == null) {            Displayable nextDisp;            if (contextID == MODE_BROWSE) {                nextDisp = attchList;            } else {                nextDisp = callBox;            } //we need to return the focus back to the box            mujMail.alert.setAlert(this, nextDisp, Lang.get(Lang.ALRT_MF_LOAD_BODY) + Lang.get(Lang.FAILED), MyAlert.DEFAULT, AlertType.ERROR);            throw new MyException(0);        }        if (textBodyString.equals("")) {            textBodyString = "<" + Lang.get(Lang.ML_BODY) + Lang.get(Lang.EMPTY) + ">\r\n.\r\n";        }                textBodyDisplays = parseTextToDisplay(textBodyString, g);        viewingMode.setCorrectStateOfMailFormAfterPreparingText(this);    }    private void setFont(Graphics g) {        if (Settings.smallFontMailForm) {            g.setFont(Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL));        } else {            g.setFont(Font.getDefaultFont());        }    }    private class TextDisplayLine {        int beginLn = 0;        int endLn = 0;        byte countReplies = 0;        public TextDisplayLine() {        }        public TextDisplayLine(int beginLn, int endLn, byte countReplies) {            this.beginLn = beginLn;            this.endLn = endLn;            this.countReplies = countReplies;        }    }        /**     * Listens to the transformed pointer events produced by      * MujMailPointerEventProducer.     * Used also for handling appropriate key pressed events.     */    //#ifdef MUJMAIL_TOUCH_SCR    private class EventListener extends  MujMailPointerEventListener.MujMailPointerEventListenerAdapter {    //#else//#     private class EventListener {    //#endif        public void left() {            mujMail.commandAction(back, MailForm.this);        }        public void right() {            changeFontSize();        }        public void up() {            getBPViewingModeWithActions().up(MailForm.this);        }        public void down() {            getBPViewingModeWithActions().down(MailForm.this);        }        public void upQuartersSlash() {            up();        }        public void downQuartersStar() {            down();        }        public void fire() {            changeFontSize();        }            }    /**     * @param mujMail - the main application object.     */    public MailForm(MujMail mujMail) {        this.mujMail = mujMail;        //mailForm        back = new Command(Lang.get(Lang.BTN_BACK), Command.BACK, 0);        reply = new Command(Lang.get(Lang.BTN_TB_REPLY), Command.OK, 2);        delete = new Command(Lang.get(Lang.BTN_DEL_UNDEL), Command.ITEM, 3);        showHeader = new Command(Lang.get(Lang.BTN_MF_HEADERS_DETAILS), Command.ITEM, 4);        //#ifdef MUJMAIL_FS        exportToFS = new Command(Lang.get(Lang.BTN_MF_EXPORT_MAIL_TO_FS), Command.ITEM, 10);        //#endif        listAttachments = new Command(Lang.get(Lang.BTN_MF_ATTACHMENTS), Command.ITEM, 5);        forward = new Command(Lang.get(Lang.BTN_TB_FORWARD), Command.ITEM, 6);        //bounce = new Command("Bounce", Command.ITEM, 11);        quotedReply = new Command(Lang.get(Lang.BTN_TB_QUOTED_REPLY), Command.ITEM, 7);        replyAll = new Command(Lang.get(Lang.BTN_TB_REPLY_ALL), Command.ITEM, 8);        showAddresses = new Command(Lang.get(Lang.BTN_MF_EMAIL_ADDRS), Command.ITEM, 9);        //address list        addMailToBook = new Command(Lang.get(Lang.BTN_MF_ADD_EMAIL), Command.ITEM, 1);        //attachments list        deleteAttachment = new Command(Lang.get(Lang.BTN_MF_DEL_ATTACHMENTS), Command.ITEM, 1);        addCommand(delete);        addCommand(forward);        addCommand(back);        addCommand(listAttachments);        addCommand(showHeader);        addCommand(showAddresses);        //#ifdef MUJMAIL_FS        addCommand(exportToFS);        //#endif        //addCommand(bounce);        setCommandListener(mujMail);            //#ifdef MUJMAIL_TOUCH_SCR        pointerEventTransformer = new MujMailPointerEventProducer(                pointerEventListener, getWidth(), getHeight());        //#endif    }        private void changeFontSize() {        Settings.smallFontMailForm = !Settings.smallFontMailForm;        mujMail.getSettings().updateValuesToForms();        mujMail.getSettings().saveSettings(true);        viewMessage(msgHeader, callBox);    }        //#ifdef MUJMAIL_FS    /**     * Exports the mail to filesystem.     */    public void exportToFilesystem() {                FileSystemMailExporter exporter = new FileSystemMailExporter(mujMail);        exporter.exportMail(callBox, msgHeader);    }    //#endif        /**     * Shows a Form with actualized header information     * @param header header that details will be shown     * @param prevScreen the screen that will be displayed after user presses     *  back button.     */    public void showHeader(MessageHeader header, Displayable prevScreen) {          if (DEBUG) System.out.println( "DEBUG MailForm.showHeader(MessageHeader, Displayable) - displayable: " + prevScreen.getClass().toString() );        this.prevScreen = prevScreen;        msgHeader = header;        setContext(MODE_BROWSE);        if (headerForm == null) {            headerForm = new Form(Lang.get(Lang.ML_HEADERS_DETAIL));        }        // remove old Items        for (int i = headerForm.size(); i > 0; --i) {            headerForm.delete(i - 1);        }        // append new ones        String sender = Functions.emailOnly(header.getFrom());        if (mujMail.getAddressBook().getContactName(sender) != null) //if the sender is in adressbook, show his full name        {            sender = mujMail.getAddressBook().getContactName(sender) + " <" + sender + ">";        } else {            sender = header.getFrom();        }        headerForm.append(new StringItem(Lang.get(Lang.ML_FROM) + " ", sender));        headerForm.append(new StringItem(Lang.get(Lang.ML_RECIPIENTS) + " ", header.getRecipients() ));        headerForm.append(new StringItem(Lang.get(Lang.ML_SUBJECT) + " ", header.getSubject()));        headerForm.append(new StringItem(Lang.get(Lang.ML_TIME) + " ", header.getTimeStr()));        headerForm.append(new StringItem(Lang.get(Lang.ML_ATTACHMENTS) + " ", String.valueOf(header.getBodyPartCount())));        headerForm.append(new StringItem(Lang.get(Lang.ML_SIZE) + " ", (header.getSize() < 10000 ? header.getSize() + " B" : (header.getSize() >> 10) + " kB")));        headerForm.addCommand(back);        mujMail.getDisplay().setCurrent(headerForm);        headerForm.setCommandListener(mujMail);    }    //used to redownload a particular bodypart and then display the attachments list    public void regetAndList(MessageHeader header, byte index) {        if (header != null && index >= 0 && index < header.getBodyPartCount()) {            msgHeader = header;            bodyPartToRedown = header.getBpOriginalOrder(index);            // TODO: (david) this will work with user folders??            callBox = mujMail.getInBox();            runMode = REDOWNLOAD_BODY;            Thread t = new Thread(this);            t.start();            t.setPriority(Thread.MAX_PRIORITY);        }    }    /**     * Lists all attachments of the message     */    public void listAttachments() {        // create a new object of List if necessary		        if (attchList == null) {            attchList = new List(Lang.get(Lang.BTN_MF_ATTACHMENTS), Choice.IMPLICIT);            deleteAttachment = new Command(Lang.get(Lang.BTN_MF_DEL_ATTACHMENTS), Command.ITEM, 2);            redownAttchment = new Command(Lang.get(Lang.BTN_MF_REDOWN_ATTACHMENTS), Command.ITEM, 3);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -