Remove logic for adding a search icon to action bar.
No longer used given that we don't show the search icon on any page. The main settings page now has the search bar. Change-Id: I9535028298739467e7fa9c75d1a2fb2b2fa3251b Fixes: 62230804 Bug: 37477506 Test: robotests
This commit is contained in:
@@ -87,8 +87,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
private static final String SAVE_KEY_CATEGORIES = ":settings:categories";
|
private static final String SAVE_KEY_CATEGORIES = ":settings:categories";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up";
|
static final String SAVE_KEY_SHOW_HOME_AS_UP = ":settings:show_home_as_up";
|
||||||
@VisibleForTesting
|
|
||||||
static final String SAVE_KEY_SHOW_SEARCH = ":settings:show_search";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When starting this activity, the invoking Intent can contain this extra
|
* When starting this activity, the invoking Intent can contain this extra
|
||||||
@@ -192,22 +190,18 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
|
|
||||||
private DynamicIndexableContentMonitor mDynamicIndexableContentMonitor;
|
private DynamicIndexableContentMonitor mDynamicIndexableContentMonitor;
|
||||||
|
|
||||||
private ActionBar mActionBar;
|
|
||||||
private SwitchBar mSwitchBar;
|
private SwitchBar mSwitchBar;
|
||||||
|
|
||||||
private Button mNextButton;
|
private Button mNextButton;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean mDisplayHomeAsUpEnabled;
|
boolean mDisplayHomeAsUpEnabled;
|
||||||
@VisibleForTesting
|
|
||||||
boolean mDisplaySearch;
|
|
||||||
|
|
||||||
private boolean mIsShowingDashboard;
|
private boolean mIsShowingDashboard;
|
||||||
private boolean mIsShortcut;
|
private boolean mIsShortcut;
|
||||||
|
|
||||||
private ViewGroup mContent;
|
private ViewGroup mContent;
|
||||||
|
|
||||||
private SearchFeatureProvider mSearchFeatureProvider;
|
|
||||||
private MetricsFeatureProvider mMetricsFeatureProvider;
|
private MetricsFeatureProvider mMetricsFeatureProvider;
|
||||||
|
|
||||||
// Categories
|
// Categories
|
||||||
@@ -232,15 +226,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
|
||||||
if (!mDisplaySearch) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
mSearchFeatureProvider.setUpSearchMenu(menu, this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SharedPreferences getSharedPreferences(String name, int mode) {
|
public SharedPreferences getSharedPreferences(String name, int mode) {
|
||||||
if (name.equals(getPackageName() + "_preferences")) {
|
if (name.equals(getPackageName() + "_preferences")) {
|
||||||
@@ -284,7 +269,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
final FeatureFactory factory = FeatureFactory.getFactory(this);
|
final FeatureFactory factory = FeatureFactory.getFactory(this);
|
||||||
|
|
||||||
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
|
mDashboardFeatureProvider = factory.getDashboardFeatureProvider(this);
|
||||||
mSearchFeatureProvider = factory.getSearchFeatureProvider();
|
|
||||||
mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
|
mMetricsFeatureProvider = factory.getMetricsFeatureProvider();
|
||||||
|
|
||||||
// Should happen before any call to getIntent()
|
// Should happen before any call to getIntent()
|
||||||
@@ -324,7 +308,7 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
setContentView(mIsShowingDashboard ?
|
setContentView(mIsShowingDashboard ?
|
||||||
R.layout.settings_main_dashboard : R.layout.settings_main_prefs);
|
R.layout.settings_main_dashboard : R.layout.settings_main_prefs);
|
||||||
|
|
||||||
mContent = (ViewGroup) findViewById(R.id.main_content);
|
mContent = findViewById(R.id.main_content);
|
||||||
|
|
||||||
getFragmentManager().addOnBackStackChangedListener(this);
|
getFragmentManager().addOnBackStackChangedListener(this);
|
||||||
|
|
||||||
@@ -355,12 +339,12 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
setActionBar(toolbar);
|
setActionBar(toolbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
mActionBar = getActionBar();
|
ActionBar actionBar = getActionBar();
|
||||||
if (mActionBar != null) {
|
if (actionBar != null) {
|
||||||
mActionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
|
actionBar.setDisplayHomeAsUpEnabled(mDisplayHomeAsUpEnabled);
|
||||||
mActionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
|
actionBar.setHomeButtonEnabled(mDisplayHomeAsUpEnabled);
|
||||||
}
|
}
|
||||||
mSwitchBar = (SwitchBar) findViewById(R.id.switch_bar);
|
mSwitchBar = findViewById(R.id.switch_bar);
|
||||||
if (mSwitchBar != null) {
|
if (mSwitchBar != null) {
|
||||||
mSwitchBar.setMetricsTag(getMetricsTag());
|
mSwitchBar.setMetricsTag(getMetricsTag());
|
||||||
}
|
}
|
||||||
@@ -427,7 +411,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
void launchSettingFragment(String initialFragmentName, boolean isSubSettings, Intent intent) {
|
void launchSettingFragment(String initialFragmentName, boolean isSubSettings, Intent intent) {
|
||||||
if (!mIsShowingDashboard && initialFragmentName != null) {
|
if (!mIsShowingDashboard && initialFragmentName != null) {
|
||||||
mDisplaySearch = false;
|
|
||||||
// UP will be shown only if it is a sub settings
|
// UP will be shown only if it is a sub settings
|
||||||
if (mIsShortcut) {
|
if (mIsShortcut) {
|
||||||
mDisplayHomeAsUpEnabled = isSubSettings;
|
mDisplayHomeAsUpEnabled = isSubSettings;
|
||||||
@@ -444,8 +427,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
} else {
|
} else {
|
||||||
// Show search icon as up affordance if we are displaying the main Dashboard
|
// Show search icon as up affordance if we are displaying the main Dashboard
|
||||||
mDisplayHomeAsUpEnabled = true;
|
mDisplayHomeAsUpEnabled = true;
|
||||||
// toolbar is search affordance so don't show search
|
|
||||||
mDisplaySearch = false;
|
|
||||||
mInitialTitleResId = R.string.dashboard_title;
|
mInitialTitleResId = R.string.dashboard_title;
|
||||||
|
|
||||||
switchToFragment(DashboardSummary.class.getName(), null /* args */, false, false,
|
switchToFragment(DashboardSummary.class.getName(), null /* args */, false, false,
|
||||||
@@ -453,13 +434,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisplaySearchMenu(boolean displaySearch) {
|
|
||||||
if (displaySearch != mDisplaySearch) {
|
|
||||||
mDisplaySearch = displaySearch;
|
|
||||||
invalidateOptionsMenu();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setTitleFromIntent(Intent intent) {
|
private void setTitleFromIntent(Intent intent) {
|
||||||
final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
|
final int initialTitleResId = intent.getIntExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, -1);
|
||||||
if (initialTitleResId > 0) {
|
if (initialTitleResId > 0) {
|
||||||
@@ -540,7 +514,6 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled);
|
outState.putBoolean(SAVE_KEY_SHOW_HOME_AS_UP, mDisplayHomeAsUpEnabled);
|
||||||
outState.putBoolean(SAVE_KEY_SHOW_SEARCH, mDisplaySearch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -548,19 +521,13 @@ public class SettingsActivity extends SettingsDrawerActivity
|
|||||||
super.onRestoreInstanceState(savedInstanceState);
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
|
|
||||||
mDisplayHomeAsUpEnabled = savedInstanceState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
|
mDisplayHomeAsUpEnabled = savedInstanceState.getBoolean(SAVE_KEY_SHOW_HOME_AS_UP);
|
||||||
mDisplaySearch = savedInstanceState.getBoolean(SAVE_KEY_SHOW_SEARCH);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
mDevelopmentPreferencesListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
|
mDevelopmentPreferencesListener = (sharedPreferences, key) -> updateTilesList();
|
||||||
@Override
|
|
||||||
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
|
|
||||||
updateTilesList();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(
|
mDevelopmentPreferences.registerOnSharedPreferenceChangeListener(
|
||||||
mDevelopmentPreferencesListener);
|
mDevelopmentPreferencesListener);
|
||||||
|
|
||||||
|
@@ -36,14 +36,6 @@ public interface SearchFeatureProvider {
|
|||||||
*/
|
*/
|
||||||
boolean isEnabled(Context context);
|
boolean isEnabled(Context context);
|
||||||
|
|
||||||
/**
|
|
||||||
* Inserts the Menu items into Settings activity.
|
|
||||||
*
|
|
||||||
* @param menu Items will be inserted into this menu.
|
|
||||||
* @param activity The activity that precedes SearchActivity.
|
|
||||||
*/
|
|
||||||
void setUpSearchMenu(Menu menu, Activity activity);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a new loader to search in index database.
|
* Returns a new loader to search in index database.
|
||||||
*/
|
*/
|
||||||
|
@@ -43,23 +43,6 @@ public class SearchFeatureProviderImpl implements SearchFeatureProvider {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUpSearchMenu(Menu menu, final Activity activity) {
|
|
||||||
if (menu == null || activity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String menuTitle = activity.getString(R.string.search_menu);
|
|
||||||
MenuItem menuItem = menu.add(Menu.NONE, Menu.NONE, Menu.NONE, menuTitle)
|
|
||||||
.setIcon(R.drawable.ic_search_24dp)
|
|
||||||
.setOnMenuItemClickListener(item -> {
|
|
||||||
Intent intent = new Intent(activity, SearchActivity.class);
|
|
||||||
activity.startActivity(intent);
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
|
|
||||||
menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatabaseResultLoader getDatabaseSearchLoader(Context context, String query) {
|
public DatabaseResultLoader getDatabaseSearchLoader(Context context, String query) {
|
||||||
return new DatabaseResultLoader(context, query, getSiteMapManager());
|
return new DatabaseResultLoader(context, query, getSiteMapManager());
|
||||||
|
@@ -61,7 +61,6 @@ public class ConfigureWifiSettings extends DashboardFragment {
|
|||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
mProgressiveDisclosureMixin.setTileLimit(
|
mProgressiveDisclosureMixin.setTileLimit(
|
||||||
mUseOpenWifiPreferenceController.isAvailable() ? 3 : 2);
|
mUseOpenWifiPreferenceController.isAvailable() ? 3 : 2);
|
||||||
((SettingsActivity) getActivity()).setDisplaySearchMenu(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -67,15 +67,10 @@ public class SettingsActivityTest {
|
|||||||
private Bitmap mBitmap;
|
private Bitmap mBitmap;
|
||||||
private SettingsActivity mActivity;
|
private SettingsActivity mActivity;
|
||||||
|
|
||||||
private FakeFeatureFactory mFeatureFactory;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
FakeFeatureFactory.setupForTest(mContext);
|
|
||||||
mFeatureFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
|
||||||
|
|
||||||
mActivity = spy(new SettingsActivity());
|
mActivity = spy(new SettingsActivity());
|
||||||
doReturn(mBitmap).when(mActivity).getBitmapFromXmlResource(anyInt());
|
doReturn(mBitmap).when(mActivity).getBitmapFromXmlResource(anyInt());
|
||||||
}
|
}
|
||||||
@@ -98,26 +93,6 @@ public class SettingsActivityTest {
|
|||||||
verify(mTaskDescription).setIcon(nullable(Bitmap.class));
|
verify(mTaskDescription).setIcon(nullable(Bitmap.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCreateOptionsMenu_setsUpSearch() {
|
|
||||||
ReflectionHelpers.setField(mActivity, "mSearchFeatureProvider",
|
|
||||||
mFeatureFactory.getSearchFeatureProvider());
|
|
||||||
mActivity.mDisplaySearch = true;
|
|
||||||
mActivity.onCreateOptionsMenu(null);
|
|
||||||
|
|
||||||
verify(mFeatureFactory.getSearchFeatureProvider()).setUpSearchMenu(nullable(Menu.class),
|
|
||||||
nullable(Activity.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSaveState_DisplaySearchSaved() {
|
|
||||||
mActivity.mDisplaySearch = true;
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
mActivity.saveState(bundle);
|
|
||||||
|
|
||||||
assertThat((boolean) bundle.get(SettingsActivity.SAVE_KEY_SHOW_SEARCH)).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSaveState_EnabledHomeSaved() {
|
public void testSaveState_EnabledHomeSaved() {
|
||||||
mActivity.mDisplayHomeAsUpEnabled = true;
|
mActivity.mDisplayHomeAsUpEnabled = true;
|
||||||
@@ -127,24 +102,6 @@ public class SettingsActivityTest {
|
|||||||
assertThat((boolean) bundle.get(SettingsActivity.SAVE_KEY_SHOW_HOME_AS_UP)).isTrue();
|
assertThat((boolean) bundle.get(SettingsActivity.SAVE_KEY_SHOW_HOME_AS_UP)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRestoreState_DisplaySearchRestored() {
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean(SettingsActivity.SAVE_KEY_SHOW_SEARCH, true);
|
|
||||||
mActivity.onRestoreInstanceState(bundle);
|
|
||||||
|
|
||||||
assertThat(mActivity.mDisplaySearch).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testRestoreState_EnabledHomeRestored() {
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putBoolean(SettingsActivity.SAVE_KEY_SHOW_SEARCH, true);
|
|
||||||
mActivity.onRestoreInstanceState(bundle);
|
|
||||||
|
|
||||||
assertThat(mActivity.mDisplaySearch).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOnClick() {
|
public void testOnClick() {
|
||||||
doReturn("com.android.settings").when(mActivity).getPackageName();
|
doReturn("com.android.settings").when(mActivity).getPackageName();
|
||||||
|
@@ -55,18 +55,6 @@ public class SearchFeatureProviderImplTest {
|
|||||||
mProvider = new SearchFeatureProviderImpl();
|
mProvider = new SearchFeatureProviderImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testPassNull_NoError() {
|
|
||||||
mProvider.setUpSearchMenu(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetUpMenu_HasItemAdded() {
|
|
||||||
mProvider.setUpSearchMenu(menu, mActivity);
|
|
||||||
|
|
||||||
verify(menu).add(anyInt(), anyInt(), anyInt(), anyString());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getSiteMapManager_shouldCacheInstance() {
|
public void getSiteMapManager_shouldCacheInstance() {
|
||||||
final SiteMapManager manager1 = mProvider.getSiteMapManager();
|
final SiteMapManager manager1 = mProvider.getSiteMapManager();
|
||||||
|
Reference in New Issue
Block a user