Update Security & screen lock preference
- change password category title to Privacy and move Location into it. - remove Advanced security preference category - remove SIM card preference category and move the SIM card lock preferece down. - move Encryption and Credential settings to a separate screen. Bug: 34976707 Test: make RunSettingsRoboTests Change-Id: Iebaba4a8aad135fa88f163de0b60b488fd9510d0
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.android.settings.location;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.support.v7.preference.Preference;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.PreferenceController;
|
||||
|
||||
public class LocationPreferenceController extends PreferenceController {
|
||||
|
||||
private static final String KEY_LOCATION = "location";
|
||||
private Preference mPreference;
|
||||
|
||||
public LocationPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayPreference(PreferenceScreen screen) {
|
||||
super.displayPreference(screen);
|
||||
mPreference = screen.findPreference(KEY_LOCATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
preference.setSummary(getLocationSummary(mContext));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return KEY_LOCATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void updateSummary() {
|
||||
updateState(mPreference);
|
||||
}
|
||||
|
||||
public static String getLocationSummary(Context context) {
|
||||
int mode = Secure.getInt(context.getContentResolver(),
|
||||
Secure.LOCATION_MODE, Secure.LOCATION_MODE_OFF);
|
||||
if (mode != Secure.LOCATION_MODE_OFF) {
|
||||
return context.getString(R.string.location_on_summary,
|
||||
context.getString(getLocationString(mode)));
|
||||
}
|
||||
return context.getString(R.string.location_off_summary);
|
||||
}
|
||||
|
||||
public static int getLocationString(int mode) {
|
||||
switch (mode) {
|
||||
case Secure.LOCATION_MODE_OFF:
|
||||
return R.string.location_mode_location_off_title;
|
||||
case Secure.LOCATION_MODE_SENSORS_ONLY:
|
||||
return R.string.location_mode_sensors_only_title;
|
||||
case Secure.LOCATION_MODE_BATTERY_SAVING:
|
||||
return R.string.location_mode_battery_saving_title;
|
||||
case Secure.LOCATION_MODE_HIGH_ACCURACY:
|
||||
return R.string.location_mode_high_accuracy_title;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -362,23 +362,9 @@ public class LocationSettings extends LocationSettingsBase
|
||||
return R.string.help_url_location_access;
|
||||
}
|
||||
|
||||
private static int getLocationString(int mode) {
|
||||
switch (mode) {
|
||||
case android.provider.Settings.Secure.LOCATION_MODE_OFF:
|
||||
return R.string.location_mode_location_off_title;
|
||||
case android.provider.Settings.Secure.LOCATION_MODE_SENSORS_ONLY:
|
||||
return R.string.location_mode_sensors_only_title;
|
||||
case android.provider.Settings.Secure.LOCATION_MODE_BATTERY_SAVING:
|
||||
return R.string.location_mode_battery_saving_title;
|
||||
case android.provider.Settings.Secure.LOCATION_MODE_HIGH_ACCURACY:
|
||||
return R.string.location_mode_high_accuracy_title;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onModeChanged(int mode, boolean restricted) {
|
||||
int modeDescription = getLocationString(mode);
|
||||
int modeDescription = LocationPreferenceController.getLocationString(mode);
|
||||
if (modeDescription != 0) {
|
||||
mLocationMode.setSummary(modeDescription);
|
||||
}
|
||||
@@ -486,15 +472,8 @@ public class LocationSettings extends LocationSettingsBase
|
||||
@Override
|
||||
public void setListening(boolean listening) {
|
||||
if (listening) {
|
||||
int mode = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF);
|
||||
if (mode != Settings.Secure.LOCATION_MODE_OFF) {
|
||||
mSummaryLoader.setSummary(this, mContext.getString(R.string.location_on_summary,
|
||||
mContext.getString(getLocationString(mode))));
|
||||
} else {
|
||||
mSummaryLoader.setSummary(this,
|
||||
mContext.getString(R.string.location_off_summary));
|
||||
}
|
||||
mSummaryLoader.setSummary(
|
||||
this, LocationPreferenceController.getLocationSummary(mContext));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user