From 2d4d993ef3eca32835aa2ac9d415bca12a45aef3 Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Wed, 22 Mar 2017 16:38:57 -0700 Subject: [PATCH] Move "scanning" from location setting actionbar to pref xml This fixes the breadcrumb for scanning settings when you search "scan". - Also did some minor cleanup in LocationSettings (creating preference using the correct context) Change-Id: I8efc62246f2e18b2bd4b5eb411b40f24e36b0f2a Fix: 36529569 Test: manual --- res/values/strings.xml | 3 -- res/xml/location_settings.xml | 5 +++ res/xml/security_settings_misc.xml | 4 +- .../settings/location/LocationSettings.java | 37 ++----------------- .../settings/location/SettingsInjector.java | 11 +++--- 5 files changed, 17 insertions(+), 43 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index d37d9d98e6a..2f474fcb358 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3099,9 +3099,6 @@ Use Wi\u2011Fi, Bluetooth, or mobile networks to determine location Use GPS to determine location - - Scanning Scanning diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml index ea85d539296..e063d13aff8 100644 --- a/res/xml/location_settings.xml +++ b/res/xml/location_settings.xml @@ -44,6 +44,11 @@ + + diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml index 943f04cc99f..c29453fafc8 100644 --- a/res/xml/security_settings_misc.xml +++ b/res/xml/security_settings_misc.xml @@ -22,8 +22,8 @@ - + android:title="@string/location_settings_title" + android:fragment="com.android.settings.location.LocationSettings"> locationServices = injector.getInjectedSettings(lockdownOnLocationAccess ? - UserHandle.myUserId() : UserHandle.USER_CURRENT); + final Context prefContext = categoryLocationServices.getContext(); + final List locationServices = injector.getInjectedSettings(prefContext, + lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT); mReceiver = new BroadcastReceiver() { @Override @@ -336,29 +330,6 @@ public class LocationSettings extends LocationSettingsBase } } - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - menu.add(0, MENU_SCANNING, 0, R.string.location_menu_scanning); - // The super class adds "Help & Feedback" menu item. - super.onCreateOptionsMenu(menu, inflater); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - final SettingsActivity activity = (SettingsActivity) getActivity(); - switch (item.getItemId()) { - case MENU_SCANNING: - activity.startPreferencePanel( - this, - ScanningSettings.class.getName(), null, - R.string.location_scanning_screen_title, null, LocationSettings.this, - 0); - return true; - default: - return super.onOptionsItemSelected(item); - } - } - @Override public int getHelpResource() { return R.string.help_url_location_access; diff --git a/src/com/android/settings/location/SettingsInjector.java b/src/com/android/settings/location/SettingsInjector.java index 18697b80dc5..da7dd9e452a 100644 --- a/src/com/android/settings/location/SettingsInjector.java +++ b/src/com/android/settings/location/SettingsInjector.java @@ -231,17 +231,17 @@ class SettingsInjector { * @param profileId Identifier of the user/profile to obtain the injected settings for or * UserHandle.USER_CURRENT for all profiles associated with current user. */ - public List getInjectedSettings(final int profileId) { + public List getInjectedSettings(Context prefContext, final int profileId) { final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE); final List profiles = um.getUserProfiles(); - ArrayList prefs = new ArrayList(); + ArrayList prefs = new ArrayList<>(); final int profileCount = profiles.size(); for (int i = 0; i < profileCount; ++i) { final UserHandle userHandle = profiles.get(i); if (profileId == UserHandle.USER_CURRENT || profileId == userHandle.getIdentifier()) { Iterable settings = getSettings(userHandle); for (InjectedSetting setting : settings) { - Preference pref = addServiceSetting(prefs, setting); + Preference pref = addServiceSetting(prefContext, prefs, setting); mSettings.add(new Setting(setting, pref)); } } @@ -265,7 +265,8 @@ class SettingsInjector { /** * Adds an injected setting to the root. */ - private Preference addServiceSetting(List prefs, InjectedSetting info) { + private Preference addServiceSetting(Context prefContext, List prefs, + InjectedSetting info) { PackageManager pm = mContext.getPackageManager(); Drawable appIcon = pm.getDrawable(info.packageName, info.iconId, null); Drawable icon = pm.getUserBadgedIcon(appIcon, info.mUserHandle); @@ -275,7 +276,7 @@ class SettingsInjector { // a separate content description. badgedAppLabel = null; } - Preference pref = new DimmableIconPreference(mContext, badgedAppLabel); + Preference pref = new DimmableIconPreference(prefContext, badgedAppLabel); pref.setTitle(info.title); pref.setSummary(null); pref.setIcon(icon);