diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2014-06-06 20:57:22 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-06-06 20:57:22 +0000 |
commit | c56acc5f3c625e50a54bea2a1f8b5cb008ce6580 (patch) | |
tree | 061bb6ca882c6d4ac5aadbbe48c3b72d1e2856ac | |
parent | e12b2f047aea6bbff26ea3381174712246b875a8 (diff) | |
parent | 3d35ec729256d4a1e1796be3e9d858eefedda23d (diff) | |
download | packages_apps_Settings-c56acc5f3c625e50a54bea2a1f8b5cb008ce6580.tar.gz packages_apps_Settings-c56acc5f3c625e50a54bea2a1f8b5cb008ce6580.tar.bz2 packages_apps_Settings-c56acc5f3c625e50a54bea2a1f8b5cb008ce6580.zip |
am 3d35ec72: Fix bug #15469483 Search menu should not be present when Settings is launched as a Shortcut
* commit '3d35ec729256d4a1e1796be3e9d858eefedda23d':
Fix bug #15469483 Search menu should not be present when Settings is launched as a Shortcut
-rw-r--r-- | src/com/android/settings/SettingsActivity.java | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index e602fa6ee..6ba79ccb2 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -133,6 +133,7 @@ public class SettingsActivity extends Activity private static final String SAVE_KEY_SEARCH_MENU_EXPANDED = ":settings:search_menu_expanded"; private static final String SAVE_KEY_SEARCH_QUERY = ":settings:search_query"; private static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up"; + private static final String SAVE_KEY_SHOW_SEARCH = ":settings:show_search"; /** * When starting this activity, the invoking Intent can contain this extra @@ -306,7 +307,9 @@ public class SettingsActivity extends Activity private SwitchBar mSwitchBar; private Button mNextButton; + private boolean mDisplayHomeAsUpEnabled; + private boolean mDisplaySearch; private boolean mIsShowingDashboard; @@ -401,6 +404,10 @@ public class SettingsActivity extends Activity @Override public boolean onCreateOptionsMenu(Menu menu) { + if (!mDisplaySearch) { + return false; + } + MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.options_menu, menu); @@ -454,6 +461,7 @@ public class SettingsActivity extends Activity getFragmentManager().addOnBackStackChangedListener(this); mDisplayHomeAsUpEnabled = true; + mDisplaySearch = true; // Getting Intent properties can only be done after the super.onCreate(...) final String initialFragmentName = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); @@ -483,12 +491,14 @@ public class SettingsActivity extends Activity } mDisplayHomeAsUpEnabled = savedState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP); + mDisplaySearch = savedState.getBoolean(SAVE_KEY_SHOW_SEARCH); } else { if (!mIsShowingDashboard) { final ComponentName cn = getIntent().getComponent(); - // No UP is we are launched thru a Settings shortcut + // No UP nor Search is shown we are launched thru a Settings "shortcut" if (!cn.getClassName().equals(SubSettings.class.getName())) { mDisplayHomeAsUpEnabled = false; + mDisplaySearch = false; } final String initialTitle = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT_TITLE); mInitialTitle = (initialTitle != null) ? initialTitle : getTitle(); @@ -610,17 +620,20 @@ public class SettingsActivity extends Activity } outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled); - - // The option menus are created if the ActionBar is visible and they are also created - // asynchronously. If you launch Settings with an Intent action like - // android.intent.action.POWER_USAGE_SUMMARY and at the same time your device is locked - // thru a LockScreen, onCreateOptionsMenu() is not yet called and references to the search - // menu item and search view are null. - boolean isExpanded = (mSearchMenuItem != null) && mSearchMenuItem.isActionViewExpanded(); - outState.putBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED, isExpanded); - - String query = (mSearchView != null) ? mSearchView.getQuery().toString() : EMPTY_QUERY; - outState.putString(SAVE_KEY_SEARCH_QUERY, query); + outState.putBoolean(SAVE_KEY_SHOW_SEARCH, mDisplaySearch); + + if (mDisplaySearch) { + // The option menus are created if the ActionBar is visible and they are also created + // asynchronously. If you launch Settings with an Intent action like + // android.intent.action.POWER_USAGE_SUMMARY and at the same time your device is locked + // thru a LockScreen, onCreateOptionsMenu() is not yet called and references to the search + // menu item and search view are null. + boolean isExpanded = (mSearchMenuItem != null) && mSearchMenuItem.isActionViewExpanded(); + outState.putBoolean(SAVE_KEY_SEARCH_MENU_EXPANDED, isExpanded); + + String query = (mSearchView != null) ? mSearchView.getQuery().toString() : EMPTY_QUERY; + outState.putString(SAVE_KEY_SEARCH_QUERY, query); + } } @Override @@ -641,7 +654,7 @@ public class SettingsActivity extends Activity mDynamicIndexableContentMonitor.register(this); - if(!TextUtils.isEmpty(mSearchQuery)) { + if(mDisplaySearch && !TextUtils.isEmpty(mSearchQuery)) { onQueryTextSubmit(mSearchQuery); } } |