Merge "Sort saved networks using case insensitive order."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 10b91cb..7b853cc 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -272,7 +272,7 @@
android:configChanges="orientation|keyboardHidden|screenSize"
android:parentActivityName="Settings$WifiSettingsActivity">
<intent-filter android:priority="1">
- <action android:name="android.settings.CONFIGURE_WIFI_SETTINGS" />
+ <action android:name="android.settings.WIFI_IP_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ba919ce..11aa84c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -744,10 +744,12 @@
<string name="security_settings_title">Security & screen lock</string>
<!-- Security Settings screen setting option title for the item to take you to the encryption and credential screen -->
<string name="encryption_and_credential_settings_title">Encryption & credentials</string>
+ <!-- Security Settings screen Encryption and crendential summary -->
+ <string name="encryption_and_credential_settings_summary">Phone encrypted</string>
<!-- Security Settings screen setting option title for the item to take you to the lock screen preference screen [CHAR LIMIT=60] -->
<string name="lockscreen_settings_title">Lock screen preferences</string>
<!-- Security Settings screen setting option summary for the item to take you to the lock screen preference screen -->
- <string name="lockscreen_settings_summary">Access settings in lock screen</string>
+ <string name="lockscreen_settings_summary">Show all notification content</string>
<!-- Main Settings screen setting option summary text for the item tot ake you to the security and location screen -->
<string name="security_settings_summary">Set My Location, screen unlock, SIM card lock, credential storage lock</string>
@@ -1069,6 +1071,12 @@
<!-- Title for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=22] -->
<string name="unlock_set_unlock_launch_picker_title">Screen lock</string>
+ <!-- Summary for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=NONE] -->
+ <string name="unlock_set_unlock_launch_picker_summary_lock_immediately"><xliff:g id="unlock_method" example="PIN">%1$s</xliff:g> / Immediately after sleep</string>
+
+ <!-- Summary for PreferenceScreen to launch picker for security method when there is none [CHAR LIMIT=NONE] -->
+ <string name="unlock_set_unlock_launch_picker_summary_lock_after_timeout"><xliff:g id="unlock_method" example="PIN">%1$s</xliff:g> / <xliff:g id="timeout_string">%2$s</xliff:g> after sleep</string>
+
<!-- Profile Security lock settings --><skip />
<!-- Title for PreferenceScreen to launch picker for security method for the managed profile when there is none [CHAR LIMIT=22] -->
<string name="unlock_set_unlock_launch_picker_title_profile">Work profile lock</string>
@@ -1320,8 +1328,14 @@
<!-- Summary shown when trust agent settings is disabled because the user hasn't set up primary security -->
<string name="disabled_because_no_backup_security">To use, first set a screen lock</string>
- <!-- Summary of preference to manage device policies -->
- <string name="manage_trust_agents_summary">View or deactivate trust agents</string>
+ <!-- Summary of preference to manage device policies when there is no trust agents-->
+ <string name="manage_trust_agents_summary">None</string>
+
+ <!-- Summary of preference to manage device policies when there is trust agent-->
+ <plurals name="manage_trust_agents_summary_on">
+ <item quantity="one">1 active trust agent</item>
+ <item quantity="other"><xliff:g id="count" example="3">%d</xliff:g> active trust agents</item>
+ </plurals>
<!-- Bluetooth settings -->
<!-- Bluetooth settings check box title on Main Settings screen -->
@@ -2318,8 +2332,12 @@
<!-- SIM lock settings title [CHAR LIMIT=40] -->
<string name="sim_lock_settings">SIM card lock settings</string>
- <!-- Security & location settings screen, setting option name [CHAR LIMIT=40] -->
- <string name="sim_lock_settings_category">Set up SIM card lock</string>
+ <!-- Security & screen lock settings screen, SIM card lock setting option name [CHAR LIMIT=40] -->
+ <string name="sim_lock_settings_category">SIM card lock</string>
+ <!-- Security & screen lock settings screen, SIM card lock setting summary when off [CHAR LIMIT=NONE] -->
+ <string name="sim_lock_settings_summary_off">Off</string>
+ <!-- Security & screen lock settings screen, SIM card lock setting summary when on [CHAR LIMIT=NONE] -->
+ <string name="sim_lock_settings_summary_on">Locked</string>
<!-- Security & location settings screen, section heading for settings related to sim card locking [CHAR LIMIT=40] -->
<string name="sim_lock_settings_title">SIM card lock</string>
<!-- SIM card lock settings screen, setting check box label [CHAR LIMIT=40] -->
@@ -4253,12 +4271,12 @@
<string name="print_settings">Printing</string>
<!-- Print setting summary in settings screen [CHAR LIMIT=50] -->
- <string name="print_settings_summary_no_service">No print service</string>
+ <string name="print_settings_summary_no_service">Off</string>
<!-- Print setting summary in settings screen [CHAR LIMIT=50] -->
<plurals name="print_settings_summary">
- <item quantity="one">1 print service</item>
- <item quantity="other"><xliff:g id="count">%1$d</xliff:g> print services</item>
+ <item quantity="one">1 print service on</item>
+ <item quantity="other"><xliff:g id="count">%1$d</xliff:g> print services on</item>
</plurals>
<!-- Title for print service settings screen [CHAR LIMIT=25] -->
@@ -6392,15 +6410,6 @@
<!-- Notification Settings: Title for the option managing notifications per application. [CHAR LIMIT=30] -->
<string name="app_notifications_title">Notifications</string>
- <!-- Notification Settings: Summary for managing notifications when notifications is on for all apps. [CHAR LIMIT=60] -->
- <string name="app_notifications_summary_on">On for all apps</string>
-
- <!-- Notification Settings: Summary for managing notifications when notifications is off for some apps. [CHAR LIMIT=60] -->
- <plurals name="app_notifications_summary_off">
- <item quantity="one">Off for 1 app</item>
- <item quantity="other">Off for <xliff:g id="off_count" example="10">%d</xliff:g> apps</item>
- </plurals>
-
<!-- [CHAR LIMIT=100] Notification importance slider title -->
<string name="notification_importance_title">Importance</string>
@@ -7198,13 +7207,12 @@
<string name="high_power_desc">Don\u2019t apply battery optimization. May drain your battery more quickly.</string>
<!-- Title of prompt dialog app can invoke to turn off optimization [CHAR LIMIT=NONE] -->
- <string name="high_power_prompt_title">Ignore battery optimizations?</string>
+ <string name="high_power_prompt_title">Let app always run in background?</string>
<!-- Body text of prompt dialog app can invoke to turn off optimization [CHAR LIMIT=NONE] -->
- <string name="high_power_prompt_body">Let app
- <xliff:g id="app_name" example="Settings">%1$s</xliff:g> stay connected in the
- background? This may use more battery.</string>
-
+ <string name="high_power_prompt_body">
+ Allowing <xliff:g id="app_name" example="Settings">%1$s</xliff:g> to always run in the background may reduce battery life.
+ \n\nYou can change this later from Settings > Apps & notifications.</string>
<!-- Summary of power usage for an app [CHAR LIMIT=NONE] -->
<string name="battery_summary"><xliff:g id="percentage" example="2">%1$d</xliff:g>%% use since last full charge</string>
@@ -7242,7 +7250,7 @@
<!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
select what the USB connection for this device should be used for. This choice
is for charging only. -->
- <string name="usb_use_charging_only">Charge this device</string>
+ <string name="usb_use_charging_only">Charging this device</string>
<!-- Decription of one of the choices in a dialog (with title defined in usb_use) that lets the
user select what the USB connection for this device should be used for. This choice
is for charging only. -->
@@ -7250,7 +7258,7 @@
<!-- Title of one of the choices in a dialog (with title defined in usb_use) that lets the user
select what the USB connection for this device should be used for. This choice
is for powering the other device only. -->
- <string name="usb_use_power_only">Supply power</string>
+ <string name="usb_use_power_only">Supplying power</string>
<!-- Decription of one of the choices in a dialog (with title defined in usb_use) that lets the
user select what the USB connection for this device should be used for. This choice
is for powering the other device. -->
@@ -7538,12 +7546,12 @@
<!-- Summary of notifications [CHAR LIMIT=NONE] -->
<plurals name="notification_summary">
- <item quantity="one"><xliff:g id="count" example="1">%d</xliff:g> app blocked from sending</item>
- <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps blocked from sending</item>
+ <item quantity="one">Off for 1 app</item>
+ <item quantity="other">Off for <xliff:g id="count" example="10">%d</xliff:g> apps</item>
</plurals>
<!-- Summary of notifications when no apps are blocked [CHAR LIMIT=NONE] -->
- <string name="notification_summary_none">All apps allowed to send</string>
+ <string name="notification_summary_none">On for all apps</string>
<!-- Summary of apps [CHAR LIMIT=NONE] -->
<string name="apps_summary"><xliff:g id="count" example="24">%1$d</xliff:g> apps installed</string>
@@ -7913,7 +7921,13 @@
<string name="notification_log_details_ranking_none">Ranking object doesn\'t contain this key.</string>
<!-- [CHAR_LIMIT=60] Label for special access screen -->
- <string name="special_access">Special access</string>
+ <string name="special_access">Special app access</string>
+
+ <!-- Summary for special access settings [CHAR_LIMIT=NONE] -->
+ <plurals name="special_access_summary">
+ <item quantity="one">1 app can use unrestricted data</item>
+ <item quantity="other"><xliff:g id="count" example="10">%d</xliff:g> apps can use unrestricted data</item>
+ </plurals>
<!-- Developer option to convert to file encryption - final warning -->
<string name="confirm_convert_to_fbe_warning">Really wipe user data and convert to file encryption?</string>
@@ -7953,9 +7967,12 @@
<!-- Title of screen controlling which apps have access to send premium SMS messages [CHAR LIMIT=60] -->
<string name="premium_sms_access">Premium SMS access</string>
- <!-- Bluetooth is disabled. -->
+ <!-- Summary for Bluetooth when disabled. [CHAR LIMIT=NONE] -->
<string name="bluetooth_disabled">Not visible to other devices</string>
+ <!-- Summary for Bluetooth when connected. [CHAR LIMIT=NONE] -->
+ <string name="bluetooth_connected_summary">Connected to </string>
+
<!-- [CHAR LIMIT=60] Name of dev option called "System UI demo mode" -->
<string name="demo_mode">System UI demo mode</string>
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index b4ab7df..c5e5e93 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -14,115 +14,116 @@
limitations under the License.
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
- android:title="@string/display_settings"
- settings:keywords="@string/keywords_display">
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/display_settings"
+ settings:keywords="@string/keywords_display">
- <Preference
- android:key="brightness"
- android:title="@string/brightness"
- settings:keywords="@string/keywords_display_brightness_level">
- <intent android:action="android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
- </Preference>
+ <Preference
+ android:key="brightness"
+ android:title="@string/brightness"
+ settings:keywords="@string/keywords_display_brightness_level">
+ <intent android:action="android.intent.action.SHOW_BRIGHTNESS_DIALOG" />
+ </Preference>
- <com.android.settingslib.RestrictedPreference
- android:key="wallpaper"
- android:title="@string/wallpaper_settings_title"
- settings:keywords="@string/keywords_display_wallpaper"
- settings:useAdminDisabledSummary="true" >
- <intent
- android:targetPackage="@string/config_wallpaper_picker_package"
- android:targetClass="@string/config_wallpaper_picker_class" />
- </com.android.settingslib.RestrictedPreference>
+ <com.android.settingslib.RestrictedPreference
+ android:key="wallpaper"
+ android:title="@string/wallpaper_settings_title"
+ settings:keywords="@string/keywords_display_wallpaper"
+ settings:useAdminDisabledSummary="true">
+ <intent
+ android:targetPackage="@string/config_wallpaper_picker_package"
+ android:targetClass="@string/config_wallpaper_picker_class" />
+ </com.android.settingslib.RestrictedPreference>
- <com.android.settings.display.NightDisplayPreference
- android:key="night_display"
- android:title="@string/night_display_title"
- android:fragment="com.android.settings.display.NightDisplaySettings"
- settings:widgetLayout="@null"
- settings:keywords="@string/keywords_display_night_display" />
+ <com.android.settings.display.NightDisplayPreference
+ android:key="night_display"
+ android:title="@string/night_display_title"
+ android:fragment="com.android.settings.display.NightDisplaySettings"
+ settings:widgetLayout="@null"
+ settings:keywords="@string/keywords_display_night_display" />
- <com.android.settings.TimeoutListPreference
- android:key="screen_timeout"
- android:title="@string/screen_timeout"
- android:summary="@string/screen_timeout_summary"
- android:entries="@array/screen_timeout_entries"
- android:entryValues="@array/screen_timeout_values" />
+ <com.android.settings.TimeoutListPreference
+ android:key="screen_timeout"
+ android:title="@string/screen_timeout"
+ android:summary="@string/screen_timeout_summary"
+ android:entries="@array/screen_timeout_entries"
+ android:entryValues="@array/screen_timeout_values" />
- <DropDownPreference
- android:key="auto_rotate"
- android:summary="%s"
- android:title="@string/display_auto_rotate_title" />
+ <DropDownPreference
+ android:key="auto_rotate"
+ android:summary="%s"
+ android:title="@string/display_auto_rotate_title" />
- <SwitchPreference
- android:key="auto_brightness"
- android:title="@string/auto_brightness_title"
- settings:keywords="@string/keywords_display_auto_brightness"
- android:summary="@string/auto_brightness_summary" />
+ <SwitchPreference
+ android:key="auto_brightness"
+ android:title="@string/auto_brightness_title"
+ settings:keywords="@string/keywords_display_auto_brightness"
+ android:summary="@string/auto_brightness_summary" />
- <Preference
- android:key="font_size"
- android:title="@string/title_font_size"
- android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
- settings:keywords="@string/keywords_display_font_size" />
+ <Preference
+ android:key="font_size"
+ android:title="@string/title_font_size"
+ android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
+ settings:keywords="@string/keywords_display_font_size" />
- <com.android.settings.display.ScreenZoomPreference
- android:key="screen_zoom"
- android:title="@string/screen_zoom_title"
- settings:keywords="@string/screen_zoom_keywords" />
+ <com.android.settings.display.ScreenZoomPreference
+ android:key="screen_zoom"
+ android:title="@string/screen_zoom_title"
+ settings:keywords="@string/screen_zoom_keywords" />
- <Preference
- android:key="screensaver"
- android:title="@string/screensaver_settings_title"
- android:fragment="com.android.settings.DreamSettings" />
+ <Preference
+ android:key="screensaver"
+ android:title="@string/screensaver_settings_title"
+ android:fragment="com.android.settings.DreamSettings" />
- <!-- Hide night mode for now
- <ListPreference
- android:key="night_mode"
- android:title="@string/night_mode_title"
- settings:keywords="@string/keywords_display_night_mode"
- android:summary="@string/night_mode_summary"
- android:entries="@array/night_mode_entries"
- android:entryValues="@array/night_mode_values" /> -->
+ <!-- Hide night mode for now
+ <ListPreference
+ android:key="night_mode"
+ android:title="@string/night_mode_title"
+ settings:keywords="@string/keywords_display_night_mode"
+ android:summary="@string/night_mode_summary"
+ android:entries="@array/night_mode_entries"
+ android:entryValues="@array/night_mode_values" /> -->
- <SwitchPreference
- android:key="camera_gesture"
- android:title="@string/camera_gesture_title"
- android:summary="@string/camera_gesture_desc" />
+ <SwitchPreference
+ android:key="camera_gesture"
+ android:title="@string/camera_gesture_title"
+ android:summary="@string/camera_gesture_desc" />
- <SwitchPreference
- android:key="lift_to_wake"
- android:title="@string/lift_to_wake_title" />
+ <SwitchPreference
+ android:key="lift_to_wake"
+ android:title="@string/lift_to_wake_title" />
- <Preference
- android:key="gesture_double_tap_screen"
- android:title="@string/ambient_display_title"
- android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"/>
+ <Preference
+ android:key="gesture_double_tap_screen"
+ android:title="@string/ambient_display_title"
+ android:fragment="com.android.settings.gestures.DoubleTapScreenSettings" />
- <Preference
- android:key="gesture_pick_up"
- android:title="@string/ambient_display_pickup_title"
- android:fragment="com.android.settings.gestures.PickupGestureSettings"/>
+ <Preference
+ android:key="gesture_pick_up"
+ android:title="@string/ambient_display_pickup_title"
+ android:fragment="com.android.settings.gestures.PickupGestureSettings" />
- <SwitchPreference
- android:key="doze"
- android:title="@string/doze_title"
- android:summary="@string/doze_summary" />
+ <SwitchPreference
+ android:key="doze"
+ android:title="@string/doze_title"
+ android:summary="@string/doze_summary" />
- <SwitchPreference
- android:key="tap_to_wake"
- android:title="@string/tap_to_wake"
- android:summary="@string/tap_to_wake_summary" />
+ <SwitchPreference
+ android:key="tap_to_wake"
+ android:title="@string/tap_to_wake"
+ android:summary="@string/tap_to_wake_summary" />
- <ListPreference
- android:key="theme"
- android:title="@string/device_theme"
- android:summary="%s" />
+ <ListPreference
+ android:key="theme"
+ android:title="@string/device_theme"
+ android:summary="%s" />
- <DropDownPreference
- android:key="vr_display_pref"
- android:summary="%s"
- android:title="@string/display_vr_pref_title" />
+ <Preference
+ android:key="vr_display_pref"
+ android:title="@string/display_vr_pref_title"
+ android:fragment="com.android.settings.display.VrDisplayPreferencePicker" />
</PreferenceScreen>
diff --git a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
index dc37efc..282f613 100644
--- a/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothSummaryUpdater.java
@@ -98,13 +98,13 @@
}
switch (mConnectionState) {
case BluetoothAdapter.STATE_CONNECTED:
- return mContext.getString(R.string.bluetooth_connected);
+ return mContext.getString(R.string.bluetooth_connected_summary);
case BluetoothAdapter.STATE_CONNECTING:
return mContext.getString(R.string.bluetooth_connecting);
case BluetoothAdapter.STATE_DISCONNECTING:
return mContext.getString(R.string.bluetooth_disconnecting);
default:
- return mContext.getString(R.string.bluetooth_disconnected);
+ return mContext.getString(R.string.disconnected);
}
}
diff --git a/src/com/android/settings/display/VrDisplayPreferenceController.java b/src/com/android/settings/display/VrDisplayPreferenceController.java
index 0eb1c88..4fef987 100644
--- a/src/com/android/settings/display/VrDisplayPreferenceController.java
+++ b/src/com/android/settings/display/VrDisplayPreferenceController.java
@@ -17,17 +17,13 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.provider.Settings;
-import android.support.v7.preference.DropDownPreference;
import android.support.v7.preference.Preference;
-import android.util.Log;
import com.android.settings.R;
import com.android.settings.core.PreferenceController;
-public class VrDisplayPreferenceController extends PreferenceController implements
- Preference.OnPreferenceChangeListener {
+public class VrDisplayPreferenceController extends PreferenceController {
- private static final String TAG = "VrDisplayPrefContr";
private static final String KEY_VR_DISPLAY_PREF = "vr_display_pref";
public VrDisplayPreferenceController(Context context) {
@@ -47,31 +43,14 @@
@Override
public void updateState(Preference preference) {
- final DropDownPreference pref = (DropDownPreference) preference;
- pref.setEntries(new CharSequence[]{
- mContext.getString(R.string.display_vr_pref_low_persistence),
- mContext.getString(R.string.display_vr_pref_off),
- });
- pref.setEntryValues(new CharSequence[]{"0", "1"});
-
int currentUser = ActivityManager.getCurrentUser();
int current = Settings.Secure.getIntForUser(mContext.getContentResolver(),
- Settings.Secure.VR_DISPLAY_MODE,
- /*default*/Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
+ Settings.Secure.VR_DISPLAY_MODE, Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
currentUser);
- pref.setValueIndex(current);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- int i = Integer.parseInt((String) newValue);
- int u = ActivityManager.getCurrentUser();
- if (!Settings.Secure.putIntForUser(mContext.getContentResolver(),
- Settings.Secure.VR_DISPLAY_MODE,
- i, u)) {
- Log.e(TAG, "Could not change setting for " +
- Settings.Secure.VR_DISPLAY_MODE);
+ if (current == 0) {
+ preference.setSummary(R.string.display_vr_pref_low_persistence);
+ } else {
+ preference.setSummary(R.string.display_vr_pref_off);
}
- return true;
}
}
diff --git a/src/com/android/settings/display/VrDisplayPreferencePicker.java b/src/com/android/settings/display/VrDisplayPreferencePicker.java
new file mode 100644
index 0000000..bccdaa5
--- /dev/null
+++ b/src/com/android/settings/display/VrDisplayPreferencePicker.java
@@ -0,0 +1,99 @@
+/*
+ * 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.display;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.provider.Settings;
+import android.text.TextUtils;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.widget.RadioButtonPickerFragment;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class VrDisplayPreferencePicker extends RadioButtonPickerFragment {
+
+ static final String PREF_KEY_PREFIX = "vr_display_pref_";
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.VR_DISPLAY_PREFERENCE;
+ }
+
+ @Override
+ protected List<VrCandidateInfo> getCandidates() {
+ List<VrCandidateInfo> candidates = new ArrayList<>();
+ final Context context = getContext();
+ candidates.add(new VrCandidateInfo(context, 0, R.string.display_vr_pref_low_persistence));
+ candidates.add(new VrCandidateInfo(context, 1, R.string.display_vr_pref_off));
+ return candidates;
+ }
+
+ @Override
+ protected String getDefaultKey() {
+ int current = Settings.Secure.getIntForUser(getContext().getContentResolver(),
+ Settings.Secure.VR_DISPLAY_MODE, Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE,
+ mUserId);
+ return PREF_KEY_PREFIX + current;
+ }
+
+ @Override
+ protected boolean setDefaultKey(String key) {
+ if (TextUtils.isEmpty(key)) {
+ return false;
+ }
+ switch (key) {
+ case PREF_KEY_PREFIX + 0:
+ return Settings.Secure.putIntForUser(getContext().getContentResolver(),
+ Settings.Secure.VR_DISPLAY_MODE, 0, mUserId);
+ case PREF_KEY_PREFIX + 1:
+ return Settings.Secure.putIntForUser(getContext().getContentResolver(),
+ Settings.Secure.VR_DISPLAY_MODE, 1, mUserId);
+ }
+ return false;
+ }
+
+ static class VrCandidateInfo extends CandidateInfo {
+
+ public final String label;
+ public final int value;
+
+ public VrCandidateInfo(Context context, int value, int resId) {
+ super(true);
+ this.value = value;
+ label = context.getString(resId);
+ }
+
+ @Override
+ public CharSequence loadLabel() {
+ return label;
+ }
+
+ @Override
+ public Drawable loadIcon() {
+ return null;
+ }
+
+ @Override
+ public String getKey() {
+ return PREF_KEY_PREFIX + value;
+ }
+ }
+}
diff --git a/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java b/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java
index b16fd18..27bd889 100644
--- a/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java
+++ b/src/com/android/settings/fuelgauge/RequestIgnoreBatteryOptimizations.java
@@ -91,8 +91,8 @@
final AlertController.AlertParams p = mAlertParams;
p.mTitle = getText(R.string.high_power_prompt_title);
p.mMessage = getString(R.string.high_power_prompt_body, ai.loadLabel(getPackageManager()));
- p.mPositiveButtonText = getText(R.string.yes);
- p.mNegativeButtonText = getText(R.string.no);
+ p.mPositiveButtonText = getText(R.string.allow);
+ p.mNegativeButtonText = getText(R.string.deny);
p.mPositiveButtonListener = this;
p.mNegativeButtonListener = this;
setupAlert();
diff --git a/src/com/android/settings/users/UserPreference.java b/src/com/android/settings/users/UserPreference.java
index 7b13597..8b53dd4 100644
--- a/src/com/android/settings/users/UserPreference.java
+++ b/src/com/android/settings/users/UserPreference.java
@@ -20,7 +20,6 @@
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.os.UserManager;
-import android.support.v7.preference.Preference;
import android.support.v7.preference.PreferenceViewHolder;
import android.util.AttributeSet;
import android.view.View;
@@ -87,6 +86,20 @@
}
@Override
+ protected boolean shouldHideSecondTarget() {
+ if (isDisabledByAdmin()) {
+ // Disabled by admin, show no secondary target.
+ return true;
+ }
+ if (canDeleteUser()) {
+ // Need to show delete user target so don't hide.
+ return false;
+ }
+ // Hide if don't have advanced setting listener.
+ return mSettingsClickListener == null;
+ }
+
+ @Override
public void onBindViewHolder(PreferenceViewHolder view) {
super.onBindViewHolder(view);
final boolean disabledByAdmin = isDisabledByAdmin();
@@ -96,14 +109,11 @@
userDeleteWidget.setVisibility(disabledByAdmin ? View.GONE : View.VISIBLE);
}
if (!disabledByAdmin) {
- UserManager um = (UserManager) getContext().getSystemService(Context.USER_SERVICE);
View deleteDividerView = view.findViewById(R.id.divider_delete);
View manageDividerView = view.findViewById(R.id.divider_manage);
View deleteView = view.findViewById(R.id.trash_user);
if (deleteView != null) {
- if (mDeleteClickListener != null
- && !RestrictedLockUtils.hasBaseUserRestriction(getContext(),
- UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId())) {
+ if (canDeleteUser()) {
deleteView.setVisibility(View.VISIBLE);
deleteDividerView.setVisibility(View.VISIBLE);
deleteView.setOnClickListener(mDeleteClickListener);
@@ -129,6 +139,12 @@
}
}
+ private boolean canDeleteUser() {
+ return mDeleteClickListener != null
+ && !RestrictedLockUtils.hasBaseUserRestriction(getContext(),
+ UserManager.DISALLOW_REMOVE_USER, UserHandle.myUserId());
+ }
+
private int getSerialNumber() {
if (mUserId == UserHandle.myUserId()) return Integer.MIN_VALUE;
if (mSerialNumber < 0) {
diff --git a/src/com/android/settings/widget/RadioButtonPickerFragment.java b/src/com/android/settings/widget/RadioButtonPickerFragment.java
index 52e8c53..2444539 100644
--- a/src/com/android/settings/widget/RadioButtonPickerFragment.java
+++ b/src/com/android/settings/widget/RadioButtonPickerFragment.java
@@ -141,8 +141,7 @@
}
for (Map.Entry<String, CandidateInfo> app : mCandidates.entrySet()) {
RadioButtonPreference pref = new RadioButtonPreference(getPrefContext());
- bindPreference(
- pref, app.getKey(), app.getValue(), defaultKey);
+ bindPreference(pref, app.getKey(), app.getValue(), defaultKey);
bindPreferenceExtra(pref, app.getKey(), app.getValue(), defaultKey, systemDefaultKey);
screen.addPreference(pref);
}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
index 2c88179..2d9ae9b 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/DefaultAppPickerFragmentTest.java
@@ -17,7 +17,6 @@
package com.android.settings.applications.defaultapps;
-import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
index a2770a0..cc059ad 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSummaryUpdaterTest.java
@@ -86,7 +86,8 @@
public void register_true_shouldSendSummaryChange() {
mSummaryUpdater.register(true);
- verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_connected));
+ verify(mListener).onSummaryChanged(
+ mContext.getString(R.string.bluetooth_connected_summary));
}
@Test
@@ -102,7 +103,8 @@
mSummaryUpdater.register(true);
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_ON);
- verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_connected));
+ verify(mListener).onSummaryChanged(
+ mContext.getString(R.string.bluetooth_connected_summary));
}
@Test
@@ -111,7 +113,8 @@
mSummaryUpdater.register(true);
mSummaryUpdater.onBluetoothStateChanged(BluetoothAdapter.STATE_TURNING_ON);
- verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disconnected));
+ verify(mListener).onSummaryChanged(
+ mContext.getString(R.string.disconnected));
}
@Test
@@ -128,7 +131,8 @@
mSummaryUpdater.onConnectionStateChanged(null /* device */,
BluetoothAdapter.STATE_CONNECTED);
- verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_connected));
+ verify(mListener).onSummaryChanged(
+ mContext.getString(R.string.bluetooth_connected_summary));
}
@Test
@@ -137,7 +141,8 @@
mSummaryUpdater.onConnectionStateChanged(null /* device */,
BluetoothAdapter.STATE_CONNECTED);
- verify(mListener).onSummaryChanged(mContext.getString(R.string.bluetooth_disconnected));
+ verify(mListener).onSummaryChanged(
+ mContext.getString(R.string.disconnected));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java b/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java
new file mode 100644
index 0000000..56d4c47
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/VrDisplayPreferencePickerTest.java
@@ -0,0 +1,82 @@
+/*
+ * 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.display;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+import android.content.ContentResolver;
+import android.os.UserHandle;
+import android.provider.Settings;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.testutils.shadow.ShadowSecureSettings;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+import java.util.List;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class VrDisplayPreferencePickerTest {
+
+ private VrDisplayPreferencePicker mPicker;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mPicker = spy(new VrDisplayPreferencePicker());
+ doReturn(RuntimeEnvironment.application).when(mPicker).getContext();
+ }
+
+ @Test
+ public void verifyMetricsConstant() {
+ assertThat(mPicker.getMetricsCategory())
+ .isEqualTo(MetricsProto.MetricsEvent.VR_DISPLAY_PREFERENCE);
+ }
+
+ @Test
+ public void getCandidates_shouldReturnTwoCandidates() {
+ List<VrDisplayPreferencePicker.VrCandidateInfo> candidates = mPicker.getCandidates();
+
+ assertThat(candidates.size()).isEqualTo(2);
+ assertThat(candidates.get(0).getKey())
+ .isEqualTo(VrDisplayPreferencePicker.PREF_KEY_PREFIX + 0);
+ assertThat(candidates.get(1).getKey())
+ .isEqualTo(VrDisplayPreferencePicker.PREF_KEY_PREFIX + 1);
+ }
+
+ @Test
+ @Config(shadows = ShadowSecureSettings.class)
+ public void getKey_shouldGetFromSettingsProvider() {
+ final ContentResolver cr = RuntimeEnvironment.application.getContentResolver();
+ Settings.Secure.putIntForUser(cr, Settings.Secure.VR_DISPLAY_MODE, 1,
+ UserHandle.myUserId());
+
+ assertThat(mPicker.getDefaultKey())
+ .isEqualTo(VrDisplayPreferencePicker.PREF_KEY_PREFIX + 1);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java
index 5dd54c0..fd4d0d2 100644
--- a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowSecureSettings.java
@@ -53,6 +53,17 @@
}
@Implementation
+ public static boolean putIntForUser(ContentResolver cr, String name, int value,
+ int userHandle) {
+ return putInt(cr, name, value);
+ }
+
+ @Implementation
+ public static int getIntForUser(ContentResolver cr, String name, int def, int userHandle) {
+ return getInt(cr, name, def);
+ }
+
+ @Implementation
public static int getInt(ContentResolver resolver, String name, int defaultValue) {
Integer value = (Integer) mValueMap.get(name);
return value == null ? defaultValue : value;
diff --git a/tests/robotests/src/com/android/settings/users/UserPreferenceTest.java b/tests/robotests/src/com/android/settings/users/UserPreferenceTest.java
new file mode 100644
index 0000000..031cd77
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/users/UserPreferenceTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.users;
+
+import static com.google.common.truth.Truth.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.view.View;
+
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settingslib.RestrictedPreferenceHelper;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ReflectionHelpers;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class UserPreferenceTest {
+
+ @Mock
+ private RestrictedPreferenceHelper mRestrictedPreferenceHelper;
+ private Context mContext;
+ private UserPreference mUserPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = RuntimeEnvironment.application;
+ mUserPreference = new UserPreference(mContext, null /* attrs */, UserHandle.USER_CURRENT,
+ null /* settingsListener */, null /* deleteListener */);
+ ReflectionHelpers.setField(mUserPreference, "mHelper", mRestrictedPreferenceHelper);
+ }
+
+ @Test
+ public void testShouldHideSecondTarget_noListener_shouldHide() {
+ assertThat(mUserPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void testShouldHideSecondTarget_disabledByAdmin_shouldHide() {
+ when(mRestrictedPreferenceHelper.isDisabledByAdmin()).thenReturn(true);
+
+ assertThat(mUserPreference.shouldHideSecondTarget()).isTrue();
+ }
+
+ @Test
+ public void testShouldHideSecondTarget_hasSettingListener_shouldNotHide() {
+ ReflectionHelpers.setField(mUserPreference, "mSettingsClickListener",
+ mock(View.OnClickListener.class));
+
+ assertThat(mUserPreference.shouldHideSecondTarget()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/users/UserSettingsTest.java b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
new file mode 100644
index 0000000..ed95175
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/users/UserSettingsTest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.users;
+
+import android.app.Activity;
+import android.content.pm.UserInfo;
+import android.os.UserManager;
+
+import com.android.settings.R;
+import com.android.settings.SettingsRobolectricTestRunner;
+import com.android.settings.TestConfig;
+import com.android.settings.dashboard.SummaryLoader;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+import org.robolectric.Robolectric;
+
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(SettingsRobolectricTestRunner.class)
+@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
+public class UserSettingsTest {
+
+ @Mock private UserManager mUserManager;
+ @Mock private SummaryLoader mSummaryLoader;
+ private Activity mActivity;
+ private SummaryLoader.SummaryProvider mSummaryProvider;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mActivity = spy(Robolectric.buildActivity(Activity.class).get());
+ when((Object) mActivity.getSystemService(UserManager.class)).thenReturn(mUserManager);
+
+ mSummaryProvider = UserSettings.SUMMARY_PROVIDER_FACTORY.createSummaryProvider(
+ mActivity, mSummaryLoader);
+ }
+
+ @Test
+ public void setListening_shouldSetSummaryWithUserName() {
+ final String name = "John";
+ final UserInfo userInfo = new UserInfo();
+ userInfo.name = name;
+ when(mUserManager.getUserInfo(anyInt())).thenReturn(userInfo);
+
+ mSummaryProvider.setListening(true);
+
+ verify(mSummaryLoader).setSummary(mSummaryProvider,
+ mActivity.getString(R.string.users_summary, name));
+ }
+
+}