Merge "Follow alphabetical sorting to make list the same with AOSP"
diff --git a/res/layout/preference_contrast_level_slider.xml b/res/layout/preference_contrast_level_slider.xml
new file mode 100644
index 0000000..1766dd7
--- /dev/null
+++ b/res/layout/preference_contrast_level_slider.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2022 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.
+-->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:gravity="center_vertical"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:clickable="false"
+ android:orientation="horizontal">
+
+ <include layout="@layout/settingslib_icon_frame"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingTop="16dp">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:singleLine="true"
+ android:textAppearance="?android:attr/textAppearanceListItem"
+ android:textColor="?android:attr/textColorPrimary"
+ android:ellipsize="marquee"
+ android:hyphenationFrequency="normalFast"
+ android:lineBreakWordStyle="phrase"
+ android:fadingEdge="horizontal"/>
+ <LinearLayout
+ android:id="@android:id/widget_frame"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:gravity="center_vertical"
+ android:orientation="vertical"/>
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layoutDirection="ltr"
+ android:orientation="vertical">
+
+ <com.android.settings.accessibility.ContrastLevelSeekBar
+ android:id="@*android:id/seekbar"
+ android:minHeight="?android:attr/listPreferredItemHeightSmall"
+ android:paddingStart="0dp"
+ android:paddingEnd="0dp"
+ android:layout_gravity="center_vertical"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:orientation="horizontal">
+ <TextView
+ android:id="@+id/left_text"
+ android:text="@string/accessibility_contrast_level_left_label"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:textAlignment="viewStart" />
+ <TextView
+ android:id="@+id/right_text"
+ android:text="@string/accessibility_contrast_level_right_label"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorSecondary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:maxLines="1"
+ android:textAlignment="viewEnd" />
+
+ </LinearLayout>
+ </LinearLayout>
+ </LinearLayout>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/res/raw-sw600dp/extra_dim_banner.json b/res/raw-sw600dp/extra_dim_banner.json
new file mode 100644
index 0000000..0d150ae
--- /dev/null
+++ b/res/raw-sw600dp/extra_dim_banner.json
@@ -0,0 +1 @@
+{"v":"5.10.0","fr":60,"ip":0,"op":300,"w":412,"h":300,"nm":"Extra_Dim_Tablet_DT","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":".grey600","cl":"grey600","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[206,149.71,0],"ix":2,"l":2},"a":{"a":0,"k":[206,149.71,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-1.417],[0,0],[0,0],[1.411,0]],"o":[[-1.411,0],[0,0],[0,0],[0,-1.417],[0,0]],"v":[[-4.603,-1.797],[-7.16,0.77],[1.023,1.797],[7.16,0.77],[4.603,-1.797]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960784314,0.525490196078,0.545098039216,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[322.062,46.777],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"button2","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-1.417],[0,0],[0,0],[1.411,0]],"o":[[-1.411,0],[0,0],[0,0],[0,-1.417],[0,0]],"v":[[-11.251,-1.797],[-13.808,0.77],[0.511,1.797],[13.808,0.77],[11.251,-1.797]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960784314,0.525490196078,0.545098039216,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[279.283,46.777],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"button1","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[208.56,330],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":16,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"op","nm":"Offset Paths 1","a":{"a":0,"k":-1.5,"ix":1},"lj":1,"ml":{"a":0,"k":4,"ix":3},"ix":2,"mn":"ADBE Vector Filter - Offset","hd":false},{"ty":"st","c":{"a":0,"k":[0.501960784314,0.525490196078,0.545098039216,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":3,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":-90,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Frame","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[206,151.661],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[-100,-100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"frame","np":1,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":".black","cl":"black","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":52,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":72,"s":[60]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":252,"s":[60]},{"t":272,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[205.5,152,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-0.5,9.5],[0,0],[21.342,-2.5],[0,0],[0,-4.354],[0,0],[-14.842,0]],"o":[[13.324,0],[0,0],[0,-4.354],[0,0],[-17.842,-1.5],[0,0],[0,4.354],[0,0]],"v":[[140.908,103.168],[163.75,88.168],[163.75,-88.832],[140.908,-102.832],[-139.408,-102.832],[-163.75,-90.832],[-163.75,91.168],[-141.25,103.168]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"dim","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":".grey600","cl":"grey600","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[128.75,177.168,0],"ix":2,"l":2},"a":{"a":0,"k":[128.75,177.168,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,37],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960813999,0.525490224361,0.54509806633,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12321","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[128.75,192.668],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"left rect - 1","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,26],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.501960813999,0.525490224361,0.54509806633,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12320","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[128.75,156.168],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"left rect - 2","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":".grey400","cl":"grey400","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[285.75,102.168,0],"ix":2,"l":2},"a":{"a":0,"k":[285.75,102.168,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,37],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.741176486015,0.75686275959,0.776470601559,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12323","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[285.75,117.668],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"right rect - 1","np":1,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[144,26],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":10,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"fl","c":{"a":0,"k":[0.741176486015,0.75686275959,0.776470601559,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 12322","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tr","p":{"a":0,"k":[285.75,81.168],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"right rect - 2","np":1,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":".blue600","cl":"blue600","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[340.75,223.168,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-6.627,0],[0,6.627],[6.627,0],[0,-6.627]],"o":[[6.627,0],[0,-6.627],[-6.627,0],[0,6.627]],"v":[[0,12],[12,0],[0,-12],[-12,0]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.101960785687,0.450980395079,0.909803926945,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"ct":1,"bm":0}],"markers":[]}
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 33f35a8..86e8840 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -220,6 +220,10 @@
<dimen name="accessibility_qs_tooltip_margin">20dp</dimen>
<dimen name="accessibility_qs_tooltip_margin_top">27dp</dimen>
+ <!-- Contrast level slider -->
+ <dimen name="contrast_level_seekbar_center_marker_height">14dp</dimen>
+ <dimen name="contrast_level_seekbar_center_marker_width">1dp</dimen>
+
<!-- Restricted icon in switch bar -->
<dimen name="restricted_icon_margin_end">16dp</dimen>
<!-- Restricted icon size in switch bar -->
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 77304b5..e973d9a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -4242,6 +4242,12 @@
<string name="accessibility_disable_animations">Remove animations</string>
<!-- Summary for the accessibility preference for disabling animations. [CHAR LIMIT=60] -->
<string name="accessibility_disable_animations_summary">Reduce movement on the screen</string>
+ <!-- Title for the accessibility preference for the contrast level slider. [CHAR LIMIT=35] -->
+ <string name="accessibility_contrast_level_title">Contrast Level</string>
+ <!-- 'Low' text at the left of the contrast level slider. [CHAR LIMIT=20] -->
+ <string name="accessibility_contrast_level_left_label">Standard</string>
+ <!-- 'High' text at the right of the contrast level slider. [CHAR LIMIT=20] -->
+ <string name="accessibility_contrast_level_right_label">High</string>
<!-- Title for the accessibility preference for primary mono. [CHAR LIMIT=35] -->
<string name="accessibility_toggle_primary_mono_title">Mono audio</string>
<!-- Summary for the accessibility preference for primary mono. [CHAR LIMIT=60] -->
@@ -7369,6 +7375,12 @@
<!-- Configure Notifications: Title for the option controlling notifications for work profile. [CHAR LIMIT=30] -->
<string name="locked_work_profile_notification_title">When work profile is locked</string>
+ <!-- Configure notifications: Title for the option controlling whether only new notifications are displayed to the user
+ on the lock screen [CHAR LIMIT=60] -->
+ <string name="unseen_notifs_lock_screen">Show only new notifications on lock screen</string>
+
+ <!-- Configure notifications: Summary for option of showing only new notifications on the lock screen. [CHAR LIMIT=100] -->
+ <string name="unseen_notifs_lock_screen_summary">After each unlock, remove existing notifications from the lock screen</string>
<!-- Configure notifications: Title for determining which notifications appear on the lock screen [CHAR LIMIT=60] -->
<string name="lock_screen_notifs_title">Notifications on lock screen</string>
diff --git a/res/xml/accessibility_color_and_motion.xml b/res/xml/accessibility_color_and_motion.xml
index a313526..72c67f9 100644
--- a/res/xml/accessibility_color_and_motion.xml
+++ b/res/xml/accessibility_color_and_motion.xml
@@ -64,6 +64,11 @@
android:title="@string/accessibility_toggle_large_pointer_icon_title"
settings:controller="com.android.settings.accessibility.LargePointerIconPreferenceController"/>
+ <com.android.settings.accessibility.ContrastLevelSeekBarPreference
+ android:key="seekbar_color_contrast"
+ android:persistent="false"
+ android:title="@string/accessibility_contrast_level_title"/>
+
<PreferenceCategory
android:key="experimental_category"
android:persistent="false"
diff --git a/res/xml/configure_notification_settings.xml b/res/xml/configure_notification_settings.xml
index 96a3f85..27d5760 100644
--- a/res/xml/configure_notification_settings.xml
+++ b/res/xml/configure_notification_settings.xml
@@ -119,9 +119,16 @@
android:fragment="com.android.settings.notification.zen.ZenModeSettings"
settings:controller="com.android.settings.notification.zen.ZenModePreferenceController"
/>
+ <SwitchPreference
+ android:key="lock_screen_show_only_unseen_notifs"
+ android:order="18"
+ android:title="@string/unseen_notifs_lock_screen"
+ android:summary="@string/unseen_notifs_lock_screen_summary"
+ settings:controller="com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController"
+ />
<com.android.settingslib.RestrictedPreference
android:key="app_and_notif_cell_broadcast_settings"
- android:order="18"
+ android:order="19"
android:title="@string/cell_broadcast_settings"
settings:useAdminDisabledSummary="true">
<intent
@@ -132,33 +139,33 @@
<SwitchPreference
android:key="silent_icons"
- android:order="19"
+ android:order="20"
android:title="@string/silent_notifications_status_bar"
settings:controller="com.android.settings.notification.SilentStatusBarPreferenceController"/>
<SwitchPreference
android:key="show_snooze_options"
- android:order="20"
+ android:order="21"
android:title="@string/snooze_options_title"
settings:controller="com.android.settings.notification.SnoozeNotificationPreferenceController" />
<!-- Notification badging -->
<SwitchPreference
android:key="notification_badging"
- android:order="21"
+ android:order="22"
android:title="@string/notification_badging_title"
settings:controller="com.android.settings.notification.BadgingNotificationPreferenceController"/>
<!-- Pulse notification light, on devices that support it -->
<SwitchPreference
android:key="notification_pulse"
- android:order="22"
+ android:order="23"
android:title="@string/notification_pulse_title"
settings:controller="com.android.settings.notification.PulseNotificationPreferenceController"/>
<com.android.settingslib.PrimarySwitchPreference
android:key="notification_assistant"
- android:order="23"
+ android:order="24"
android:title="@string/notification_assistant_title"
android:summary="@string/notification_assistant_summary"
settings:controller="com.android.settings.notification.NotificationAssistantPreferenceController"/>
diff --git a/src/com/android/settings/accessibility/ContrastLevelSeekBar.java b/src/com/android/settings/accessibility/ContrastLevelSeekBar.java
new file mode 100644
index 0000000..8723285
--- /dev/null
+++ b/src/com/android/settings/accessibility/ContrastLevelSeekBar.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2022 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 static android.view.HapticFeedbackConstants.CLOCK_TICK;
+
+import static com.android.settings.Utils.isNightMode;
+import static com.android.settings.accessibility.ContrastLevelSeekBarPreference.CONTRAST_SLIDER_TICKS;
+
+import android.content.Context;
+import android.content.res.ColorStateList;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.util.AttributeSet;
+import android.widget.SeekBar;
+
+import com.android.settings.R;
+
+/**
+ * A custom seekbar for the contrast level setting.
+ *
+ * Adds a center line indicator between left and right, which snaps to if close.
+ * Updates the Settings.Secure.CONTRAST_LEVEL setting on progress changed.
+ *
+ * TODO(b/266071578): remove this class and replace this with the final UI
+ */
+public class ContrastLevelSeekBar extends SeekBar {
+
+ private final Context mContext;
+ private int mLastProgress = -1;
+
+ private final Paint mMarkerPaint;
+ private final Rect mMarkerRect;
+
+ private final OnSeekBarChangeListener mProxySeekBarListener = new OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) { }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) { }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ if (!fromUser || progress == mLastProgress) return;
+ seekBar.performHapticFeedback(CLOCK_TICK);
+ mLastProgress = progress;
+
+ // rescale progress from [0, 1, 2] to [0, 0.5, 1]
+ final float contrastLevel = (float) progress / CONTRAST_SLIDER_TICKS;
+
+ Settings.Secure.putFloatForUser(mContext.getContentResolver(),
+ Settings.Secure.CONTRAST_LEVEL, contrastLevel, UserHandle.USER_CURRENT);
+ }
+ };
+
+ public ContrastLevelSeekBar(Context context, AttributeSet attrs) {
+ this(context, attrs, com.android.internal.R.attr.seekBarStyle);
+ }
+
+ public ContrastLevelSeekBar(Context context, AttributeSet attrs, int defStyleAttr) {
+ this(context, attrs, defStyleAttr, 0 /* defStyleRes */);
+ }
+
+ public ContrastLevelSeekBar(
+ Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ super(context, attrs, defStyleAttr, defStyleRes);
+ mContext = context;
+ Resources res = getResources();
+ mMarkerRect = new Rect(0 /* left */, 0 /* top */,
+ res.getDimensionPixelSize(R.dimen.contrast_level_seekbar_center_marker_width),
+ res.getDimensionPixelSize(R.dimen.contrast_level_seekbar_center_marker_height));
+ mMarkerPaint = new Paint();
+
+ // the might be a better colour for the markers, but this slider is temporary anyway
+ mMarkerPaint.setColor(isNightMode(context) ? Color.WHITE : Color.BLACK);
+ mMarkerPaint.setStyle(Paint.Style.FILL);
+ // Remove the progress colour
+ setProgressTintList(ColorStateList.valueOf(Color.TRANSPARENT));
+ super.setOnSeekBarChangeListener(mProxySeekBarListener);
+ }
+
+ @Override
+ public void setOnSeekBarChangeListener(OnSeekBarChangeListener listener) { }
+
+ // Note: the superclass AbsSeekBar.onDraw is synchronized.
+ @Override
+ protected synchronized void onDraw(Canvas canvas) {
+
+ // Draw a marker at the center of the seekbar
+ int seekBarCenter = (getHeight() - getPaddingBottom()) / 2;
+ float sliderWidth = getWidth() - mMarkerRect.right - getPaddingEnd();
+ canvas.save();
+ canvas.translate(sliderWidth / 2f,
+ seekBarCenter - (mMarkerRect.bottom / 2f));
+ canvas.drawRect(mMarkerRect, mMarkerPaint);
+ canvas.restore();
+ super.onDraw(canvas);
+ }
+}
diff --git a/src/com/android/settings/accessibility/ContrastLevelSeekBarPreference.java b/src/com/android/settings/accessibility/ContrastLevelSeekBarPreference.java
new file mode 100644
index 0000000..15795d8
--- /dev/null
+++ b/src/com/android/settings/accessibility/ContrastLevelSeekBarPreference.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2022 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.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.util.AttributeSet;
+
+import androidx.core.content.res.TypedArrayUtils;
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.R;
+import com.android.settings.widget.SeekBarPreference;
+
+/** A slider preference that directly controls the contrast level **/
+public class ContrastLevelSeekBarPreference extends SeekBarPreference {
+
+ /**
+ * The number of ticks of the slider (the more ticks, the more continuous the slider feels).
+ */
+ public static final int CONTRAST_SLIDER_TICKS = 2;
+
+ private final Context mContext;
+ private ContrastLevelSeekBar mSeekBar;
+
+ public ContrastLevelSeekBarPreference(Context context, AttributeSet attrs) {
+ super(context, attrs, TypedArrayUtils.getAttr(context,
+ R.attr.preferenceStyle,
+ android.R.attr.preferenceStyle));
+ mContext = context;
+ setLayoutResource(R.layout.preference_contrast_level_slider);
+ }
+
+ @Override
+ public void onBindViewHolder(PreferenceViewHolder view) {
+ super.onBindViewHolder(view);
+ mSeekBar = (ContrastLevelSeekBar) view.findViewById(
+ com.android.internal.R.id.seekbar);
+ init();
+ }
+
+ private void init() {
+ if (mSeekBar == null) {
+ return;
+ }
+ final float contrastLevel = Settings.Secure.getFloatForUser(
+ mContext.getContentResolver(), Settings.Secure.CONTRAST_LEVEL,
+ 0.f /* default */, UserHandle.USER_CURRENT);
+
+ mSeekBar.setMax(CONTRAST_SLIDER_TICKS);
+
+ // Rescale contrast from [0, 0.5, 1] to [0, 1, 2]
+ int progress = Math.max(0, Math.round(contrastLevel * CONTRAST_SLIDER_TICKS));
+
+ mSeekBar.setProgress(progress);
+ mSeekBar.setEnabled(isEnabled());
+ }
+}
diff --git a/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.java b/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.java
new file mode 100644
index 0000000..a37e29d
--- /dev/null
+++ b/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2023 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.notification;
+
+import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS;
+
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+
+import com.android.settings.R;
+import com.android.settings.core.TogglePreferenceController;
+
+public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceController
+ extends TogglePreferenceController {
+
+ private static final int UNSET = 0;
+ @VisibleForTesting
+ static final int ON = 1;
+ @VisibleForTesting
+ static final int OFF = 2;
+
+ public ShowOnlyUnseenNotificationsOnLockscreenPreferenceController(
+ Context context,
+ String preferenceKey) {
+ super(context, preferenceKey);
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Settings.Secure.getInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET) == ON;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ return Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, isChecked ? ON : OFF);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ int setting = Settings.Secure.getInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, UNSET);
+ if (setting == UNSET) {
+ return CONDITIONALLY_UNAVAILABLE;
+ } else {
+ return AVAILABLE;
+ }
+ }
+
+ @Override
+ public int getSliceHighlightMenuRes() {
+ return R.string.menu_key_notifications;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ContrastLevelSeekBarPreferenceTest.java b/tests/robotests/src/com/android/settings/accessibility/ContrastLevelSeekBarPreferenceTest.java
new file mode 100644
index 0000000..ff073f5
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/ContrastLevelSeekBarPreferenceTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2022 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 static com.android.settings.accessibility.ContrastLevelSeekBarPreference.CONTRAST_SLIDER_TICKS;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import androidx.preference.PreferenceViewHolder;
+
+import com.android.settings.testutils.shadow.ShadowInteractionJankMonitor;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+import org.robolectric.annotation.Config;
+
+@RunWith(RobolectricTestRunner.class)
+@Config(shadows = {ShadowInteractionJankMonitor.class})
+public class ContrastLevelSeekBarPreferenceTest {
+
+ private Context mContext;
+ private AttributeSet mAttrs;
+ private PreferenceViewHolder mHolder;
+ private ContrastLevelSeekBar mSeekBar;
+ private ContrastLevelSeekBarPreference mSeekBarPreference;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mSeekBarPreference = new ContrastLevelSeekBarPreference(mContext, mAttrs);
+ LayoutInflater inflater = LayoutInflater.from(mContext);
+ final View view =
+ inflater.inflate(mSeekBarPreference.getLayoutResource(),
+ new LinearLayout(mContext), false);
+ mHolder = PreferenceViewHolder.createInstanceForTests(view);
+ mSeekBar = view.findViewById(com.android.internal.R.id.seekbar);
+ }
+
+ @Test
+ public void seekBarPreferenceOnBindViewHolder_shouldInitSeekBarValue() {
+ mSeekBarPreference.onBindViewHolder(mHolder);
+
+ assertThat(mSeekBar.getMax()).isEqualTo(CONTRAST_SLIDER_TICKS);
+ assertThat(mSeekBar.getProgress()).isEqualTo(0);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/accessibility/ContrastLevelSeekBarTest.java b/tests/robotests/src/com/android/settings/accessibility/ContrastLevelSeekBarTest.java
new file mode 100644
index 0000000..fd24436
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/accessibility/ContrastLevelSeekBarTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2022 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 static android.view.HapticFeedbackConstants.CLOCK_TICK;
+import static android.view.HapticFeedbackConstants.CONTEXT_CLICK;
+
+import static com.android.settings.accessibility.ContrastLevelSeekBarPreference.CONTRAST_SLIDER_TICKS;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.robolectric.Shadows.shadowOf;
+
+import android.content.Context;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.widget.SeekBar;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class ContrastLevelSeekBarTest {
+
+ private Context mContext;
+ private ContrastLevelSeekBar mSeekBar;
+ private SeekBar.OnSeekBarChangeListener mProxySeekBarListener;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mSeekBar = new ContrastLevelSeekBar(mContext, null);
+ mProxySeekBarListener = shadowOf(mSeekBar).getOnSeekBarChangeListener();
+ }
+
+ @Test
+ public void onProgressChanged_minimumValue_shouldModifyContrast() {
+ // Assign the test value of SeekBar progress
+ mProxySeekBarListener.onProgressChanged(mSeekBar, 0, true);
+
+ assertThat(Settings.Secure.getFloatForUser(
+ mContext.getContentResolver(), Settings.Secure.CONTRAST_LEVEL,
+ -10f, UserHandle.USER_CURRENT)).isEqualTo(0);
+ }
+
+ @Test
+ public void onProgressChanged_centerValue_shouldModifyContrast() {
+ // Assign the test value of SeekBar progress
+ mProxySeekBarListener.onProgressChanged(mSeekBar, CONTRAST_SLIDER_TICKS / 2, true);
+
+ assertThat(Settings.Secure.getFloatForUser(
+ mContext.getContentResolver(), Settings.Secure.CONTRAST_LEVEL,
+ -10f, UserHandle.USER_CURRENT)).isWithin(1e-8f).of(0.5f);
+ }
+
+ @Test
+ public void onProgressChanged_maximumValue_shouldModifyContrast() {
+ // Assign the test value of SeekBar progress
+ mProxySeekBarListener.onProgressChanged(mSeekBar, CONTRAST_SLIDER_TICKS, true);
+
+ assertThat(Settings.Secure.getFloatForUser(
+ mContext.getContentResolver(), Settings.Secure.CONTRAST_LEVEL,
+ -10f, UserHandle.USER_CURRENT)).isEqualTo(1);
+ }
+
+ @Test
+ public void onProgressChanged_minimumValue_clockTickFeedbackPerformed() {
+ mSeekBar.performHapticFeedback(CONTEXT_CLICK);
+ mProxySeekBarListener.onProgressChanged(mSeekBar, 0, true);
+
+ assertThat(shadowOf(mSeekBar).lastHapticFeedbackPerformed()).isEqualTo(CLOCK_TICK);
+ }
+
+ @Test
+ public void onProgressChanged_centerValue_clockTickFeedbackPerformed() {
+ mSeekBar.performHapticFeedback(CONTEXT_CLICK);
+ mProxySeekBarListener.onProgressChanged(mSeekBar, CONTRAST_SLIDER_TICKS / 2, true);
+
+ assertThat(shadowOf(mSeekBar).lastHapticFeedbackPerformed()).isEqualTo(CLOCK_TICK);
+ }
+
+ @Test
+ public void onProgressChanged_maximumValue_clockTickFeedbackPerformed() {
+ mSeekBar.performHapticFeedback(CONTEXT_CLICK);
+ mProxySeekBarListener.onProgressChanged(mSeekBar, CONTRAST_SLIDER_TICKS, true);
+
+ assertThat(shadowOf(mSeekBar).lastHapticFeedbackPerformed()).isEqualTo(CLOCK_TICK);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java
new file mode 100644
index 0000000..cc26e54
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/notification/ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2023 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.notification;
+
+import static android.provider.Settings.Secure.LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS;
+
+import static com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.OFF;
+import static com.android.settings.notification.ShowOnlyUnseenNotificationsOnLockscreenPreferenceController.ON;
+
+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.when;
+
+import android.app.admin.DevicePolicyManager;
+import android.content.Context;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.RuntimeEnvironment;
+
+@RunWith(RobolectricTestRunner.class)
+public class ShowOnlyUnseenNotificationsOnLockscreenPreferenceControllerTest {
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private Context mContext;
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ private PreferenceScreen mScreen;
+
+ private ShowOnlyUnseenNotificationsOnLockscreenPreferenceController mController;
+ private Preference mPreference;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ doReturn(mock(DevicePolicyManager.class)).when(mContext)
+ .getSystemService(Context.DEVICE_POLICY_SERVICE);
+ mController = new ShowOnlyUnseenNotificationsOnLockscreenPreferenceController(mContext,
+ "key");
+ mPreference = new Preference(RuntimeEnvironment.application);
+ mPreference.setKey(mController.getPreferenceKey());
+ when(mScreen.findPreference(mPreference.getKey())).thenReturn(mPreference);
+ }
+
+ @Test
+ public void display_configUnset_shouldNotDisplay() {
+ mController.displayPreference(mScreen);
+ assertThat(mPreference.isVisible()).isFalse();
+ }
+
+ @Test
+ public void display_configSet_showDisplay() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, OFF);
+ mController.displayPreference(mScreen);
+ assertThat(mPreference.isVisible()).isTrue();
+ }
+
+ @Test
+ public void isChecked_settingIsOff_shouldReturnFalse() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, OFF);
+
+ assertThat(mController.isChecked()).isFalse();
+ }
+
+ @Test
+ public void isChecked_settingIsOn_shouldReturnTrue() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, ON);
+
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void setChecked_setFalse_disablesSetting() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, ON);
+
+ mController.setChecked(false);
+ int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, -1);
+
+ assertThat(updatedValue).isEqualTo(OFF);
+ }
+
+ @Test
+ public void setChecked_setTrue_enablesSetting() {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, OFF);
+
+ mController.setChecked(true);
+ int updatedValue = Settings.Secure.getInt(mContext.getContentResolver(),
+ LOCK_SCREEN_SHOW_ONLY_UNSEEN_NOTIFICATIONS, -1);
+
+ assertThat(updatedValue).isEqualTo(ON);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/dashboard/DashboardFragmentRegistryTest.java b/tests/unit/src/com/android/settings/dashboard/DashboardFragmentRegistryTest.java
index 435fe01..712ea39 100644
--- a/tests/unit/src/com/android/settings/dashboard/DashboardFragmentRegistryTest.java
+++ b/tests/unit/src/com/android/settings/dashboard/DashboardFragmentRegistryTest.java
@@ -21,6 +21,7 @@
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.android.settings.accounts.AccountDashboardFragment;
+import com.android.settings.applications.specialaccess.SpecialAccessSettings;
import com.android.settingslib.drawer.CategoryKey;
import org.junit.Test;
@@ -41,4 +42,13 @@
assertThat(fragment).isEqualTo(AccountDashboardFragment.class.getName());
}
+
+ @Test
+ public void specialAppAccessCategoryShouldRedirectToSpecialAppAccessPage() {
+ final String fragment =
+ DashboardFragmentRegistry.CATEGORY_KEY_TO_PARENT_MAP.get(
+ CategoryKey.CATEGORY_SPECIAL_APP_ACCESS);
+
+ assertThat(fragment).isEqualTo(SpecialAccessSettings.class.getName());
+ }
}