1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-02 00:25:10 -04:00

Fixes Issue 1450

Fixes Issue 1456

Don't add canned searches to account list if no real accounts exist.

Fix NPE.

Prep work for searching named folders.
This commit is contained in:
Daniel Applebaum 2010-04-24 04:35:39 +00:00
parent 8e0ee1a6e1
commit e7e59ef858
3 changed files with 59 additions and 32 deletions

View File

@ -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<String> accountUuidsSet = new HashSet<String>();
@ -767,37 +768,53 @@ public class MessagingController implements Runnable
listener.listLocalMessagesStarted(account, null);
}
if (integrate || displayableOnly)
if (integrate || displayableOnly || folderNames != null || noSpecialFolders)
{
List<LocalFolder> tmpFoldersToSearch = new LinkedList<LocalFolder>();
try
{
LocalStore store = account.getLocalStore();
List<? extends Folder> folders = store.getPersonalNamespaces();
ArrayList<String> folderNameList = null;
if (folderNames != null)
{
folderNameList = new ArrayList<String>();
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);

View File

@ -388,8 +388,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC
BaseAccount[] accounts = Preferences.getPreferences(this).getAccounts();
List<BaseAccount> newAccounts = new ArrayList<BaseAccount>(accounts.length + 4);
newAccounts.add(integratedInboxAccount);
newAccounts.add(unreadAccount);
if (accounts.length > 0)
{
newAccounts.add(integratedInboxAccount);
newAccounts.add(unreadAccount);
}
for (BaseAccount account : accounts)
{

View File

@ -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);
}