Hide search icon in search mode.

This is a kludge - the real solution is to use the proper action modes
in the framework. That's too large to do this late.

Bug: 5232787
Change-Id: I76b68b250c384bdabf51e8831f833afd65c0c73b
This commit is contained in:
Ben Komalo 2011-08-30 14:57:21 -07:00
parent 8466f79a06
commit f97ec4d1e8
4 changed files with 32 additions and 2 deletions

View File

@ -178,6 +178,11 @@ public class ActionBarController {
*/
public String getSearchHint();
/**
* Called when the action bar initially shows the search entry field.
*/
public void onSearchStarted();
/**
* Called when a search is submitted.
*
@ -275,7 +280,7 @@ public class ActionBarController {
/**
* @return true if the search box is shown.
*/
private boolean isInSearchMode() {
public boolean isInSearchMode() {
return mSearchMode == MODE_SEARCH;
}
@ -311,6 +316,7 @@ public class ActionBarController {
mSearchView.setIconified(false);
refresh();
mCallback.onSearchStarted();
}
public void exitSearchMode() {

View File

@ -627,6 +627,11 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
*/
public abstract boolean onBackPressed(boolean isSystemBackKey);
public void onSearchStarted() {
// Show/hide the original search icon.
mActivity.invalidateOptionsMenu();
}
/**
* Must be called from {@link Activity#onSearchRequested()}.
* This initiates the search entry mode - see {@link #onSearchSubmit} for when the search
@ -748,6 +753,9 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
protected void onSearchExit() {
if ((mListContext != null) && mListContext.isSearch()) {
mActivity.finish();
} else {
// Re show the search icon.
mActivity.invalidateOptionsMenu();
}
}
@ -793,7 +801,10 @@ abstract class UIControllerBase implements MailboxListFragment.Callback,
}
}
menu.findItem(R.id.search).setVisible(accountSearchable && mailboxHasServerCounterpart);
boolean showSearchIcon = !mActionBarController.isInSearchMode()
&& accountSearchable && mailboxHasServerCounterpart;
menu.findItem(R.id.search).setVisible(showSearchIcon);
menu.findItem(R.id.mailbox_settings).setVisible(isEas && mailboxHasServerCounterpart);
return true;
}

View File

@ -233,6 +233,14 @@ class UIControllerOnePane extends UIControllerBase {
return UIControllerOnePane.this.getSearchHint();
}
@Override
public void onSearchStarted() {
if (!isMessageListInstalled()) {
return;
}
UIControllerOnePane.this.onSearchStarted();
}
@Override
public void onSearchSubmit(String queryTerm) {
if (!isMessageListInstalled()) {

View File

@ -694,6 +694,11 @@ class UIControllerTwoPane extends UIControllerBase implements ThreePaneLayout.Ca
return UIControllerTwoPane.this.getSearchHint();
}
@Override
public void onSearchStarted() {
UIControllerTwoPane.this.onSearchStarted();
}
@Override
public void onSearchSubmit(final String queryTerm) {
UIControllerTwoPane.this.onSearchSubmit(queryTerm);