Pushes some search behavior to base controller
This enables search on one pane with the same caveats as on two pane Change-Id: I80ab6ada0f718367fe6d584b18bc84d04a27bf7b
This commit is contained in:
parent
f3d07fb3e6
commit
a308618509
|
@ -439,6 +439,28 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the parent mailbox used for the mailbox list fragment.
|
||||
*
|
||||
* IMPORTANT: Do not confuse {@link #getMailboxListMailboxId()} with
|
||||
* {@link #getMessageListMailboxId()}
|
||||
*/
|
||||
protected long getMailboxListMailboxId() {
|
||||
return isMailboxListInstalled() ? getMailboxListFragment().getSelectedMailboxId()
|
||||
: Mailbox.NO_MAILBOX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the mailbox used for the message list fragment.
|
||||
*
|
||||
* IMPORTANT: Do not confuse {@link #getMailboxListMailboxId()} with
|
||||
* {@link #getMessageListMailboxId()}
|
||||
*/
|
||||
protected long getMessageListMailboxId() {
|
||||
return isMessageListInstalled() ? getMessageListFragment().getMailboxId()
|
||||
: Mailbox.NO_MAILBOX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut for {@link #open} with {@link Message#NO_MESSAGE}.
|
||||
*/
|
||||
|
@ -633,6 +655,26 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
|
|||
mActivity.invalidateOptionsMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Kicks off a search query, if the UI is in a state where a search is possible.
|
||||
*/
|
||||
protected void onSearchSubmit(final String queryTerm) {
|
||||
final long accountId = getUIAccountId();
|
||||
if (!Account.isNormalAccount(accountId)) {
|
||||
return; // Invalid account to search from.
|
||||
}
|
||||
|
||||
// TODO: do a global search for EAS inbox.
|
||||
final long mailboxId = getMessageListMailboxId();
|
||||
|
||||
if (Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "Submitting search: " + queryTerm);
|
||||
}
|
||||
|
||||
mActivity.startActivity(EmailActivity.createSearchIntent(
|
||||
mActivity, accountId, mailboxId, queryTerm));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getClass().getSimpleName(); // Shown on logcat
|
||||
|
|
|
@ -259,7 +259,10 @@ class UIControllerOnePane extends UIControllerBase {
|
|||
|
||||
@Override
|
||||
public void onSearchSubmit(String queryTerm) {
|
||||
// STOPSHIP implement search
|
||||
if (!isMessageListInstalled()) {
|
||||
return;
|
||||
}
|
||||
UIControllerOnePane.this.onSearchSubmit(queryTerm);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -341,27 +341,6 @@ class UIControllerTwoPane extends UIControllerBase implements
|
|||
:Account.NO_ACCOUNT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the parent mailbox used for the mailbox list fragment.
|
||||
*
|
||||
* IMPORTANT: Do not confuse {@link #getMailboxListMailboxId()} with
|
||||
* {@link #getMessageListMailboxId()}
|
||||
*/
|
||||
private long getMailboxListMailboxId() {
|
||||
return isMailboxListInstalled() ? getMailboxListFragment().getSelectedMailboxId()
|
||||
: Mailbox.NO_MAILBOX;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of the mailbox used for the message list fragment.
|
||||
*
|
||||
* IMPORTANT: Do not confuse {@link #getMailboxListMailboxId()} with
|
||||
* {@link #getMessageListMailboxId()}
|
||||
*/
|
||||
private long getMessageListMailboxId() {
|
||||
return isMessageListInstalled() ? getMessageListFragment().getMailboxId()
|
||||
: Mailbox.NO_MAILBOX;
|
||||
}
|
||||
|
||||
/*
|
||||
* STOPSHIP Remove this -- see the base class method.
|
||||
|
@ -937,20 +916,7 @@ class UIControllerTwoPane extends UIControllerBase implements
|
|||
|
||||
@Override
|
||||
public void onSearchSubmit(final String queryTerm) {
|
||||
final long accountId = getUIAccountId();
|
||||
if (!Account.isNormalAccount(accountId)) {
|
||||
return; // Invalid account to search from.
|
||||
}
|
||||
|
||||
// TODO: do a global search for EAS inbox.
|
||||
final long mailboxId = getMessageListMailboxId();
|
||||
|
||||
if (Email.DEBUG) {
|
||||
Log.d(Logging.LOG_TAG, "Submitting search: " + queryTerm);
|
||||
}
|
||||
|
||||
mActivity.startActivity(EmailActivity.createSearchIntent(
|
||||
mActivity, accountId, mailboxId, queryTerm));
|
||||
UIControllerTwoPane.this.onSearchSubmit(queryTerm);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue