diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 021a7f1cc..6ea002279 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -198,10 +198,6 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
diff --git a/res/xml/searchable.xml b/res/layout/action_bar_search.xml
similarity index 58%
rename from res/xml/searchable.xml
rename to res/layout/action_bar_search.xml
index e716bbbbb..73c7f7f14 100644
--- a/res/xml/searchable.xml
+++ b/res/layout/action_bar_search.xml
@@ -14,8 +14,17 @@
limitations under the License.
-->
-
+
+
+
diff --git a/res/values/dimensions.xml b/res/values/dimensions.xml
index 3461752cb..9a62b1107 100644
--- a/res/values/dimensions.xml
+++ b/res/values/dimensions.xml
@@ -65,4 +65,6 @@
340dip
+
+ 360dip
diff --git a/res/values/strings.xml b/res/values/strings.xml
index db491bec6..22b20f91a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -52,6 +52,8 @@
+
+
@@ -1099,11 +1101,12 @@ save attachment.
target language. Typical alternatives include "+999" and ">999". [CHAR_LIMIT=4] -->
999+
-
- Email
-
+
Search email
+
+ Search %1$s
+
Mailbox check frequency
diff --git a/src/com/android/email/activity/ActionBarController.java b/src/com/android/email/activity/ActionBarController.java
index 978c5492f..52b09addb 100644
--- a/src/com/android/email/activity/ActionBarController.java
+++ b/src/com/android/email/activity/ActionBarController.java
@@ -28,15 +28,39 @@ import android.content.Context;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
+import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
+import android.widget.SearchView;
import android.widget.TextView;
/**
* Manages the account name and the custom view part on the action bar.
+ *
+ * TODO Show current mailbox name/unread count on the account spinner
+ * -- and remove mMailboxNameContainer.
+ *
+ * TODO Stop using the action bar spinner and create our own spinner as a custom view.
+ * (so we'll be able to just hide it, etc.)
+ *
+ * TODO Update search hint somehow
*/
public class ActionBarController {
+ private static final String BUNDLE_KEY_MODE = "ActionBarController.BUNDLE_KEY_MODE";
+
+ /**
+ * Constants for {@link #mMode}.
+ *
+ * In {@link #MODE_NORMAL} mode, we don't show the search box.
+ * In {@link #MODE_SEARCH} mode, we do show the search box.
+ * The action bar doesn't really care if the activity is showing search results.
+ * If the activity is showing search results, and the {@link Callback#onSearchExit} is called,
+ * the activity probably wants to close itself, but this class doesn't make the desision.
+ */
+ private static final int MODE_NORMAL = 0;
+ private static final int MODE_SEARCH = 1;
+
private static final int LOADER_ID_ACCOUNT_LIST
= EmailActivity.ACTION_BAR_CONTROLLER_LOADER_ID_BASE + 0;
@@ -44,9 +68,12 @@ public class ActionBarController {
private final LoaderManager mLoaderManager;
private final ActionBar mActionBar;
- private final View mActionBarMailboxNameView;
- private final TextView mActionBarMailboxName;
- private final TextView mActionBarUnreadCount;
+ private final View mActionBarCustomView;
+ private final View mMailboxNameContainer;
+ private final TextView mMailboxNameView;
+ private final TextView mUnreadCountView;
+ private final View mSearchContainer;
+ private final SearchView mSearchView;
private final ActionBarNavigationCallback mActionBarNavigationCallback =
new ActionBarNavigationCallback();
@@ -56,8 +83,15 @@ public class ActionBarController {
/** The current account ID; used to determine if the account has changed. */
private long mLastAccountIdForDirtyCheck = Account.NO_ACCOUNT;
+ /** Either {@link #MODE_NORMAL} or {@link #MODE_SEARCH}. */
+ private int mMode = MODE_NORMAL;
+
public final Callback mCallback;
+ public interface SearchContext {
+ public long getTargetMailboxId();
+ }
+
public interface Callback {
/** @return true if an account is selected. */
public boolean isAccountSelected();
@@ -97,6 +131,18 @@ public class ActionBarController {
/** Called when no accounts are found in the database. */
public void onNoAccountsFound();
+
+ /**
+ * Called when a search is submitted.
+ *
+ * @param queryTerm query string
+ */
+ public void onSearchSubmit(String queryTerm);
+
+ /**
+ * Called when the search box is closed.
+ */
+ public void onSearchExit();
}
public ActionBarController(Context context, LoaderManager loaderManager,
@@ -110,42 +156,122 @@ public class ActionBarController {
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME
| ActionBar.DISPLAY_SHOW_CUSTOM);
- // The custom view for the current mailbox and the unread count.
+ // Prepare the custom view
final LayoutInflater inflater = LayoutInflater.from(mContext);
- mActionBarMailboxNameView = inflater.inflate(R.layout.action_bar_current_mailbox, null);
+ mActionBarCustomView = inflater.inflate(R.layout.action_bar_custom_view, null);
final ActionBar.LayoutParams customViewLayout = new ActionBar.LayoutParams(
ActionBar.LayoutParams.WRAP_CONTENT,
ActionBar.LayoutParams.MATCH_PARENT);
- customViewLayout.setMargins(mContext.getResources().getDimensionPixelSize(
- R.dimen.action_bar_mailbox_name_left_margin) , 0, 0, 0);
- mActionBar.setCustomView(mActionBarMailboxNameView, customViewLayout);
+ customViewLayout.setMargins(0 , 0, 0, 0);
+ mActionBar.setCustomView(mActionBarCustomView, customViewLayout);
- mActionBarMailboxName = UiUtilities.getView(mActionBarMailboxNameView, R.id.mailbox_name);
- mActionBarUnreadCount = UiUtilities.getView(mActionBarMailboxNameView, R.id.unread_count);
+ // Mailbox name / unread count
+ mMailboxNameContainer = UiUtilities.getView(mActionBarCustomView,
+ R.id.current_mailbox_container);
+ mMailboxNameView = UiUtilities.getView(mMailboxNameContainer, R.id.mailbox_name);
+ mUnreadCountView = UiUtilities.getView(mMailboxNameContainer, R.id.unread_count);
+
+ // Search
+ mSearchContainer = UiUtilities.getView(mActionBarCustomView, R.id.search_container);
+ mSearchView = UiUtilities.getView(mSearchContainer, R.id.search_view);
+ mSearchView.setSubmitButtonEnabled(true);
+ mSearchView.setOnQueryTextListener(mOnQueryText);
}
- /**
- * Must be called when the host activity is created.
- */
+ /** Must be called from {@link UIControllerBase#onActivityCreated()} */
public void onActivityCreated() {
loadAccounts();
refresh();
}
+ /** Must be called from {@link UIControllerBase#onActivityDestroy()} */
+ public void onActivityDestroy() {
+ }
+
+ /** Must be called from {@link UIControllerBase#onSaveInstanceState} */
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putInt(BUNDLE_KEY_MODE, mMode);
+ }
+
+ /** Must be called from {@link UIControllerBase#onRestoreInstanceState} */
+ public void onRestoreInstanceState(Bundle savedState) {
+ mMode= savedState.getInt(BUNDLE_KEY_MODE);
+ }
+
+ /**
+ * @return true if the search box is shown.
+ */
+ private boolean isInSearchMode() {
+ return mMode == MODE_SEARCH;
+ }
+
+ /**
+ * Show the search box.
+ *
+ * @param initialQueryTerm if non-empty, set to the search box.
+ */
+ public void enterSearchMode(String initialQueryTerm) {
+ if (isInSearchMode()) {
+ return;
+ }
+ if (!TextUtils.isEmpty(initialQueryTerm)) {
+ mSearchView.setQuery(initialQueryTerm, false);
+ }
+ mMode = MODE_SEARCH;
+ refresh();
+ }
+
+ private void exitSearchMode() {
+ if (!isInSearchMode()) {
+ return;
+ }
+ mMode = MODE_NORMAL;
+ refresh();
+ mCallback.onSearchExit();
+ }
+
+ /**
+ * Performs the back action.
+ *
+ * @param isSystemBackKey true
if the system back key was pressed.
+ * false
if it's caused by the "home" icon click on the action bar.
+ */
+ public boolean onBackPressed(boolean isSystemBackKey) {
+ if (isInSearchMode()) {
+ exitSearchMode();
+ return true;
+ }
+ return false;
+ }
+
/** Refreshes the action bar display. */
public void refresh() {
- mActionBar.setDisplayOptions(mCallback.shouldShowUp()
+ final boolean showUp = isInSearchMode() || mCallback.shouldShowUp();
+ mActionBar.setDisplayOptions(showUp
? ActionBar.DISPLAY_HOME_AS_UP : 0, ActionBar.DISPLAY_HOME_AS_UP);
- mActionBarMailboxNameView.setVisibility(mCallback.shouldShowMailboxName()
- ? View.VISIBLE : View.GONE);
+ // TODO In search mode, account spinner should be hidden.
+ // (See also the TODO in the class header -- this methods needs a lot of change.)
- mActionBarMailboxName.setText(mCallback.getCurrentMailboxName());
+ if (isInSearchMode()) {
+ boolean wasVisible = (mSearchView.getVisibility() == View.VISIBLE);
+ mSearchView.setVisibility(View.VISIBLE);
+ if (!wasVisible) {
+ mSearchView.requestFocus();
+ }
+ mMailboxNameContainer.setVisibility(View.GONE);
+ } else {
+ mSearchView.setVisibility(View.GONE);
+ mMailboxNameContainer.setVisibility(mCallback.shouldShowMailboxName()
+ ? View.VISIBLE : View.GONE);
+ }
+
+ mMailboxNameView.setText(mCallback.getCurrentMailboxName());
// Note on action bar, we show only "unread count". Some mailboxes such as Outbox don't
// have the idea of "unread count", in which case we just omit the count.
- mActionBarUnreadCount.setText(UiUtilities.getMessageCountForUi(mContext,
- mCallback.getCurrentMailboxUnreadCount(), true));
+ mUnreadCountView.setText(UiUtilities.getMessageCountForUi(mContext,
+ mCallback.getCurrentMailboxUnreadCount(), true));
// Update the account list only when the account has changed.
if (mLastAccountIdForDirtyCheck != mCallback.getUIAccountId()) {
@@ -253,4 +379,20 @@ public class ActionBarController {
return true;
}
}
+
+ private final SearchView.OnQueryTextListener mOnQueryText
+ = new SearchView.OnQueryTextListener() {
+ @Override
+ public boolean onQueryTextChange(String newText) {
+ // Event not handled. Let the search do the default action.
+ return false;
+ }
+
+ @Override
+ public boolean onQueryTextSubmit(String query) {
+ mCallback.onSearchSubmit(mSearchView.getQuery().toString());
+ return true; // Event handled.
+ }
+ };
+
}
diff --git a/src/com/android/email/activity/EmailActivity.java b/src/com/android/email/activity/EmailActivity.java
index fb5d76019..7341621d5 100644
--- a/src/com/android/email/activity/EmailActivity.java
+++ b/src/com/android/email/activity/EmailActivity.java
@@ -34,7 +34,6 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.Fragment;
-import android.app.SearchManager;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
@@ -62,6 +61,7 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra
private static final String EXTRA_ACCOUNT_ID = "ACCOUNT_ID";
private static final String EXTRA_MAILBOX_ID = "MAILBOX_ID";
private static final String EXTRA_MESSAGE_ID = "MESSAGE_ID";
+ private static final String EXTRA_QUERY_STRING = "QUERY_STRING";
/** Loader IDs starting with this is safe to use from UIControllers. */
static final int UI_CONTROLLER_LOADER_ID_BASE = 100;
@@ -139,6 +139,28 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra
return i;
}
+ /**
+ * Create an intent to launch search activity.
+ *
+ * @param accountId ID of the account for the mailbox. Must not be {@link Account#NO_ACCOUNT}.
+ * @param mailboxId ID of the mailbox to search, or {@link Mailbox#NO_MAILBOX} to perform
+ * global search.
+ * @param query query string.
+ */
+ public static Intent createSearchIntent(Activity fromActivity, long accountId,
+ long mailboxId, String query) {
+ // STOPSHIP temporary search UI
+ if (accountId == Account.NO_ACCOUNT) {
+ throw new IllegalArgumentException();
+ }
+ Intent i = IntentUtilities.createRestartAppIntent(fromActivity, EmailActivity.class);
+ i.putExtra(EXTRA_ACCOUNT_ID, accountId);
+ i.putExtra(EXTRA_MAILBOX_ID, mailboxId);
+ i.putExtra(EXTRA_QUERY_STRING, query);
+ i.setAction(Intent.ACTION_SEARCH);
+ return i;
+ }
+
/**
* Initialize {@link #mUIController}.
*/
@@ -176,7 +198,7 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra
mErrorBanner = new BannerController(this, errorMessage, errorBannerHeight);
if (savedInstanceState != null) {
- mUIController.restoreInstanceState(savedInstanceState);
+ mUIController.onRestoreInstanceState(savedInstanceState);
} else {
// This needs to be done after installRestoredFragments.
// See UIControllerTwoPane.preFragmentTransactionCheck()
@@ -235,13 +257,10 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra
// STOPSHIP Temporary search UI
Intent intent = getIntent();
if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
- // TODO Very temporary (e.g. no database access in UI thread)
- Bundle appData = getIntent().getBundleExtra(SearchManager.APP_DATA);
- if (appData == null) return; // ??
- final long accountId = appData.getLong(EXTRA_ACCOUNT_ID);
- final long mailboxId = appData.getLong(EXTRA_MAILBOX_ID);
- final String queryString = intent.getStringExtra(SearchManager.QUERY);
- Log.d(Logging.LOG_TAG, queryString);
+ final long accountId = intent.getLongExtra(EXTRA_ACCOUNT_ID, Account.NO_ACCOUNT);
+ final long mailboxId = intent.getLongExtra(EXTRA_MAILBOX_ID, Mailbox.NO_MAILBOX);
+ final String queryString = intent.getStringExtra(EXTRA_QUERY_STRING);
+ Log.d(Logging.LOG_TAG, "Search: " + queryString);
// Switch to search mailbox
// TODO How to handle search from within the search mailbox??
final Controller controller = Controller.getInstance(mContext);
@@ -346,27 +365,15 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
- // STOPSHIP Temporary search/sync options UI
- // Only show search/sync options for EAS 12.0 and later
+ // STOPSHIP Temporary sync options UI
boolean isEas = false;
- boolean canSearch = false;
+
long accountId = mUIController.getActualAccountId();
if (accountId > 0) {
// Move database operations out of the UI thread
- if ("eas".equals(Account.getProtocol(mContext, accountId))) {
- isEas = true;
- Account account = Account.restoreAccountWithId(mContext, accountId);
- if (account != null) {
- // We should set a flag in the account indicating ability to handle search
- String protocolVersion = account.mProtocolVersion;
- if (Double.parseDouble(protocolVersion) >= 12.0) {
- canSearch = true;
- }
- }
- }
+ isEas = "eas".equals(Account.getProtocol(mContext, accountId));
}
- // Should use an isSearchable call to prevent search on inappropriate accounts/boxes
- menu.findItem(R.id.search).setVisible(canSearch);
+
// Should use an isSyncable call to prevent drafts/outbox from allowing this
menu.findItem(R.id.sync_lookback).setVisible(isEas);
menu.findItem(R.id.sync_frequency).setVisible(isEas);
@@ -374,13 +381,19 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra
return mUIController.onPrepareOptionsMenu(getMenuInflater(), menu);
}
+ /**
+ * Called when the search key is pressd.
+ *
+ * Use the below command to emulate the key press on devices without the search key.
+ * adb shell input keyevent 84
+ */
@Override
public boolean onSearchRequested() {
- Bundle bundle = new Bundle();
- bundle.putLong(EXTRA_ACCOUNT_ID, mUIController.getActualAccountId());
- bundle.putLong(EXTRA_MAILBOX_ID, mUIController.getSearchMailboxId());
- startSearch(null, false, bundle, false);
- return true;
+ if (Email.DEBUG) {
+ Log.d(Logging.LOG_TAG, this + " onSearchRequested");
+ }
+ mUIController.onSearchRequested();
+ return true; // Event handled.
}
// STOPSHIP Set column from user options
@@ -491,9 +504,6 @@ public class EmailActivity extends Activity implements View.OnClickListener, Fra
case R.id.sync_frequency:
showDialog(MAILBOX_SYNC_FREQUENCY_DIALOG);
return true;
- case R.id.search:
- onSearchRequested();
- return true;
}
return super.onOptionsItemSelected(item);
}
diff --git a/src/com/android/email/activity/UIControllerBase.java b/src/com/android/email/activity/UIControllerBase.java
index af6a0b68a..8eb1eeb7a 100644
--- a/src/com/android/email/activity/UIControllerBase.java
+++ b/src/com/android/email/activity/UIControllerBase.java
@@ -210,6 +210,7 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, this + " onActivityDestroy");
}
+ mActionBarController.onActivityDestroy();
mRefreshManager.unregisterListener(mRefreshListener);
mTaskTracker.cancellAllInterrupt();
}
@@ -223,17 +224,19 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
}
outState.putBoolean(BUNDLE_KEY_RESUME_INBOX_LOOKUP, mResumeInboxLookup);
outState.putLong(BUNDLE_KEY_INBOX_LOOKUP_ACCOUNT_ID, mInboxLookupAccountId);
+ mActionBarController.onSaveInstanceState(outState);
}
/**
* Handles the {@link android.app.Activity#onRestoreInstanceState} callback.
*/
- public void restoreInstanceState(Bundle savedInstanceState) {
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
if (Logging.DEBUG_LIFECYCLE && Email.DEBUG) {
Log.d(Logging.LOG_TAG, this + " restoreInstanceState");
}
mResumeInboxLookup = savedInstanceState.getBoolean(BUNDLE_KEY_RESUME_INBOX_LOOKUP);
mInboxLookupAccountId = savedInstanceState.getLong(BUNDLE_KEY_INBOX_LOOKUP_ACCOUNT_ID);
+ mActionBarController.onRestoreInstanceState(savedInstanceState);
}
/**
@@ -482,10 +485,25 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
/**
* Performs the back action.
*
+ * NOTE The method in the base class has precedence. Subclasses overriding this method MUST
+ * call super's method first.
+ *
* @param isSystemBackKey true
if the system back key was pressed.
* false
if it's caused by the "home" icon click on the action bar.
*/
- public abstract boolean onBackPressed(boolean isSystemBackKey);
+ public boolean onBackPressed(boolean isSystemBackKey) {
+ if (mActionBarController.onBackPressed(isSystemBackKey)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Must be called from {@link Activity#onSearchRequested()}.
+ */
+ public void onSearchRequested() {
+ mActionBarController.enterSearchMode(null);
+ }
/**
* Callback called when the inbox lookup (started by {@link #startInboxLookup}) is finished.
@@ -550,6 +568,11 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
mInboxFinder = null;
}
+ /** @return true if the search menu option should be enabled. */
+ protected boolean canSearch() {
+ return false;
+ }
+
/**
* Handles the {@link android.app.Activity#onCreateOptionsMenu} callback.
*/
@@ -575,6 +598,29 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
} else {
item.setVisible(false);
}
+
+ // STOPSHIP Temporary search options code
+ // Only show search/sync options for EAS 12.0 and later
+ boolean canSearch = false;
+ if (canSearch()) {
+ long accountId = getActualAccountId();
+ if (accountId > 0) {
+ // Move database operations out of the UI thread
+ if ("eas".equals(Account.getProtocol(mActivity, accountId))) {
+ Account account = Account.restoreAccountWithId(mActivity, accountId);
+ if (account != null) {
+ // We should set a flag in the account indicating ability to handle search
+ String protocolVersion = account.mProtocolVersion;
+ if (Double.parseDouble(protocolVersion) >= 12.0) {
+ canSearch = true;
+ }
+ }
+ }
+ }
+ }
+ // Should use an isSearchable call to prevent search on inappropriate accounts/boxes
+ menu.findItem(R.id.search).setVisible(canSearch);
+
return true;
}
@@ -596,6 +642,9 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
return true;
case R.id.account_settings:
return onAccountSettings();
+ case R.id.search:
+ onSearchRequested();
+ return true;
}
return false;
}
@@ -619,13 +668,6 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
return true;
}
- /**
- * STOPSHIP For experimental UI. Remove this.
- *
- * @return mailbox ID which we search for messages.
- */
- public abstract long getSearchMailboxId();
-
/**
* STOPSHIP For experimental UI. Remove this.
*
diff --git a/src/com/android/email/activity/UIControllerOnePane.java b/src/com/android/email/activity/UIControllerOnePane.java
index a51ca74e0..9d67d105f 100644
--- a/src/com/android/email/activity/UIControllerOnePane.java
+++ b/src/com/android/email/activity/UIControllerOnePane.java
@@ -258,6 +258,16 @@ class UIControllerOnePane extends UIControllerBase {
Welcome.actionStart(mActivity);
mActivity.finish();
}
+
+ @Override
+ public void onSearchSubmit(String queryTerm) {
+ // STOPSHIP implement search
+ }
+
+ @Override
+ public void onSearchExit() {
+ // STOPSHIP implement search
+ }
}
public UIControllerOnePane(EmailActivity activity) {
@@ -284,8 +294,8 @@ class UIControllerOnePane extends UIControllerBase {
}
@Override
- public void restoreInstanceState(Bundle savedInstanceState) {
- super.restoreInstanceState(savedInstanceState);
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
mPreviousFragment = mActivity.getFragmentManager().getFragment(savedInstanceState,
BUNDLE_KEY_PREVIOUS_FRAGMENT);
}
@@ -397,6 +407,10 @@ class UIControllerOnePane extends UIControllerBase {
// This is VERY important -- no check for DEBUG_LIFECYCLE
Log.d(Logging.LOG_TAG, this + " onBackPressed: " + isSystemBackKey);
}
+ // Super's method has precedence. Must call it first.
+ if (super.onBackPressed(isSystemBackKey)) {
+ return true;
+ }
// If the mailbox list is shown and showing a nested mailbox, let it navigate up first.
if (isMailboxListInstalled() && getMailboxListFragment().navigateUp()) {
if (DEBUG_FRAGMENTS) {
@@ -644,14 +658,10 @@ class UIControllerOnePane extends UIControllerBase {
return Mailbox.NO_MAILBOX;
}
- /*
- * STOPSHIP Remove this -- see the base class method.
- */
- @Override
- public long getSearchMailboxId() {
- // Search is still experimental, and doesn't have to work on the phone.
- Utility.showToast(mActivity, "STOPSHIP: Search not supported on 1 pane");
- return Mailbox.NO_MAILBOX;
+ @Override protected boolean canSearch() {
+ return false; // STOPSHIP no search on one pane yet
+ // Search is enabled only on the message list. (for now)
+ // return isMessageListInstalled();
}
@Override
diff --git a/src/com/android/email/activity/UIControllerTwoPane.java b/src/com/android/email/activity/UIControllerTwoPane.java
index 15ecf8680..eb41c35d1 100644
--- a/src/com/android/email/activity/UIControllerTwoPane.java
+++ b/src/com/android/email/activity/UIControllerTwoPane.java
@@ -410,14 +410,6 @@ class UIControllerTwoPane extends UIControllerBase implements
return getMessageListMailboxId();
}
- /*
- * STOPSHIP Remove this -- see the base class method.
- */
- @Override
- public long getSearchMailboxId() {
- return getMessageListMailboxId();
- }
-
private long getMessageId() {
return isMessageViewInstalled() ? getMessageViewFragment().getMessageId()
: Message.NO_MESSAGE;
@@ -494,8 +486,8 @@ class UIControllerTwoPane extends UIControllerBase implements
/** {@inheritDoc} */
@Override
- public void restoreInstanceState(Bundle savedInstanceState) {
- super.restoreInstanceState(savedInstanceState);
+ public void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
}
@Override
@@ -812,14 +804,24 @@ class UIControllerTwoPane extends UIControllerBase implements
/** {@inheritDoc} */
@Override
public boolean onBackPressed(boolean isSystemBackKey) {
+ // Super's method has precedence. Must call it first.
+ if (super.onBackPressed(isSystemBackKey)) {
+ return true;
+ }
if (mThreePane.onBackPressed(isSystemBackKey)) {
return true;
- } else if (isMailboxListInstalled() && getMailboxListFragment().navigateUp()) {
+ }
+ if (isMailboxListInstalled() && getMailboxListFragment().navigateUp()) {
return true;
}
return false;
}
+ @Override protected boolean canSearch() {
+ // Search is always enabled on two-pane. (if the account supports it)
+ return true;
+ }
+
/**
* Handles the "refresh" option item. Opens the settings activity.
* TODO used by experimental code in the activity -- otherwise can be private.
@@ -991,5 +993,25 @@ class UIControllerTwoPane extends UIControllerBase implements
return leftPaneHidden
|| (isMailboxListInstalled() && !getMailboxListFragment().isRoot());
}
+
+ @Override
+ public void onSearchSubmit(String queryTerm) {
+ // STOPSHIP temporary code
+ final long accountId = getUIAccountId();
+ if (accountId == Account.NO_ACCOUNT) {
+ return; // no account selected.
+ }
+ final long mailboxId = getMessageListMailboxId();
+
+ // TODO global search?
+
+ mActivity.startActivity(EmailActivity.createSearchIntent(
+ mActivity, accountId, mailboxId, queryTerm));
+ }
+
+ @Override
+ public void onSearchExit() {
+ // STOPSHIP If the activity is a "search" instance, finish() it.
+ }
}
}