summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings
diff options
context:
space:
mode:
authorFabrice Di Meglio <fdimeglio@google.com>2014-06-06 12:13:29 -0700
committerFabrice Di Meglio <fdimeglio@google.com>2014-06-06 12:13:29 -0700
commit3d35ec729256d4a1e1796be3e9d858eefedda23d (patch)
treecca54671688de2817a34fccbbce0c254bb72f1b6 /src/com/android/settings
parent132652c5576462f036ed9437720b15b0c31430e4 (diff)
downloadpackages_apps_Settings-3d35ec729256d4a1e1796be3e9d858eefedda23d.tar.gz
packages_apps_Settings-3d35ec729256d4a1e1796be3e9d858eefedda23d.tar.bz2
packages_apps_Settings-3d35ec729256d4a1e1796be3e9d858eefedda23d.zip
Fix bug #15469483 Search menu should not be present when Settings is launched as a Shortcut
- create the Search menu only for non shortcut launch Change-Id: I8f83fb6c199509f2b2215a20b19f92e3d736b733
Diffstat (limited to 'src/com/android/settings')
-rw-r--r--src/com/android/settings/SettingsActivity.java39
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);
}
}