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
This commit is contained in:
@@ -3099,9 +3099,6 @@
|
||||
<string name="location_mode_battery_saving_description">Use Wi\u2011Fi, Bluetooth, or mobile networks to determine location</string>
|
||||
<!-- [CHAR LIMIT=130] Location mode screen, description for sensors only mode -->
|
||||
<string name="location_mode_sensors_only_description">Use GPS to determine location</string>
|
||||
<!-- Help menu label [CHAR LIMIT=20] Location settings screen, overflow menu that takes the user
|
||||
to scanning settings activity -->
|
||||
<string name="location_menu_scanning">Scanning</string>
|
||||
<!-- [CHAR LIMIT=30] Wireless background scanning settings screen, screen title -->
|
||||
<string name="location_scanning_screen_title">Scanning</string>
|
||||
<!-- [CHAR LIMIT=130] Preference title for Wi-Fi always scanning -->
|
||||
|
@@ -44,6 +44,11 @@
|
||||
</intent>
|
||||
</Preference>
|
||||
|
||||
<Preference
|
||||
android:key="location_scanning"
|
||||
android:title="@string/location_scanning_screen_title"
|
||||
android:fragment="com.android.settings.location.ScanningSettings"/>
|
||||
|
||||
<PreferenceCategory
|
||||
android:key="recent_location_requests"
|
||||
android:title="@string/location_category_recent_location_requests" />
|
||||
|
@@ -22,8 +22,8 @@
|
||||
|
||||
<Preference
|
||||
android:key="location"
|
||||
android:title="@string/location_settings_title">
|
||||
<intent android:action="android.settings.LOCATION_SOURCE_SETTINGS"/>
|
||||
android:title="@string/location_settings_title"
|
||||
android:fragment="com.android.settings.location.LocationSettings">
|
||||
</Preference>
|
||||
|
||||
<SwitchPreference
|
||||
|
@@ -17,9 +17,7 @@
|
||||
package com.android.settings.location;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
@@ -27,16 +25,13 @@ import android.location.SettingInjectorService;
|
||||
import android.os.Bundle;
|
||||
import android.os.UserHandle;
|
||||
import android.os.UserManager;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceCategory;
|
||||
import android.support.v7.preference.PreferenceGroup;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Switch;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
|
||||
import com.android.settings.DimmableIconPreference;
|
||||
import com.android.settings.R;
|
||||
@@ -98,8 +93,6 @@ public class LocationSettings extends LocationSettingsBase
|
||||
/** Key for preference category "Location services" */
|
||||
private static final String KEY_LOCATION_SERVICES = "location_services";
|
||||
|
||||
private static final int MENU_SCANNING = Menu.FIRST;
|
||||
|
||||
private SwitchBar mSwitchBar;
|
||||
private Switch mSwitch;
|
||||
private boolean mValidListener = false;
|
||||
@@ -311,8 +304,9 @@ public class LocationSettings extends LocationSettingsBase
|
||||
injector = new SettingsInjector(context);
|
||||
// If location access is locked down by device policy then we only show injected settings
|
||||
// for the primary profile.
|
||||
List<Preference> locationServices = injector.getInjectedSettings(lockdownOnLocationAccess ?
|
||||
UserHandle.myUserId() : UserHandle.USER_CURRENT);
|
||||
final Context prefContext = categoryLocationServices.getContext();
|
||||
final List<Preference> 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;
|
||||
|
@@ -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<Preference> getInjectedSettings(final int profileId) {
|
||||
public List<Preference> getInjectedSettings(Context prefContext, final int profileId) {
|
||||
final UserManager um = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
|
||||
final List<UserHandle> profiles = um.getUserProfiles();
|
||||
ArrayList<Preference> prefs = new ArrayList<Preference>();
|
||||
ArrayList<Preference> 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<InjectedSetting> 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<Preference> prefs, InjectedSetting info) {
|
||||
private Preference addServiceSetting(Context prefContext, List<Preference> 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);
|
||||
|
Reference in New Issue
Block a user