Merge "Fix the issue that title of Color inversion page is wrong" into rvc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 3684056..54525d5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4944,7 +4944,7 @@
     <string name="accessibility_screen_magnification_navbar_summary">When magnification is turned on, you can zoom in on your screen.\n\n<b>To zoom</b>, start magnification, then tap anywhere on the screen.\n<ul><li>Drag 2 or more fingers to scroll</li>\n<li>Pinch 2 or more fingers to adjust zoom</li></ul>\n\n<b>To zoom temporarily</b>, start magnification, then touch &amp; hold anywhere on the screen.\n<ul><li>Drag to move around the screen</li>\n<li>Lift finger to zoom out</li></ul>\n\nYou can’t zoom in on the keyboard or navigation bar.</string>
     <!-- Title for the accessibility tutorial dialog in accessibility service with button. [CHAR LIMIT=50] -->
     <string name="accessibility_tutorial_dialog_title_button">Use accessibility button to open</string>
-    <!-- Title for the accessibility tutorial dialog in accessibility service with volume keys. [CHAR LIMIT=50] -->
+    <!-- Title for the accessibility tutorial dialog in accessibility service with volume keys. [CHAR LIMIT=100] -->
     <string name="accessibility_tutorial_dialog_title_volume">Hold volume keys to open</string>
     <!-- Title for the accessibility tutorial dialog in accessibility service with triple tap. [CHAR LIMIT=100] -->
     <string name="accessibility_tutorial_dialog_title_triple">Triple tap screen to open</string>
@@ -8666,7 +8666,7 @@
     <!-- Settings text. This text lets a user know that they should only connect work and personal apps
     if they trust the work app with their personal data. The work app could potentially show that data
     to the user's IT admin. [CHAR LIMIT=NONE] -->
-    <string name="interact_across_profiles_summary_2">Only connect apps that you trust with your personal data. Work apps may expose your data to your IT admin.</string>
+    <string name="interact_across_profiles_summary_2">Only connect apps if you trust them not to share personal data with your IT admin.</string>
 
     <!-- Dialog title. This dialog is shown when a user tries to connect a work app to a personal
     app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should
@@ -8677,7 +8677,7 @@
     app (e.g. their work Calendar to their personal Calendar), and it's confirming that they should
     connect the apps only if they trust the work app with their personal data.
     The placeholder is the app name. [CHAR LIMIT=NONE] -->
-    <string name="interact_across_profiles_consent_dialog_summary"><xliff:g id="name" example="Calendar">%1$s</xliff:g> may expose your personal data to your IT admin.</string>
+    <string name="interact_across_profiles_consent_dialog_summary">Only connect apps if you trust them not to share personal data with your IT admin.</string>
 
     <!-- Title of a section in a dialog. This section shows the app data that will be
     accessible when work and personal apps are connected. [CHAR LIMIT=NONE] -->
@@ -8708,12 +8708,12 @@
     <!-- Banner title. This banner lets a user know that they need to install an app in their
     work profile in order to connect it to the corresponding personal app.
     The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=NONE]-->
-    <string name="interact_across_profiles_install_work_app_title">Install work <xliff:g id="name" example="Calendar">%1$s</xliff:g> to connect these apps</string>
+    <string name="interact_across_profiles_install_work_app_title">To connect these apps, install <xliff:g id="name" example="Calendar">%1$s</xliff:g> in your work profile</string>
 
     <!-- Banner title. This banner lets a user know that they need to install an app in their
     personal profile in order to connect it to the corresponding work app.
     The placeholder would be the app name (e.g. Calendar). [CHAR LIMIT=NONE]-->
-    <string name="interact_across_profiles_install_personal_app_title">Install personal <xliff:g id="name" example="Calendar">%1$s</xliff:g> to connect these apps</string>
+    <string name="interact_across_profiles_install_personal_app_title">To connect these apps, install <xliff:g id="name" example="Calendar">%1$s</xliff:g> in your personal profile</string>
 
     <!-- Banner text. This banner lets a user know that they need to install an app in their
     work/personal profile in order to connect it to the corresponding personal app.
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 8393f80..d8f5e87 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -501,6 +501,11 @@
         <item name="rowStyle">@style/SliceRow.Settings</item>
     </style>
 
