Merge "Make the private DNS mode dialog entries full width."
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 397658f..688e6d0 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1545,7 +1545,6 @@
<activity android:name=".password.ConfirmDeviceCredentialActivity$InternalActivity"
android:exported="false"
android:permission="android.permission.MANAGE_USERS"
- android:resizeableActivity="false"
android:taskAffinity="com.android.settings.workmode"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter android:priority="1">
diff --git a/res/drawable/ic_partial_system_update_current.xml b/res/drawable/ic_partial_system_update_current.xml
new file mode 100644
index 0000000..18be203
--- /dev/null
+++ b/res/drawable/ic_partial_system_update_current.xml
@@ -0,0 +1,24 @@
+<!--
+Copyright (C) 2019 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="20.0"
+ android:viewportHeight="22.0">
+ <path
+ android:fillColor="#FF1E8E3E"
+ android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
+</vector>
diff --git a/res/drawable/ic_partial_system_update_stale.xml b/res/drawable/ic_partial_system_update_stale.xml
new file mode 100644
index 0000000..711be2c
--- /dev/null
+++ b/res/drawable/ic_partial_system_update_stale.xml
@@ -0,0 +1,24 @@
+<!--
+Copyright (C) 2019 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="20.0"
+ android:viewportHeight="22.0">
+ <path
+ android:fillColor="#FFD93025"
+ android:pathData="M15,17L5,17L5,14.33l1.59,1.58L8,14.5l-3,-3 -1,-1 -4,4 1.41,1.42L3,14.33L3,20a2.006,2.006 0,0 0,2 2L15,22a2.006,2.006 0,0 0,2 -2L17,13L15,13ZM15,20L5,20L5,19L15,19ZM5,5L15,5L15,7.67L13.41,6.09 12,7.5l4,4 4,-4L18.59,6.08 17,7.67L17,2a1.997,1.997 0,0 0,-2 -1.99L5,0A2.006,2.006 0,0 0,3 2v7L5,9ZM5,2L15,2L15,3L5,3Z"/>
+</vector>
diff --git a/res/layout/captioning_preview.xml b/res/layout/captioning_preview.xml
index b90c3a5..d8d2e4f 100644
--- a/res/layout/captioning_preview.xml
+++ b/res/layout/captioning_preview.xml
@@ -15,41 +15,32 @@
limitations under the License.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<FrameLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/preview_viewport"
+ android:clipToPadding="true"
+ android:clipChildren="true"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/captioning_preview_height"
+ android:contentDescription="@null"
+ android:scaleType="centerCrop"
+ android:src="@drawable/caption_background"/>
<FrameLayout
- android:id="@+id/preview_viewport"
+ android:id="@+id/preview_window"
android:layout_width="match_parent"
- android:layout_height="@dimen/captioning_preview_height" >
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom|start"
+ android:padding="16dp">
- <ImageView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:contentDescription="@null"
- android:scaleType="centerCrop"
- android:src="@drawable/caption_background" />
-
- <FrameLayout
- android:id="@+id/preview_window"
- android:layout_width="match_parent"
+ <com.android.internal.widget.SubtitleView
+ android:id="@+id/preview_text"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|start"
- android:padding="16dp" >
-
- <com.android.internal.widget.SubtitleView
- android:id="@+id/preview_text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/captioning_preview_text" />
- </FrameLayout>
+ android:text="@string/captioning_preview_text"/>
</FrameLayout>
-
- <FrameLayout
- android:id="@+id/properties_fragment"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
-</LinearLayout>
+</FrameLayout>
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index 00ab443..ca8399b 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -56,7 +56,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/SudContentIllustration"
- app:sudVideo="@raw/face_enroll_introduction_animation"/>
+ app:sudVideo="@raw/face_settings"/>
</FrameLayout>
@@ -75,6 +75,27 @@
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:background="@drawable/ic_info_outline_24dp">
+ </ImageView>
+ <Space
+ android:layout_width="24dp"
+ android:layout_height="wrap_content"/>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/security_settings_face_enroll_introduction_footer_part_0"/>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingTop="24dp">
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
android:background="@drawable/ic_face_enroll_introduction_shield">
</ImageView>
<Space
diff --git a/res/layout/magnification_video_preference.xml b/res/layout/magnification_video_preference.xml
index fe7f26f..ff7089c 100644
--- a/res/layout/magnification_video_preference.xml
+++ b/res/layout/magnification_video_preference.xml
@@ -16,7 +16,9 @@
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="wrap_content"
+ android:clipChildren="true"
+ android:clipToPadding="true">
<ImageView
android:id="@+id/video_background"
diff --git a/res/raw/system_nav_3_button.mp4 b/res/raw/system_nav_3_button.mp4
index 1287f28..86fb236 100644
--- a/res/raw/system_nav_3_button.mp4
+++ b/res/raw/system_nav_3_button.mp4
Binary files differ
diff --git a/res/raw/system_nav_fully_gestural.mp4 b/res/raw/system_nav_fully_gestural.mp4
index 165ce33..ae9c6d7 100644
--- a/res/raw/system_nav_fully_gestural.mp4
+++ b/res/raw/system_nav_fully_gestural.mp4
Binary files differ
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index ffe0aa5..9ac9110 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -675,15 +675,6 @@
</string-array>
<!-- Keys for the list of accessibility timeouts xml. -->
- <string-array name="accessibility_timeout_content_selector_keys" translatable="false">
- <item>accessibility_content_timeout_default</item>
- <item>accessibility_content_timeout_10secs</item>
- <item>accessibility_content_timeout_30secs</item>
- <item>accessibility_content_timeout_1min</item>
- <item>accessibility_content_timeout_2mins</item>
- </string-array>
-
- <!-- Keys for the list of accessibility timeouts xml. -->
<string-array name="accessibility_timeout_control_selector_keys" translatable="false">
<item>accessibility_control_timeout_default</item>
<item>accessibility_control_timeout_10secs</item>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 26cdde1..f802257 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -890,6 +890,8 @@
<string name="security_settings_face_preference_title">Face authentication</string>
<!-- Introduction title shown in face enrollment education screen [CHAR LIMIT=40] -->
<string name="security_settings_face_enroll_education_title">How to set up Face unlock</string>
+ <!-- Introduction title shown in face enrollment education screen for accessibility [CHAR LIMI=40]-->
+ <string name="security_settings_face_enroll_education_title_accessibility">Set up Face unlock</string>
<!-- Introduction title shown in face enrollment education screen to show the face authentication feature, when face unlock is disabled by device admin [CHAR LIMIT=60] -->
<string name="security_settings_face_enroll_education_title_unlock_disabled">Use your face to authenticate</string>
<!-- Introduction detail message shown in face education [CHAR LIMIT=NONE] -->
@@ -917,6 +919,8 @@
<!-- Introduction detail message shown in face enrollment screen in setup wizard. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_enroll_introduction_message_setup">Use your face to unlock your phone, authorize purchases, or sign in to apps</string>
<!-- Introduction message shown in face enrollment that provides extra detail. [CHAR LIMIT=NONE] -->
+ <string name="security_settings_face_enroll_introduction_footer_part_0"></string>
+ <!-- Introduction message shown in face enrollment that provides extra detail. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_enroll_introduction_footer_part_1"></string>
<!-- Introduction message shown in face enrollment that provides extra detail. [CHAR LIMIT=NONE] -->
<string name="security_settings_face_enroll_introduction_footer_part_2"></string>
@@ -925,7 +929,7 @@
<!-- Title shown in face enrollment dialog [CHAR LIMIT=40] -->
<string name="security_settings_face_enroll_repeat_title">Center your face in the circle</string>
<!-- Button text to skip enrollment of face [CHAR LIMIT=40] -->
- <string name="security_settings_face_enroll_enrolling_skip">Do it later</string>
+ <string name="security_settings_face_enroll_enrolling_skip">Skip</string>
<!-- Text shown when "Add face" button is disabled -->
<string name="face_add_max">You can add up to <xliff:g id="count" example="5">%d</xliff:g> faces</string>
<!-- Text shown when users has enrolled a maximum number of faces [CHAR LIMIT=NONE] -->
@@ -965,7 +969,7 @@
<!-- Button text in face settings which lets the user enroll their face [CHAR LIMIT=40] -->
<string name="security_settings_face_settings_enroll">Set up new face unlock</string>
<!-- Text shown in face settings explaining what your face can be used for. [CHAR LIMIT=NONE] -->
- <string name="security_settings_face_settings_footer">Use Face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face while your eyes are open.\n\nYour phone can be unlocked by someone who looks a lot like you, say, your child or an identical sibling.</string>
+ <string name="security_settings_face_settings_footer">Use Face unlock to unlock your device, sign in to apps, and confirm payments.\n\nKeep in mind:\nLooking at the phone can unlock it when you don\u2019t intend to.\n\nYour phone can be unlocked by someone else if it\u2019s held up to your face while your eyes are open.\n\nYour phone can be unlocked by someone who looks a lot like you, say, an identical sibling.</string>
<!-- Dialog title shown when the user removes an enrollment [CHAR LIMIT=35] -->
<string name="security_settings_face_settings_remove_dialog_title">Delete face data?</string>
<!-- Dialog contents shown when the user removes an enrollment [CHAR LIMIT=NONE] -->
@@ -4815,7 +4819,7 @@
<!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
<string name="interaction_control_category_title">Interaction controls</string>
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->
- <string name="user_installed_services_category_title">Downloaded services</string>
+ <string name="user_installed_services_category_title">Downloaded apps</string>
<!-- Title for the accessibility preference category of settings considered to be experimental, meaning they might be changed or removed in the future. [CHAR LIMIT=50] -->
<string name="experimental_category_title">Experimental</string>
<!-- Title for feature flags dashboard where developers can turn on experimental features [CHAR LIMIT=50] -->
@@ -4891,12 +4895,10 @@
<string name="accessibility_timeout_1min">1 minute</string>
<!-- Option heading to leave the timeout requirement for accessibility users at 2 mins. [CHAR LIMIT=35] -->
<string name="accessibility_timeout_2mins">2 minutes</string>
- <!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
- <string name="accessibility_content_timeout_preference_title">Time to read</string>
+ <!-- Title for accessibility settings timeout item. [CHAR LIMIT=43] -->
+ <string name="accessibility_setting_item_control_timeout_title">Time to take action (Accessibility timeout)</string>
<!-- Title for accessibility preference to accessibility timeout. [CHAR LIMIT=35] -->
<string name="accessibility_control_timeout_preference_title">Time to take action</string>
- <!-- Descriptive text for accessibility preference to accessibility content timeout. [CHAR LIMIT=NONE] -->
- <string name="accessibility_content_timeout_preference_summary">Choose how long to show messages that you need to read, but are visible only temporarily.\n\nNot all apps support this setting.</string>
<!-- Descriptive text for accessibility preference to accessibility control timeout. [CHAR LIMIT=NONE] -->
<string name="accessibility_control_timeout_preference_summary">Choose how long to show messages that ask you to take action, but are visible only temporarily.\n\nNot all apps support this setting.</string>
@@ -4921,7 +4923,7 @@
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
<string name="accessibility_touch_vibration_title">Touch feedback</string>
<!-- Used in the acessibilty service settings to control turning on/off the service entirely -->
- <string name="accessibility_service_master_switch_title">Use service</string>
+ <string name="accessibility_service_master_switch_title">Use <xliff:g id="service" example="TalkBack">%1$s</xliff:g></string>
<!-- Used in the Color correction settings screen to control turning on/off the feature entirely -->
<string name="accessibility_daltonizer_master_switch_title">Use color correction</string>
<!-- Used in the Captions settings screen to control turning on/off the feature entirely -->
@@ -5147,7 +5149,7 @@
</string>
<!-- Title for the action perform in accessibility dialog. [CHAR LIMIT=NONE] -->
- <string name="accessibility_service_action_perform_title">View and platform actions</string>
+ <string name="accessibility_service_action_perform_title">View and perform actions</string>
<!-- Description for the action perform in accessibility dialog. [CHAR LIMIT=NONE] -->
<string name="accessibility_service_action_perform_description">It can track your interactions
@@ -10056,6 +10058,12 @@
<!-- [CHAR LIMIT=60] Name of setting that changes the UI to dark -->
<string name="dark_ui_mode">Dark Theme</string>
+ <!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is still on-->
+ <string name="dark_ui_mode_disabled_summary_dark_theme_on">On / Temporarily disabled due to Battery Saver</string>
+
+ <!-- [CHAR LIMIT=60] Summary string on dark theme explaining why the toggle is disabled while the setting is off-->
+ <string name="dark_ui_mode_disabled_summary_dark_theme_off">Temporarily turned on due to Battery Saver</string>
+
<!-- [CHAR_LIMIT=NONE] Summary that is shown in the footer when dark mode is selected -->
<string name="dark_ui_settings_dark_summary">Supported apps will also switch to dark theme</string>
diff --git a/res/xml/accessibility_content_timeout_settings.xml b/res/xml/accessibility_content_timeout_settings.xml
deleted file mode 100644
index ea8d88a..0000000
--- a/res/xml/accessibility_content_timeout_settings.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2018 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.
- -->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:key="accessibility_content_timeout_preference"
- android:title="@string/accessibility_content_timeout_preference_title"
- android:persistent="false" >
-
- <com.android.settings.widget.VideoPreference
- android:key="accessibility_content_timeout_video"
- android:title="@string/summary_placeholder"
- settings:animation="@raw/accessibility_timeout"
- settings:preview="@drawable/accessibility_timeout"
- settings:controller="com.android.settings.widget.VideoPreferenceController"
- android:persistent="false" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="accessibility_content_timeout_default"
- android:title="@string/accessibility_timeout_default"
- settings:allowDividerAbove="true"
- android:persistent="false" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="accessibility_content_timeout_10secs"
- android:title="@string/accessibility_timeout_10secs"
- android:persistent="false" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="accessibility_content_timeout_30secs"
- android:title="@string/accessibility_timeout_30secs"
- android:persistent="false" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="accessibility_content_timeout_1min"
- android:title="@string/accessibility_timeout_1min"
- android:persistent="false" />
-
- <com.android.settings.widget.RadioButtonPreference
- android:key="accessibility_content_timeout_2mins"
- android:title="@string/accessibility_timeout_2mins"
- android:persistent="false" />
-
- <com.android.settingslib.widget.FooterPreference
- android:title="@string/accessibility_content_timeout_preference_summary"
- android:selectable="false" />
-
-</PreferenceScreen>
diff --git a/res/xml/accessibility_settings.xml b/res/xml/accessibility_settings.xml
index b4968f8..d9c61b5 100644
--- a/res/xml/accessibility_settings.xml
+++ b/res/xml/accessibility_settings.xml
@@ -77,12 +77,6 @@
android:key="toggle_disable_animations"
android:title="@string/accessibility_disable_animations" />
- <Preference
- android:fragment="com.android.settings.accessibility.AccessibilityContentTimeoutPreferenceFragment"
- android:key="accessibility_content_timeout_preference_fragment"
- android:title="@string/accessibility_content_timeout_preference_title"
- android:persistent="false" />
-
</PreferenceCategory>
<PreferenceCategory
@@ -115,7 +109,7 @@
<Preference
android:fragment="com.android.settings.accessibility.AccessibilityControlTimeoutPreferenceFragment"
android:key="accessibility_control_timeout_preference_fragment"
- android:title="@string/accessibility_control_timeout_preference_title"
+ android:title="@string/accessibility_setting_item_control_timeout_title"
android:persistent="false" />
<Preference
diff --git a/res/xml/captioning_settings.xml b/res/xml/captioning_settings.xml
index 3129738..56e0e2d 100644
--- a/res/xml/captioning_settings.xml
+++ b/res/xml/captioning_settings.xml
@@ -21,6 +21,12 @@
android:key="captioning_preference_screen"
android:title="@string/accessibility_captioning_title" >
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="caption_preview"
+ android:title="@string/summary_placeholder"
+ android:layout="@layout/captioning_preview"
+ settings:searchable="false"/>
+
<PreferenceCategory
android:key="standard"
android:title="@string/captioning_standard_options_title" >
diff --git a/src/com/android/settings/accessibility/AccessibilityContentTimeoutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityContentTimeoutPreferenceFragment.java
deleted file mode 100644
index 8a41bd4..0000000
--- a/src/com/android/settings/accessibility/AccessibilityContentTimeoutPreferenceFragment.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2018 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.accessibility;
-
-import android.app.settings.SettingsEnums;
-import android.content.Context;
-import android.content.res.Resources;
-import android.provider.SearchIndexableResource;
-
-import androidx.preference.Preference;
-
-import com.android.settings.R;
-import com.android.settings.dashboard.DashboardFragment;
-import com.android.settings.search.BaseSearchIndexProvider;
-import com.android.settingslib.core.AbstractPreferenceController;
-import com.android.settingslib.core.lifecycle.Lifecycle;
-import com.android.settingslib.search.SearchIndexable;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-@SearchIndexable
-public final class AccessibilityContentTimeoutPreferenceFragment extends DashboardFragment
- implements AccessibilityTimeoutController.OnChangeListener {
-
- static final String TAG = "AccessibilityContentTimeoutPreferenceFragment";
- private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
-
- @Override
- public void onCheckedChanged(Preference preference) {
- for (AbstractPreferenceController controller : sControllers) {
- controller.updateState(preference);
- }
- }
-
- @Override
- public void onResume() {
- super.onResume();
-
- for (AbstractPreferenceController controller :
- buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
- ((AccessibilityTimeoutController)controller).setOnChangeListener(this);
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
-
- for (AbstractPreferenceController controller :
- buildPreferenceControllers(getPrefContext(), getSettingsLifecycle())) {
- ((AccessibilityTimeoutController)controller).setOnChangeListener(null);
- }
- }
-
- @Override
- public int getMetricsCategory() {
- return SettingsEnums.ACCESSIBILITY;
- }
-
- @Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.accessibility_content_timeout_settings;
- }
-
- @Override
- protected List<AbstractPreferenceController> createPreferenceControllers(Context context) {
- return buildPreferenceControllers(context, getSettingsLifecycle());
- }
-
- private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
- Lifecycle lifecycle) {
- if (sControllers.size() == 0) {
- Resources resources = context.getResources();
-
- String[] timeoutKeys = resources.getStringArray(
- R.array.accessibility_timeout_content_selector_keys);
-
- for (int i=0; i < timeoutKeys.length; i++) {
- sControllers.add(new AccessibilityTimeoutController(
- context, lifecycle, timeoutKeys[i], TAG));
- }
- }
- return sControllers;
- }
-
- public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
- @Override
- public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
- boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.accessibility_content_timeout_settings;
- return Arrays.asList(sir);
- }
-
- @Override
- public List<String> getNonIndexableKeys(Context context) {
- final List<String> keys = super.getNonIndexableKeys(context);
- return keys;
- }
-
- @Override
- public List<AbstractPreferenceController> createPreferenceControllers(
- Context context) {
- return buildPreferenceControllers(context, null);
- }
- };
-}
\ No newline at end of file
diff --git a/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java b/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java
index a6426bf..df950e8 100644
--- a/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/AccessibilityControlTimeoutPreferenceFragment.java
@@ -98,7 +98,7 @@
for (int i=0; i < timeoutKeys.length; i++) {
sControllers.add(new AccessibilityTimeoutController(
- context, lifecycle, timeoutKeys[i], TAG));
+ context, lifecycle, timeoutKeys[i]));
}
}
return sControllers;
@@ -126,4 +126,4 @@
return buildPreferenceControllers(context, null);
}
};
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java
index 148e901..1dbae00 100644
--- a/src/com/android/settings/accessibility/AccessibilitySettings.java
+++ b/src/com/android/settings/accessibility/AccessibilitySettings.java
@@ -132,8 +132,6 @@
"vibration_preference_screen";
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
"daltonizer_preference";
- private static final String ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE =
- "accessibility_content_timeout_preference_fragment";
private static final String ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE =
"accessibility_control_timeout_preference_fragment";
private static final String DARK_UI_MODE_PREFERENCE =
@@ -727,8 +725,6 @@
mToggleInversionPreference.getOrder() + 1);
mToggleDisableAnimationsPreference.setOrder(
mToggleLargePointerIconPreference.getOrder() + 1);
- findPreference(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE).setOrder(
- mToggleDisableAnimationsPreference.getOrder() + 1);
mToggleInversionPreference.setSummary(R.string.summary_empty);
displayCategory.addPreference(mToggleInversionPreference);
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
@@ -795,8 +791,6 @@
updateAccessibilityShortcut(mAccessibilityShortcutPreferenceScreen);
updateAccessibilityTimeoutSummary(getContentResolver(),
- findPreference(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE));
- updateAccessibilityTimeoutSummary(getContentResolver(),
findPreference(ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE));
}
@@ -806,14 +800,8 @@
int[] timeoutValues = getResources().getIntArray(
R.array.accessibility_timeout_selector_values);
- int timeoutValue = 0;
- if (pref.getKey().equals(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE)) {
- timeoutValue = AccessibilityTimeoutController.getSecureAccessibilityTimeoutValue(
- resolver, AccessibilityTimeoutController.CONTENT_TIMEOUT_SETTINGS_SECURE);
- } else if (pref.getKey().equals(ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE)) {
- timeoutValue = AccessibilityTimeoutController.getSecureAccessibilityTimeoutValue(
+ int timeoutValue = AccessibilityTimeoutController.getSecureAccessibilityTimeoutValue(
resolver, AccessibilityTimeoutController.CONTROL_TIMEOUT_SETTINGS_SECURE);
- }
int idx = Ints.indexOf(timeoutValues, timeoutValue);
pref.setSummary(timeoutSummarys[idx == -1 ? 0 : idx]);
diff --git a/src/com/android/settings/accessibility/AccessibilityTimeoutController.java b/src/com/android/settings/accessibility/AccessibilityTimeoutController.java
index a6c5f6f..057013c 100644
--- a/src/com/android/settings/accessibility/AccessibilityTimeoutController.java
+++ b/src/com/android/settings/accessibility/AccessibilityTimeoutController.java
@@ -36,6 +36,9 @@
import java.util.HashMap;
import java.util.Map;
+/**
+ * Controller class that control accessibility time out settings.
+ */
public class AccessibilityTimeoutController extends AbstractPreferenceController implements
LifecycleObserver, RadioButtonPreference.OnClickListener, PreferenceControllerMixin {
static final String CONTENT_TIMEOUT_SETTINGS_SECURE =
@@ -43,11 +46,11 @@
static final String CONTROL_TIMEOUT_SETTINGS_SECURE =
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS;
- // pair the preference key and timeout value
+ // pair the preference key and timeout value.
private final Map<String, Integer> mAccessibilityTimeoutKeyToValueMap = new HashMap<>();
+ // RadioButtonPreference key, each preference represent a timeout value.
private final String mPreferenceKey;
- private final String mfragmentTag;
private final ContentResolver mContentResolver;
private final Resources mResources;
private OnChangeListener mOnChangeListener;
@@ -55,7 +58,7 @@
private int mAccessibilityUiTimeoutValue;
public AccessibilityTimeoutController(Context context, Lifecycle lifecycle,
- String preferenceKey, String fragmentTag) {
+ String preferenceKey) {
super(context);
mContentResolver = context.getContentResolver();
@@ -65,7 +68,6 @@
lifecycle.addObserver(this);
}
mPreferenceKey = preferenceKey;
- mfragmentTag = fragmentTag;
}
protected static int getSecureAccessibilityTimeoutValue(ContentResolver resolver, String name) {
@@ -84,14 +86,8 @@
private Map<String, Integer> getTimeoutValueToKeyMap() {
if (mAccessibilityTimeoutKeyToValueMap.size() == 0) {
- String[] timeoutKeys = null;
- if (mfragmentTag.equals(AccessibilityContentTimeoutPreferenceFragment.TAG)) {
- timeoutKeys = mResources.getStringArray(
- R.array.accessibility_timeout_content_selector_keys);
- } else if (mfragmentTag.equals(AccessibilityControlTimeoutPreferenceFragment.TAG)) {
- timeoutKeys = mResources.getStringArray(
+ String[] timeoutKeys = mResources.getStringArray(
R.array.accessibility_timeout_control_selector_keys);
- }
int[] timeoutValues = mResources.getIntArray(
R.array.accessibility_timeout_selector_values);
@@ -109,11 +105,9 @@
}
private void handlePreferenceChange(String value) {
- if (mfragmentTag.equals(AccessibilityContentTimeoutPreferenceFragment.TAG)) {
- putSecureString(Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, value);
- } else if (mfragmentTag.equals(AccessibilityControlTimeoutPreferenceFragment.TAG)) {
- putSecureString(Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, value);
- }
+ // save value to both content and control timeout setting.
+ putSecureString(Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, value);
+ putSecureString(Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, value);
}
@Override
@@ -144,16 +138,10 @@
}
}
- private int getAccessibilityTimeoutValue(String fragmentTag) {
- int timeoutValue = 0;
- // two kinds of Secure value, one is content timeout, the other is control timeout.
- if (AccessibilityContentTimeoutPreferenceFragment.TAG.equals(fragmentTag)) {
- timeoutValue = getSecureAccessibilityTimeoutValue(mContentResolver,
- CONTENT_TIMEOUT_SETTINGS_SECURE);
- } else if (AccessibilityControlTimeoutPreferenceFragment.TAG.equals(fragmentTag)) {
- timeoutValue = getSecureAccessibilityTimeoutValue(mContentResolver,
+ private int getAccessibilityTimeoutValue() {
+ // get accessibility control timeout value
+ int timeoutValue = getSecureAccessibilityTimeoutValue(mContentResolver,
CONTROL_TIMEOUT_SETTINGS_SECURE);
- }
return timeoutValue;
}
@@ -167,7 +155,7 @@
public void updateState(Preference preference) {
super.updateState(preference);
- mAccessibilityUiTimeoutValue = getAccessibilityTimeoutValue(mfragmentTag);
+ mAccessibilityUiTimeoutValue = getAccessibilityTimeoutValue();
// reset RadioButton
mPreference.setChecked(false);
@@ -175,7 +163,13 @@
updatePreferenceCheckedState(preferenceValue);
}
- public static interface OnChangeListener {
+ /**
+ * Listener interface handles checked event.
+ */
+ public interface OnChangeListener {
+ /**
+ * A hook that is called when preference checked.
+ */
void onCheckedChanged(Preference preference);
}
-}
\ No newline at end of file
+}
diff --git a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
index ae7e3fd..bddca9c 100644
--- a/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
+++ b/src/com/android/settings/accessibility/CaptionPropertiesFragment.java
@@ -22,13 +22,8 @@
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
-import android.preference.PreferenceFrameLayout;
import android.provider.Settings;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnLayoutChangeListener;
-import android.view.ViewGroup;
-import android.view.ViewGroup.LayoutParams;
import android.view.accessibility.CaptioningManager;
import android.view.accessibility.CaptioningManager.CaptionStyle;
@@ -46,6 +41,7 @@
import com.android.settings.widget.ToggleSwitch;
import com.android.settings.widget.ToggleSwitch.OnBeforeCheckedChangeListener;
import com.android.settingslib.accessibility.AccessibilityUtils;
+import com.android.settingslib.widget.LayoutPreference;
import java.util.Locale;
@@ -54,6 +50,7 @@
*/
public class CaptionPropertiesFragment extends SettingsPreferenceFragment
implements OnPreferenceChangeListener, OnValueChangedListener {
+ private static final String PREF_CAPTION_PREVIEW = "caption_preview";
private static final String PREF_BACKGROUND_COLOR = "captioning_background_color";
private static final String PREF_BACKGROUND_OPACITY = "captioning_background_opacity";
private static final String PREF_FOREGROUND_COLOR = "captioning_foreground_color";
@@ -116,43 +113,6 @@
}
@Override
- public View onCreateView(
- LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- final View rootView = inflater.inflate(R.layout.captioning_preview, container, false);
-
- // We have to do this now because PreferenceFrameLayout looks at it
- // only when the view is added.
- if (container instanceof PreferenceFrameLayout) {
- ((PreferenceFrameLayout.LayoutParams) rootView.getLayoutParams()).removeBorders = true;
- }
-
- final View content = super.onCreateView(inflater, container, savedInstanceState);
- ((ViewGroup) rootView.findViewById(R.id.properties_fragment)).addView(
- content, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
-
- return rootView;
- }
-
- @Override
- public void onViewCreated(View view, Bundle savedInstanceState) {
- super.onViewCreated(view, savedInstanceState);
-
- final boolean enabled = mCaptioningManager.isEnabled();
- mPreviewText = (SubtitleView) view.findViewById(R.id.preview_text);
- mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
-
- mPreviewWindow = view.findViewById(R.id.preview_window);
- mPreviewViewport = view.findViewById(R.id.preview_viewport);
- mPreviewViewport.addOnLayoutChangeListener(new OnLayoutChangeListener() {
- @Override
- public void onLayoutChange(View v, int left, int top, int right, int bottom,
- int oldLeft, int oldTop, int oldRight, int oldBottom) {
- refreshPreviewText();
- }
- });
- }
-
- @Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -263,6 +223,19 @@
}
private void initializeAllPreferences() {
+ final LayoutPreference captionPreview = findPreference(PREF_CAPTION_PREVIEW);
+
+ final boolean enabled = mCaptioningManager.isEnabled();
+ mPreviewText = captionPreview.findViewById(R.id.preview_text);
+ mPreviewText.setVisibility(enabled ? View.VISIBLE : View.INVISIBLE);
+
+ mPreviewWindow = captionPreview.findViewById(R.id.preview_window);
+
+ mPreviewViewport = captionPreview.findViewById(R.id.preview_viewport);
+ mPreviewViewport.addOnLayoutChangeListener(
+ (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
+ -> refreshPreviewText());
+
mLocale = (LocalePreference) findPreference(PREF_LOCALE);
mFontSize = (ListPreference) findPreference(PREF_FONT_SIZE);
@@ -370,9 +343,9 @@
/**
* Unpack the specified color value and update the preferences.
*
- * @param color color preference
+ * @param color color preference
* @param opacity opacity preference
- * @param value packed value
+ * @param value packed value
*/
private void parseColorOpacity(ColorPreference color, ColorPreference opacity, int value) {
final int colorValue;
diff --git a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
index 3403b3b..3e12011 100644
--- a/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/RingVibrationPreferenceFragment.java
@@ -51,7 +51,7 @@
@Override
protected int getPreviewVibrationAudioAttributesUsage() {
- return AudioAttributes.USAGE_NOTIFICATION;
+ return AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
}
@Override
diff --git a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
index bb26283..dcf1f1c 100644
--- a/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
+++ b/src/com/android/settings/accessibility/ShortcutServicePickerFragment.java
@@ -15,8 +15,6 @@
*/
package com.android.settings.accessibility;
-import static android.content.DialogInterface.BUTTON_POSITIVE;
-
import static com.android.internal.accessibility.AccessibilityShortcutController.COLOR_INVERSION_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.DALTONIZER_COMPONENT_NAME;
@@ -25,7 +23,6 @@
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
@@ -191,6 +188,7 @@
((ShortcutServicePickerFragment) fragment).onServiceConfirmed(
bundle.getString(EXTRA_KEY));
}
+ dismiss();
}
}
diff --git a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
index d1adf3c..f3f2af2 100644
--- a/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleAccessibilityServicePreferenceFragment.java
@@ -86,6 +86,16 @@
}
@Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ mSwitchBar.setLabelDelegate((boolean isChecked) -> {
+ final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
+ return getString(R.string.accessibility_service_master_switch_title,
+ info.getResolveInfo().loadLabel(getPackageManager()));
+ });
+ }
+
+ @Override
public void onResume() {
mSettingsContentObserver.register(getContentResolver());
updateSwitchBarToggleSwitch();
@@ -120,7 +130,7 @@
return serviceInfo;
}
}
- return null;
+ throw new IllegalStateException("ServiceInfo is not found.");
}
@Override
@@ -128,18 +138,12 @@
switch (dialogId) {
case DIALOG_ID_ENABLE_WARNING: {
final AccessibilityServiceInfo info = getAccessibilityServiceInfo();
- if (info == null) {
- return null;
- }
mDialog = AccessibilityServiceWarning
.createCapabilitiesDialog(getActivity(), info, this);
break;
}
case DIALOG_ID_DISABLE_WARNING: {
AccessibilityServiceInfo info = getAccessibilityServiceInfo();
- if (info == null) {
- return null;
- }
mDialog = AccessibilityServiceWarning
.createDisableDialog(getActivity(), info, this);
break;
diff --git a/src/com/android/settings/accounts/AddAccountSettings.java b/src/com/android/settings/accounts/AddAccountSettings.java
index cca15c9..d4d93dd 100644
--- a/src/com/android/settings/accounts/AddAccountSettings.java
+++ b/src/com/android/settings/accounts/AddAccountSettings.java
@@ -100,8 +100,9 @@
addAccountOptions.putBoolean(EXTRA_HAS_MULTIPLE_USERS,
Utils.hasMultipleUsers(AddAccountSettings.this));
addAccountOptions.putParcelable(EXTRA_USER, mUserHandle);
- intent.putExtras(addAccountOptions);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtras(addAccountOptions)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivityForResultAsUser(intent, ADD_ACCOUNT_REQUEST, mUserHandle);
} else {
setResult(RESULT_OK);
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
index fae1785..956ba49 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEducation.java
@@ -33,6 +33,7 @@
import android.view.accessibility.AccessibilityManager;
import android.widget.Button;
import android.widget.CompoundButton;
+import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.Utils;
@@ -59,19 +60,28 @@
private View mIllustrationAccessibility;
private Handler mHandler;
private Intent mResultIntent;
+ private TextView mDescriptionText;
private CompoundButton.OnCheckedChangeListener mSwitchDiversityListener =
new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ int titleRes = isChecked ?
+ R.string.security_settings_face_enroll_education_title_accessibility
+ : R.string.security_settings_face_enroll_education_title;
+ getLayout().setHeaderText(titleRes);
+ setTitle(titleRes);
+
if (isChecked) {
mIllustrationNormal.stop();
mIllustrationNormal.setVisibility(View.INVISIBLE);
mIllustrationAccessibility.setVisibility(View.VISIBLE);
+ mDescriptionText.setVisibility(View.INVISIBLE);
} else {
mIllustrationNormal.setVisibility(View.VISIBLE);
mIllustrationNormal.start();
mIllustrationAccessibility.setVisibility(View.INVISIBLE);
+ mDescriptionText.setVisibility(View.VISIBLE);
}
}
};
@@ -88,6 +98,7 @@
mIllustrationNormal = findViewById(R.id.illustration_normal);
mIllustrationAccessibility = findViewById(R.id.illustration_accessibility);
+ mDescriptionText = findViewById(R.id.sud_layout_description);
mFooterBarMixin = getLayout().getMixin(FooterBarMixin.class);
mFooterBarMixin.setSecondaryButton(
diff --git a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
index 990e68d..d532a76 100644
--- a/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
+++ b/src/com/android/settings/biometrics/face/FaceSettingsRemoveButtonPreferenceController.java
@@ -94,6 +94,7 @@
Log.e(TAG, "Unable to remove face: " + face.getBiometricId()
+ " error: " + errMsgId + " " + errString);
Toast.makeText(mContext, errString, Toast.LENGTH_SHORT).show();
+ mRemoving = false;
}
@Override
@@ -131,6 +132,7 @@
mFaceManager.remove(faces.get(0), mUserId, mRemovalCallback);
} else {
mButton.setEnabled(true);
+ mRemoving = false;
}
}
};
diff --git a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
index 112d7b8..6817d0d 100644
--- a/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
+++ b/src/com/android/settings/bluetooth/AdvancedBluetoothDetailsHeaderController.java
@@ -149,7 +149,7 @@
final TextView title = mLayoutPreference.findViewById(R.id.entity_header_title);
title.setText(mCachedDevice.getName());
final TextView summary = mLayoutPreference.findViewById(R.id.entity_header_summary);
- summary.setText(mCachedDevice.getConnectionSummary());
+ summary.setText(mCachedDevice.getConnectionSummary(true /* shortSummary */));
if (!mCachedDevice.isConnected()) {
updateDisconnectLayout();
diff --git a/src/com/android/settings/display/DarkUIPreferenceController.java b/src/com/android/settings/display/DarkUIPreferenceController.java
index 9df2402..d3d30b5 100644
--- a/src/com/android/settings/display/DarkUIPreferenceController.java
+++ b/src/com/android/settings/display/DarkUIPreferenceController.java
@@ -17,27 +17,53 @@
package com.android.settings.display;
import android.app.UiModeManager;
+import android.content.BroadcastReceiver;
import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.PowerManager;
import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+import com.android.settings.R;
import com.android.settings.core.TogglePreferenceController;
+import com.android.settingslib.core.lifecycle.LifecycleObserver;
+import com.android.settingslib.core.lifecycle.events.OnStart;
+import com.android.settingslib.core.lifecycle.events.OnStop;
-public class DarkUIPreferenceController extends TogglePreferenceController {
+public class DarkUIPreferenceController extends TogglePreferenceController implements
+ LifecycleObserver, OnStart, OnStop {
public static final String DARK_MODE_PREFS = "dark_mode_prefs";
public static final String PREF_DARK_MODE_DIALOG_SEEN = "dark_mode_dialog_seen";
public static final int DIALOG_SEEN = 1;
+
+ @VisibleForTesting
+ SwitchPreference mPreference;
+
private UiModeManager mUiModeManager;
+ private PowerManager mPowerManager;
private Context mContext;
+
private Fragment mFragment;
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ updateEnabledStateIfNeeded();
+ }
+ };
+
public DarkUIPreferenceController(Context context, String key) {
super(context, key);
mContext = context;
mUiModeManager = context.getSystemService(UiModeManager.class);
+ mPowerManager = context.getSystemService(PowerManager.class);
}
@Override
@@ -46,6 +72,18 @@
}
@Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ mPreference = screen.findPreference(getPreferenceKey());
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ super.updateState(preference);
+ updateEnabledStateIfNeeded();
+ }
+
+ @Override
public boolean setChecked(boolean isChecked) {
final boolean dialogSeen =
Settings.Secure.getInt(mContext.getContentResolver(),
@@ -68,6 +106,29 @@
}
@VisibleForTesting
+ void updateEnabledStateIfNeeded() {
+ if (mPreference == null) {
+ return;
+ }
+ boolean isBatterySaver = isPowerSaveMode();
+ mPreference.setEnabled(!isBatterySaver);
+ if (isBatterySaver) {
+ int stringId = mUiModeManager.getNightMode() == UiModeManager.MODE_NIGHT_YES
+ ? R.string.dark_ui_mode_disabled_summary_dark_theme_on
+ : R.string.dark_ui_mode_disabled_summary_dark_theme_off;
+ mPreference.setSummary(mContext.getString(stringId));
+ } else {
+ mPreference.setSummary(null);
+ }
+ }
+
+ @VisibleForTesting
+ boolean isPowerSaveMode() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
+
+ @VisibleForTesting
void setUiModeManager(UiModeManager uiModeManager) {
mUiModeManager = uiModeManager;
}
@@ -77,6 +138,17 @@
}
@Override
+ public void onStart() {
+ mContext.registerReceiver(mReceiver,
+ new IntentFilter(PowerManager.ACTION_POWER_SAVE_MODE_CHANGED));
+ }
+
+ @Override
+ public void onStop() {
+ mContext.unregisterReceiver(mReceiver);
+ }
+
+ @Override
public int getAvailabilityStatus() {
return AVAILABLE;
}
diff --git a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
index 1fe7e7d..d5e1723 100644
--- a/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
+++ b/src/com/android/settings/notification/RecentNotifyingAppsPreferenceController.java
@@ -79,7 +79,6 @@
private final PackageManager mPm;
private final NotificationBackend mNotificationBackend;
private IUsageStatsManager mUsageStatsManager;
- private final int mUserId;
private final IconDrawableFactory mIconDrawableFactory;
private Calendar mCal;
@@ -104,7 +103,6 @@
ApplicationsState appState, Fragment host) {
super(context);
mIconDrawableFactory = IconDrawableFactory.newInstance(context);
- mUserId = UserHandle.myUserId();
mPm = context.getPackageManager();
mHost = host;
mApplicationsState = appState;
@@ -177,7 +175,6 @@
e.printStackTrace();
}
if (events != null) {
-
ArrayMap<String, NotifyingApp> aggregatedStats = new ArrayMap<>();
UsageEvents.Event event = new UsageEvents.Event();
@@ -205,7 +202,8 @@
}
}
- private static String getKey(int userId, String pkg) {
+ @VisibleForTesting
+ static String getKey(int userId, String pkg) {
return userId + "|" + pkg;
}
@@ -252,12 +250,13 @@
}
boolean rebindPref = true;
- NotificationAppPreference pref = appPreferences.remove(pkgName);
+ NotificationAppPreference pref = appPreferences.remove(getKey(app.getUserId(),
+ pkgName));
if (pref == null) {
pref = new NotificationAppPreference(prefContext);
rebindPref = false;
}
- pref.setKey(pkgName);
+ pref.setKey(getKey(app.getUserId(), pkgName));
pref.setTitle(appEntry.label);
pref.setIcon(mIconDrawableFactory.getBadgedIcon(appEntry.info));
pref.setIconSize(TwoTargetPreference.ICON_SIZE_SMALL);
@@ -267,11 +266,11 @@
Bundle args = new Bundle();
args.putString(AppInfoBase.ARG_PACKAGE_NAME, pkgName);
args.putInt(AppInfoBase.ARG_PACKAGE_UID, appEntry.info.uid);
-
pref.setIntent(new SubSettingLauncher(mHost.getActivity())
.setDestination(AppNotificationSettings.class.getName())
.setTitleRes(R.string.notifications_title)
.setArguments(args)
+ .setUserHandle(new UserHandle(UserHandle.getUserId(appEntry.info.uid)))
.setSourceMetricsCategory(
SettingsEnums.MANAGE_APPLICATIONS_NOTIFICATIONS)
.toIntent());
@@ -301,11 +300,11 @@
int count = 0;
for (NotifyingApp app : mApps) {
final ApplicationsState.AppEntry appEntry = mApplicationsState.getEntry(
- app.getPackage(), mUserId);
+ app.getPackage(), app.getUserId());
if (appEntry == null) {
continue;
}
- if (!shouldIncludePkgInRecents(app.getPackage())) {
+ if (!shouldIncludePkgInRecents(app.getPackage(), app.getUserId())) {
continue;
}
displayableApps.add(app);
@@ -321,14 +320,14 @@
/**
* Whether or not the app should be included in recent list.
*/
- private boolean shouldIncludePkgInRecents(String pkgName) {
+ private boolean shouldIncludePkgInRecents(String pkgName, int userId) {
final Intent launchIntent = new Intent().addCategory(Intent.CATEGORY_LAUNCHER)
.setPackage(pkgName);
if (mPm.resolveActivity(launchIntent, 0) == null) {
// Not visible on launcher -> likely not a user visible app, skip if non-instant.
final ApplicationsState.AppEntry appEntry =
- mApplicationsState.getEntry(pkgName, mUserId);
+ mApplicationsState.getEntry(pkgName, userId);
if (appEntry == null || appEntry.info == null || !AppUtils.isInstant(appEntry.info)) {
Log.d(TAG, "Not a user visible or instant app, skipping " + pkgName);
return false;
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index f8743d1..3341304 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -61,6 +61,16 @@
void onSwitchChanged(Switch switchView, boolean isChecked);
}
+ public interface LabelDelegate {
+ /**
+ * Called to create label and set the title with Accessibility
+ * service name to the textView of switchBar.
+ *
+ * @param isChecked The checked state of switchView.
+ */
+ String createLabel(boolean isChecked);
+ }
+
private static final int[] XML_ATTRIBUTES = {
R.attr.switchBarMarginStart,
R.attr.switchBarMarginEnd,
@@ -90,6 +100,7 @@
private boolean mDisabledByAdmin;
private EnforcedAdmin mEnforcedAdmin = null;
private String mMetricsTag;
+ private LabelDelegate mLabelDelegate;
public SwitchBar(Context context) {
@@ -178,7 +189,11 @@
}
public void setTextViewLabelAndBackground(boolean isChecked) {
- mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
+ if(mLabelDelegate != null) {
+ mLabel = mLabelDelegate.createLabel(isChecked);
+ } else {
+ mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
+ }
setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
updateText();
}
@@ -383,4 +398,9 @@
requestLayout();
}
+
+ public void setLabelDelegate(LabelDelegate labelDelegate) {
+ mLabelDelegate = labelDelegate;
+ setTextViewLabelAndBackground(isChecked());
+ }
}
diff --git a/src/com/android/settings/widget/UsageGraph.java b/src/com/android/settings/widget/UsageGraph.java
index 7cef66f..505dc58 100644
--- a/src/com/android/settings/widget/UsageGraph.java
+++ b/src/com/android/settings/widget/UsageGraph.java
@@ -288,7 +288,11 @@
canvas.drawPath(mPath, paint);
}
- private void drawFilledPath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
+ @VisibleForTesting
+ void drawFilledPath(Canvas canvas, SparseIntArray localPaths, Paint paint) {
+ if (localPaths.size() == 0) {
+ return;
+ }
mPath.reset();
float lastStartX = localPaths.keyAt(0);
mPath.moveTo(localPaths.keyAt(0), localPaths.valueAt(0));
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
index a07ffb9..43bdc30 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilitySettingsTest.java
@@ -27,11 +27,9 @@
import android.os.Vibrator;
import android.provider.Settings;
-import androidx.preference.ListPreference;
import androidx.preference.Preference;
import com.android.settings.R;
-import com.android.settings.display.DarkUIPreferenceController;
import com.android.settings.testutils.XmlTestUtils;
import org.junit.Before;
@@ -46,8 +44,6 @@
@RunWith(RobolectricTestRunner.class)
public class AccessibilitySettingsTest {
private static final String VIBRATION_PREFERENCE_SCREEN = "vibration_preference_screen";
- private static final String ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE =
- "accessibility_content_timeout_preference_fragment";
private static final String ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE =
"accessibility_control_timeout_preference_fragment";
private static final String DARK_UI_MODE_PREFERENCE =
@@ -71,9 +67,9 @@
@Test
public void testNonIndexableKeys_existInXmlLayout() {
final List<String> niks = AccessibilitySettings.SEARCH_INDEX_DATA_PROVIDER
- .getNonIndexableKeys(mContext);
+ .getNonIndexableKeys(mContext);
final List<String> keys =
- XmlTestUtils.getKeysFromPreferenceXml(mContext, R.xml.accessibility_settings);
+ XmlTestUtils.getKeysFromPreferenceXml(mContext, R.xml.accessibility_settings);
assertThat(keys).containsAllIn(niks);
}
@@ -113,12 +109,6 @@
for (int i = 0; i < testingValues.length; i++) {
Settings.Secure.putString(mContentResolver,
- Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, testingValues[i]);
-
- verifyAccessibilityTimeoutSummary(ACCESSIBILITY_CONTENT_TIMEOUT_PREFERENCE,
- exceptedResIds[i]);
-
- Settings.Secure.putString(mContentResolver,
Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, testingValues[i]);
verifyAccessibilityTimeoutSummary(ACCESSIBILITY_CONTROL_TIMEOUT_PREFERENCE,
diff --git a/tests/robotests/src/com/android/settings/accessibility/AccessibilityTimeoutControllerTest.java b/tests/robotests/src/com/android/settings/accessibility/AccessibilityTimeoutControllerTest.java
index 531282b..7891664 100644
--- a/tests/robotests/src/com/android/settings/accessibility/AccessibilityTimeoutControllerTest.java
+++ b/tests/robotests/src/com/android/settings/accessibility/AccessibilityTimeoutControllerTest.java
@@ -45,8 +45,7 @@
@RunWith(RobolectricTestRunner.class)
public class AccessibilityTimeoutControllerTest
implements AccessibilityTimeoutController.OnChangeListener {
- private static final String PREF_KEY = "accessibility_content_timeout_30secs";
- private static String PREF_TITLE;
+ private static final String PREF_KEY = "accessibility_control_timeout_30secs";
private AccessibilityTimeoutController mController;
@@ -62,15 +61,14 @@
public void setup() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
- mController = new AccessibilityTimeoutController(mContext, mock(Lifecycle.class),
- PREF_KEY, AccessibilityContentTimeoutPreferenceFragment.TAG);
+ mController = new AccessibilityTimeoutController(mContext, mock(Lifecycle.class), PREF_KEY);
mController.setOnChangeListener(this);
mContentResolver = mContext.getContentResolver();
- PREF_TITLE = mContext.getResources().getString(R.string.accessibility_timeout_30secs);
+ String prefTitle = mContext.getResources().getString(R.string.accessibility_timeout_30secs);
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mMockPref);
when(mMockPref.getKey()).thenReturn(PREF_KEY);
- when(mMockPref.getTitle()).thenReturn(PREF_TITLE);
+ when(mMockPref.getTitle()).thenReturn(prefTitle);
mController.displayPreference(mScreen);
}
@@ -87,7 +85,7 @@
@Test
public void updateState_notChecked() {
Settings.Secure.putString(mContentResolver,
- Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, "0");
+ Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, "0");
mController.updateState(mMockPref);
@@ -99,7 +97,7 @@
@Test
public void updateState_checked() {
Settings.Secure.putString(mContentResolver,
- Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS, "30000");
+ Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS, "30000");
mController.updateState(mMockPref);
@@ -113,8 +111,8 @@
mController.onRadioButtonClicked(mMockPref);
String accessibilityUiTimeoutValue = Settings.Secure.getString(mContentResolver,
- Settings.Secure.ACCESSIBILITY_NON_INTERACTIVE_UI_TIMEOUT_MS);
+ Settings.Secure.ACCESSIBILITY_INTERACTIVE_UI_TIMEOUT_MS);
assertThat(accessibilityUiTimeoutValue).isEqualTo("30000");
}
-}
\ No newline at end of file
+}
diff --git a/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
new file mode 100644
index 0000000..3659803
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/DarkUIPreferenceControllerTest.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2019 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.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.content.Context;
+import android.os.Handler;
+import android.os.IPowerManager;
+import android.os.PowerManager;
+
+import androidx.fragment.app.Fragment;
+import androidx.preference.PreferenceScreen;
+import androidx.preference.SwitchPreference;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class DarkUIPreferenceControllerTest {
+
+ private DarkUIPreferenceController mController;
+ private Context mContext;
+ @Mock
+ private Fragment mFragment;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mController = spy(new DarkUIPreferenceController(mContext, "dark_ui_mode"));
+ mController.setParentFragment(mFragment);
+ mController.mPreference = new SwitchPreference(mContext);
+ mController.onStart();
+ }
+
+ @Test
+ public void batterySaverToggles_disabledStateUpdates() {
+ doReturn(true).when(mController).isPowerSaveMode();
+ mController.updateEnabledStateIfNeeded();
+ assertThat(mController.mPreference.isEnabled()).isFalse();
+
+ doReturn(false).when(mController).isPowerSaveMode();
+ mController.updateEnabledStateIfNeeded();
+ assertThat(mController.mPreference.isEnabled()).isTrue();
+
+ doReturn(true).when(mController).isPowerSaveMode();
+ mController.updateEnabledStateIfNeeded();
+ assertThat(mController.mPreference.isEnabled()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java
index d47d125..93bd8dc 100644
--- a/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/notification/RecentNotifyingAppsPreferenceControllerTest.java
@@ -168,7 +168,6 @@
@Test
public void display_showRecents() throws Exception {
-
List<Event> events = new ArrayList<>();
Event app = new Event();
app.mEventType = Event.NOTIFICATION_INTERRUPTION;
@@ -262,8 +261,12 @@
ArgumentCaptor<Preference> prefCaptor = ArgumentCaptor.forClass(Preference.class);
verify(mCategory, times(2)).addPreference(prefCaptor.capture());
List<Preference> prefs = prefCaptor.getAllValues();
- assertThat(prefs.get(1).getKey()).isEqualTo(app.getPackageName());
- assertThat(prefs.get(0).getKey()).isEqualTo(app1.getPackageName());
+ assertThat(prefs.get(1).getKey()).isEqualTo(
+ RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(),
+ app.getPackageName()));
+ assertThat(prefs.get(0).getKey()).isEqualTo(
+ RecentNotifyingAppsPreferenceController.getKey(UserHandle.myUserId(),
+ app1.getPackageName()));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
index 7f09c3b..ebb496c 100644
--- a/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
+++ b/tests/robotests/src/com/android/settings/widget/UsageGraphTest.java
@@ -24,6 +24,8 @@
import android.content.Context;
import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.util.SparseIntArray;
import com.android.settingslib.R;
@@ -177,4 +179,14 @@
assertThat(localPaths.keyAt(5)).isEqualTo(1001);
assertThat(localPaths.valueAt(5)).isEqualTo(-1);
}
+
+ @Test
+ public void drawFilledPath_emptyPath_shouldNotCrash() {
+ final Canvas canvas = new Canvas();
+ final SparseIntArray localPaths = new SparseIntArray();
+ final Paint paint = new Paint();
+
+ // Should not crash
+ mGraph.drawFilledPath(canvas, localPaths, paint);
+ }
}