From e6132286a00ce2676a0ad79ffc9f8c87e4cf7e6e Mon Sep 17 00:00:00 2001 From: Bao-Long Nguyen-Trong Date: Tue, 23 Jun 2009 14:57:16 +0000 Subject: [PATCH] FIxed issue 501 --- .../android/email/MessagingController.java | 88 +++++++++---------- src/com/android/email/MessagingListener.java | 5 +- .../android/email/activity/MessageList.java | 9 ++ 3 files changed, 55 insertions(+), 47 deletions(-) diff --git a/src/com/android/email/MessagingController.java b/src/com/android/email/MessagingController.java index c862be676..ab18ec581 100644 --- a/src/com/android/email/MessagingController.java +++ b/src/com/android/email/MessagingController.java @@ -1461,53 +1461,49 @@ public class MessagingController implements Runnable { } private void processPendingMarkAllAsRead(PendingCommand command, Account account) throws MessagingException { - String folder = command.arguments[0]; - - Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication); - LocalFolder localFolder = (LocalFolder)localStore.getFolder(folder); - localFolder.open(OpenMode.READ_WRITE); - Message[] messages = localFolder.getMessages(null); - for (Message message : messages) - { - if (message.isSet(Flag.SEEN) == false) - { - message.setFlag(Flag.SEEN, true); - } - } - localFolder.setUnreadMessageCount(0); - for (MessagingListener l : getListeners()) { - l.folderStatusChanged(account, folder); - } - try - { - if (account.getErrorFolderName().equals(folder)) - { - return; - } - - Store remoteStore = Store.getInstance(account.getStoreUri(), mApplication); - Folder remoteFolder = remoteStore.getFolder(folder); - - if (!remoteFolder.exists()) { - return; - } - remoteFolder.open(OpenMode.READ_WRITE); - if (remoteFolder.getMode() != OpenMode.READ_WRITE) { - return; - } - - remoteFolder.setFlags(new Flag[] { Flag.SEEN }, true); - remoteFolder.close(false); - } - catch (UnsupportedOperationException uoe) - { - Log.w(Email.LOG_TAG, "Could not mark all server-side as read because store doesn't support operation", uoe); - } - finally - { - localFolder.close(false); - } + String folder = command.arguments[0]; + Store localStore = Store.getInstance(account.getLocalStoreUri(), mApplication); + LocalFolder localFolder = (LocalFolder) localStore.getFolder(folder); + localFolder.open(OpenMode.READ_WRITE); + Message[] messages = localFolder.getMessages(null); + for (Message message : messages) { + if (message.isSet(Flag.SEEN) == false) { + message.setFlag(Flag.SEEN, true); + for (MessagingListener l : getListeners()) { + l.listLocalMessagesUpdateMessage(account, folder, message); + } + } + } + localFolder.setUnreadMessageCount(0); + for (MessagingListener l : getListeners()) { + l.folderStatusChanged(account, folder); + } + try { + if (account.getErrorFolderName().equals(folder)) { + return; + } + + Store remoteStore = Store.getInstance(account.getStoreUri(), mApplication); + Folder remoteFolder = remoteStore.getFolder(folder); + + if (!remoteFolder.exists()) { + return; + } + remoteFolder.open(OpenMode.READ_WRITE); + if (remoteFolder.getMode() != OpenMode.READ_WRITE) { + return; + } + + remoteFolder.setFlags(new Flag[]{Flag.SEEN}, true); + remoteFolder.close(false); + } + catch (UnsupportedOperationException uoe) { + Log.w(Email.LOG_TAG, "Could not mark all server-side as read because store doesn't support operation", uoe); + } + finally { + localFolder.close(false); + } } static long uidfill = 0; diff --git a/src/com/android/email/MessagingListener.java b/src/com/android/email/MessagingListener.java index cc7daaa80..a30e26c08 100644 --- a/src/com/android/email/MessagingListener.java +++ b/src/com/android/email/MessagingListener.java @@ -47,7 +47,10 @@ public class MessagingListener { public void listLocalMessagesAddMessage(Account account, String folder, Message message) { } - + + public void listLocalMessagesUpdateMessage(Account account, String folder, Message message) { + } + public void listLocalMessagesRemoveMessage(Account account, String folder, Message message) { } diff --git a/src/com/android/email/activity/MessageList.java b/src/com/android/email/activity/MessageList.java index 2c5fbc25f..3fd920a71 100644 --- a/src/com/android/email/activity/MessageList.java +++ b/src/com/android/email/activity/MessageList.java @@ -1228,8 +1228,17 @@ public class MessageList extends K9ListActivity { } + @Override + public void listLocalMessagesUpdateMessage(Account account, String folder, Message message) { + if (!account.equals(mAccount) || !folder.equals(mFolderName)) { + return; + } + + addOrUpdateMessage(folder, message, false, true); + } }; + private Drawable mAttachmentIcon; private Drawable mAnsweredIcon; private View footerView = null;