Changed all the calls to MessageList to work using the new LocalSearch class. These are all tested and working changes.

This commit is contained in:
Sander Bogaert 2012-10-13 15:06:57 -04:00
parent f01f2f15cd
commit bf82d0af7c
6 changed files with 76 additions and 130 deletions

View File

@ -62,7 +62,6 @@ import com.fsck.k9.FontSizes;
import com.fsck.k9.K9;
import com.fsck.k9.Preferences;
import com.fsck.k9.R;
import com.fsck.k9.SearchAccount;
import com.fsck.k9.activity.misc.ExtendedAsyncTask;
import com.fsck.k9.activity.misc.NonConfigurationInstance;
import com.fsck.k9.activity.setup.AccountSettings;
@ -79,6 +78,9 @@ import com.fsck.k9.mail.Transport;
import com.fsck.k9.mail.internet.MimeUtility;
import com.fsck.k9.mail.store.StorageManager;
import com.fsck.k9.mail.store.WebDavStore;
import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchAccount;
import com.fsck.k9.search.SearchModifier;
import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.view.ColorChip;
import com.fsck.k9.preferences.SettingsExporter;
@ -424,8 +426,18 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
* Creates and initializes the special accounts ('Unified Inbox' and 'All Messages')
*/
private void createSpecialAccounts() {
integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(this);
unreadAccount = SearchAccount.createAllMessagesAccount(this);
// create the unified inbox meta account ( all accounts is default when none specified )
String name = getString(R.string.integrated_inbox_title);
LocalSearch tmpSearch = new LocalSearch(name);
tmpSearch.addAllowedFolder(SearchSpecification.GENERIC_INBOX_NAME);
integratedInboxAccount = new SearchAccount(tmpSearch, name,
getString(R.string.integrated_inbox_detail));
// create the all messages search ( all accounts is default when none specified )
name = getString(R.string.search_all_messages_title);
tmpSearch = new LocalSearch(name);
unreadAccount = new SearchAccount(tmpSearch, name,
getString(R.string.search_all_messages_detail));
}
@SuppressWarnings("unchecked")
@ -550,7 +562,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
pendingWork.put(account, "true");
final SearchAccount searchAccount = (SearchAccount)account;
MessagingController.getInstance(getApplication()).searchLocalMessages(searchAccount, null, new MessagingListener() {
MessagingController.getInstance(getApplication())
.searchLocalMessages(searchAccount.getRelatedSearch(), new MessagingListener() {
@Override
public void searchStats(AccountStats stats) {
mListener.accountStatusChanged(searchAccount, stats);
@ -607,7 +620,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
private boolean onOpenAccount(BaseAccount account) {
if (account instanceof SearchAccount) {
SearchAccount searchAccount = (SearchAccount)account;
MessageList.actionHandle(this, searchAccount.getDescription(), searchAccount);
MessageList.actionDisplaySearch(this, searchAccount.getRelatedSearch(), false);
} else {
Account realAccount = (Account)account;
if (!realAccount.isEnabled()) {
@ -624,8 +637,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
if (K9.FOLDER_NONE.equals(realAccount.getAutoExpandFolderName())) {
FolderList.actionHandleAccount(this, realAccount);
} else {
MessageList.actionHandleFolder(this, realAccount, realAccount.getAutoExpandFolderName());
}
LocalSearch search = new LocalSearch(realAccount.getAutoExpandFolderName());
search.addAllowedFolder(realAccount.getAutoExpandFolderName());
search.addAccountUuid(realAccount.getUuid());
MessageList.actionDisplaySearch(this, search, true);}
}
return true;
}
@ -1769,49 +1784,20 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
}
@Override
public void onClick(View v) {
String description = getString(R.string.search_title, account.getDescription(), getString(searchModifier.resId));
final String description = getString(R.string.search_title, account.getDescription(), getString(searchModifier.resId));
LocalSearch search = null;
if (account instanceof SearchAccount) {
SearchAccount searchAccount = (SearchAccount)account;
MessageList.actionHandle(Accounts.this,
description, "", searchAccount.isIntegrate(),
combine(searchAccount.getRequiredFlags(), searchModifier.requiredFlags),
combine(searchAccount.getForbiddenFlags(), searchModifier.forbiddenFlags));
search = ((SearchAccount) account).getRelatedSearch();
search.setName(description);
} else {
SearchSpecification searchSpec = new SearchSpecification() {
@Override
public String[] getAccountUuids() {
return new String[] { account.getUuid() };
}
@Override
public Flag[] getForbiddenFlags() {
return searchModifier.forbiddenFlags;
}
@Override
public String getQuery() {
return "";
}
@Override
public Flag[] getRequiredFlags() {
return searchModifier.requiredFlags;
}
@Override
public boolean isIntegrate() {
return false;
}
@Override
public String[] getFolderNames() {
return null;
}
};
MessageList.actionHandle(Accounts.this, description, searchSpec);
search = new LocalSearch(description);
search.addAccountUuid(account.getUuid());
}
search.allRequiredFlags(searchModifier.requiredFlags);
search.allForbiddenFlags(searchModifier.forbiddenFlags);
MessageList.actionDisplaySearch(Accounts.this, search, false);
}
}

View File

@ -67,6 +67,7 @@ import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
import com.fsck.k9.search.LocalSearch;
import com.fsck.k9.search.SearchModifier;
import com.fsck.k9.search.SearchSpecification;
import com.fsck.k9.service.MailService;
@ -621,7 +622,10 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
}
private void onOpenFolder(String folder) {
MessageList.actionHandleFolder(this, mAccount, folder);
LocalSearch search = new LocalSearch(folder);
search.addAccountUuid(mAccount.getUuid());
search.addAllowedFolder(folder);
MessageList.actionDisplaySearch(this, search, false);
}
private void onCompact(Account account) {
@ -1258,86 +1262,34 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
}
@Override
public void onClick(View v) {
String description = getString(R.string.search_title,
final String description = getString(R.string.search_title,
getString(R.string.message_list_title, account.getDescription(), displayName),
getString(searchModifier.resId));
SearchSpecification searchSpec = new SearchSpecification() {
@Override
public String[] getAccountUuids() {
return new String[] { account.getUuid() };
}
@Override
public Flag[] getForbiddenFlags() {
return searchModifier.forbiddenFlags;
}
@Override
public String getQuery() {
return "";
}
@Override
public Flag[] getRequiredFlags() {
return searchModifier.requiredFlags;
}
@Override
public boolean isIntegrate() {
return false;
}
@Override
public String[] getFolderNames() {
return new String[] { folderName };
}
};
MessageList.actionHandle(FolderList.this, description, searchSpec);
LocalSearch search = new LocalSearch(description);
try {
search.allRequiredFlags(searchModifier.requiredFlags);
search.allForbiddenFlags(searchModifier.forbiddenFlags);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
search.addAllowedFolder(folderName);
search.addAccountUuid(account.getUuid());
MessageList.actionDisplaySearch(FolderList.this, search, false);
}
}
private static Flag[] UNREAD_FLAG_ARRAY = { Flag.SEEN };
private void openUnreadSearch(Context context, final Account account) {
String description = getString(R.string.search_title, mAccount.getDescription(), getString(R.string.unread_modifier));
SearchSpecification searchSpec = new SearchSpecification() {
//interface has no override @Override
public String[] getAccountUuids() {
return new String[] { account.getUuid() };
}
//interface has no override @Override
public Flag[] getForbiddenFlags() {
return UNREAD_FLAG_ARRAY;
}
//interface has no override @Override
public String getQuery() {
return "";
}
@Override
public Flag[] getRequiredFlags() {
return null;
}
@Override
public boolean isIntegrate() {
return false;
}
@Override
public String[] getFolderNames() {
return null;
}
};
MessageList.actionHandle(context, description, searchSpec);
LocalSearch search = new LocalSearch(description);
search.addAccountUuid(account.getUuid());
try {
search.allRequiredFlags(new Flag[]{Flag.SEEN});
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

View File

@ -31,8 +31,7 @@ public class LauncherShortcuts extends AccountList {
Intent shortcutIntent = null;
if (account instanceof SearchSpecification) {
shortcutIntent = MessageList.actionHandleAccountIntent(this, account.getDescription(),
(SearchSpecification) account);
shortcutIntent = MessageList.intentDisplaySearch(this, (SearchSpecification) account, true, true);
} else {
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
true);

View File

@ -3160,8 +3160,11 @@ public class MessagingController implements Runnable {
builder.setContentTitle(mApplication.getString(R.string.notification_bg_send_title));
builder.setContentText(account.getDescription());
Intent intent = MessageList.actionHandleFolderIntent(mApplication, account,
account.getInboxFolderName());
LocalSearch search = new LocalSearch(account.getInboxFolderName());
search.addAllowedFolder(account.getInboxFolderName());
search.addAccountUuid(account.getUuid());
Intent intent = MessageList.intentDisplaySearch(mApplication, search, true, true);
PendingIntent pi = PendingIntent.getActivity(mApplication, 0, intent, 0);
builder.setContentIntent(pi);
@ -3243,8 +3246,11 @@ public class MessagingController implements Runnable {
mApplication.getString(R.string.notification_bg_title_separator) +
folder.getName());
Intent intent = MessageList.actionHandleFolderIntent(mApplication, account,
account.getInboxFolderName());
LocalSearch search = new LocalSearch(account.getInboxFolderName());
search.addAllowedFolder(account.getInboxFolderName());
search.addAccountUuid(account.getUuid());
Intent intent = MessageList.intentDisplaySearch(mApplication, search, true, true);
PendingIntent pi = PendingIntent.getActivity(mApplication, 0, intent, 0);
builder.setContentIntent(pi);

View File

@ -302,7 +302,7 @@ public class MessageProvider extends ContentProvider {
final SearchAccount integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(getContext());
final MessagingController msgController = MessagingController.getInstance(K9.app);
msgController.searchLocalMessages(integratedInboxAccount, null,
msgController.searchLocalMessages(integratedInboxAccount.getRelatedSearch(),
new MesssageInfoHolderRetrieverListener(queue));
final List<MessageInfoHolder> holders = queue.take();

View File

@ -8,6 +8,7 @@ import com.fsck.k9.R;
import com.fsck.k9.activity.UnreadWidgetConfiguration;
import com.fsck.k9.activity.FolderList;
import com.fsck.k9.activity.MessageList;
import com.fsck.k9.search.LocalSearch;
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
@ -62,8 +63,10 @@ public class UnreadWidgetProvider extends AppWidgetProvider {
clickIntent = FolderList.actionHandleAccountIntent(context, account, null,
false);
} else {
clickIntent = MessageList.actionHandleFolderIntent(context, account,
account.getAutoExpandFolderName());
LocalSearch search = new LocalSearch(account.getAutoExpandFolderName());
search.addAllowedFolder(account.getAutoExpandFolderName());
search.addAccountUuid(account.getUuid());
clickIntent = MessageList.intentDisplaySearch(context, search, true, true);
}
clickIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
}