Make more room in the ActionBar

See bug #14898161

- allow Search Option Menu only on the Dashboard (and no more
in the Settings screens)
- push the "Start Now" Day Dream Option Menu to be a real Menu
so that we can see the "Day Dream" title

Change-Id: I4a7c21fb3599ada8efc82bd5bd8c9f5049937ceb
This commit is contained in:
Fabrice Di Meglio
2014-05-13 14:39:41 -07:00
parent 15826d4ea1
commit 35062d6983
2 changed files with 13 additions and 4 deletions

View File

@@ -150,7 +150,7 @@ public class DreamSettings extends SettingsPreferenceFragment {
// create "start" action // create "start" action
MenuItem start = createMenuItem(menu, R.string.screensaver_settings_dream_start, MenuItem start = createMenuItem(menu, R.string.screensaver_settings_dream_start,
MenuItem.SHOW_AS_ACTION_ALWAYS, MenuItem.SHOW_AS_ACTION_NEVER,
isEnabled, new Runnable(){ isEnabled, new Runnable(){
@Override @Override
public void run() { public void run() {
@@ -160,7 +160,7 @@ public class DreamSettings extends SettingsPreferenceFragment {
// create "when to dream" overflow menu item // create "when to dream" overflow menu item
MenuItem whenToDream = createMenuItem(menu, MenuItem whenToDream = createMenuItem(menu,
R.string.screensaver_settings_when_to_dream, R.string.screensaver_settings_when_to_dream,
MenuItem.SHOW_AS_ACTION_IF_ROOM, MenuItem.SHOW_AS_ACTION_NEVER,
isEnabled, isEnabled,
new Runnable() { new Runnable() {
@Override @Override

View File

@@ -304,6 +304,8 @@ public class SettingsActivity extends Activity
private ActionBar mActionBar; private ActionBar mActionBar;
private boolean mDisplayHomeAsUpEnabled; private boolean mDisplayHomeAsUpEnabled;
private boolean mIsShowingDashboard;
private SearchView mSearchView; private SearchView mSearchView;
private MenuItem mSearchMenuItem; private MenuItem mSearchMenuItem;
private boolean mSearchMenuItemExpanded = false; private boolean mSearchMenuItemExpanded = false;
@@ -387,6 +389,11 @@ public class SettingsActivity extends Activity
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
// Only show the Search menu on the main screen (Dashboard)
if (!mIsShowingDashboard) {
return true;
}
MenuInflater inflater = getMenuInflater(); MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu); inflater.inflate(R.menu.options_menu, menu);
@@ -442,7 +449,9 @@ public class SettingsActivity extends Activity
// Getting Intent properties can only be done after the super.onCreate(...) // Getting Intent properties can only be done after the super.onCreate(...)
final String initialFragmentName = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); final String initialFragmentName = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT);
if (initialFragmentName == null) { mIsShowingDashboard = (initialFragmentName == null);
if (mIsShowingDashboard) {
Index.getInstance(this).update(); Index.getInstance(this).update();
} }
@@ -468,7 +477,7 @@ public class SettingsActivity extends Activity
// We need to build the Categories in all cases // We need to build the Categories in all cases
buildDashboardCategories(mCategories); buildDashboardCategories(mCategories);
if (initialFragmentName != null) { if (!mIsShowingDashboard) {
final ComponentName cn = getIntent().getComponent(); final ComponentName cn = getIntent().getComponent();
// No UP is we are launched thru a Settings shortcut // No UP is we are launched thru a Settings shortcut
if (!cn.getClassName().equals(SubSettings.class.getName())) { if (!cn.getClassName().equals(SubSettings.class.getName())) {