+    <style name="Widget.SliceView.ContextualCard">
+        <item name="rowStyle">@style/SliceRow</item>
+        <item name="android:background">@color/contextual_card_background</item>
+    </style>
+
     <style name="Widget.SliceView.Panel">
         <item name="titleSize">16sp</item>
         <item name="rowStyle">@style/SliceRow</item>
@@ -511,35 +516,6 @@
         <item name="rowStyle">@style/SliceRow.Slider</item>
     </style>
 
-    <style name="SliceRow.Slider">
-        <!-- 2dp start padding for the start icon -->
-        <item name="titleItemStartPadding">10dp</item>
-        <item name="titleItemEndPadding">0dp</item>
-
-        <!-- Padding between content and the start icon is 14dp -->
-        <item name="contentStartPadding">5dp</item>
-        <!-- Padding between content and end items is 16dp -->
-        <item name="contentEndPadding">16dp</item>
-
-        <!-- Both side margins of end item are 16dp -->
-        <item name="endItemStartPadding">0dp</item>
-        <item name="endItemEndPadding">24dp</item>
-
-        <!-- Both side margins of bottom divider are 12dp -->
-        <item name="bottomDividerStartPadding">12dp</item>
-        <item name="bottomDividerEndPadding">12dp</item>
-
-        <item name="actionDividerHeight">32dp</item>
-        <!-- Align text with slider -->
-        <item name="titleStartPadding">6dp</item>
-        <item name="subContentStartPadding">6dp</item>
-    </style>
-
-    <style name="Widget.SliceView.ContextualCard">
-        <item name="rowStyle">@style/SliceRow</item>
-        <item name="android:background">@color/contextual_card_background</item>
-    </style>
-
     <style name="SliceRow">
         <!-- 2dp start padding for the start icon -->
         <item name="titleItemStartPadding">2dp</item>
@@ -566,6 +542,23 @@
         <item name="contentStartPadding">8dp</item>
     </style>
 
+    <style name="SliceRow.Slider">
+        <!-- 10dp start padding for the start icon -->
+        <item name="titleItemStartPadding">10dp</item>
+
+        <!-- Padding between content and the start icon is 5dp -->
+        <item name="contentStartPadding">5dp</item>
+
+        <!-- 0dp start padding for the end item -->
+        <item name="endItemStartPadding">0dp</item>
+        <!-- 24dp end padding for the end item -->
+        <item name="endItemEndPadding">24dp</item>
+
+        <!-- Align text with slider -->
+        <item name="titleStartPadding">6dp</item>
+        <item name="subContentStartPadding">6dp</item>
+    </style>
+
     <style name="DisclaimerPositiveButton" parent="@style/SudGlifButton.Primary">
         <item name="android:layout_margin">16dp</item>
         <item name="android:paddingStart">8dp</item>
diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
index 6b0759a..f8b64fb 100644
--- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java
@@ -30,6 +30,7 @@
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
+import android.os.Handler;
 import android.os.UserHandle;
 import android.provider.Settings;
 import android.text.Html;
@@ -96,6 +97,7 @@
     private int mUserShortcutTypes = UserShortcutType.EMPTY;
     private CheckBox mSoftwareTypeCheckBox;
     private CheckBox mHardwareTypeCheckBox;
+    private SettingsContentObserver mSettingsContentObserver;
 
     // For html description of accessibility service, must follow the rule, such as
     // <img src="R.drawable.fileName"/>, a11y settings will get the resources successfully.
@@ -133,6 +135,17 @@
             removeDialog(DialogEnums.EDIT_SHORTCUT);
             mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
         };
+
+        final List<String> shortcutFeatureKeys = new ArrayList<>();
+        shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
+        shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
+        mSettingsContentObserver = new SettingsContentObserver(new Handler(), shortcutFeatureKeys) {
+            @Override
+            public void onChange(boolean selfChange, Uri uri) {
+                updateShortcutPreferenceData();
+                updateShortcutPreference();
+            }
+        };
         return super.onCreateView(inflater, container, savedInstanceState);
     }
 
