From b1a1de8f7b829e8a07e74c5e79eeb1b29bb19d42 Mon Sep 17 00:00:00 2001 From: cketti Date: Fri, 27 Jan 2012 08:39:10 +0100 Subject: [PATCH] Restore mark as unread in message view Fixes issue 3958 Fixes issue 3319 --- src/com/fsck/k9/activity/MessageView.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index fb6afcc60..64f4c9208 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -20,6 +20,7 @@ import com.fsck.k9.crypto.PgpData; import com.fsck.k9.helper.FileBrowserHelper; import com.fsck.k9.helper.FileBrowserHelper.FileBrowserFailOverCallback; import com.fsck.k9.mail.*; +import com.fsck.k9.mail.store.LocalStore.LocalMessage; import com.fsck.k9.mail.store.StorageManager; import com.fsck.k9.view.AttachmentView; import com.fsck.k9.view.ToggleScrollView; @@ -726,10 +727,15 @@ public class MessageView extends K9Activity implements OnClickListener { private void onFlag() { if (mMessage != null) { - mController.setFlag(mAccount, - mMessage.getFolder().getName(), new String[] {mMessage.getUid()}, Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED)); + boolean newState = !mMessage.isSet(Flag.FLAGGED); + mController.setFlag(mAccount, mMessage.getFolder().getName(), + new String[] {mMessage.getUid()}, Flag.FLAGGED, newState); try { - mMessage.setFlag(Flag.FLAGGED, !mMessage.isSet(Flag.FLAGGED)); + // FIXME: This is a hack to change the flagged state of our message object. We + // can't call Message.setFlag() because that would "adjust" the flagged count + // another time (first time by MessagingController.setFlag(...)). + ((LocalMessage)mMessage).setFlagInternal(Flag.FLAGGED, newState); + mMessageView.setHeaders(mMessage, mAccount); } catch (MessagingException me) { Log.e(K9.LOG_TAG, "Could not set flag on local message", me); @@ -876,9 +882,13 @@ public class MessageView extends K9Activity implements OnClickListener { private void onMarkAsUnread() { if (mMessage != null) { -// (Issue 3319) mController.setFlag(mAccount, mMessageReference.folderName, new String[] { mMessage.getUid() }, Flag.SEEN, false); + mController.setFlag(mAccount, mMessage.getFolder().getName(), + new String[] { mMessage.getUid() }, Flag.SEEN, false); try { - mMessage.setFlag(Flag.SEEN, false); + // FIXME: This is a hack to mark our message object as unread. We can't call + // Message.setFlag() because that would "adjust" the unread count twice. + ((LocalMessage)mMessage).setFlagInternal(Flag.SEEN, false); + mMessageView.setHeaders(mMessage, mAccount); String subject = mMessage.getSubject(); setTitle(subject);