diff --git a/src/com/fsck/k9/MessagingController.java b/src/com/fsck/k9/MessagingController.java index 1b25794a1..ba004c855 100644 --- a/src/com/fsck/k9/MessagingController.java +++ b/src/com/fsck/k9/MessagingController.java @@ -701,22 +701,23 @@ public class MessagingController implements Runnable public void searchLocalMessages(SearchSpecification searchSpecification, final Message[] messages, final MessagingListener listener) { - searchLocalMessages(searchSpecification.getAccountUuids(), searchSpecification.getQuery(), messages, - searchSpecification.isIntegrate(), searchSpecification.getRequiredFlags(), searchSpecification.getForbiddenFlags(), listener); + searchLocalMessages(searchSpecification.getAccountUuids(), null, messages, + searchSpecification.getQuery(), searchSpecification.isIntegrate(), searchSpecification.getRequiredFlags(), searchSpecification.getForbiddenFlags(), listener); } /** * Find all messages in any local account which match the query 'query' - * @param searchAccounts TODO + * @param folderNames TODO * @param query * @param listener + * @param searchAccounts TODO * @param account TODO * @param account * @throws MessagingException */ - public void searchLocalMessages(final String[] accountUuids, final String query, final Message[] messages, final boolean integrate, final Flag[] requiredFlags, - final Flag[] forbiddenFlags, final MessagingListener listener) + public void searchLocalMessages(final String[] accountUuids, final String[] folderNames, final Message[] messages, final String query, final boolean integrate, + final Flag[] requiredFlags, final Flag[] forbiddenFlags, final MessagingListener listener) { final AccountStats stats = new AccountStats(); final Set accountUuidsSet = new HashSet(); @@ -767,37 +768,53 @@ public class MessagingController implements Runnable listener.listLocalMessagesStarted(account, null); } - if (integrate || displayableOnly) + if (integrate || displayableOnly || folderNames != null || noSpecialFolders) { List tmpFoldersToSearch = new LinkedList(); try { LocalStore store = account.getLocalStore(); List folders = store.getPersonalNamespaces(); + ArrayList folderNameList = null; + if (folderNames != null) + { + folderNameList = new ArrayList(); + for (String folderName : folderNames) + { + folderNameList.add(folderName); + } + } for (Folder folder : folders) { LocalFolder localFolder = (LocalFolder)folder; boolean include = true; folder.refresh(prefs); String localFolderName = localFolder.getName(); - if (noSpecialFolders && ( - localFolderName.equals(account.getTrashFolderName()) || - localFolderName.equals(account.getOutboxFolderName()) || - localFolderName.equals(account.getDraftsFolderName()) || - localFolderName.equals(account.getSentFolderName()) || - localFolderName.equals(account.getErrorFolderName()))) + if (integrate) { - include = false; + include = localFolder.isIntegrate(); } - else if (displayableOnly && modeMismatch(account.getFolderDisplayMode(), folder.getDisplayClass())) + else { - include = false; - } - else if (integrate && localFolder.isIntegrate() == false) - { - include = false; - + if (folderNameList != null && folderNameList.contains(localFolder.getName()) == false) + { + include = false; + } + else if (noSpecialFolders && ( + localFolderName.equals(account.getTrashFolderName()) || + localFolderName.equals(account.getOutboxFolderName()) || + localFolderName.equals(account.getDraftsFolderName()) || + localFolderName.equals(account.getSentFolderName()) || + localFolderName.equals(account.getErrorFolderName()))) + { + include = false; + } + else if (displayableOnly && modeMismatch(account.getFolderDisplayMode(), folder.getDisplayClass())) + { + include = false; + } } + if (include) { tmpFoldersToSearch.add(localFolder); diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index e5f93ae32..02166b9f7 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -388,8 +388,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC BaseAccount[] accounts = Preferences.getPreferences(this).getAccounts(); List newAccounts = new ArrayList(accounts.length + 4); - newAccounts.add(integratedInboxAccount); - newAccounts.add(unreadAccount); + if (accounts.length > 0) + { + newAccounts.add(integratedInboxAccount); + newAccounts.add(unreadAccount); + } for (BaseAccount account : accounts) { diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 13365b089..d01086ddb 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -488,7 +488,7 @@ public class MessageList } else if (mQueryString != null) { - mController.searchLocalMessages(mAccountUuids, mQueryString, null, mIntegrate, mQueryFlags, mForbiddenFlags, mAdapter.mListener); + mController.searchLocalMessages(mAccountUuids, null, null, mQueryString, mIntegrate, mQueryFlags, mForbiddenFlags, mAdapter.mListener); } mHandler.refreshTitle(); @@ -2096,21 +2096,28 @@ public class MessageList FooterViewHolder holder = (FooterViewHolder)footerView.getTag(); - if (mCurrentFolder != null && mCurrentFolder.loading) + if (mCurrentFolder != null && mAccount != null) { - holder.main.setText(getString(R.string.status_loading_more)); - holder.progress.setVisibility(ProgressBar.VISIBLE); - } - else - { - if (mCurrentFolder != null && mCurrentFolder.lastCheckFailed == false) + if (mCurrentFolder.loading) { - holder.main.setText(String.format(getString(R.string.load_more_messages_fmt), mAccount.getDisplayCount())); + holder.main.setText(getString(R.string.status_loading_more)); + holder.progress.setVisibility(ProgressBar.VISIBLE); } else { - holder.main.setText(getString(R.string.status_loading_more_failed)); + if (mCurrentFolder.lastCheckFailed == false) + { + holder.main.setText(String.format(getString(R.string.load_more_messages_fmt), mAccount.getDisplayCount())); + } + else + { + holder.main.setText(getString(R.string.status_loading_more_failed)); + } + holder.progress.setVisibility(ProgressBar.INVISIBLE); } + } + else + { holder.progress.setVisibility(ProgressBar.INVISIBLE); }