From c5dc626bbcc36c36a1d6db6c8efa68c15905c838 Mon Sep 17 00:00:00 2001 From: cketti Date: Tue, 2 Apr 2013 19:30:41 +0200 Subject: [PATCH] Show "check mail" action when displaying Unified Inbox etc. --- src/com/fsck/k9/activity/MessageList.java | 14 ++++--------- .../fsck/k9/fragment/MessageListFragment.java | 21 +++++++++++++++++-- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 96b6bbfa2..1e48d158f 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -1045,21 +1045,15 @@ public class MessageList extends K9FragmentActivity implements MessageListFragme if (!mMessageListFragment.isSingleAccountMode()) { menu.findItem(R.id.expunge).setVisible(false); - menu.findItem(R.id.check_mail).setVisible(false); menu.findItem(R.id.send_messages).setVisible(false); } else { menu.findItem(R.id.send_messages).setVisible(mMessageListFragment.isOutbox()); - - if (mMessageListFragment.isRemoteFolder()) { - menu.findItem(R.id.check_mail).setVisible(true); - menu.findItem(R.id.expunge).setVisible( - mMessageListFragment.isAccountExpungeCapable()); - } else { - menu.findItem(R.id.check_mail).setVisible(false); - menu.findItem(R.id.expunge).setVisible(false); - } + menu.findItem(R.id.expunge).setVisible(mMessageListFragment.isRemoteFolder() && + mMessageListFragment.isAccountExpungeCapable()); } + menu.findItem(R.id.check_mail).setVisible(mMessageListFragment.isCheckMailSupported()); + // If this is an explicit local search, show the option to search on the server if (!mMessageListFragment.isRemoteSearch() && mMessageListFragment.isRemoteSearchAllowed()) { diff --git a/src/com/fsck/k9/fragment/MessageListFragment.java b/src/com/fsck/k9/fragment/MessageListFragment.java index eab6df34a..7a7393c68 100644 --- a/src/com/fsck/k9/fragment/MessageListFragment.java +++ b/src/com/fsck/k9/fragment/MessageListFragment.java @@ -384,6 +384,7 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick private LocalSearch mSearch = null; private boolean mSingleAccountMode; private boolean mSingleFolderMode; + private boolean mAllAccounts; private MessageListHandler mHandler = new MessageListHandler(); @@ -901,11 +902,13 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick mCurrentFolder = getFolder(mFolderName, mAccount); } + mAllAccounts = false; if (mSingleAccountMode) { mAccountUuids = new String[] { mAccount.getUuid() }; } else { if (accountUuids.length == 1 && accountUuids[0].equals(SearchSpecification.ALL_ACCOUNTS)) { + mAllAccounts = true; Account[] accounts = mPreferences.getAccounts(); @@ -2829,8 +2832,17 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick } public void checkMail() { - mController.synchronizeMailbox(mAccount, mFolderName, mListener, null); - mController.sendPendingMessages(mAccount, mListener); + if (isSingleAccountMode() && isSingleFolderMode()) { + mController.synchronizeMailbox(mAccount, mFolderName, mListener, null); + mController.sendPendingMessages(mAccount, mListener); + } else if (mAllAccounts) { + mController.checkMail(mContext, null, true, true, mListener); + } else { + for (String accountUuid : mAccountUuids) { + Account account = mPreferences.getAccount(accountUuid); + mController.checkMail(mContext, account, true, true, mListener); + } + } } /** @@ -3452,4 +3464,9 @@ public class MessageListFragment extends SherlockFragment implements OnItemClick mController.markAllMessagesRead(mAccount, mFolderName); } } + + public boolean isCheckMailSupported() { + return (mAllAccounts || !isSingleAccountMode() || !isSingleFolderMode() || + isRemoteFolder()); + } }