viewmessage.java
来自「moblie syncml mail javame」· Java 代码 · 共 1,271 行 · 第 1/4 页
JAVA
1,271 行
} else if (messageToSet < 0) {
messageToSet = msgNumber - 1;
shift = fcml.getNumMessages();
}
if (Math.abs(shift) > 1) {
for (int i = 0; i < shift; i++) {
fcml.scroll(1);
fcml.repaint();
}
} else {
fcml.scroll(shift);
}
fcml.setActiveElement(messageToSet);
cleanup();
UIController.showViewMessageScreen(
fcml, fcml.getSelectedMessage());
//repaint();
}
private void addCommands() {
deleteCommand = new Command(Localization.getMessages().DELETE_COMMAND_LABEL,
UIController.COMMAND_TYPE, 27);
forwardCommand = new Command(Localization.getMessages().MVF_FORWARD_COMMAND, UIController.COMMAND_TYPE, 25);
linksCommand = new Command(Localization.getMessages().MVF_LINKS_COMMAND, UIController.COMMAND_TYPE, 55);
//numbersCommand=new Command(Localization.getMessages().MVF_NUMBERS_COMMAND, UIController.COMMAND_TYPE,65);
fullMessageCommand = new Command(Localization.getMessages().MVF_FULL_MSG_CMD, UIController.COMMAND_TYPE, 2);
callCommand = new Command(Localization.getMessages().CALL_SENDER_COMMAND, UIController.COMMAND_TYPE, 26);
attachList = new Command(Localization.getMessages().ATTACHMENT_LIST_CMD, UIController.COMMAND_TYPE, 1);
if (message.isMultipart()) {
addCommand(attachList);
}
//#ifdef isBlackberry
//# this.addCommand( UIController.nextCommand );
//# this.addCommand( UIController.previousCommand );
//# this.addCommand( UIController.blackberryExitCommand );
//#endif
//this commands are always present
this.addCommand(UIController.backCommand);
if (!UiUtils.isOutgoing(message)) {
this.addCommand(forwardCommand);
this.addCommand(linksCommand);
}
//this.addCommand(numbersCommand);
// allows to send log message if the SyncClient is not running
// This is present if the message is incomplete.
if (message.getFlags().isSet(MessageFlags.PARTIAL)) {
if (UIController.isSyncPermitted()) {
this.addCommand(fullMessageCommand);
}
}
//this are present if the message is incoming
if (UiUtils.isIncoming(message)) {
replyCommand = new Command(Localization.getMessages().MVF_REPLY_COMMAND, UIController.COMMAND_TYPE, 9);
replyAllCommand = new Command(Localization.getMessages().MVF_REPLY_ALL_COMMAND, UIController.COMMAND_TYPE, 10);
//flagCommand=new Command("Flag",Command.SCREEN,4);
saveSenderCommand = new Command(Localization.getMessages().MVF_SAVE_SENDER_COMMAND, UIController.COMMAND_TYPE, 45);
recipientsCommand = new Command(Localization.getMessages().MVF_RECIPIENTS_COMMAND, UIController.COMMAND_TYPE, 75);
setMarkAsReadCommand();
setFollowUpCommand();
this.addCommand(deleteCommand);
this.addCommand(replyCommand);
int numRec = message.getNumberOfRecipients();
// TODO: verify why the code below is needed
Address[] to = message.getTo();
for (int i = 0; i < to.length; i++) {
if (!StringUtil.equalsIgnoreCase(to[i].getEmail(), UIController.getMyAddress())) {
numRec++;
}
}
if (numRec > 1) {
this.addCommand(replyAllCommand);
}
this.addCommand(recipientsCommand);
//this.addCommand(flagCommand);
this.addCommand(saveSenderCommand);
} else if (UiUtils.isOutgoing(message)) {
//outbox or draft
this.addCommand(deleteCommand);
//sendCommand = new Command(Localization.getMessages().SEND_COMMAND_LABEL, UIController.COMMAND_TYPE, 0);
//editCommand = new Command(Localization.getMessages().EDIT_COMMAND_LABEL, UIController.COMMAND_TYPE, 1);
//this.addCommand(sendCommand);
//this.addCommand(editCommand);
} else if (UiUtils.isSent(message)) {
//sendCommand=new Command(Localization.getMessages("MVF_ResendCommand"),UIController.COMMAND_TYPE, 0);
editCommand = new Command(Localization.getMessages().EDIT_COMMAND_LABEL, UIController.COMMAND_TYPE, 1);
//this.addCommand(sendCommand);
this.addCommand(editCommand);
}
//Display a non-autodismiss alert if the contact list is not ready
if (!UIController.getContactsLoader().isLocked()) {
setCallCommand();
}
this.setCommandListener(this);
}
public void enableCallCommand() {
setCallCommand();
}
private void setCallCommand() {
Address from = message.getFrom();
// check in case of missing from like for messages in Sent Folder
if (from != null) {
removeCommand(callCommand);
try {
contactToCall = ((RMSContactManager) UIController.getContactManager()).searchContactFromMail(from.getEmail());
} catch (MailException ex) {
Log.error("Error searching contact from email address in ViewMessage setting CallCommand ");
ex.printStackTrace();
} catch (ContactManagerException ex) {
Log.error("Error searching contact from email address in ViewMessage setting CallCommand ");
ex.printStackTrace();
}
if (isValidForCall(contactToCall)) {
addCommand(callCommand);
}
}
}
private void setMarkAsReadCommand() {
removeCommand(markAsReadCommand);
if (message.getFlags().isSet(MessageFlags.OPENED)) {
markAsReadCommand = new Command(Localization.getMessages().UNREAD_COMMAND_LABEL, UIController.COMMAND_TYPE, 35);
} else {
markAsReadCommand = new Command(Localization.getMessages().READ_COMMAND_LABEL, UIController.COMMAND_TYPE, 35);
}
this.addCommand(markAsReadCommand);
}
private void setFollowUpCommand() {
removeCommand(followUpCommand);
if (message.getFlags().isSet(MessageFlags.FLAGGED)) {
followUpCommand = new Command(Localization.getMessages().UNFLAG_COMMAND_LABEL, UIController.COMMAND_TYPE, 30);
} else {
followUpCommand = new Command(Localization.getMessages().FLAG_COMMAND_LABEL, UIController.COMMAND_TYPE, 30);
}
this.addCommand(followUpCommand);
}
/**
*
*/
public void commandAction(Command command, Displayable displayable) {
if (command == UIController.backCommand) {
try {
if (!UIController.isSyncInProgress()) {
UIController.getInboxMessageList().resetTitle();
}
// UIController.getInboxMessageList().activate(
// UIController.getInboxMessageList().getActiveElementId());
cleanup(); // FIXME
//UIController.showInboxScreen();
UIController.showBackScreen();
} catch (Exception ex) {
ex.printStackTrace();
Log.error("ViewMessage: " + ex);
}
} else if (command == UIController.nextCommand) {
try {
this.setTitle(Localization.getMessages().MESSAGE_VIEW_NEXT_MESSAGE);
repaint();
serviceRepaints();
getNextMessage(NEXT_MESSAGE);
} catch (NullPointerException nex) {
Log.error(this, nex.getMessage());
}
} else if (command == UIController.previousCommand) {
try {
this.setTitle(Localization.getMessages().MESSAGE_VIEW_PREVIOUS_MESSAGE);
repaint();
serviceRepaints();
getNextMessage(PREVIOUS_MESSAGE);
} catch (NullPointerException nex) {
Log.error(this, nex.getMessage());
}
} else if (command == replyCommand) {
UIController.replyMessage(message);
cleanup(); // FIXME
} else if (command == forwardCommand) {
UIController.forwardMessage(message);
cleanup(); //FIXME
// TODO: when we'll go to the recipient list
// from here, we'l need to remove the
// cleanup call since if we wanna
// come back after the fw, we need to have
// the message or we'll throw a NPE
} else if (command == deleteCommand) {
deleteMessage();
} else if (command == saveSenderCommand) {
if (UIController.checkContactListFull()) {
UIController.showErrorAlert(
Localization.getMessages().AB_LIMIT_ERROR_MSG);
return;
}
Contact contact;
try {
// resetting the message in contact list
UIController.getContactList().setMessage(new Message());
if (message.getFrom() != null) {
contact = new Contact(
message.getFrom().getName(),
message.getFrom().getEmail());
UIController.showAddContactScreen(
UIController.display.getCurrent(), contact);
} else {
UIController.showAlert(Localization.getMessages().FROM_IS_NULL);
}
} catch (Exception ex) {
ex.printStackTrace();
Log.error(this, "Mail Exception while adding Contact" + ex);
UIController.showAddContactScreen(UIController.display.getCurrent());
UIController.showErrorAlert(
Localization.getMessages().MESSAGE_VIEW_UNABLE_TO_CREATE_CONTACT);
}
} else if (command == linksCommand) {
String content = message.getTextContent();
UIController.showLinkList(UIController.display.getCurrent(), content);
} else if (command == attachList) {
UIController.showAttachmentsList(UIController.display.getCurrent(), message);
} /*else if (command==numbersCommand ){
UIController.showPhoneNumberList(UIController.display.getCurrent(), message.getTextContent());
}*/ else if (command == recipientsCommand) {
Log.info("showing recipients for message " + message.getSubject());
UIController.showRecipientsList(UIController.display.getCurrent(), message);
} else if (command == editCommand) {
message.setMessageId(message.createUniqueMessageIDValue());
UIController.updateComposeMessageScreen(message, "");
UIController.showComposeMessageScreen(UIController.display.getCurrent(), UIController.getComposeMessageScreen().body);
//XXX
} else if (command == replyAllCommand) {
UIController.replyAll(message);
cleanup(); // FIXME
} else if (command == markAsReadCommand) {
UIController.changeReadFlag(message);
setMarkAsReadCommand();
} else if (command == followUpCommand) {
UIController.changeFollowUpFlag(message);
setFollowUpCommand();
UIController.getInboxMessageList().activate(UIController.getInboxMessageList().getActiveElementId());
} else if (command == fullMessageCommand) {
this.removeCommand(fullMessageCommand);
fullMsgPerformed = true;
this.setTitle(Localization.getMessages().MVF_FULL_MESSAGE_LOADING);
repaint();
UIController.setSyncCaller(UIController.USER);
UIController.getFullMessage(message);
} else if (command == callCommand) {
UIController.phoneCall(contactToCall, this);
} else if (command == UIController.blackberryExitCommand) {
UIController.midlet.destroyApp(true);
} else {
Log.info("MessageViewForm: command not implemented");
}
}
/*
private void deleteMessage() {
UIController.deleteMessage(message);
cleanup(); // FIXME
UIController.showInboxScreen();
}
*/
private void deleteMessage() {
if (UIController.getConfig().getDeleteConfirmation()) {
ModalPopup popup =
new ModalPopup(Localization.getMessages().POPUP_DELETE_MESSAGE_TITLE,
Localization.getMessages().POPUP_DELETE_MESSAGE_TEXT,
new DeletePopupAction(message));
UIController.showModalPopup(popup, this);
} else {
UIController.deleteMessage(message);
//UIController.showBackScreen();
}
}
private void enterBody(int dir) {
insideBody = true;
}
protected void keyRepeated(int keyCode) {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?