From 0c5bdf2c970c28b5e301f4d79a0cdf91d6d26ef9 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 2 Apr 2013 19:17:58 +0200 Subject: [PATCH] Add "Mark all as read" action to message list --- res/menu/message_list_option.xml | 6 ++++++ res/values/strings.xml | 2 ++ src/com/fsck/k9/activity/MessageList.java | 7 +++++++ src/com/fsck/k9/fragment/MessageListFragment.java | 10 ++++++++++ 4 files changed, 25 insertions(+) diff --git a/res/menu/message_list_option.xml b/res/menu/message_list_option.xml index df7999d58..dd5891372 100644 --- a/res/menu/message_list_option.xml +++ b/res/menu/message_list_option.xml @@ -175,6 +175,12 @@ android:showAsAction="never" android:title="@string/batch_select_all"/> + + + Refreshed %s Refreshed %s (Push active) on %s + + Mark all as read diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index b3bde3e9c..96b6bbfa2 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -805,6 +805,10 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme mMessageListFragment.onRemoteSearch(); return true; } + case R.id.mark_all_as_read: { + mMessageListFragment.markAllAsRead(); + return true; + } // MessageView case R.id.next_message: { showNextMessage(); @@ -1032,9 +1036,12 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme menu.findItem(R.id.select_all).setVisible(false); menu.findItem(R.id.send_messages).setVisible(false); menu.findItem(R.id.expunge).setVisible(false); + menu.findItem(R.id.mark_all_as_read).setVisible(false); } else { menu.findItem(R.id.set_sort).setVisible(true); menu.findItem(R.id.select_all).setVisible(true); + menu.findItem(R.id.mark_all_as_read).setVisible( + mMessageListFragment.isMarkAllAsReadSupported()); if (!mMessageListFragment.isSingleAccountMode()) { menu.findItem(R.id.expunge).setVisible(false); diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index 142c82d6f..eab6df34a 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -3442,4 +3442,14 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick public boolean isInitialized() { return mInitialized; } + + public boolean isMarkAllAsReadSupported() { + return (isSingleAccountMode() && isSingleFolderMode()); + } + + public void markAllAsRead() { + if (isMarkAllAsReadSupported()) { + mController.markAllMessagesRead(mAccount, mFolderName); + } + } }