mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 00:58:50 -05:00
Deduplicated code to create SearchAccounts for special accounts
This commit is contained in:
parent
ae6679769b
commit
f6ebe4d4e0
@ -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;
|
||||
|
@ -73,16 +73,11 @@ public abstract class AccountList extends K9ListActivity implements OnItemClickL
|
||||
List<BaseAccount> accounts = new ArrayList<BaseAccount>();
|
||||
|
||||
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));
|
||||
|
@ -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")
|
||||
|
@ -245,7 +245,7 @@ public class MessageProvider extends ContentProvider {
|
||||
final BlockingQueue<List<MessageInfoHolder>> queue = new SynchronousQueue<List<MessageInfoHolder>>();
|
||||
|
||||
// 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,
|
||||
|
Loading…
Reference in New Issue
Block a user