@@ -229,6 +242,7 @@
         final AccessibilityManager am = getPrefContext().getSystemService(
                 AccessibilityManager.class);
         am.addTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+        mSettingsContentObserver.register(getContentResolver());
         updateShortcutPreferenceData();
         updateShortcutPreference();
     }
@@ -238,6 +252,7 @@
         final AccessibilityManager am = getPrefContext().getSystemService(
                 AccessibilityManager.class);
         am.removeTouchExplorationStateChangeListener(mTouchExplorationStateChangeListener);
+        mSettingsContentObserver.unregister(getContentResolver());
         super.onPause();
     }
 
@@ -618,7 +633,7 @@
                 getShortcutTypeSummary(getPrefContext()));
     }
 
-    private void updateShortcutPreferenceData() {
+    protected void updateShortcutPreferenceData() {
         if (mComponentName == null) {
             return;
         }
@@ -651,7 +666,7 @@
         mShortcutPreference.setTitle(title);
     }
 
-    private void updateShortcutPreference() {
+    protected void updateShortcutPreference() {
         if (mComponentName == null) {
             return;
         }
diff --git a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
index 23fb153..52f8f71 100644
--- a/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
+++ b/src/com/android/settings/accessibility/ToggleScreenMagnificationPreferenceFragment.java
@@ -467,7 +467,8 @@
         showDialog(DialogEnums.MAGNIFICATION_EDIT_SHORTCUT);
     }
 
-    private void updateShortcutPreferenceData() {
+    @Override
+    protected void updateShortcutPreferenceData() {
         // Get the user shortcut type from settings provider.
         mUserShortcutType = getUserShortcutTypeFromSettings(getPrefContext());
         if (mUserShortcutType != UserShortcutType.EMPTY) {
@@ -489,7 +490,8 @@
         mShortcutPreference.setTitle(title);
     }
 
-    private void updateShortcutPreference() {
+    @Override
+    protected void updateShortcutPreference() {
         final int shortcutTypes = getUserShortcutTypes(getPrefContext(), UserShortcutType.SOFTWARE);
         mShortcutPreference.setChecked(
                 hasMagnificationValuesInSettings(getPrefContext(), shortcutTypes));
diff --git a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
index ad47c03..8b1497e 100644
--- a/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
+++ b/src/com/android/settings/applications/specialaccess/interactacrossprofiles/InteractAcrossProfilesDetails.java
@@ -255,11 +255,6 @@
         dialogTitle.setText(
                 getString(R.string.interact_across_profiles_consent_dialog_title, mAppLabel));
 
-        final TextView dialogSummary = dialogView.findViewById(
-                R.id.interact_across_profiles_consent_dialog_summary);
-        dialogSummary.setText(
-                getString(R.string.interact_across_profiles_consent_dialog_summary, mAppLabel));
-
         final TextView appDataSummary = dialogView.findViewById(R.id.app_data_summary);
         appDataSummary.setText(getString(
                 R.string.interact_across_profiles_consent_dialog_app_data_summary, mAppLabel));
diff --git a/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java b/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java
index fb2dbc3..ef11e00 100644
--- a/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java
+++ b/src/com/android/settings/display/NightDisplayAutoModePreferenceController.java
@@ -74,7 +74,7 @@
         if (String.valueOf(ColorDisplayManager.AUTO_MODE_TWILIGHT).equals(newValue)
                 && !mLocationManager.isLocationEnabled()) {
             TwilightLocationDialog.show(mContext);
-            return false;
+            return true;
         }
         return mColorDisplayManager.setNightDisplayAutoMode(Integer.parseInt((String) newValue));
     }
diff --git a/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java b/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java
index 6acaf82..2ac9a9f 100644
--- a/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java
+++ b/src/com/android/settings/display/darkmode/DarkModeScheduleSelectorController.java
@@ -33,7 +33,7 @@
  */
 public class DarkModeScheduleSelectorController extends BasePreferenceController
         implements Preference.OnPreferenceChangeListener {
-
+    private static final String TAG = DarkModeScheduleSelectorController.class.getSimpleName();
     private final UiModeManager mUiModeManager;
     private PowerManager mPowerManager;
     private DropDownPreference mPreference;
@@ -51,7 +51,6 @@
     public void displayPreference(PreferenceScreen screen) {
         super.displayPreference(screen);
         mPreference = screen.findPreference(getPreferenceKey());
-        init();
     }
 
     @Override
@@ -59,7 +58,8 @@
         return BasePreferenceController.AVAILABLE;
     }
 
-    private void init() {
+    @Override
+    public final void updateState(Preference preference) {
         final boolean batterySaver = mPowerManager.isPowerSaveMode();
         mPreference.setEnabled(!batterySaver);
         mCurrentMode = getCurrentMode();
@@ -87,25 +87,25 @@
         if (newMode == mCurrentMode) {
             return false;
         }
-        mCurrentMode = newMode;
-        if (mCurrentMode == mPreference.findIndexOfValue(
+        if (newMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_never))) {
             boolean active = (mContext.getResources().getConfiguration().uiMode
                     & Configuration.UI_MODE_NIGHT_YES) != 0;
             int mode = active ? UiModeManager.MODE_NIGHT_YES
                     : UiModeManager.MODE_NIGHT_NO;
             mUiModeManager.setNightMode(mode);
-        } else if (mCurrentMode == mPreference.findIndexOfValue(
+        } else if (newMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_auto))) {
             if (!mLocationManager.isLocationEnabled()) {
                 TwilightLocationDialog.show(mContext);
-                return false;
+                return true;
             }
             mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_AUTO);
-        } else if (mCurrentMode == mPreference.findIndexOfValue(
+        } else if (newMode == mPreference.findIndexOfValue(
                 mContext.getString(R.string.dark_ui_auto_mode_custom))) {
             mUiModeManager.setNightMode(UiModeManager.MODE_NIGHT_CUSTOM);
         }
+        mCurrentMode = newMode;
         return true;
     }
 }
diff --git a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
index 33faee0..4d420d1 100644
--- a/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
+++ b/tests/robotests/src/com/android/settings/applications/manageapplications/ManageApplicationsTest.java
@@ -56,6 +56,7 @@
 import androidx.recyclerview.widget.RecyclerView;
 
 import com.android.settings.R;
+import com.android.settings.testutils.shadow.ShadowAppUtils;
 import com.android.settings.testutils.shadow.ShadowUserManager;
 import com.android.settings.widget.LoadingViewController;
 import com.android.settingslib.applications.ApplicationsState;
@@ -76,7 +77,7 @@
 import java.util.ArrayList;
 
 @RunWith(RobolectricTestRunner.class)
-@Config(shadows = ShadowUserManager.class)
+@Config(shadows = {ShadowUserManager.class, ShadowAppUtils.class})
 public class ManageApplicationsTest {
 
     @Mock
diff --git a/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppUtils.java b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppUtils.java
new file mode 100644
index 0000000..871a536
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/testutils/shadow/ShadowAppUtils.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2020 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.testutils.shadow;
+
+import android.content.Context;
+
+import com.android.settingslib.applications.AppUtils;
+
+import org.robolectric.annotation.Implementation;
+import org.robolectric.annotation.Implements;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Implements(AppUtils.class)
+public class ShadowAppUtils {
+
+    private static Map<String, String> sAppContentDesMap;
+
+    @Implementation
+    protected static CharSequence getAppContentDescription(Context context, String packageName,
+            int userId) {
+        if (sAppContentDesMap != null) {
+            return sAppContentDesMap.get(packageName);
+        }
+        return null;
+    }
+
+    public static void setAppContentDescription(String packageName, String appContentDes) {
+        if (sAppContentDesMap == null) {
+            sAppContentDesMap = new HashMap<>();
+        }
+        sAppContentDesMap.put(packageName, appContentDes);
+    }
+}