diff --git a/src/com/fsck/k9/SearchAccount.java b/src/com/fsck/k9/SearchAccount.java index b990e8d09..bf2f25570 100644 --- a/src/com/fsck/k9/SearchAccount.java +++ b/src/com/fsck/k9/SearchAccount.java @@ -12,6 +12,39 @@ import com.fsck.k9.mail.Flag; * is defined by {@link com.fsck.k9.activity.SearchModifier}. */ public class SearchAccount implements BaseAccount, SearchSpecification, Serializable { + /** + * Create a {@code SearchAccount} instance for the Unified Inbox. + * + * @param context + * A {@link Context} instance that will be used to get localized strings and will be + * passed on to the {@code SearchAccount} instance. + * + * @return The {@link SearchAccount} instance for the Unified Inbox. + */ + public static SearchAccount createUnifiedInboxAccount(Context context) { + SearchAccount unifiedInbox = new SearchAccount(context, true, null, null); + unifiedInbox.setDescription(context.getString(R.string.integrated_inbox_title)); + unifiedInbox.setEmail(context.getString(R.string.integrated_inbox_detail)); + return unifiedInbox; + } + + /** + * Create a {@code SearchAccount} instance for the special account "All messages". + * + * @param context + * A {@link Context} instance that will be used to get localized strings and will be + * passed on to the {@code SearchAccount} instance. + * + * @return The {@link SearchAccount} instance for the Unified Inbox. + */ + public static SearchAccount createAllMessagesAccount(Context context) { + SearchAccount allMessages = new SearchAccount(context, false, null, null); + allMessages.setDescription(context.getString(R.string.search_all_messages_title)); + allMessages.setEmail(context.getString(R.string.search_all_messages_detail)); + return allMessages; + } + + private static final long serialVersionUID = -4388420303235543976L; private Flag[] mRequiredFlags = null; private Flag[] mForbiddenFlags = null; diff --git a/src/com/fsck/k9/activity/AccountList.java b/src/com/fsck/k9/activity/AccountList.java index a229702ad..52c64dbe3 100644 --- a/src/com/fsck/k9/activity/AccountList.java +++ b/src/com/fsck/k9/activity/AccountList.java @@ -73,16 +73,11 @@ public abstract class AccountList extends K9ListActivity implements OnItemClickL List accounts = new ArrayList(); if (displaySpecialAccounts() && !K9.isHideSpecialAccounts()) { - BaseAccount integratedInboxAccount = new SearchAccount(this, true, null, null); - integratedInboxAccount.setDescription(getString(R.string.integrated_inbox_title)); - integratedInboxAccount.setEmail(getString(R.string.integrated_inbox_detail)); + BaseAccount unifiedInboxAccount = SearchAccount.createUnifiedInboxAccount(this); + BaseAccount allMessagesAccount = SearchAccount.createAllMessagesAccount(this); - BaseAccount unreadAccount = new SearchAccount(this, false, null, null); - unreadAccount.setDescription(getString(R.string.search_all_messages_title)); - unreadAccount.setEmail(getString(R.string.search_all_messages_detail)); - - accounts.add(integratedInboxAccount); - accounts.add(unreadAccount); + accounts.add(unifiedInboxAccount); + accounts.add(allMessagesAccount); } accounts.addAll(Arrays.asList(realAccounts)); diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 031785e62..339494044 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -382,16 +382,11 @@ public class Accounts extends K9ListActivity implements OnItemClickListener, OnC } /** - * Creates and initializes the special accounts ('Integrated Inbox' and 'All Messages') + * Creates and initializes the special accounts ('Unified Inbox' and 'All Messages') */ private void createSpecialAccounts() { - unreadAccount = new SearchAccount(this, false, null, null); - unreadAccount.setDescription(getString(R.string.search_all_messages_title)); - unreadAccount.setEmail(getString(R.string.search_all_messages_detail)); - - integratedInboxAccount = new SearchAccount(this, true, null, null); - integratedInboxAccount.setDescription(getString(R.string.integrated_inbox_title)); - integratedInboxAccount.setEmail(getString(R.string.integrated_inbox_detail)); + integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(this); + unreadAccount = SearchAccount.createAllMessagesAccount(this); } @SuppressWarnings("unchecked") diff --git a/src/com/fsck/k9/provider/MessageProvider.java b/src/com/fsck/k9/provider/MessageProvider.java index f2c1ec693..50220c31c 100644 --- a/src/com/fsck/k9/provider/MessageProvider.java +++ b/src/com/fsck/k9/provider/MessageProvider.java @@ -60,7 +60,7 @@ public class MessageProvider extends ContentProvider { *

Type: TEXT

*/ String SENDER = "sender"; - + /** *

Type: TEXT

*/ @@ -245,7 +245,7 @@ public class MessageProvider extends ContentProvider { final BlockingQueue> queue = new SynchronousQueue>(); // new code for integrated inbox, only execute this once as it will be processed afterwards via the listener - final SearchAccount integratedInboxAccount = new SearchAccount(getContext(), true, null, null); + final SearchAccount integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(getContext()); final MessagingController msgController = MessagingController.getInstance(K9.app); msgController.searchLocalMessages(integratedInboxAccount, null,