mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-25 17:18: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}.
|
* is defined by {@link com.fsck.k9.activity.SearchModifier}.
|
||||||
*/
|
*/
|
||||||
public class SearchAccount implements BaseAccount, SearchSpecification, Serializable {
|
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 static final long serialVersionUID = -4388420303235543976L;
|
||||||
private Flag[] mRequiredFlags = null;
|
private Flag[] mRequiredFlags = null;
|
||||||
private Flag[] mForbiddenFlags = null;
|
private Flag[] mForbiddenFlags = null;
|
||||||
|
@ -73,16 +73,11 @@ public abstract class AccountList extends K9ListActivity implements OnItemClickL
|
|||||||
List<BaseAccount> accounts = new ArrayList<BaseAccount>();
|
List<BaseAccount> accounts = new ArrayList<BaseAccount>();
|
||||||
|
|
||||||
if (displaySpecialAccounts() && !K9.isHideSpecialAccounts()) {
|
if (displaySpecialAccounts() && !K9.isHideSpecialAccounts()) {
|
||||||
BaseAccount integratedInboxAccount = new SearchAccount(this, true, null, null);
|
BaseAccount unifiedInboxAccount = SearchAccount.createUnifiedInboxAccount(this);
|
||||||
integratedInboxAccount.setDescription(getString(R.string.integrated_inbox_title));
|
BaseAccount allMessagesAccount = SearchAccount.createAllMessagesAccount(this);
|
||||||
integratedInboxAccount.setEmail(getString(R.string.integrated_inbox_detail));
|
|
||||||
|
|
||||||
BaseAccount unreadAccount = new SearchAccount(this, false, null, null);
|
accounts.add(unifiedInboxAccount);
|
||||||
unreadAccount.setDescription(getString(R.string.search_all_messages_title));
|
accounts.add(allMessagesAccount);
|
||||||
unreadAccount.setEmail(getString(R.string.search_all_messages_detail));
|
|
||||||
|
|
||||||
accounts.add(integratedInboxAccount);
|
|
||||||
accounts.add(unreadAccount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
accounts.addAll(Arrays.asList(realAccounts));
|
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() {
|
private void createSpecialAccounts() {
|
||||||
unreadAccount = new SearchAccount(this, false, null, null);
|
integratedInboxAccount = SearchAccount.createUnifiedInboxAccount(this);
|
||||||
unreadAccount.setDescription(getString(R.string.search_all_messages_title));
|
unreadAccount = SearchAccount.createAllMessagesAccount(this);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -245,7 +245,7 @@ public class MessageProvider extends ContentProvider {
|
|||||||
final BlockingQueue<List<MessageInfoHolder>> queue = new SynchronousQueue<List<MessageInfoHolder>>();
|
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
|
// 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);
|
final MessagingController msgController = MessagingController.getInstance(K9.app);
|
||||||
|
|
||||||
msgController.searchLocalMessages(integratedInboxAccount, null,
|
msgController.searchLocalMessages(integratedInboxAccount, null,
|
||||||
|
Loading…
Reference in New Issue
Block a user