Merge "Move "scanning" from location setting actionbar to pref xml"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c68bd47..127e458 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -3101,9 +3101,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 -->
diff --git a/res/xml/location_settings.xml b/res/xml/location_settings.xml
index ea85d53..e063d13 100644
--- a/res/xml/location_settings.xml
+++ b/res/xml/location_settings.xml
@@ -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" />
diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml
index 943f04c..c29453f 100644
--- a/res/xml/security_settings_misc.xml
+++ b/res/xml/security_settings_misc.xml
@@ -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
diff --git a/src/com/android/settings/location/LocationSettings.java b/src/com/android/settings/location/LocationSettings.java
index 2185f50..e540b2c 100644
--- a/src/com/android/settings/location/LocationSettings.java
+++ b/src/com/android/settings/location/LocationSettings.java
@@ -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.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 @@
/** 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 @@
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
@@ -337,29 +331,6 @@
}
@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 18697b8..da7dd9e 100644
--- a/src/com/android/settings/location/SettingsInjector.java
+++ b/src/com/android/settings/location/SettingsInjector.java
@@ -231,17 +231,17 @@
* @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 @@
/**
* 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 @@
// 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);