mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 19:52:17 -05:00
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:
parent
f01f2f15cd
commit
bf82d0af7c
@ -62,7 +62,6 @@ import com.fsck.k9.FontSizes;
|
|||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
import com.fsck.k9.R;
|
import com.fsck.k9.R;
|
||||||
import com.fsck.k9.SearchAccount;
|
|
||||||
import com.fsck.k9.activity.misc.ExtendedAsyncTask;
|
import com.fsck.k9.activity.misc.ExtendedAsyncTask;
|
||||||
import com.fsck.k9.activity.misc.NonConfigurationInstance;
|
import com.fsck.k9.activity.misc.NonConfigurationInstance;
|
||||||
import com.fsck.k9.activity.setup.AccountSettings;
|
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.internet.MimeUtility;
|
||||||
import com.fsck.k9.mail.store.StorageManager;
|
import com.fsck.k9.mail.store.StorageManager;
|
||||||
import com.fsck.k9.mail.store.WebDavStore;
|
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.search.SearchSpecification;
|
||||||
import com.fsck.k9.view.ColorChip;
|
import com.fsck.k9.view.ColorChip;
|
||||||
import com.fsck.k9.preferences.SettingsExporter;
|
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')
|
* Creates and initializes the special accounts ('Unified Inbox' and 'All Messages')
|
||||||
*/
|
*/
|
||||||
private void createSpecialAccounts() {
|
private void createSpecialAccounts() {
|
||||||
integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(this);
|
// create the unified inbox meta account ( all accounts is default when none specified )
|
||||||
unreadAccount = SearchAccount.createAllMessagesAccount(this);
|
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")
|
@SuppressWarnings("unchecked")
|
||||||
@ -550,7 +562,8 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
|||||||
pendingWork.put(account, "true");
|
pendingWork.put(account, "true");
|
||||||
final SearchAccount searchAccount = (SearchAccount)account;
|
final SearchAccount searchAccount = (SearchAccount)account;
|
||||||
|
|
||||||
MessagingController.getInstance(getApplication()).searchLocalMessages(searchAccount, null, new MessagingListener() {
|
MessagingController.getInstance(getApplication())
|
||||||
|
.searchLocalMessages(searchAccount.getRelatedSearch(), new MessagingListener() {
|
||||||
@Override
|
@Override
|
||||||
public void searchStats(AccountStats stats) {
|
public void searchStats(AccountStats stats) {
|
||||||
mListener.accountStatusChanged(searchAccount, stats);
|
mListener.accountStatusChanged(searchAccount, stats);
|
||||||
@ -607,7 +620,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
|||||||
private boolean onOpenAccount(BaseAccount account) {
|
private boolean onOpenAccount(BaseAccount account) {
|
||||||
if (account instanceof SearchAccount) {
|
if (account instanceof SearchAccount) {
|
||||||
SearchAccount searchAccount = (SearchAccount)account;
|
SearchAccount searchAccount = (SearchAccount)account;
|
||||||
MessageList.actionHandle(this, searchAccount.getDescription(), searchAccount);
|
MessageList.actionDisplaySearch(this, searchAccount.getRelatedSearch(), false);
|
||||||
} else {
|
} else {
|
||||||
Account realAccount = (Account)account;
|
Account realAccount = (Account)account;
|
||||||
if (!realAccount.isEnabled()) {
|
if (!realAccount.isEnabled()) {
|
||||||
@ -624,8 +637,10 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
|||||||
if (K9.FOLDER_NONE.equals(realAccount.getAutoExpandFolderName())) {
|
if (K9.FOLDER_NONE.equals(realAccount.getAutoExpandFolderName())) {
|
||||||
FolderList.actionHandleAccount(this, realAccount);
|
FolderList.actionHandleAccount(this, realAccount);
|
||||||
} else {
|
} 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;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1769,49 +1784,20 @@ public class Accounts extends K9ListActivity implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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) {
|
if (account instanceof SearchAccount) {
|
||||||
SearchAccount searchAccount = (SearchAccount)account;
|
search = ((SearchAccount) account).getRelatedSearch();
|
||||||
|
search.setName(description);
|
||||||
MessageList.actionHandle(Accounts.this,
|
|
||||||
description, "", searchAccount.isIntegrate(),
|
|
||||||
combine(searchAccount.getRequiredFlags(), searchModifier.requiredFlags),
|
|
||||||
combine(searchAccount.getForbiddenFlags(), searchModifier.forbiddenFlags));
|
|
||||||
} else {
|
} else {
|
||||||
SearchSpecification searchSpec = new SearchSpecification() {
|
search = new LocalSearch(description);
|
||||||
@Override
|
search.addAccountUuid(account.getUuid());
|
||||||
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.allRequiredFlags(searchModifier.requiredFlags);
|
||||||
|
search.allForbiddenFlags(searchModifier.forbiddenFlags);
|
||||||
|
MessageList.actionDisplaySearch(Accounts.this, search, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@ import com.fsck.k9.mail.Folder;
|
|||||||
import com.fsck.k9.mail.Message;
|
import com.fsck.k9.mail.Message;
|
||||||
import com.fsck.k9.mail.MessagingException;
|
import com.fsck.k9.mail.MessagingException;
|
||||||
import com.fsck.k9.mail.store.LocalStore.LocalFolder;
|
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.SearchModifier;
|
||||||
import com.fsck.k9.search.SearchSpecification;
|
import com.fsck.k9.search.SearchSpecification;
|
||||||
import com.fsck.k9.service.MailService;
|
import com.fsck.k9.service.MailService;
|
||||||
@ -621,7 +622,10 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onOpenFolder(String folder) {
|
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) {
|
private void onCompact(Account account) {
|
||||||
@ -1258,86 +1262,34 @@ public class FolderList extends K9ListActivity implements OnNavigationListener {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
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(R.string.message_list_title, account.getDescription(), displayName),
|
||||||
getString(searchModifier.resId));
|
getString(searchModifier.resId));
|
||||||
|
|
||||||
SearchSpecification searchSpec = new SearchSpecification() {
|
LocalSearch search = new LocalSearch(description);
|
||||||
@Override
|
try {
|
||||||
public String[] getAccountUuids() {
|
search.allRequiredFlags(searchModifier.requiredFlags);
|
||||||
return new String[] { account.getUuid() };
|
search.allForbiddenFlags(searchModifier.forbiddenFlags);
|
||||||
}
|
} catch (Exception e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
@Override
|
e.printStackTrace();
|
||||||
public Flag[] getForbiddenFlags() {
|
}
|
||||||
return searchModifier.forbiddenFlags;
|
search.addAllowedFolder(folderName);
|
||||||
}
|
search.addAccountUuid(account.getUuid());
|
||||||
|
MessageList.actionDisplaySearch(FolderList.this, search, false);
|
||||||
@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);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Flag[] UNREAD_FLAG_ARRAY = { Flag.SEEN };
|
|
||||||
|
|
||||||
private void openUnreadSearch(Context context, final Account account) {
|
private void openUnreadSearch(Context context, final Account account) {
|
||||||
String description = getString(R.string.search_title, mAccount.getDescription(), getString(R.string.unread_modifier));
|
String description = getString(R.string.search_title, mAccount.getDescription(), getString(R.string.unread_modifier));
|
||||||
|
LocalSearch search = new LocalSearch(description);
|
||||||
SearchSpecification searchSpec = new SearchSpecification() {
|
search.addAccountUuid(account.getUuid());
|
||||||
//interface has no override @Override
|
try {
|
||||||
public String[] getAccountUuids() {
|
search.allRequiredFlags(new Flag[]{Flag.SEEN});
|
||||||
return new String[] { account.getUuid() };
|
} catch (Exception e) {
|
||||||
}
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
//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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,7 @@ public class LauncherShortcuts extends AccountList {
|
|||||||
Intent shortcutIntent = null;
|
Intent shortcutIntent = null;
|
||||||
|
|
||||||
if (account instanceof SearchSpecification) {
|
if (account instanceof SearchSpecification) {
|
||||||
shortcutIntent = MessageList.actionHandleAccountIntent(this, account.getDescription(),
|
shortcutIntent = MessageList.intentDisplaySearch(this, (SearchSpecification) account, true, true);
|
||||||
(SearchSpecification) account);
|
|
||||||
} else {
|
} else {
|
||||||
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
|
shortcutIntent = FolderList.actionHandleAccountIntent(this, (Account) account, null,
|
||||||
true);
|
true);
|
||||||
|
@ -3160,8 +3160,11 @@ public class MessagingController implements Runnable {
|
|||||||
builder.setContentTitle(mApplication.getString(R.string.notification_bg_send_title));
|
builder.setContentTitle(mApplication.getString(R.string.notification_bg_send_title));
|
||||||
builder.setContentText(account.getDescription());
|
builder.setContentText(account.getDescription());
|
||||||
|
|
||||||
Intent intent = MessageList.actionHandleFolderIntent(mApplication, account,
|
LocalSearch search = new LocalSearch(account.getInboxFolderName());
|
||||||
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);
|
PendingIntent pi = PendingIntent.getActivity(mApplication, 0, intent, 0);
|
||||||
builder.setContentIntent(pi);
|
builder.setContentIntent(pi);
|
||||||
|
|
||||||
@ -3243,8 +3246,11 @@ public class MessagingController implements Runnable {
|
|||||||
mApplication.getString(R.string.notification_bg_title_separator) +
|
mApplication.getString(R.string.notification_bg_title_separator) +
|
||||||
folder.getName());
|
folder.getName());
|
||||||
|
|
||||||
Intent intent = MessageList.actionHandleFolderIntent(mApplication, account,
|
LocalSearch search = new LocalSearch(account.getInboxFolderName());
|
||||||
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);
|
PendingIntent pi = PendingIntent.getActivity(mApplication, 0, intent, 0);
|
||||||
builder.setContentIntent(pi);
|
builder.setContentIntent(pi);
|
||||||
|
|
||||||
|
@ -302,7 +302,7 @@ public class MessageProvider extends ContentProvider {
|
|||||||
final SearchAccount integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(getContext());
|
final SearchAccount integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(getContext());
|
||||||
final MessagingController msgController = MessagingController.getInstance(K9.app);
|
final MessagingController msgController = MessagingController.getInstance(K9.app);
|
||||||
|
|
||||||
msgController.searchLocalMessages(integratedInboxAccount, null,
|
msgController.searchLocalMessages(integratedInboxAccount.getRelatedSearch(),
|
||||||
new MesssageInfoHolderRetrieverListener(queue));
|
new MesssageInfoHolderRetrieverListener(queue));
|
||||||
|
|
||||||
final List<MessageInfoHolder> holders = queue.take();
|
final List<MessageInfoHolder> holders = queue.take();
|
||||||
|
@ -8,6 +8,7 @@ import com.fsck.k9.R;
|
|||||||
import com.fsck.k9.activity.UnreadWidgetConfiguration;
|
import com.fsck.k9.activity.UnreadWidgetConfiguration;
|
||||||
import com.fsck.k9.activity.FolderList;
|
import com.fsck.k9.activity.FolderList;
|
||||||
import com.fsck.k9.activity.MessageList;
|
import com.fsck.k9.activity.MessageList;
|
||||||
|
import com.fsck.k9.search.LocalSearch;
|
||||||
|
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.appwidget.AppWidgetManager;
|
import android.appwidget.AppWidgetManager;
|
||||||
@ -62,8 +63,10 @@ public class UnreadWidgetProvider extends AppWidgetProvider {
|
|||||||
clickIntent = FolderList.actionHandleAccountIntent(context, account, null,
|
clickIntent = FolderList.actionHandleAccountIntent(context, account, null,
|
||||||
false);
|
false);
|
||||||
} else {
|
} else {
|
||||||
clickIntent = MessageList.actionHandleFolderIntent(context, account,
|
LocalSearch search = new LocalSearch(account.getAutoExpandFolderName());
|
||||||
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);
|
clickIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user