Merge "Change to show two footer buttons in SUW lockscreen page."
diff --git a/Android.mk b/Android.mk
index c99e30c..e385b34 100644
--- a/Android.mk
+++ b/Android.mk
@@ -23,6 +23,7 @@
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_STATIC_ANDROID_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout \
androidx.slice_slice-builders \
androidx.slice_slice-core \
androidx.slice_slice-view \
@@ -40,6 +41,7 @@
ims-common
LOCAL_STATIC_JAVA_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout-solver \
androidx.lifecycle_lifecycle-runtime \
androidx.lifecycle_lifecycle-extensions \
guava \
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 871f609..213e5a4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -139,7 +139,11 @@
android:label="@string/network_settings_title"
android:theme="@style/Theme.Settings.Home"
android:launchMode="singleTask">
- <!-- TODO(b/114749736): add intent filter here and disable the one in telephony -->
+ <intent-filter android:priority="1">
+ <action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
+ <action android:name="android.settings.DATA_ROAMING_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
</activity>
<!-- Alias for launcher activity only, as this belongs to each profile. -->
@@ -1473,7 +1477,7 @@
<activity android:name=".SetupRedactionInterstitial"
android:enabled="false"
android:exported="true"
- android:theme="@style/SuwThemeGlif.DayNight"
+ android:theme="@style/SudThemeGlif.DayNight"
android:label="@string/lock_screen_notifications_interstitial_title"
android:icon="@drawable/ic_suggested_notifications">
<intent-filter>
@@ -2003,9 +2007,8 @@
</intent-filter>
</activity>
- <!-- TODO: Is this needed? -->
<activity android:name="BandMode"
- android:theme="@android:style/Theme.DeviceDefault.Light.Dialog.Alert"
+ android:label="@string/band_mode_title"
android:process="com.android.phone">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
@@ -3050,7 +3053,7 @@
<intent-filter>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER"/>
<action android:name="android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR"/>
- <action android:name="android.settings.WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK"/>
+ <action android:name="android.settings.PROCESS_WIFI_DPP_QR_CODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 787c559..7b0b28e 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -245,6 +245,22 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="homepage_status_bar_color">#cc000000</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values-night/colors.xml"
+ line="25"
+ column="3"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" <color name="crypt_keeper_clock_foreground">#ff666666</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -1301,6 +1317,70 @@
priority="4"
summary="Using hardcoded color"
explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="homepage_status_bar_color">#ccFFFFFF</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="133"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="qr_corner_line_color">#ffdadce0</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="136"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="qr_focused_corner_line_color">#ff1a73e8</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="137"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
+ errorLine1=" <color name="qr_background_color">#b3ffffff</color> <!-- 70% white transparency -->"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="138"
+ column="5"/>
+ </issue>
+
+ <issue
+ id="HardCodedColor"
+ severity="Error"
+ message="Avoid using hardcoded color"
+ category="Correctness"
+ priority="4"
+ summary="Using hardcoded color"
+ explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
errorLine1=" android:background="@color/lock_pattern_background" />"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
@@ -2441,7 +2521,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="5805"
+ line="5885"
column="36"/>
</issue>
@@ -2473,7 +2553,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="425"
+ line="388"
column="44"/>
</issue>
@@ -2489,7 +2569,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="431"
+ line="394"
column="44"/>
</issue>
@@ -2505,7 +2585,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="432"
+ line="395"
column="44"/>
</issue>
@@ -2521,23 +2601,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="467"
- column="34"/>
- </issue>
-
- <issue
- id="HardCodedColor"
- severity="Error"
- message="Avoid using hardcoded color"
- category="Correctness"
- priority="4"
- summary="Using hardcoded color"
- explanation="Hardcoded color values are bad because theme changes cannot be uniformly applied.Instead use the theme specific colors such as `?android:attr/textColorPrimary` in attributes.
This ensures that a theme change from a light to a dark theme can be uniformlyapplied across the app."
- errorLine1=" <item name="strokeColor">@color/homepage_card_stroke_color</item>"
- errorLine2=" ^">
- <location
- file="res/values/styles.xml"
- line="474"
+ line="430"
column="34"/>
</issue>
@@ -2553,7 +2617,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="54"
+ line="57"
column="39"/>
</issue>
@@ -2569,7 +2633,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="55"
+ line="58"
column="40"/>
</issue>
@@ -2585,7 +2649,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="56"
+ line="59"
column="38"/>
</issue>
@@ -2601,7 +2665,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="90"
+ line="97"
column="47"/>
</issue>
@@ -2617,7 +2681,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="90"
+ line="97"
column="47"/>
</issue>
@@ -2633,7 +2697,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="96"
+ line="103"
column="40"/>
</issue>
@@ -2649,7 +2713,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="96"
+ line="103"
column="40"/>
</issue>
@@ -2665,7 +2729,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="159"
+ line="166"
column="45"/>
</issue>
@@ -2681,7 +2745,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="160"
+ line="167"
column="49"/>
</issue>
@@ -2697,7 +2761,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="168"
+ line="175"
column="45"/>
</issue>
@@ -2713,7 +2777,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="169"
+ line="176"
column="49"/>
</issue>
@@ -2729,7 +2793,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="185"
+ line="192"
column="39"/>
</issue>
@@ -2745,7 +2809,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="186"
+ line="193"
column="40"/>
</issue>
@@ -2761,7 +2825,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="187"
+ line="194"
column="38"/>
</issue>
diff --git a/res/drawable/ic_battery_saver_accent_24dp.xml b/res/drawable/ic_battery_saver_accent_24dp.xml
new file mode 100644
index 0000000..c8def54
--- /dev/null
+++ b/res/drawable/ic_battery_saver_accent_24dp.xml
@@ -0,0 +1,29 @@
+<!--
+ 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0"
+ android:tint="?android:attr/colorAccent">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M15,14l-2,0l0,2l-2,0l0,-2l-2,0l0,-2l2,0l0,-2l2,0l0,2l2,0z"/>
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M16.2,22.5H7.8c-1.3,0 -2.3,-1 -2.3,-2.3V5.8c0,-1.3 1,-2.3 2.3,-2.3h0.7v-2h7v2h0.7c1.3,0 2.3,1.1 2.3,2.3v14.3C18.5,21.5 17.5,22.5 16.2,22.5zM7.8,5.5c-0.2,0 -0.3,0.2 -0.3,0.3v14.3c0,0.2 0.2,0.3 0.3,0.3h8.3c0.2,0 0.3,-0.1 0.3,-0.3V5.8c0,-0.2 -0.1,-0.3 -0.3,-0.3h-2.7v-2h-3v2H7.8z"/>
+</vector>
diff --git a/res/drawable/ic_fingerprint_list_icon.xml b/res/drawable/ic_fingerprint_list_icon.xml
index ce1ce5e..6a563aa 100644
--- a/res/drawable/ic_fingerprint_list_icon.xml
+++ b/res/drawable/ic_fingerprint_list_icon.xml
@@ -19,6 +19,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M17.81,4.47c-0.08,0 -0.16,-0.02 -0.23,-0.06C15.66,3.42 14,3 12.01,3c-1.98,0 -3.86,0.47 -5.57,1.41 -0.24,0.13 -0.54,0.04 -0.68,-0.2 -0.13,-0.24 -0.04,-0.55 0.2,-0.68C7.82,2.52 9.86,2 12.01,2c2.13,0 3.99,0.47 6.03,1.52 0.25,0.13 0.34,0.43 0.21,0.67 -0.09,0.18 -0.26,0.28 -0.44,0.28zM3.5,9.72c-0.1,0 -0.2,-0.03 -0.29,-0.09 -0.23,-0.16 -0.28,-0.47 -0.12,-0.7 0.99,-1.4 2.25,-2.5 3.75,-3.27C9.98,4.04 14,4.03 17.15,5.65c1.5,0.77 2.76,1.86 3.75,3.25 0.16,0.22 0.11,0.54 -0.12,0.7 -0.23,0.16 -0.54,0.11 -0.7,-0.12 -0.9,-1.26 -2.04,-2.25 -3.39,-2.94 -2.87,-1.47 -6.54,-1.47 -9.4,0.01 -1.36,0.7 -2.5,1.7 -3.4,2.96 -0.08,0.14 -0.23,0.21 -0.39,0.21zM9.75,21.79c-0.13,0 -0.26,-0.05 -0.35,-0.15 -0.87,-0.87 -1.34,-1.43 -2.01,-2.64 -0.69,-1.23 -1.05,-2.73 -1.05,-4.34 0,-2.97 2.54,-5.39 5.66,-5.39s5.66,2.42 5.66,5.39c0,0.28 -0.22,0.5 -0.5,0.5s-0.5,-0.22 -0.5,-0.5c0,-2.42 -2.09,-4.39 -4.66,-4.39 -2.57,0 -4.66,1.97 -4.66,4.39 0,1.44 0.32,2.77 0.93,3.85 0.64,1.15 1.08,1.64 1.85,2.42 0.19,0.2 0.19,0.51 0,0.71 -0.11,0.1 -0.24,0.15 -0.37,0.15zM16.92,19.94c-1.19,0 -2.24,-0.3 -3.1,-0.89 -1.49,-1.01 -2.38,-2.65 -2.38,-4.39 0,-0.28 0.22,-0.5 0.5,-0.5s0.5,0.22 0.5,0.5c0,1.41 0.72,2.74 1.94,3.56 0.71,0.48 1.54,0.71 2.54,0.71 0.24,0 0.64,-0.03 1.04,-0.1 0.27,-0.05 0.53,0.13 0.58,0.41 0.05,0.27 -0.13,0.53 -0.41,0.58 -0.57,0.11 -1.07,0.12 -1.21,0.12zM14.91,22c-0.04,0 -0.09,-0.01 -0.13,-0.02 -1.59,-0.44 -2.63,-1.03 -3.72,-2.1 -1.4,-1.39 -2.17,-3.24 -2.17,-5.22 0,-1.62 1.38,-2.94 3.08,-2.94 1.7,0 3.08,1.32 3.08,2.94 0,1.07 0.93,1.94 2.08,1.94s2.08,-0.87 2.08,-1.94c0,-3.77 -3.25,-6.83 -7.25,-6.83 -2.84,0 -5.44,1.58 -6.61,4.03 -0.39,0.81 -0.59,1.76 -0.59,2.8 0,0.78 0.07,2.01 0.67,3.61 0.1,0.26 -0.03,0.55 -0.29,0.64 -0.26,0.1 -0.55,-0.04 -0.64,-0.29 -0.49,-1.31 -0.73,-2.61 -0.73,-3.96 0,-1.2 0.23,-2.29 0.68,-3.24 1.33,-2.79 4.28,-4.6 7.51,-4.6 4.55,0 8.25,3.51 8.25,7.83 0,1.62 -1.38,2.94 -3.08,2.94s-3.08,-1.32 -3.08,-2.94c0,-1.07 -0.93,-1.94 -2.08,-1.94s-2.08,0.87 -2.08,1.94c0,1.71 0.66,3.31 1.87,4.51 0.95,0.94 1.86,1.46 3.27,1.85 0.27,0.07 0.42,0.35 0.35,0.61 -0.05,0.23 -0.26,0.38 -0.47,0.38z"/>
</vector>
diff --git a/res/drawable/ic_lock_list_icon.xml b/res/drawable/ic_lock_list_icon.xml
index 7a323f2..9660f9c 100644
--- a/res/drawable/ic_lock_list_icon.xml
+++ b/res/drawable/ic_lock_list_icon.xml
@@ -18,7 +18,7 @@
android:height="24.0dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
- android:tint="?attr/suwListItemIconColor">
+ android:tint="?attr/sudListItemIconColor">
<path
android:fillColor="@android:color/white"
android:pathData="M18.0,8.0l-1.0,0.0L17.0,6.0c0.0,-2.76 -2.24,-5.0 -5.0,-5.0S7.0,3.24 7.0,6.0l0.0,2.0L6.0,8.0c-1.1,0.0 -2.0,0.9 -2.0,2.0l0.0,10.0c0.0,1.0 0.9,2.0 2.0,2.0l12.0,0.0c1.1,0.0 2.0,-0.9 2.0,-2.0L20.0,10.0c0.0,-1.1 -0.9,-2.0 -2.0,-2.0zm-6.0,9.0c-1.1,0.0 -2.0,-0.9 -2.0,-2.0s0.9,-2.0 2.0,-2.0 2.0,0.9 2.0,2.0 -0.9,2.0 -2.0,2.0zm3.1,-9.0L8.9,8.0L8.9,6.0c0.0,-1.71 1.39,-3.1 3.1,-3.1 1.71,0.0 3.1,1.39 3.1,3.1l0.0,2.0z"/>
diff --git a/res/drawable/ic_password.xml b/res/drawable/ic_password.xml
index 57591c2..7d5f471 100644
--- a/res/drawable/ic_password.xml
+++ b/res/drawable/ic_password.xml
@@ -20,15 +20,15 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M21.5,9.39l-1.63,0l0.81,-1.42l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0z" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M13.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M6.68,7.97l-0.86,-0.5l-0.82,1.42l-0.82,-1.42l-0.86,0.5l0.81,1.42l-1.63,0l0,1l1.63,0l-0.81,1.41l0.86,0.5l0.82,-1.41l0.82,1.41l0.86,-0.5l-0.81,-1.41l1.63,0l0,-1l-1.63,0z" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M21,17.89H3c-0.28,0 -0.5,-0.22 -0.5,-0.5v-1c0,-0.28 0.22,-0.5 0.5,-0.5h18c0.28,0 0.5,0.22 0.5,0.5v1C21.5,17.66 21.28,17.89 21,17.89z" />
</vector>
diff --git a/res/drawable/ic_pattern.xml b/res/drawable/ic_pattern.xml
index 003111e..b41129f 100644
--- a/res/drawable/ic_pattern.xml
+++ b/res/drawable/ic_pattern.xml
@@ -20,18 +20,18 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M4,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M4,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M12,4m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M20,12m-2,0a2,2 0,1 1,4 0a2,2 0,1 1,-4 0" />
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M20,18c-0.93,0 -1.7,0.64 -1.93,1.5h-4.14c-0.22,-0.86 -1,-1.5 -1.93,-1.5s-1.7,0.64 -1.93,1.5H5.93c-0.05,-0.18 -0.12,-0.35 -0.21,-0.51l5.28,-5.28C11.29,13.89 11.63,14 12,14c1.1,0 2,-0.9 2,-2c0,-0.37 -0.11,-0.71 -0.28,-1.01l5.28,-5.28C19.29,5.89 19.63,6 20,6c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2s-2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C12.71,10.11 12.37,10 12,10c-1.1,0 -2,0.9 -2,2c0,0.37 0.11,0.71 0.28,1.01l-5.28,5.28C4.71,18.11 4.37,18 4,18c-1.1,0 -2,0.9 -2,2s0.9,2 2,2c0.93,0 1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5s1.7,-0.64 1.93,-1.5h4.14c0.22,0.86 1,1.5 1.93,1.5c1.1,0 2,-0.9 2,-2S21.1,18 20,18z" />
</vector>
diff --git a/res/drawable/ic_pin.xml b/res/drawable/ic_pin.xml
index 0176019..577e04f 100644
--- a/res/drawable/ic_pin.xml
+++ b/res/drawable/ic_pin.xml
@@ -20,6 +20,6 @@
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M20,4L4,4A2,2 0,0 0,2 6L2,18a2,2 0,0 0,2 2L20,20a2,2 0,0 0,2 -2L22,6A2,2 0,0 0,20 4ZM7.1,15L5.9,15L5.9,10.2L4.7,10.2L4.7,9L7.1,9v6ZM13.2,11.4A1.2,1.2 0,0 1,12 12.6L10.8,12.6v1.2h2.4L13.2,15L9.6,15L9.6,12.6a1.2,1.2 0,0 1,1.2 -1.2L12,11.4L12,10.2L9.6,10.2L9.6,9L12,9a1.2,1.2 0,0 1,1.2 1.2v1.2ZM19.3,11.1a0.9,0.9 0,0 1,-0.9 0.9,0.9 0.9,0 0,1 0.9,0.9v0.9A1.2,1.2 0,0 1,18.1 15L15.7,15L15.7,13.8h2.4L18.1,12.6L16.9,12.6L16.9,11.4h1.2L18.1,10.2L15.7,10.2L15.7,9h2.4a1.2,1.2 0,0 1,1.2 1.2v0.9Z" />
</vector>
diff --git a/res/drawable/ic_skip.xml b/res/drawable/ic_skip.xml
index 4376215..9d8ae2b 100644
--- a/res/drawable/ic_skip.xml
+++ b/res/drawable/ic_skip.xml
@@ -21,6 +21,6 @@
android:viewportHeight="24"
android:autoMirrored="true">
<path
- android:fillColor="?attr/suwListItemIconColor"
+ android:fillColor="?attr/sudListItemIconColor"
android:pathData="M18.4,10.6C16.55,8.99 14.15,8 11.5,8c-4.65,0 -8.58,3.03 -9.96,7.22L3.9,16c1.05,-3.19 4.05,-5.5 7.6,-5.5 1.95,0 3.73,0.72 5.12,1.88L13,16h9V7l-3.6,3.6z"/>
</vector>
diff --git a/res/drawable/ic_suggested_notifications.xml b/res/drawable/ic_suggested_notifications.xml
index d15d13a..5bce000 100644
--- a/res/drawable/ic_suggested_notifications.xml
+++ b/res/drawable/ic_suggested_notifications.xml
@@ -19,9 +19,9 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
- android:fillColor="@color/suw_color_accent_light"
+ android:fillColor="@color/sud_color_accent_light"
android:pathData="M18,17v-6c0,-3.07 -1.63,-5.64 -4.5,-6.32V4c0,-0.83 -0.67,-1.5 -1.5,-1.5S10.5,3.17 10.5,4v0.68C7.64,5.36 6,7.92 6,11v6H4v2h10h0.38H20v-2H18zM16,17H8v-6c0,-2.48 1.51,-4.5 4,-4.5s4,2.02 4,4.5V17z"/>
<path
- android:fillColor="@color/suw_color_accent_light"
+ android:fillColor="@color/sud_color_accent_light"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4C10,21.1 10.9,22 12,22z"/>
</vector>
diff --git a/res/layout-land/choose_lock_pattern.xml b/res/layout-land/choose_lock_pattern.xml
index d2d436f..1cc4352 100644
--- a/res/layout-land/choose_lock_pattern.xml
+++ b/res/layout-land/choose_lock_pattern.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent"
android:icon="@drawable/ic_lock"
android:layout="@layout/sud_glif_blank_template"
- settings:suwHeaderText="@string/lock_settings_picker_title">
+ settings:sucHeaderText="@string/lock_settings_picker_title">
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
android:id="@+id/topLayout"
@@ -37,18 +37,18 @@
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1.0"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginBottom="@dimen/suw_content_frame_padding_bottom"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:src="@drawable/ic_lock"/>
@@ -65,8 +65,8 @@
android:orientation="vertical">
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
@@ -74,7 +74,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="2" />
@@ -85,16 +85,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
- android:gravity="?attr/suwGlifHeaderGravity"
+ android:gravity="?attr/sudGlifHeaderGravity"
android:textSize="18sp"/>
<Button
android:id="@+id/screen_lock_options"
- style="@style/SuwGlifButton.Tertiary"
+ style="@style/SudGlifButton.Tertiary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
- android:gravity="?attr/suwGlifHeaderGravity"
+ android:gravity="?attr/sudGlifHeaderGravity"
android:text="@string/setup_lock_settings_options_button_label"
android:visibility="gone" />
@@ -122,7 +122,7 @@
<!-- left : skip -->
<Button android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skip_label"
diff --git a/res/layout-land/confirm_lock_password.xml b/res/layout-land/confirm_lock_password.xml
index a6a85d3..d140bad 100644
--- a/res/layout-land/confirm_lock_password.xml
+++ b/res/layout-land/confirm_lock_password.xml
@@ -28,7 +28,7 @@
android:layout_height="match_parent">
<TextView
- style="@android:style/TextAppearance.Material.Title"
+ style="@*android:style/TextAppearance.DeviceDefault.Title"
android:id="@+id/headerText"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
@@ -38,7 +38,7 @@
android:textColor="?android:attr/colorAccent"/>
<TextView
- style="@android:style/TextAppearance.Material.Body1"
+ style="@*android:style/TextAppearance.DeviceDefault.Body1"
android:id="@+id/detailsText"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
@@ -78,7 +78,7 @@
android:gravity="center"
style="@style/TextAppearance.PasswordEntry"/>
- <TextView style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
+ <TextView style="@style/TextAppearance.ErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
diff --git a/res/layout-land/confirm_lock_pattern.xml b/res/layout-land/confirm_lock_pattern.xml
index b0a0a96..bcfd907 100644
--- a/res/layout-land/confirm_lock_pattern.xml
+++ b/res/layout-land/confirm_lock_pattern.xml
@@ -37,7 +37,7 @@
android:orientation="vertical">
<TextView
- style="@android:style/TextAppearance.Material.Headline"
+ style="@*android:style/TextAppearance.DeviceDefault.Headline"
android:id="@+id/headerText"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
@@ -46,7 +46,7 @@
android:textColor="?android:attr/colorAccent"/>
<TextView
- style="@android:style/TextAppearance.Material.Body1"
+ style="@*android:style/TextAppearance.DeviceDefault.Body1"
android:id="@+id/detailsText"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
@@ -94,7 +94,7 @@
android:layout_gravity="center_vertical"/>
<TextView
- style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
+ style="@style/TextAppearance.ErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
@@ -111,4 +111,4 @@
</LinearLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>
-</FrameLayout>
\ No newline at end of file
+</FrameLayout>
diff --git a/res/layout-land/confirm_lock_pattern_normal.xml b/res/layout-land/confirm_lock_pattern_normal.xml
index 7989c5e..21c9b1e 100644
--- a/res/layout-land/confirm_lock_pattern_normal.xml
+++ b/res/layout-land/confirm_lock_pattern_normal.xml
@@ -40,34 +40,34 @@
android:paddingBottom="24dp">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:src="@drawable/ic_lock" />
<TextView
android:id="@+id/headerText"
- style="@style/SuwGlifHeaderTitle"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/detailsText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides" />
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides" />
<Button
android:id="@+id/cancelButton"
style="@style/SetupWizardButton.Negative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:text="@string/cancel" />
<Space
@@ -76,13 +76,13 @@
android:layout_weight="1" />
<TextView
- style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
+ style="@style/TextAppearance.ErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:layout_marginBottom="24dp"
android:gravity="center_vertical"/>
</LinearLayout>
diff --git a/res/layout-land/fingerprint_enroll_enrolling.xml b/res/layout-land/fingerprint_enroll_enrolling.xml
index 7e22234..f96bdde 100644
--- a/res/layout-land/fingerprint_enroll_enrolling.xml
+++ b/res/layout-land/fingerprint_enroll_enrolling.xml
@@ -28,7 +28,7 @@
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
@@ -42,25 +42,25 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginBottom="@dimen/suw_content_frame_padding_bottom"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:src="@drawable/ic_fingerprint_header" />
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
@@ -71,14 +71,14 @@
android:layout_height="wrap_content">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/start_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_start_message"/>
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/repeat_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -94,7 +94,7 @@
<Button
android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_enrolling_skip" />
@@ -123,7 +123,7 @@
</com.google.android.setupdesign.view.FillContentLayout>
<TextView
- style="@style/TextAppearance.FingerprintErrorText"
+ style="@style/TextAppearance.ErrorText"
android:id="@+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout-land/fingerprint_enroll_find_sensor.xml b/res/layout-land/fingerprint_enroll_find_sensor.xml
index 0decbf2..f4c97a3 100644
--- a/res/layout-land/fingerprint_enroll_find_sensor.xml
+++ b/res/layout-land/fingerprint_enroll_find_sensor.xml
@@ -34,8 +34,8 @@
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginBottom="@dimen/suw_content_frame_padding_bottom"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginBottom="@dimen/sud_content_frame_padding_bottom"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical">
@@ -55,25 +55,25 @@
android:clipToPadding="false">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:src="@drawable/ic_fingerprint_header" />
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp" />
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/>
diff --git a/res/layout-land/fingerprint_enroll_finish.xml b/res/layout-land/fingerprint_enroll_finish.xml
index 53e430e..7d292c6 100644
--- a/res/layout-land/fingerprint_enroll_finish.xml
+++ b/res/layout-land/fingerprint_enroll_finish.xml
@@ -29,7 +29,7 @@
android:fillViewport="true">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
@@ -45,19 +45,19 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:contentDescription="@null"
android:src="@drawable/ic_fingerprint_header"/>
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
@@ -65,7 +65,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
@@ -79,7 +79,7 @@
<ImageView
android:id="@+id/fingerprint_in_app_indicator"
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@android:string/fingerprint_icon_content_description"
diff --git a/res/layout-land/storage_summary_donut.xml b/res/layout-land/storage_summary_donut.xml
index 5fe4cc8..f43737a 100644
--- a/res/layout-land/storage_summary_donut.xml
+++ b/res/layout-land/storage_summary_donut.xml
@@ -42,7 +42,7 @@
android:fontFamily="@*android:string/config_headlineFontFamily"
android:singleLine="true"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Display1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Display1"
android:textSize="36sp" />
<TextView
@@ -54,7 +54,7 @@
android:maxLines="10"
android:paddingBottom="20dp"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" />
<Button
android:id="@+id/deletion_helper_button"
diff --git a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
index 4217867..4eed0f6 100644
--- a/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
+++ b/res/layout-land/wifi_dpp_qrcode_scanner_fragment.xml
@@ -19,29 +19,40 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <com.android.settings.wifi.qrcode.QrPreviewLayout
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center">
- <TextureView
- android:id="@+id/preview_view"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"/>
- <com.android.settings.wifi.qrcode.QrDecorateView
- android:id="@+id/decorate_view"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"/>
- </com.android.settings.wifi.qrcode.QrPreviewLayout>
+ android:layout_height="match_parent">
- <TextView android:id="@+id/error_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:gravity="center_horizontal">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <com.android.settings.wifi.qrcode.QrPreviewLayout
+ android:layout_width="@dimen/qrcode_preview_size"
+ android:layout_height="@dimen/qrcode_preview_size">
+ <TextureView
+ android:id="@+id/preview_view"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+ <com.android.settings.wifi.qrcode.QrDecorateView
+ android:id="@+id/decorate_view"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"/>
+ </com.android.settings.wifi.qrcode.QrPreviewLayout>
+
+ <TextView android:id="@+id/error_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"/>
+
+ </LinearLayout>
+
+ </ScrollView>
</LinearLayout>
diff --git a/res/layout-sw300dp-land/font_size_activity.xml b/res/layout-sw300dp-land/font_size_activity.xml
index 69abac1..6664704 100644
--- a/res/layout-sw300dp-land/font_size_activity.xml
+++ b/res/layout-sw300dp-land/font_size_activity.xml
@@ -56,7 +56,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="6dp"
- android:textAppearance="@android:style/TextAppearance.Material.Widget.TextView"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
android:elevation="2dp" />
<com.android.settings.widget.LabeledSeekBar
@@ -102,7 +102,7 @@
android:layout_height="wrap_content"
android:text="@string/font_size_summary"
android:layout_marginBottom="16dp"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead" />
</LinearLayout>
</ScrollView>
</LinearLayout>
diff --git a/res/layout-sw300dp-land/screen_zoom_activity.xml b/res/layout-sw300dp-land/screen_zoom_activity.xml
index 8d6e735..cd7c67c 100644
--- a/res/layout-sw300dp-land/screen_zoom_activity.xml
+++ b/res/layout-sw300dp-land/screen_zoom_activity.xml
@@ -56,7 +56,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="6dp"
- android:textAppearance="@android:style/TextAppearance.Material.Widget.TextView"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
android:elevation="2dp" />
<com.android.settings.widget.LabeledSeekBar
@@ -102,7 +102,7 @@
android:layout_height="wrap_content"
android:text="@string/screen_zoom_summary"
android:layout_marginBottom="16dp"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead" />
</LinearLayout>
</ScrollView>
</LinearLayout>
diff --git a/res/layout-sw360dp/homepage_condition_full_tile.xml b/res/layout-sw360dp/homepage_condition_full_tile.xml
new file mode 100644
index 0000000..4a8ad0a
--- /dev/null
+++ b/res/layout-sw360dp/homepage_condition_full_tile.xml
@@ -0,0 +1,74 @@
+<?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.
+-->
+
+<com.google.android.material.card.MaterialCardView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/ContextualCardStyle">
+
+ <LinearLayout
+ android:id="@+id/content"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:paddingStart="@dimen/homepage_card_padding_start"
+ android:paddingEnd="@dimen/homepage_card_padding_end"
+ android:paddingTop="@dimen/homepage_condition_full_card_padding_top"
+ android:paddingBottom="@dimen/homepage_condition_full_card_padding_bottom"
+ android:orientation="horizontal"
+ android:gravity="center_vertical">
+
+ <ImageView
+ android:id="@android:id/icon"
+ android:layout_width="@dimen/homepage_card_icon_size"
+ android:layout_height="@dimen/homepage_card_icon_size"
+ android:tint="?android:attr/colorAccent"/>
+
+ <LinearLayout
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingStart="@dimen/homepage_condition_full_card_padding_start"
+ android:paddingEnd="@dimen/homepage_condition_full_card_padding_end"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@android:id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
+ android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
+
+ <TextView
+ android:id="@android:id/summary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
+
+ </LinearLayout>
+
+ <include layout="@layout/vertical_divider"/>
+
+ <Button
+ android:id="@+id/first_action"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ style="@style/ConditionFullCardBorderlessButton"/>
+
+ </LinearLayout>
+
+</com.google.android.material.card.MaterialCardView>
diff --git a/res/layout-sw360dp/storage_summary_donut.xml b/res/layout-sw360dp/storage_summary_donut.xml
index 5fe4cc8..f43737a 100644
--- a/res/layout-sw360dp/storage_summary_donut.xml
+++ b/res/layout-sw360dp/storage_summary_donut.xml
@@ -42,7 +42,7 @@
android:fontFamily="@*android:string/config_headlineFontFamily"
android:singleLine="true"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Display1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Display1"
android:textSize="36sp" />
<TextView
@@ -54,7 +54,7 @@
android:maxLines="10"
android:paddingBottom="20dp"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" />
<Button
android:id="@+id/deletion_helper_button"
diff --git a/res/layout/admin_support_details_dialog.xml b/res/layout/admin_support_details_dialog.xml
index 922451f..66eaf0d 100644
--- a/res/layout/admin_support_details_dialog.xml
+++ b/res/layout/admin_support_details_dialog.xml
@@ -34,7 +34,7 @@
android:layout_height="wrap_content"
android:paddingStart="@dimen/admin_details_dialog_padding"
android:text="@string/disabled_by_policy_title"
- android:textAppearance="@android:style/TextAppearance.Material.Title" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Title" />
</LinearLayout>
<ScrollView
@@ -48,7 +48,7 @@
<TextView android:id="@+id/admin_support_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:text="@string/default_admin_support_msg"
android:maxLength="200"
android:autoLink="email|phone|web"
diff --git a/res/layout/band_mode.xml b/res/layout/band_mode.xml
index ddbc7ae..b43dd1d 100644
--- a/res/layout/band_mode.xml
+++ b/res/layout/band_mode.xml
@@ -19,7 +19,7 @@
android:padding="4dip"
android:gravity="center_horizontal"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="wrap_content">
<ListView android:id="@+id/band"
android:layout_width="match_parent"
diff --git a/res/layout/battery_header.xml b/res/layout/battery_header.xml
index 9f5bde9..b3b699a 100644
--- a/res/layout/battery_header.xml
+++ b/res/layout/battery_header.xml
@@ -22,15 +22,12 @@
android:layout_height="match_parent"
android:layout_gravity="center"
android:orientation="horizontal"
- android:paddingTop="24dp"
- android:paddingBottom="24dp"
style="@style/EntityHeader">
<LinearLayout
- android:layout_width="0dp"
+ android:layout_width="170dp"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_marginStart="56dp"
+ android:layout_marginStart="72dp"
android:layout_marginEnd="8dp"
android:orientation="vertical">
@@ -39,8 +36,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
- android:fontFamily="@*android:string/config_headlineFontFamily"
- android:textAppearance="@android:style/TextAppearance.Material.Display1"/>
+ android:textAppearance="@style/TextAppearance.EntityHeaderTitle"
+ android:textSize="36sp" />
<TextView
android:id="@+id/summary1"
@@ -48,20 +45,21 @@
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:minLines="2"
- android:textAppearance="@android:style/TextAppearance.Material.Small"/>
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/>
+ android:textColor="?android:attr/textColorPrimary"/>
<TextView
android:id="@+id/summary2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Small"/>
-
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Small"/>
+ android:textColor="?android:attr/textColorPrimary"/>
</LinearLayout>
<com.android.settings.fuelgauge.BatteryMeterView
android:id="@+id/battery_header_icon"
- android:layout_width="@dimen/battery_meter_width"
+ android:layout_width="match_parent"
android:layout_height="@dimen/battery_meter_height"
- android:layout_marginEnd="16dp"/>
+ android:layout_gravity="center"/>
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/bluetooth_pin_confirm.xml b/res/layout/bluetooth_pin_confirm.xml
index 33140d9..c55c9ff 100644
--- a/res/layout/bluetooth_pin_confirm.xml
+++ b/res/layout/bluetooth_pin_confirm.xml
@@ -40,7 +40,7 @@
android:gravity="center_vertical"
android:text="@string/bluetooth_pairing_key_msg"
android:visibility="gone"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="@color/bluetooth_dialog_text_color" />
<TextView
@@ -52,7 +52,7 @@
android:layout_marginBottom="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical"
android:visibility="gone"
- android:textAppearance="@android:style/TextAppearance.Material.Headline" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Headline" />
<TextView
android:id="@+id/pairing_code_message"
@@ -63,7 +63,7 @@
android:layout_marginBottom="@dimen/bluetooth_dialog_padding"
android:gravity="center_vertical"
android:text="@string/bluetooth_enter_passkey_msg"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="@color/bluetooth_dialog_text_color"
android:visibility="gone" />
@@ -73,7 +73,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/bluetooth_dialog_padding"
android:layout_marginEnd="@dimen/bluetooth_dialog_padding"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="@color/bluetooth_dialog_text_color" />
</LinearLayout>
diff --git a/res/layout/bluetooth_pin_entry.xml b/res/layout/bluetooth_pin_entry.xml
index c309a24..0c6861c 100644
--- a/res/layout/bluetooth_pin_entry.xml
+++ b/res/layout/bluetooth_pin_entry.xml
@@ -60,7 +60,7 @@
android:layout_marginBottom="16dp"
android:gravity="center"
android:paddingStart="@dimen/bluetooth_checkbox_padding"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"/>
<TextView
@@ -71,7 +71,7 @@
android:layout_marginEnd="@dimen/bluetooth_pairing_padding"
android:layout_marginBottom="12dp"
android:gravity="center_vertical"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorSecondary"/>
<CheckBox
@@ -84,7 +84,7 @@
android:gravity="center_vertical"
android:paddingStart="@dimen/bluetooth_checkbox_padding"
android:text="@string/bluetooth_pairing_shares_phonebook"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
diff --git a/res/layout/choose_lock_dialog_item.xml b/res/layout/choose_lock_dialog_item.xml
index 46ad539..f87b7c4 100644
--- a/res/layout/choose_lock_dialog_item.xml
+++ b/res/layout/choose_lock_dialog_item.xml
@@ -26,5 +26,5 @@
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorAlertDialogListItem" />
diff --git a/res/layout/choose_lock_password.xml b/res/layout/choose_lock_password.xml
index 1962ee0..68583b5 100644
--- a/res/layout/choose_lock_password.xml
+++ b/res/layout/choose_lock_password.xml
@@ -22,10 +22,10 @@
android:icon="@drawable/ic_lock"
android:importantForAutofill="noExcludeDescendants"
settings:sucFooter="@layout/choose_lock_password_footer"
- settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">
+ settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
@@ -35,7 +35,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="2"/>
@@ -71,7 +71,7 @@
<Button
android:id="@+id/screen_lock_options"
- style="@style/SuwGlifButton.Tertiary"
+ style="@style/SudGlifButton.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_lock_settings_options_button_label"
diff --git a/res/layout/choose_lock_password_footer.xml b/res/layout/choose_lock_password_footer.xml
index 0b7791c..58d80cf 100644
--- a/res/layout/choose_lock_password_footer.xml
+++ b/res/layout/choose_lock_password_footer.xml
@@ -17,13 +17,13 @@
<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
+ style="@style/SudGlifButtonBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- left : skip -->
<Button android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skip_label"
@@ -32,7 +32,7 @@
<!-- left : clear -->
<Button android:id="@+id/clear_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
@@ -45,7 +45,7 @@
<!-- right : continue -->
<Button android:id="@+id/next_button"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next_label" />
diff --git a/res/layout/choose_lock_pattern_common.xml b/res/layout/choose_lock_pattern_common.xml
index 6d64b88..b31062e 100644
--- a/res/layout/choose_lock_pattern_common.xml
+++ b/res/layout/choose_lock_pattern_common.xml
@@ -24,7 +24,7 @@
android:icon="@drawable/ic_lock"
android:layout="@layout/sud_glif_blank_template"
settings:sucFooter="@layout/choose_lock_pattern_common_footer"
- settings:suwHeaderText="@string/lockpassword_choose_your_screen_lock_header">
+ settings:sucHeaderText="@string/lockpassword_choose_your_screen_lock_header">
<com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient
android:id="@+id/topLayout"
@@ -35,21 +35,21 @@
android:orientation="vertical">
<LinearLayout
- style="@style/SuwGlifHeaderContainer"
+ style="@style/SudGlifHeaderContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_lock" />
<TextView
- android:id="@+id/suw_layout_title"
- style="@style/SuwGlifHeaderTitle"
+ android:id="@+id/suc_layout_title"
+ style="@style/SudGlifHeaderTitle"
android:accessibilityLiveRegion="polite"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -58,7 +58,7 @@
<!-- takes up all space above button bar at bottom -->
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
@@ -71,10 +71,10 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginHorizontal="?attr/suwMarginSides"
+ android:layout_marginHorizontal="?attr/sudMarginSides"
android:minLines="2" />
<TextView android:id="@+id/headerText"
@@ -82,7 +82,7 @@
android:layout_height="wrap_content"
android:minLines="2"
android:gravity="center"
- android:paddingHorizontal="?attr/suwMarginSides"
+ android:paddingHorizontal="?attr/sudMarginSides"
android:textSize="12sp" />
<com.google.android.setupdesign.view.FillContentLayout
@@ -111,7 +111,7 @@
<Button
android:id="@+id/screen_lock_options"
- style="@style/SuwGlifButton.Tertiary"
+ style="@style/SudGlifButton.Tertiary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/setup_lock_settings_options_button_label"
diff --git a/res/layout/choose_lock_pattern_common_footer.xml b/res/layout/choose_lock_pattern_common_footer.xml
index b0397ea..b582854 100644
--- a/res/layout/choose_lock_pattern_common_footer.xml
+++ b/res/layout/choose_lock_pattern_common_footer.xml
@@ -18,13 +18,13 @@
<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
<com.google.android.setupdesign.view.ButtonBarLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar.Stackable"
+ style="@style/SudGlifButtonBar.Stackable"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- left : skip -->
<Button android:id="@+id/skip_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/skip_label"
@@ -32,7 +32,7 @@
<!-- left : retry -->
<Button android:id="@+id/footerLeftButton"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lockpattern_tutorial_cancel_label" />
@@ -44,7 +44,7 @@
<!-- right : confirm or ok -->
<Button android:id="@+id/footerRightButton"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lockpattern_tutorial_continue_label" />
diff --git a/res/layout/confirm_lock_password_base.xml b/res/layout/confirm_lock_password_base.xml
index 1e42fbe..22934ba 100644
--- a/res/layout/confirm_lock_password_base.xml
+++ b/res/layout/confirm_lock_password_base.xml
@@ -31,7 +31,7 @@
android:paddingTop="@dimen/confirm_credentials_top_padding">
<TextView
- style="@android:style/TextAppearance.Material.Headline"
+ style="@*android:style/TextAppearance.DeviceDefault.Headline"
android:id="@+id/headerText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
@@ -41,7 +41,7 @@
android:textColor="?android:attr/colorAccent"/>
<TextView
- style="@android:style/TextAppearance.Material.Body1"
+ style="@*android:style/TextAppearance.DeviceDefault.Body1"
android:id="@+id/detailsText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
@@ -79,7 +79,7 @@
style="@style/TextAppearance.PasswordEntry"/>
<TextView
- style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
+ style="@style/TextAppearance.ErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
diff --git a/res/layout/confirm_lock_password_normal.xml b/res/layout/confirm_lock_password_normal.xml
index 4b92a4a..7b04127 100644
--- a/res/layout/confirm_lock_password_normal.xml
+++ b/res/layout/confirm_lock_password_normal.xml
@@ -29,11 +29,11 @@
<TextView
android:id="@+id/detailsText"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides" />
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides" />
<Space
android:layout_width="match_parent"
@@ -58,7 +58,7 @@
<TextView
android:id="@+id/errorText"
- style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
+ style="@style/TextAppearance.ErrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:accessibilityLiveRegion="polite"/>
@@ -72,11 +72,11 @@
<Button
android:id="@+id/cancelButton"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:layout_marginBottom="80dp"
android:layout_gravity="center_horizontal"
android:text="@string/cancel" />
diff --git a/res/layout/confirm_lock_pattern_base.xml b/res/layout/confirm_lock_pattern_base.xml
index f841391..25fa08f 100644
--- a/res/layout/confirm_lock_pattern_base.xml
+++ b/res/layout/confirm_lock_pattern_base.xml
@@ -40,7 +40,7 @@
android:orientation="vertical">
<TextView
- style="@android:style/TextAppearance.Material.Headline"
+ style="@*android:style/TextAppearance.DeviceDefault.Headline"
android:id="@+id/headerText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
@@ -50,7 +50,7 @@
android:textColor="?android:attr/colorAccent"/>
<TextView
- style="@android:style/TextAppearance.Material.Body1"
+ style="@*android:style/TextAppearance.DeviceDefault.Body1"
android:id="@+id/detailsText"
android:layout_marginStart="?attr/confirmDeviceCredentialsSideMargin"
android:layout_marginEnd="?attr/confirmDeviceCredentialsSideMargin"
@@ -85,7 +85,7 @@
android:orientation="vertical">
<TextView
- style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
+ style="@style/TextAppearance.ErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
diff --git a/res/layout/confirm_lock_pattern_normal_base.xml b/res/layout/confirm_lock_pattern_normal_base.xml
index acb2bbe..a08d516 100644
--- a/res/layout/confirm_lock_pattern_normal_base.xml
+++ b/res/layout/confirm_lock_pattern_normal_base.xml
@@ -33,31 +33,31 @@
android:orientation="vertical">
<ImageView
- android:id="@+id/suw_layout_icon"
- style="@style/SuwGlifIcon"
+ android:id="@+id/suc_layout_icon"
+ style="@style/SudGlifIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="?attr/suwGlifHeaderGravity"
+ android:layout_gravity="?attr/sudGlifHeaderGravity"
android:src="@drawable/ic_lock" />
<TextView
android:id="@+id/headerText"
- style="@style/SuwGlifHeaderTitle"
+ style="@style/SudGlifHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/detailsText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides" />
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides" />
</LinearLayout>
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -80,23 +80,23 @@
</com.google.android.setupdesign.view.FillContentLayout>
<TextView
- style="@style/TextAppearance.ConfirmDeviceCredentialsErrorText"
+ style="@style/TextAppearance.ErrorText"
android:accessibilityLiveRegion="polite"
android:id="@+id/errorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
- android:layout_marginHorizontal="?attr/suwMarginSides"
+ android:layout_marginHorizontal="?attr/sudMarginSides"
android:layout_marginTop="12dp"
android:gravity="center_vertical"/>
<Button
android:id="@+id/cancelButton"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_marginStart="?attr/suwMarginSides"
- android:layout_marginEnd="?attr/suwMarginSides"
+ android:layout_marginStart="?attr/sudMarginSides"
+ android:layout_marginEnd="?attr/sudMarginSides"
android:layout_marginBottom="80dp"
android:text="@string/cancel" />
diff --git a/res/layout/data_usage_detail.xml b/res/layout/data_usage_detail.xml
index 5113139..8079fe1 100644
--- a/res/layout/data_usage_detail.xml
+++ b/res/layout/data_usage_detail.xml
@@ -64,14 +64,14 @@
android:singleLine="true"
android:ellipsize="marquee"
android:text="@string/data_usage_label_foreground"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="viewStart" />
<TextView
android:id="@+id/app_foreground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="viewEnd" />
</LinearLayout>
@@ -87,14 +87,14 @@
android:singleLine="true"
android:ellipsize="marquee"
android:text="@string/data_usage_label_background"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="viewStart" />
<TextView
android:id="@+id/app_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="viewEnd" />
</LinearLayout>
diff --git a/res/layout/encryption_interstitial.xml b/res/layout/encryption_interstitial.xml
index ff56a7c..3e227cb1 100644
--- a/res/layout/encryption_interstitial.xml
+++ b/res/layout/encryption_interstitial.xml
@@ -20,11 +20,10 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:icon="@drawable/ic_lock"
- app:sucFooter="@layout/encryption_interstitial_footer">
+ android:icon="@drawable/ic_lock">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
@@ -33,7 +32,7 @@
<TextView
android:id="@+id/encryption_message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
diff --git a/res/layout/encryption_interstitial_footer.xml b/res/layout/encryption_interstitial_footer.xml
deleted file mode 100644
index 2f876f3..0000000
--- a/res/layout/encryption_interstitial_footer.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/encrypt_dont_require_password"
- style="@style/SuwGlifButton.Secondary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/encryption_interstitial_no" />
-
- <Space
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1" />
-
- <Button
- android:id="@+id/encrypt_require_password"
- style="@style/SuwGlifButton.Primary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/encryption_interstitial_yes" />
-
-</LinearLayout>
diff --git a/res/layout/face_enroll_enrolling.xml b/res/layout/face_enroll_enrolling.xml
index 7aef9b6..e7af493 100644
--- a/res/layout/face_enroll_enrolling.xml
+++ b/res/layout/face_enroll_enrolling.xml
@@ -24,7 +24,7 @@
style="?attr/face_layout_theme">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -57,7 +57,7 @@
</com.android.settings.biometrics.face.FaceSquareFrameLayout>
<TextView
- style="@style/TextAppearance.FaceErrorText"
+ style="@style/TextAppearance.ErrorText"
android:id="@+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/face_enroll_finish.xml b/res/layout/face_enroll_finish.xml
index df46098..62176a7 100644
--- a/res/layout/face_enroll_finish.xml
+++ b/res/layout/face_enroll_finish.xml
@@ -24,7 +24,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -44,7 +44,7 @@
android:layout_weight="1">
<ImageView
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
diff --git a/res/layout/face_enroll_introduction.xml b/res/layout/face_enroll_introduction.xml
index df3cf72..69b00fe 100644
--- a/res/layout/face_enroll_introduction.xml
+++ b/res/layout/face_enroll_introduction.xml
@@ -25,7 +25,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
@@ -34,14 +34,14 @@
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/description_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_face_enroll_introduction_message" />
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/error_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -51,7 +51,7 @@
android:layout_weight="1">
<ImageView
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
@@ -65,7 +65,7 @@
android:layout_gravity="center">
<Button
android:id="@+id/accessibility_button"
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/filter_spinner_item.xml b/res/layout/filter_spinner_item.xml
deleted file mode 100644
index ffdd623..0000000
--- a/res/layout/filter_spinner_item.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2015 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.
--->
-
-<TextView
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@android:id/text1"
- style="?android:attr/spinnerItemStyle"
- android:maxLines="1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ellipsize="marquee"
- android:textColor="?android:attr/colorForegroundInverse"
- android:textAppearance="@style/TextAppearance.Switch"
- android:textAlignment="inherit" />
diff --git a/res/layout/fingerprint_enroll_enrolling_base.xml b/res/layout/fingerprint_enroll_enrolling_base.xml
index 6ca3fdc..3a476fa 100644
--- a/res/layout/fingerprint_enroll_enrolling_base.xml
+++ b/res/layout/fingerprint_enroll_enrolling_base.xml
@@ -24,7 +24,7 @@
style="?attr/fingerprint_layout_theme">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -38,7 +38,7 @@
android:layout_height="wrap_content">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/start_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -46,7 +46,7 @@
android:text="@string/security_settings_fingerprint_enroll_start_message"/>
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:id="@+id/repeat_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -77,7 +77,7 @@
</com.google.android.setupdesign.view.FillContentLayout>
<TextView
- style="@style/TextAppearance.FingerprintErrorText"
+ style="@style/TextAppearance.ErrorText"
android:id="@+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/fingerprint_enroll_find_sensor_base.xml b/res/layout/fingerprint_enroll_find_sensor_base.xml
index 56d3ea4..c03ac5a 100644
--- a/res/layout/fingerprint_enroll_find_sensor_base.xml
+++ b/res/layout/fingerprint_enroll_find_sensor_base.xml
@@ -31,7 +31,7 @@
android:clipChildren="false">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
@@ -39,10 +39,10 @@
android:clipChildren="false">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_glif_margin_top"
+ android:layout_marginTop="@dimen/sud_description_glif_margin_top"
android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/>
</LinearLayout>
diff --git a/res/layout/fingerprint_enroll_finish_base.xml b/res/layout/fingerprint_enroll_finish_base.xml
index 7120d90..2fa5da6 100644
--- a/res/layout/fingerprint_enroll_finish_base.xml
+++ b/res/layout/fingerprint_enroll_finish_base.xml
@@ -24,7 +24,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -33,10 +33,10 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_glif_margin_top"
+ android:layout_marginTop="@dimen/sud_description_glif_margin_top"
android:minLines="3"
android:text="@string/security_settings_fingerprint_enroll_finish_message"/>
@@ -57,7 +57,7 @@
<ImageView
android:id="@+id/fingerprint_in_app_indicator"
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="7dp"
@@ -67,7 +67,7 @@
<!-- Added to align elements with fingerprint_enroll_enrolling_base -->
<TextView
- style="@style/TextAppearance.FingerprintErrorText"
+ style="@style/TextAppearance.ErrorText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
diff --git a/res/layout/fingerprint_enroll_introduction.xml b/res/layout/fingerprint_enroll_introduction.xml
index adb46e5..4ee7057 100644
--- a/res/layout/fingerprint_enroll_introduction.xml
+++ b/res/layout/fingerprint_enroll_introduction.xml
@@ -24,7 +24,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
@@ -33,14 +33,14 @@
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/description_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/security_settings_fingerprint_enroll_introduction_message" />
<com.google.android.setupdesign.view.RichTextView
android:id="@+id/error_text"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
@@ -50,7 +50,7 @@
android:layout_weight="1">
<ImageView
- style="@style/SuwContentIllustration"
+ style="@style/SudContentIllustration"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@null"
diff --git a/res/layout/font_size_activity.xml b/res/layout/font_size_activity.xml
index aa3930c..3e84336 100644
--- a/res/layout/font_size_activity.xml
+++ b/res/layout/font_size_activity.xml
@@ -48,7 +48,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="6dp"
- android:textAppearance="@android:style/TextAppearance.Material.Widget.TextView"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
android:elevation="2dp" />
<LinearLayout
@@ -94,7 +94,7 @@
android:layout_height="wrap_content"
android:text="@string/font_size_summary"
android:layout_marginBottom="16dp"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead" />
</LinearLayout>
</LinearLayout>
</ScrollView>
diff --git a/res/layout/font_size_preview.xml b/res/layout/font_size_preview.xml
index d84bb39..669ece0 100644
--- a/res/layout/font_size_preview.xml
+++ b/res/layout/font_size_preview.xml
@@ -36,25 +36,25 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/font_size_preview_text_headline"
- android:textAppearance="@android:style/TextAppearance.Material.Headline"/>
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Headline"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/font_size_preview_text_title"
- android:textAppearance="@android:style/TextAppearance.Material.Title"/>
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Title"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/font_size_preview_text_subtitle"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"/>
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/font_size_preview_text_body"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"/>
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"/>
</LinearLayout>
</view>
</ScrollView>
diff --git a/res/layout/homepage_condition_full_tile.xml b/res/layout/homepage_condition_full_tile.xml
index 4b12625..2de1464 100644
--- a/res/layout/homepage_condition_full_tile.xml
+++ b/res/layout/homepage_condition_full_tile.xml
@@ -25,49 +25,50 @@
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingStart="@dimen/homepage_card_padding_start"
- android:paddingEnd="@dimen/homepage_card_padding_end"
- android:paddingTop="@dimen/homepage_condition_full_card_padding_top"
- android:paddingBottom="@dimen/homepage_condition_full_card_padding_bottom"
- android:orientation="horizontal"
- android:gravity="center_vertical">
-
- <ImageView
- android:id="@android:id/icon"
- android:layout_width="@dimen/homepage_card_icon_size"
- android:layout_height="@dimen/homepage_card_icon_size"
- android:tint="?android:attr/colorAccent"/>
+ android:paddingTop="@dimen/homepage_condition_half_card_padding_top"
+ android:orientation="vertical">
<LinearLayout
- android:layout_width="0dp"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_weight="1"
- android:paddingStart="@dimen/homepage_condition_full_card_padding_start"
- android:paddingEnd="@dimen/homepage_condition_full_card_padding_end"
+ android:paddingStart="@dimen/homepage_card_padding_start"
+ android:paddingEnd="@dimen/homepage_card_padding_end"
android:orientation="vertical">
+ <ImageView
+ android:id="@android:id/icon"
+ android:layout_width="@dimen/homepage_card_icon_size"
+ android:layout_height="@dimen/homepage_card_icon_size"
+ android:tint="?android:attr/colorAccent"/>
+
<TextView
android:id="@android:id/title"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:layout_marginTop="@dimen/homepage_condition_half_card_title_margin_top"
android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
- style="@style/TextAppearance.ConditionCardTitle"/>
+ android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
<TextView
android:id="@android:id/summary"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/TextAppearance.ConditionCardSummary"/>
+ android:maxLines="1"
+ android:ellipsize="end"
+ android:layout_marginBottom="@dimen/homepage_condition_half_card_summary_margin_bottom"
+ android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
+
+ <include layout="@layout/horizontal_divider"/>
</LinearLayout>
-
- <include layout="@layout/vertical_divider"/>
-
<Button
android:id="@+id/first_action"
- android:layout_width="wrap_content"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/ConditionFullCardBorderlessButton"/>
+ android:scrollbars="none"
+ style="@style/ConditionHalfCardBorderlessButton"/>
</LinearLayout>
diff --git a/res/layout/homepage_condition_half_tile.xml b/res/layout/homepage_condition_half_tile.xml
index 895183f..8f5af02 100644
--- a/res/layout/homepage_condition_half_tile.xml
+++ b/res/layout/homepage_condition_half_tile.xml
@@ -18,7 +18,7 @@
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="@dimen/homepage_condition_half_card_height"
+ android:layout_height="wrap_content"
style="@style/ContextualCardStyle">
<LinearLayout
@@ -49,7 +49,7 @@
android:ellipsize="end"
android:layout_marginTop="@dimen/homepage_condition_half_card_title_margin_top"
android:layout_marginBottom="@dimen/homepage_condition_card_title_margin_bottom"
- style="@style/TextAppearance.ConditionCardTitle"/>
+ android:textAppearance="@style/TextAppearance.ConditionCardTitle"/>
<TextView
android:id="@android:id/summary"
@@ -58,7 +58,7 @@
android:maxLines="1"
android:ellipsize="end"
android:layout_marginBottom="@dimen/homepage_condition_half_card_summary_margin_bottom"
- style="@style/TextAppearance.ConditionCardSummary"/>
+ android:textAppearance="@style/TextAppearance.ConditionCardSummary"/>
<include layout="@layout/horizontal_divider"/>
diff --git a/res/layout/homepage_dismissal_view.xml b/res/layout/homepage_dismissal_view.xml
index e60b375..7d1abf3 100644
--- a/res/layout/homepage_dismissal_view.xml
+++ b/res/layout/homepage_dismissal_view.xml
@@ -20,6 +20,7 @@
android:id="@+id/dismissal_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:background="@color/homepage_card_dismissal_background"
android:orientation="vertical">
<TextView
@@ -40,6 +41,7 @@
style="@style/ContextualCardDismissalButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/homepage_card_dismissal_margin_bottom"
android:text="@string/contextual_card_dismiss_keep"/>
<Button
@@ -47,6 +49,7 @@
style="@style/ContextualCardDismissalButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginBottom="@dimen/homepage_card_dismissal_margin_bottom"
android:text="@string/contextual_card_dismiss_remove"/>
</LinearLayout>
diff --git a/res/layout/homepage_slice_half_tile.xml b/res/layout/homepage_slice_half_tile.xml
index 7de9eb6..46f3cda 100644
--- a/res/layout/homepage_slice_half_tile.xml
+++ b/res/layout/homepage_slice_half_tile.xml
@@ -24,12 +24,12 @@
<ViewFlipper
android:id="@+id/view_flipper"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="match_parent">
<LinearLayout
android:id="@+id/content"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
+ android:layout_height="match_parent"
android:paddingStart="@dimen/homepage_card_padding_start"
android:paddingEnd="@dimen/homepage_card_padding_end"
android:paddingTop="@dimen/homepage_half_card_padding_top"
diff --git a/res/layout/homepage_slice_tile.xml b/res/layout/homepage_slice_tile.xml
index 9fa7d61..2b7c1b0 100644
--- a/res/layout/homepage_slice_tile.xml
+++ b/res/layout/homepage_slice_tile.xml
@@ -30,6 +30,7 @@
android:id="@+id/slice_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
android:paddingStart="@dimen/homepage_card_padding_start"
android:paddingEnd="@dimen/homepage_card_padding_end"/>
diff --git a/res/layout/manage_applications_apps.xml b/res/layout/manage_applications_apps.xml
index 765ced6..c2f58c3 100644
--- a/res/layout/manage_applications_apps.xml
+++ b/res/layout/manage_applications_apps.xml
@@ -14,60 +14,73 @@
limitations under the License.
-->
-<LinearLayout
+<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
- <FrameLayout
+ <androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_weight="1">
+ android:layout_height="match_parent"
+ android:fillViewport="true"
+ settings:layout_behavior="com.android.settings.widget.FloatingAppBarScrollingViewBehavior">
- <LinearLayout
- android:id="@+id/list_container"
+ <FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:orientation="vertical"
- android:visibility="gone">
+ android:paddingTop="@dimen/app_bar_height">
- <FrameLayout
- android:id="@+id/pinned_header"
+ <LinearLayout
+ android:id="@+id/list_container"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:visibility="gone">
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="0px"
- android:layout_weight="1">
-
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/apps_list"
+ <FrameLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- settings:fastScrollEnabled="true"
- settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
- settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
- settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
- settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
+ android:layout_height="match_parent">
- <TextView
- android:id="@android:id/empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center"
- android:text="@string/no_applications"
- android:textAppearance="?android:attr/textAppearanceLarge"
- android:visibility="invisible" />
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/apps_list"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ settings:fastScrollEnabled="true"
+ settings:fastScrollHorizontalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollHorizontalTrackDrawable="@drawable/line_drawable"
+ settings:fastScrollVerticalThumbDrawable="@drawable/thumb_drawable"
+ settings:fastScrollVerticalTrackDrawable="@drawable/line_drawable"/>
- </FrameLayout>
+ <TextView
+ android:id="@android:id/empty"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:layout_gravity="center"
+ android:text="@string/no_applications"
+ android:textAppearance="?android:attr/textAppearanceLarge"
+ android:visibility="invisible"/>
- </LinearLayout>
+ </FrameLayout>
- <include layout="@layout/loading_container" />
+ </LinearLayout>
- </FrameLayout>
+ <include layout="@layout/loading_container"/>
-</LinearLayout>
+ </FrameLayout>
+
+ </androidx.core.widget.NestedScrollView>
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ <FrameLayout
+ android:id="@+id/pinned_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ settings:layout_scrollFlags="scroll|enterAlways"/>
+ </com.google.android.material.appbar.AppBarLayout>
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/layout/master_clear.xml b/res/layout/master_clear.xml
index 83b02ff..9c1dd80 100644
--- a/res/layout/master_clear.xml
+++ b/res/layout/master_clear.xml
@@ -21,9 +21,9 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:theme="@style/SuwThemeGlifV3.DayNight"
+ android:theme="@style/SudThemeGlifV3.DayNight"
android:icon="@drawable/ic_delete_accent"
- app:suwHeaderText="@string/master_clear_title">
+ app:sucHeaderText="@string/master_clear_title">
<ScrollView
android:id="@+id/master_clear_scrollview"
@@ -34,33 +34,33 @@
<LinearLayout
android:id="@+id/master_clear_container"
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/master_clear_desc"/>
<TextView
android:id="@+id/also_erases_external"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_also_erases_external"/>
<TextView
android:id="@+id/also_erases_esim"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_also_erases_esim"/>
<TextView
android:id="@+id/accounts_label"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
@@ -76,21 +76,21 @@
</LinearLayout>
<TextView
android:id="@+id/other_users_present"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_other_users_present"/>
<TextView
android:id="@+id/no_cancel_mobile_plan"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="@string/master_clear_desc_no_cancel_mobile_plan"/>
<TextView
android:id="@+id/erase_external_option_text"
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/master_clear_desc_erase_external_storage"/>
@@ -103,7 +103,7 @@
android:clickable="true">
<CheckBox
android:id="@+id/erase_external"
- style="@style/SuwCheckBox"
+ style="@style/SudCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
@@ -116,12 +116,12 @@
android:layout_gravity="center_vertical"
android:orientation="vertical">
<TextView
- style="@style/TextAppearance.SuwGlifItemTitle"
+ style="@style/TextAppearance.SudGlifItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/erase_external_storage"/>
<TextView
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/erase_external_storage_description"/>
diff --git a/res/layout/master_clear_account.xml b/res/layout/master_clear_account.xml
index 0b522f2..f95a44f 100644
--- a/res/layout/master_clear_account.xml
+++ b/res/layout/master_clear_account.xml
@@ -20,7 +20,7 @@
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
- style="@style/SuwDescription.Glif" >
+ style="@style/SudDescription.Glif" >
<ImageView
android:id="@android:id/icon"
android:layout_width="56dp"
@@ -30,6 +30,6 @@
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- style="@style/TextAppearance.SuwGlifItemSummary"/>
+ style="@style/TextAppearance.SudGlifItemSummary"/>
</LinearLayout>
diff --git a/res/layout/master_clear_confirm.xml b/res/layout/master_clear_confirm.xml
index 2acdfce..b4c0270 100644
--- a/res/layout/master_clear_confirm.xml
+++ b/res/layout/master_clear_confirm.xml
@@ -19,20 +19,20 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:theme="@style/SuwThemeGlifV3.DayNight"
+ android:theme="@style/SudThemeGlifV3.DayNight"
android:id="@+id/setup_wizard_layout"
android:icon="@drawable/ic_delete_accent"
- app:suwHeaderText="@string/master_clear_confirm_title">
+ app:sucHeaderText="@string/master_clear_confirm_title">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/master_clear_confirm"
- style="@style/SuwItemTitle.GlifDescription"
+ style="@style/SudItemTitle.GlifDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/master_clear_final_desc"/>
diff --git a/res/layout/password_requirement_item.xml b/res/layout/password_requirement_item.xml
index 8080f10..ff7e04c 100644
--- a/res/layout/password_requirement_item.xml
+++ b/res/layout/password_requirement_item.xml
@@ -18,5 +18,5 @@
android:id="@+id/description_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:gravity="?attr/suwGlifHeaderGravity"
+ android:gravity="?attr/sudGlifHeaderGravity"
android:textSize="14sp"/>
diff --git a/res/layout/preference.xml b/res/layout/preference.xml
index cf85e5d..195671b 100644
--- a/res/layout/preference.xml
+++ b/res/layout/preference.xml
@@ -35,7 +35,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
@@ -48,7 +48,7 @@
android:layout_alignStart="@android:id/title"
android:visibility="gone"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="10" />
diff --git a/res/layout/preference_multiline_title.xml b/res/layout/preference_multiline_title.xml
index 16c25d5..ae93ead 100644
--- a/res/layout/preference_multiline_title.xml
+++ b/res/layout/preference_multiline_title.xml
@@ -34,7 +34,7 @@
android:id="@android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
@@ -47,7 +47,7 @@
android:layout_alignStart="@android:id/title"
android:visibility="gone"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="10" />
diff --git a/res/layout/preference_progress_category.xml b/res/layout/preference_progress_category.xml
index 2ac3dc1..91a0312 100644
--- a/res/layout/preference_progress_category.xml
+++ b/res/layout/preference_progress_category.xml
@@ -46,7 +46,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="start|center"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:textColor="?android:attr/colorAccent"/>
<ProgressBar
diff --git a/res/layout/preference_volume_slider.xml b/res/layout/preference_volume_slider.xml
index da3a028..34c732d 100644
--- a/res/layout/preference_volume_slider.xml
+++ b/res/layout/preference_volume_slider.xml
@@ -58,7 +58,7 @@
android:layout_weight="1"
android:paddingStart="12dp"
android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary"
android:ellipsize="marquee"
android:fadingEdge="horizontal"/>
@@ -94,7 +94,7 @@
android:singleLine="true"
android:ellipsize="end"
android:visibility="gone"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"/>
</LinearLayout>
diff --git a/res/layout/preference_widget_seekbar_settings.xml b/res/layout/preference_widget_seekbar_settings.xml
index fb1e9c8..9893a1b 100644
--- a/res/layout/preference_widget_seekbar_settings.xml
+++ b/res/layout/preference_widget_seekbar_settings.xml
@@ -35,7 +35,7 @@
android:paddingStart="56dp"
android:paddingEnd="8dp"
android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary" />
<TextView
diff --git a/res/layout/preset_picker_item.xml b/res/layout/preset_picker_item.xml
index 405b735..47887e1 100644
--- a/res/layout/preset_picker_item.xml
+++ b/res/layout/preset_picker_item.xml
@@ -44,6 +44,6 @@
android:maxLines="2"
android:minLines="2"
android:gravity="top|center_horizontal"
- android:textAppearance="@android:style/TextAppearance.Material.Body1" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" />
</LinearLayout>
diff --git a/res/layout/preview_seek_bar_view_pager.xml b/res/layout/preview_seek_bar_view_pager.xml
index 264991a..12f2611 100644
--- a/res/layout/preview_seek_bar_view_pager.xml
+++ b/res/layout/preview_seek_bar_view_pager.xml
@@ -36,7 +36,7 @@
android:paddingStart="32dp"
android:gravity="start|center"
android:text="@string/screen_zoom_preview_title"
- android:textAppearance="@android:style/TextAppearance.Material.Widget.ActionBar.Title"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title"
android:importantForAccessibility="no" />
</LinearLayout>
diff --git a/res/layout/redaction_interstitial.xml b/res/layout/redaction_interstitial.xml
index 929ac07..f911572 100644
--- a/res/layout/redaction_interstitial.xml
+++ b/res/layout/redaction_interstitial.xml
@@ -22,11 +22,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:icon="@drawable/ic_suggested_notifications"
- settings:sucFooter="@layout/redaction_interstitial_footer"
- settings:suwHeaderText="@string/lock_screen_notifications_interstitial_title">
+ settings:sucHeaderText="@string/lock_screen_notifications_interstitial_title">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
@@ -35,7 +34,7 @@
<TextView
android:id="@+id/message"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lock_screen_notifications_interstitial_message" />
@@ -49,7 +48,7 @@
<com.android.settings.RestrictedRadioButton
android:id="@+id/show_all"
- style="@style/SuwRadioButton"
+ style="@style/SudRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
@@ -58,7 +57,7 @@
<com.android.settings.RestrictedRadioButton
android:id="@+id/redact_sensitive"
- style="@style/SuwRadioButton"
+ style="@style/SudRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
@@ -67,7 +66,7 @@
<RadioButton
android:id="@+id/hide_all"
- style="@style/SuwRadioButton"
+ style="@style/SudRadioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
diff --git a/res/layout/redaction_interstitial_footer.xml b/res/layout/redaction_interstitial_footer.xml
deleted file mode 100644
index 1d8758b..0000000
--- a/res/layout/redaction_interstitial_footer.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License
--->
-
-<!-- TODO: Use aapt:attr when it is fixed (b/36809755) -->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwGlifButtonBar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Button
- android:id="@+id/redaction_done_button"
- style="@style/SuwGlifButton.Primary"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:text="@string/app_notifications_dialog_done" />
-
-</FrameLayout>
diff --git a/res/layout/reset_esim_checkbox.xml b/res/layout/reset_esim_checkbox.xml
index e2ae4bb..2195435 100644
--- a/res/layout/reset_esim_checkbox.xml
+++ b/res/layout/reset_esim_checkbox.xml
@@ -15,7 +15,7 @@
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwDescription"
+ style="@style/SudDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
@@ -25,7 +25,7 @@
<CheckBox
android:id="@+id/erase_esim"
- style="@style/SuwCheckBox"
+ style="@style/SudCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
@@ -42,12 +42,12 @@
<TextView
android:id="@+id/erase_esim_title"
- style="@style/TextAppearance.SuwGlifItemTitle"
+ style="@style/TextAppearance.SudGlifItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
- style="@style/TextAppearance.SuwGlifItemSummary"
+ style="@style/TextAppearance.SudGlifItemSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset_esim_desc"/>
diff --git a/res/layout/running_processes_header.xml b/res/layout/running_processes_header.xml
index a696b38..b2db025 100644
--- a/res/layout/running_processes_header.xml
+++ b/res/layout/running_processes_header.xml
@@ -30,7 +30,7 @@
android:layout_height="48dp"
android:singleLine="true"
android:ellipsize="marquee"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:textColor="?android:attr/textColorPrimary"
android:textAlignment="viewStart"
android:gravity="left|center_vertical"
@@ -63,7 +63,7 @@
<TextView
android:id="@+id/systemSizePrefix"
android:text="@string/running_processes_header_system_prefix"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -81,7 +81,7 @@
android:contentDescription="@null" />
<TextView
android:id="@+id/systemSize"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -108,7 +108,7 @@
<TextView
android:id="@+id/appsSizePrefix"
android:text="@string/running_processes_header_apps_prefix"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -126,7 +126,7 @@
android:contentDescription="@null" />
<TextView
android:id="@+id/appsSize"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -153,7 +153,7 @@
<TextView
android:id="@+id/freeSizePrefix"
android:text="@string/running_processes_header_free_prefix"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -171,7 +171,7 @@
android:contentDescription="@null" />
<TextView
android:id="@+id/freeSize"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
@@ -186,7 +186,7 @@
android:layout_marginTop="8dp"
android:singleLine="true"
android:ellipsize="marquee"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:textColor="?android:attr/textColorPrimary"
android:textAlignment="viewStart"
android:gravity="left|center_vertical"
diff --git a/res/layout/running_processes_item.xml b/res/layout/running_processes_item.xml
index 036a90e..45121eb 100644
--- a/res/layout/running_processes_item.xml
+++ b/res/layout/running_processes_item.xml
@@ -48,7 +48,7 @@
android:layout_weight="1"
android:singleLine="true"
android:ellipsize="marquee"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textAlignment="viewStart" />
<TextView
@@ -56,7 +56,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
@@ -70,7 +70,7 @@
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="viewStart" />
@@ -79,7 +79,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
diff --git a/res/layout/screen_zoom_activity.xml b/res/layout/screen_zoom_activity.xml
index 0141019..4cfa7b6 100644
--- a/res/layout/screen_zoom_activity.xml
+++ b/res/layout/screen_zoom_activity.xml
@@ -48,7 +48,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:padding="6dp"
- android:textAppearance="@android:style/TextAppearance.Material.Widget.TextView"
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.Widget.TextView"
android:elevation="2dp" />
<LinearLayout
@@ -93,7 +93,7 @@
android:layout_height="wrap_content"
android:text="@string/screen_zoom_summary"
android:layout_marginBottom="16dp"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead" />
</LinearLayout>
</LinearLayout>
</ScrollView>
diff --git a/res/layout/screen_zoom_preview_app_icon.xml b/res/layout/screen_zoom_preview_app_icon.xml
index 087afb8..1d56410 100644
--- a/res/layout/screen_zoom_preview_app_icon.xml
+++ b/res/layout/screen_zoom_preview_app_icon.xml
@@ -37,5 +37,5 @@
android:ellipsize="end"
android:gravity="center_horizontal|top"
android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Caption" />
-</LinearLayout>
\ No newline at end of file
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Caption" />
+</LinearLayout>
diff --git a/res/layout/screen_zoom_preview_settings.xml b/res/layout/screen_zoom_preview_settings.xml
index 9a0cc59..3401fcf 100644
--- a/res/layout/screen_zoom_preview_settings.xml
+++ b/res/layout/screen_zoom_preview_settings.xml
@@ -57,7 +57,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wifi_settings"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary" />
@@ -65,7 +65,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/wifi_display_status_not_available"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</LinearLayout>
@@ -96,14 +96,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/data_usage_summary_title"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_data_usage"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</LinearLayout>
@@ -134,14 +134,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/display_settings_title"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/display_summary_example"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</LinearLayout>
@@ -172,14 +172,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sound_settings"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sound_settings_example_summary"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</LinearLayout>
@@ -210,14 +210,14 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/applications_settings"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/apps_summary_example"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</LinearLayout>
diff --git a/res/layout/settings_homepage_container.xml b/res/layout/settings_homepage_container.xml
index 75d449f..1e5bdce 100644
--- a/res/layout/settings_homepage_container.xml
+++ b/res/layout/settings_homepage_container.xml
@@ -31,8 +31,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
- android:paddingTop="@dimen/app_bar_height"
- android:descendantFocusability="blocksDescendants">
+ android:descendantFocusability="blocksDescendants"
+ android:paddingTop="104dp">
+ <!-- height of status bar(24dp) + height of action bar(48dp) + top/bottom margins(16dp) -->
<FrameLayout
android:id="@+id/contextual_cards_content"
@@ -52,6 +53,13 @@
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
+
+ <Space
+ android:layout_width="match_parent"
+ android:layout_height="@*android:dimen/status_bar_height"
+ android:background="@android:color/transparent"
+ app:layout_scrollFlags="scroll|enterAlways"/>
+
<include layout="@layout/search_bar"/>
</com.google.android.material.appbar.AppBarLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/res/layout/settings_summary_preference.xml b/res/layout/settings_summary_preference.xml
index ae3b70d..e76190f 100644
--- a/res/layout/settings_summary_preference.xml
+++ b/res/layout/settings_summary_preference.xml
@@ -31,7 +31,7 @@
android:fontFamily="@*android:string/config_headlineFontFamily"
android:paddingTop="0dp"
android:textColor="?android:attr/colorAccent"
- android:textAppearance="@android:style/TextAppearance.Material.Display1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Display1"
/>
<TextView android:id="@android:id/summary"
diff --git a/res/layout/setup_choose_lock_generic_biometrics_header.xml b/res/layout/setup_choose_lock_generic_biometrics_header.xml
index ca808e8..daeeedd 100644
--- a/res/layout/setup_choose_lock_generic_biometrics_header.xml
+++ b/res/layout/setup_choose_lock_generic_biometrics_header.xml
@@ -16,11 +16,11 @@
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="@dimen/suw_description_glif_margin_top"
- android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
+ android:paddingTop="@dimen/sud_description_glif_margin_top"
+ android:paddingBottom="@dimen/sud_description_glif_margin_bottom_lists"
android:text="@string/lock_settings_picker_biometrics_added_security_message" />
diff --git a/res/layout/setup_choose_lock_generic_header.xml b/res/layout/setup_choose_lock_generic_header.xml
index 8875e1f..7ec16d2 100644
--- a/res/layout/setup_choose_lock_generic_header.xml
+++ b/res/layout/setup_choose_lock_generic_header.xml
@@ -16,11 +16,11 @@
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
- android:paddingTop="@dimen/suw_description_glif_margin_top"
- android:paddingBottom="@dimen/suw_description_glif_margin_bottom_lists"
+ android:paddingTop="@dimen/sud_description_glif_margin_top"
+ android:paddingBottom="@dimen/sud_description_glif_margin_bottom_lists"
android:text="@string/setup_lock_settings_picker_message" />
diff --git a/res/layout/setup_screen_lock_fingerprint_details.xml b/res/layout/setup_screen_lock_fingerprint_details.xml
index 06ca778..fc4ed98 100644
--- a/res/layout/setup_screen_lock_fingerprint_details.xml
+++ b/res/layout/setup_screen_lock_fingerprint_details.xml
@@ -20,6 +20,6 @@
android:layout_height="wrap_content"
android:paddingTop="6dip"
android:paddingBottom="6dip"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
android:text="@string/unlock_setup_wizard_fingerprint_details" />
diff --git a/res/layout/storage_internal_forget.xml b/res/layout/storage_internal_forget.xml
index cb47d3b..a2b646e 100644
--- a/res/layout/storage_internal_forget.xml
+++ b/res/layout/storage_internal_forget.xml
@@ -28,12 +28,12 @@
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/suw_description_margin_top"
- android:paddingBottom="@dimen/suw_description_margin_bottom"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:paddingTop="@dimen/sud_description_margin_top"
+ android:paddingBottom="@dimen/sud_description_margin_bottom"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorPrimary" />
</ScrollView>
diff --git a/res/layout/storage_internal_format.xml b/res/layout/storage_internal_format.xml
index 8aec28f..08434b0 100644
--- a/res/layout/storage_internal_format.xml
+++ b/res/layout/storage_internal_format.xml
@@ -28,12 +28,12 @@
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/suw_description_margin_top"
- android:paddingBottom="@dimen/suw_description_margin_bottom"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:paddingTop="@dimen/sud_description_margin_top"
+ android:paddingBottom="@dimen/sud_description_margin_bottom"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorPrimary" />
</ScrollView>
diff --git a/res/layout/storage_internal_unmount.xml b/res/layout/storage_internal_unmount.xml
index 7e728c8..2ae489c 100644
--- a/res/layout/storage_internal_unmount.xml
+++ b/res/layout/storage_internal_unmount.xml
@@ -28,12 +28,12 @@
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:paddingTop="@dimen/suw_description_margin_top"
- android:paddingBottom="@dimen/suw_description_margin_bottom"
- android:paddingStart="@dimen/suw_layout_margin_sides"
- android:paddingEnd="@dimen/suw_layout_margin_sides"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:paddingTop="@dimen/sud_description_margin_top"
+ android:paddingBottom="@dimen/sud_description_margin_bottom"
+ android:paddingStart="@dimen/sud_layout_margin_sides"
+ android:paddingEnd="@dimen/sud_layout_margin_sides"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorPrimary" />
</ScrollView>
diff --git a/res/layout/storage_item.xml b/res/layout/storage_item.xml
index aa2b4f8..cefb399 100644
--- a/res/layout/storage_item.xml
+++ b/res/layout/storage_item.xml
@@ -61,7 +61,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textAlignment="viewStart"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
@@ -71,7 +71,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="10"
android:layout_alignParentEnd="true"/>
diff --git a/res/layout/storage_summary.xml b/res/layout/storage_summary.xml
index d48d62d..ce03b54 100644
--- a/res/layout/storage_summary.xml
+++ b/res/layout/storage_summary.xml
@@ -35,7 +35,7 @@
android:fontFamily="@*android:string/config_headlineFontFamily"
android:singleLine="true"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/colorAccent"
android:textSize="36sp"/>
@@ -44,7 +44,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:maxLines="10" />
<ProgressBar
diff --git a/res/layout/storage_summary_donut.xml b/res/layout/storage_summary_donut.xml
index 7a10fe7..1637189 100644
--- a/res/layout/storage_summary_donut.xml
+++ b/res/layout/storage_summary_donut.xml
@@ -32,7 +32,7 @@
android:fontFamily="@*android:string/config_headlineFontFamily"
android:singleLine="true"
android:textAlignment="center"
- android:textAppearance="@android:style/TextAppearance.Material.Display1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Display1"
android:textSize="36sp" />
<TextView
@@ -43,7 +43,7 @@
android:layout_marginEnd="4dp"
android:maxLines="10"
android:textAlignment="center"
- android:textAppearance="@android:style/TextAppearance.Material.Body1" />
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1" />
<com.android.settings.widget.DonutView
android:id="@+id/donut"
diff --git a/res/layout/storage_wizard_checklist.xml b/res/layout/storage_wizard_checklist.xml
index 6f21bb8..842cbdb 100644
--- a/res/layout/storage_wizard_checklist.xml
+++ b/res/layout/storage_wizard_checklist.xml
@@ -22,36 +22,36 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist" />
<TextView
android:id="@+id/storage_wizard_migrate_v2_checklist_media"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist_media"
android:drawableStart="@drawable/ic_sd_card"
android:drawableTint="?android:attr/textColorSecondary"
- android:drawablePadding="@dimen/suw_description_margin_bottom" />
+ android:drawablePadding="@dimen/sud_description_margin_bottom" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist_apps"
android:drawableStart="@drawable/ic_apps_alt"
android:drawableTint="?android:attr/textColorSecondary"
- android:drawablePadding="@dimen/suw_description_margin_bottom" />
+ android:drawablePadding="@dimen/sud_description_margin_bottom" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorPrimary"
android:text="@string/storage_wizard_migrate_v2_checklist_battery"
android:drawableStart="@drawable/ic_battery_charging_full"
android:drawableTint="?android:attr/textColorSecondary"
- android:drawablePadding="@dimen/suw_description_margin_bottom" />
+ android:drawablePadding="@dimen/sud_description_margin_bottom" />
</LinearLayout>
diff --git a/res/layout/storage_wizard_generic.xml b/res/layout/storage_wizard_generic.xml
index 0e7c1fd..2b96101 100644
--- a/res/layout/storage_wizard_generic.xml
+++ b/res/layout/storage_wizard_generic.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -31,8 +31,8 @@
android:id="@+id/storage_wizard_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textColor="?android:attr/textColorPrimary" />
<FrameLayout
diff --git a/res/layout/storage_wizard_init.xml b/res/layout/storage_wizard_init.xml
index 73af8da..d02e871 100644
--- a/res/layout/storage_wizard_init.xml
+++ b/res/layout/storage_wizard_init.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -30,7 +30,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
@@ -42,23 +42,23 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginStart="@dimen/suw_glif_margin_sides"
+ android:layout_marginStart="@dimen/sud_glif_margin_sides"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:text="@string/storage_wizard_init_v2_internal_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorSecondary"
android:text="@string/storage_wizard_init_v2_internal_summary" />
<Button
android:id="@+id/storage_wizard_init_internal"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/storage_wizard_init_v2_internal_action"
@@ -69,7 +69,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:orientation="horizontal"
android:gravity="center_vertical">
<View
@@ -97,7 +97,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
@@ -109,23 +109,23 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
- android:layout_marginStart="@dimen/suw_glif_margin_sides"
+ android:layout_marginStart="@dimen/sud_glif_margin_sides"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:text="@string/storage_wizard_init_v2_external_title" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="@dimen/suw_description_margin_bottom"
+ android:layout_marginBottom="@dimen/sud_description_margin_bottom"
android:textColor="?android:attr/textColorSecondary"
android:text="@string/storage_wizard_init_v2_external_summary" />
<Button
android:id="@+id/storage_wizard_init_external"
- style="@style/SuwGlifButton.Primary"
+ style="@style/SudGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/storage_wizard_init_v2_external_action"
diff --git a/res/layout/storage_wizard_progress.xml b/res/layout/storage_wizard_progress.xml
index a68750f..cf5bc43 100644
--- a/res/layout/storage_wizard_progress.xml
+++ b/res/layout/storage_wizard_progress.xml
@@ -22,7 +22,7 @@
android:layout_height="match_parent">
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
@@ -31,22 +31,22 @@
android:id="@+id/storage_wizard_progress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
android:indeterminate="false"
style="?android:attr/progressBarStyleHorizontal" />
<TextView
android:id="@+id/storage_wizard_progress_summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textColor="?android:attr/textColorSecondary" />
<TextView
android:id="@+id/storage_wizard_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_margin_top"
- android:lineSpacingExtra="@dimen/suw_description_line_spacing_extra"
+ android:layout_marginTop="@dimen/sud_description_margin_top"
+ android:lineSpacingExtra="@dimen/sud_description_line_spacing_extra"
android:textColor="?android:attr/textColorPrimary"
android:visibility="gone" />
diff --git a/res/layout/tall_preference_category.xml b/res/layout/tall_preference_category.xml
index f0630f8..7eefdab 100644
--- a/res/layout/tall_preference_category.xml
+++ b/res/layout/tall_preference_category.xml
@@ -21,7 +21,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dip"
- android:textAppearance="@android:style/TextAppearance.Material.Body2"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body2"
android:textColor="?android:attr/colorAccent"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
diff --git a/res/layout/text_description_preference.xml b/res/layout/text_description_preference.xml
index 6b8594b..70385aa 100644
--- a/res/layout/text_description_preference.xml
+++ b/res/layout/text_description_preference.xml
@@ -18,5 +18,5 @@
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:padding="16dip" />
diff --git a/res/layout/time_zone_search_item.xml b/res/layout/time_zone_search_item.xml
index bb75226..8d059a8 100644
--- a/res/layout/time_zone_search_item.xml
+++ b/res/layout/time_zone_search_item.xml
@@ -63,7 +63,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
- android:textAppearance="@style/Preference_TextAppearanceMaterialSubhead"
+ android:textAppearance="?android:attr/textAppearanceListItem"
android:ellipsize="marquee" />
<RelativeLayout
diff --git a/res/layout/widget_text_views.xml b/res/layout/widget_text_views.xml
index d95599d..9f0506e 100644
--- a/res/layout/widget_text_views.xml
+++ b/res/layout/widget_text_views.xml
@@ -26,7 +26,7 @@
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="fill_horizontal|top"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="viewStart"
android:singleLine="true"
@@ -40,7 +40,7 @@
android:layout_weight="1"
android:layout_marginStart="8dip"
android:layout_gravity="fill_horizontal|top"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:textAlignment="viewEnd"
android:singleLine="true"
diff --git a/res/layout/wifi_dialog.xml b/res/layout/wifi_dialog.xml
index 2a395b6..df676fc 100644
--- a/res/layout/wifi_dialog.xml
+++ b/res/layout/wifi_dialog.xml
@@ -68,7 +68,7 @@
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@null"
- android:src="@drawable/ic_qrcode_24dp"
+ android:src="@drawable/ic_scan_24dp"
android:visibility="gone"
android:contentDescription="@string/wifi_add_network" />
</RelativeLayout>
@@ -303,7 +303,7 @@
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:background="@null"
- android:src="@drawable/ic_qrcode_24dp"
+ android:src="@drawable/ic_scan_24dp"
android:visibility="gone"
android:contentDescription="@string/wifi_add_network" />
</RelativeLayout>
diff --git a/res/layout/wifi_dpp_add_device_fragment.xml b/res/layout/wifi_dpp_add_device_fragment.xml
index 03add62..2d1ce5b 100644
--- a/res/layout/wifi_dpp_add_device_fragment.xml
+++ b/res/layout/wifi_dpp_add_device_fragment.xml
@@ -15,34 +15,49 @@
limitations under the License.
-->
-<LinearLayout
+<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <ProgressBar
- android:id="@+id/progress_bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:indeterminate="true"/>
-
- <ImageView
- android:id="@+id/wifi_ap_picture_view"
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"/>
+ android:layout_height="match_parent">
- <TextView android:id="@+id/choose_different_network"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ImageView
+ android:id="@+id/wifi_ap_picture_view"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintTop_toBottomOf="@+id/header"/>
+
+ <Button
+ android:id="@+id/choose_different_network"
+ style="@style/SuwGlifButton.Secondary"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintTop_toBottomOf="@+id/wifi_ap_picture_view"
+ android:layout_marginTop="8dp"
+ android:text="@string/wifi_dpp_choose_different_network"/>
+
+ </LinearLayout>
+
+ </ScrollView>
+
+ <include
+ layout="@layout/wifi_dpp_fragment_footer"
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_gravity="center"/>
+ app:layout_constraintBottom_toBottomOf="parent"/>
- <include layout="@layout/wifi_dpp_fragment_footer"
- android:gravity="center|bottom"/>
-
-</LinearLayout>
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
index a65cf3e..c3fccd0 100644
--- a/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
+++ b/res/layout/wifi_dpp_choose_saved_wifi_network_fragment.xml
@@ -15,21 +15,39 @@
limitations under the License.
-->
-<LinearLayout
+<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <ListView android:id="@+id/saved_wifi_network_list"
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_footer"
- android:gravity="center|bottom"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
-</LinearLayout>
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ListView android:id="@+id/saved_wifi_network_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_constraintTop_toBottomOf="@+id/header"/>
+
+ </LinearLayout>
+
+ </ScrollView>
+
+ <include
+ layout="@layout/wifi_dpp_fragment_footer"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="parent"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/res/layout/wifi_dpp_fragment_footer.xml b/res/layout/wifi_dpp_fragment_footer.xml
index 98c6485..36ec1d7 100644
--- a/res/layout/wifi_dpp_fragment_footer.xml
+++ b/res/layout/wifi_dpp_fragment_footer.xml
@@ -18,16 +18,15 @@
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal">
+ android:layout_height="wrap_content"
+ style="@style/SuwGlifButtonBar">
<Button
android:id="@+id/button_left"
+ style="@style/SuwGlifButton.Secondary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|start"
- android:text="left"
- style="?android:attr/borderlessButtonStyle"/>
+ android:layout_gravity="start"/>
<Space
android:layout_width="0dp"
@@ -36,9 +35,9 @@
<Button
android:id="@+id/button_right"
+ style="@style/SuwGlifButton.Primary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:layout_gravity="bottom|end"
- android:text="right"/>
+ android:layout_gravity="end"/>
</LinearLayout>
diff --git a/res/layout/wifi_dpp_fragment_header.xml b/res/layout/wifi_dpp_fragment_header.xml
index 266a3e8..20bcd7d 100644
--- a/res/layout/wifi_dpp_fragment_header.xml
+++ b/res/layout/wifi_dpp_fragment_header.xml
@@ -27,13 +27,13 @@
android:paddingEnd="16dp">
<ImageView
- android:id="@+id/header_icon"
+ android:id="@android:id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:scaleType="fitCenter"/>
<TextView
- android:id="@+id/title"
+ android:id="@android:id/title"
style="@style/TextAppearance.EntityHeaderTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -44,7 +44,7 @@
android:paddingEnd="32dp"/>
<TextView
- android:id="@+id/description"
+ android:id="@android:id/summary"
style="@style/TextAppearance.EntityHeaderSummary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/res/layout/wifi_dpp_qrcode_generator_fragment.xml b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
index 789b3a3..2617aea 100644
--- a/res/layout/wifi_dpp_qrcode_generator_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_generator_fragment.xml
@@ -22,13 +22,27 @@
android:layout_height="match_parent"
android:orientation="vertical">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <ImageView
- android:id="@+id/barcode_view"
+ <ScrollView
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="center"/>
+ android:layout_height="match_parent">
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <ImageView
+ android:id="@+id/qrcode_view"
+ android:layout_width="@dimen/qrcode_size"
+ android:layout_height="@dimen/qrcode_size"
+ android:src="@android:color/transparent"/>
+
+ </LinearLayout>
+
+ </ScrollView>
</LinearLayout>
diff --git a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
index 913998f..c5e416b 100644
--- a/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
+++ b/res/layout/wifi_dpp_qrcode_scanner_fragment.xml
@@ -19,30 +19,45 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical">
+ android:layout_height="match_parent">
- <include layout="@layout/wifi_dpp_fragment_header"/>
-
- <com.android.settings.wifi.qrcode.QrPreviewLayout
+ <ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
- <TextureView
- android:id="@+id/preview_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
- <com.android.settings.wifi.qrcode.QrDecorateView
- android:id="@+id/decorate_view"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
- </com.android.settings.wifi.qrcode.QrPreviewLayout>
- <TextView android:id="@+id/error_message"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center"/>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ android:gravity="center_horizontal">
+
+ <include layout="@layout/wifi_dpp_fragment_header"/>
+
+ <com.android.settings.wifi.qrcode.QrPreviewLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TextureView
+ android:id="@+id/preview_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ <com.android.settings.wifi.qrcode.QrDecorateView
+ android:id="@+id/decorate_view"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"/>
+ </com.android.settings.wifi.qrcode.QrPreviewLayout>
+
+ <TextView
+ android:id="@+id/error_message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dp"
+ android:text="@string/wifi_dpp_could_not_detect_valid_qr_code"
+ android:visibility="invisible"
+ android:textColor="?android:attr/colorError"/>
+
+ </LinearLayout>
+
+ </ScrollView>
</LinearLayout>
diff --git a/res/layout/zen_onboarding.xml b/res/layout/zen_onboarding.xml
index 35b992d..27922c6 100644
--- a/res/layout/zen_onboarding.xml
+++ b/res/layout/zen_onboarding.xml
@@ -32,7 +32,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/zen_onboarding_dnd_visual_disturbances_header"
- android:textAppearance="@android:style/TextAppearance.Material.DialogWindowTitle" />
+ android:textAppearance="@android:style/TextAppearance.DeviceDefault.DialogWindowTitle" />
<LinearLayout
android:id="@+id/zen_onboarding_new_setting"
diff --git a/res/layout/zen_rule_type.xml b/res/layout/zen_rule_type.xml
index dea39ed..bd50273 100644
--- a/res/layout/zen_rule_type.xml
+++ b/res/layout/zen_rule_type.xml
@@ -42,7 +42,7 @@
android:singleLine="true"
android:textSize="16sp"
android:ellipsize="marquee"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:fadingEdge="horizontal" />
<TextView android:id="@+id/subtitle"
@@ -52,7 +52,7 @@
android:layout_alignStart="@id/title"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:maxLines="2"
android:visibility="gone" />
diff --git a/res/layout/zen_rule_widget.xml b/res/layout/zen_rule_widget.xml
index c6214e7..3d75469 100644
--- a/res/layout/zen_rule_widget.xml
+++ b/res/layout/zen_rule_widget.xml
@@ -19,14 +19,7 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
- <ImageView
- android:id="@+id/zen_automatic_rule_widget"
- android:layout_width="wrap_content"
- android:layout_height="fill_parent"
- android:paddingStart="16dip"
- android:paddingEnd="16dip"
- android:src="@drawable/ic_settings"
- android:contentDescription="zen_mode_rule_settings"
- android:layout_gravity="center"
- android:background="?android:attr/selectableItemBackground" />
+
+ <include layout="@layout/preference_widget_gear"
+ android:id="@+id/zen_automatic_rule_widget" />
</LinearLayout>
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index bc06f47..cdbeada 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -21,5 +21,8 @@
<color name="switchbar_switch_thumb_tint">@android:color/black</color>
<color name="homepage_accessibility_background">#783BE5</color>
<color name="homepage_support_background">#3F5FBD</color>
+ <!-- 80% black for status bar of homepage -->
+ <color name="homepage_status_bar_color">#cc000000</color>
+ <color name="homepage_card_dismissal_background">@*android:color/material_grey_800</color>
</resources>
diff --git a/res/values/aliases.xml b/res/values/aliases.xml
index 060ba1d..881d3ca 100644
--- a/res/values/aliases.xml
+++ b/res/values/aliases.xml
@@ -15,7 +15,6 @@
-->
<resources>
- <item name="notification_app_section" type="layout">@*android:layout/preference_category_material</item>
<item name="confirm_lock_pattern" type="layout">@layout/confirm_lock_pattern_base</item>
<item name="confirm_lock_pattern_normal" type="layout">@layout/confirm_lock_pattern_normal_base</item>
<item name="confirm_lock_password" type="layout">@layout/confirm_lock_password_base</item>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index e80d151..6f336eb 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1105,8 +1105,8 @@
</string-array>
<string-array name="wifi_privacy_entries">
- <item>Default (use randomized MAC)</item>
- <item>Trusted</item>
+ <item>Use device MAC</item>
+ <item>Use randomized MAC (default)</item>
</string-array>
<string-array name="wifi_hidden_entries">
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 587184b..da01be0 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -30,7 +30,7 @@
<color name="title_color">@android:color/holo_blue_light</color>
<color name="setup_lock_pattern_view_regular_color_light">@color/lock_pattern_view_regular_color</color>
<color name="setup_lock_pattern_view_success_color_dark">#ff84ffff</color>
- <color name="setup_lock_pattern_view_success_color_light">@color/suw_color_accent_light</color>
+ <color name="setup_lock_pattern_view_success_color_light">@color/sud_color_accent_light</color>
<color name="setup_lock_pattern_view_error_color_dark">#fff44336</color>
<color name="setup_wizard_wifi_color_dark">#89ffffff</color>
<color name="setup_wizard_wifi_color_light">#89000000</color>
@@ -104,6 +104,7 @@
<color name="homepage_about_background">#9FA8DA</color>
<color name="homepage_privacy_background">#5E97F6</color>
<color name="homepage_card_stroke_color">#1f000000</color>
+ <color name="homepage_card_dismissal_background">@*android:color/material_grey_50</color>
<!-- End of dashboard/homepage icon background colors -->
<color name="switchbar_text_color">@android:color/white</color>
@@ -128,5 +129,13 @@
<!-- launcher icon color -->
<color name="icon_launcher_setting_color">@*android:color/accent_device_default_light</color>
-</resources>
+ <!-- 80% white for status bar of homepage -->
+ <color name="homepage_status_bar_color">#ccFFFFFF</color>
+
+ <!-- QR code scanner colors -->
+ <color name="qr_corner_line_color">#ffdadce0</color>
+ <color name="qr_focused_corner_line_color">#ff1a73e8</color>
+ <color name="qr_background_color">#b3ffffff</color> <!-- 70% white transparency -->
+ <!-- End of QR code scanner colors -->
+</resources>
\ No newline at end of file
diff --git a/res/values/config.xml b/res/values/config.xml
index 82e185c..1a504dd 100755
--- a/res/values/config.xml
+++ b/res/values/config.xml
@@ -171,4 +171,10 @@
<!-- ComponentName to launch a vendor-specific enrollment activity if available -->
<string name="config_face_enroll" translatable="false"></string>
+
+ <!-- Max allowed value for screen timeout, in milliseconds -->
+ <integer name="max_lock_after_timeout_ms">1800000</integer>
+
+ <!-- App intent -->
+ <string name="config_account_intent_uri" translatable="false"></string>
</resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index a109d57..1a3d6ff 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -105,8 +105,6 @@
<dimen name="search_bar_avatar_size">32dp</dimen>
<dimen name="search_bar_avatar_start_margin">4dp</dimen>
<dimen name="search_bar_avatar_end_margin">16dp</dimen>
- <!-- appbar height is equal search bar height (48dp) plus search bar top and bottom margin -->
- <dimen name="app_bar_height">80dp</dimen>
<!-- Dimensions for Wifi Assistant Card -->
<dimen name="wifi_assistant_padding_top_bottom">16dp</dimen>
@@ -116,6 +114,8 @@
<dimen name="wifi_assistant_height">182dp</dimen>
<dimen name="wifi_assistant_image_top">32dp</dimen>
<dimen name="wifi_assistant_image_start">24dp</dimen>
+ <!-- appbar height is equal search bar height (48dp) plus search bar top and bottom margin -->
+ <dimen name="app_bar_height">80dp</dimen>
<!-- CryptKeeper top margin for password/pin screen -->
<dimen name="crypt_keeper_password_top_margin">88dip</dimen>
@@ -332,6 +332,7 @@
<dimen name="homepage_half_card_padding_top">12dp</dimen>
<dimen name="homepage_half_card_padding_bottom">16dp</dimen>
<dimen name="homepage_half_card_title_margin_top">12dp</dimen>
+ <dimen name="homepage_card_dismissal_margin_bottom">2dp</dimen>
<!-- Horizontal divider size and margin -->
<dimen name="horizontal_divider_margin_top">4dp</dimen>
@@ -346,7 +347,6 @@
<!-- Condition cards size and padding -->
<dimen name="homepage_condition_card_title_margin_bottom">2dp</dimen>
- <dimen name="homepage_condition_half_card_height">150dp</dimen>
<dimen name="homepage_condition_half_card_padding_top">12dp</dimen>
<dimen name="homepage_condition_half_card_title_margin_top">12dp</dimen>
<dimen name="homepage_condition_half_card_summary_margin_bottom">12dp</dimen>
@@ -356,7 +356,7 @@
<dimen name="homepage_condition_full_card_padding_bottom">12dp</dimen>
<dimen name="homepage_condition_header_padding_top">10dp</dimen>
<dimen name="homepage_condition_header_padding_bottom">10dp</dimen>
- <dimen name="homepage_condition_header_icons_margin_start">24dp</dimen>
+ <dimen name="homepage_condition_header_icons_margin_start">16dp</dimen>
<dimen name="homepage_condition_header_indicator_padding_top">4dp</dimen>
<dimen name="homepage_condition_header_indicator_padding_start">16dp</dimen>
<dimen name="homepage_condition_header_indicator_padding_end">16dp</dimen>
@@ -366,4 +366,8 @@
<dimen name="homepage_condition_header_icon_width_height">24dp</dimen>
<dimen name="homepage_condition_header_icon_margin_end">24dp</dimen>
+ <!-- QR code picture size -->
+ <dimen name="qrcode_size">264dp</dimen>
+ <dimen name="qrcode_preview_size">360dp</dimen>
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e435b65..89a18b4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2077,19 +2077,39 @@
<!-- Label for the spinner to show Wifi MAC randomization [CHAR LIMIT=25] -->
<string name="wifi_privacy_settings">Privacy</string>
<!-- Title for the fragment to add a device into the wifi network [CHAR LIMIT=50] -->
- <string name="wifi_dpp_add_device_to_network">Add a device to this network</string>
+ <string name="wifi_dpp_add_device_to_network">Add a device</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=120] -->
- <string name="wifi_dpp_center_qr_code">Center the device\u2019s QR code below to add device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
+ <string name="wifi_dpp_center_qr_code">Center the QR code below to add the device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
<!-- Title for the fragment to scan QR code [CHAR LIMIT=50] -->
<string name="wifi_dpp_scan_qr_code">Scan QR code</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
- <string name="wifi_dpp_scan_qr_code_join_network">Join \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d by scanning a QR code</string>
+ <string name="wifi_dpp_scan_qr_code_join_network">Center the QR code below to connect to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
<!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
<string name="wifi_dpp_scan_qr_code_join_unknown_network">Join Wi\u2011Fi by scanning a QR code</string>
<!-- Title for the fragment to share Wi-Fi [CHAR LIMIT=50] -->
<string name="wifi_dpp_share_wifi">Share Wi\u2011Fi</string>
<!-- Hint for the user to use another device to scan QR code on screen to join Wi-Fi [CHAR LIMIT=NONE] -->
<string name="wifi_dpp_scan_qr_code_with_another_device">Scan this QR code with another device to join \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d</string>
+ <!-- Hint for QR code detection [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_could_not_detect_valid_qr_code">Couldn\u2019t read QR code</string>
+ <!-- Title for the fragment choose network [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_choose_network">Choose network</string>
+ <!-- Hint for the user to center another device's QR code in the below camera window [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_choose_network_to_connect_device">To connect your device, choose a network</string>
+ <!-- Hint for the user to add the device to a Wi-Fi network [CHAR LIMIT=NONE] -->
+ <string name="wifi_dpp_add_device_to_wifi">Add this device to \u201c<xliff:g id="ssid" example="OfficeWifi">%1$s</xliff:g>\u201d?</string>
+ <!-- Title for the fragment to tell the user that Wi-Fi shared with device successfully [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_wifi_shared_with_device">Wi\u2011Fi shared with device</string>
+ <!-- Button label to add another device to Wi-Fi [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_add_another_device">Add another device</string>
+ <!-- Button label to choose different Wi-Fi network [CHAR LIMIT=80] -->
+ <string name="wifi_dpp_choose_different_network">Choose different network</string>
+ <!-- Hint for QR code detection [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_could_not_add_device">Couldn\u2019t add device</string>
+ <!-- Title for the fragment to show that device found but naming known [CHAR LIMIT=50] -->
+ <string name="wifi_dpp_device_found">Device found</string>
+ <!-- Label for the try again button [CHAR LIMIT=20]-->
+ <string name="retry">Retry</string>
<!-- Label for the check box to share a network with other users on the same device -->
<string name="wifi_shared">Share with other device users</string>
<!-- Hint for unchanged fields -->
@@ -2644,6 +2664,9 @@
<!-- Description about the feature adaptive brightness -->
<string name="auto_brightness_description">Your screen brightness will automatically adjust to your environment and activities. You can move the slider manually to help adaptive brightness learn your preferences.</string>
+ <!-- Display settings screen, display white balance settings title [CHAR LIMIT=30] -->
+ <string name="display_white_balance_title">Display white balance</string>
+
<!-- Night display screen, setting option name to enable night display (renamed "Night Light" with title caps). [CHAR LIMIT=30] -->
<string name="night_display_title">Night Light</string>
<!-- Night display screen, description of night display feature (renamed "Night Light" with title caps). [CHAR LIMIT=NONE] -->
@@ -5221,6 +5244,9 @@
<item quantity="other">%1$d apps restricted</item>
</plurals>
+ <!-- Title to display the battery percentage. [CHAR LIMIT=24] -->
+ <string name="battery_header_title_alternate"><xliff:g id="number" example="88">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="%">%</xliff:g></font></small></string>
+
<!-- Title for force stop dialog [CHAR LIMIT=30] -->
<string name="dialog_stop_title">Stop app?</string>
<!-- Message body for force stop dialog [CHAR LIMIT=NONE] -->
@@ -5808,9 +5834,6 @@
Used in SetupWizard for XLarge screen [CHAR LIMIT=20] -->
<string name="wifi_setup_detail">Network details</string>
- <!-- Do not translate. This is a stub which will be removed soon. -->
- <string name="time_zone_auto_stub" translatable="false">Select Time Zone</string>
-
<!-- Content description of the enabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
<string name="accessibility_sync_enabled">Sync enabled</string>
<!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
@@ -7122,8 +7145,8 @@
<!-- Sound: Other sounds: Title for the option enabling touch sounds for screen locking sounds. [CHAR LIMIT=30] -->
<string name="screen_locking_sounds_title">Screen locking sounds</string>
- <!-- Sound: Other sounds: Title for the option enabling charging sounds. [CHAR LIMIT=30] -->
- <string name="charging_sounds_title">Charging sounds</string>
+ <!-- Sound: Other sounds: Title for the option enabling charging sounds and vibration. [CHAR LIMIT=30] -->
+ <string name="charging_sounds_title">Charging sounds and vibration</string>
<!-- Sound: Other sounds: Title for the option enabling docking sounds. [CHAR LIMIT=30] -->
<string name="docking_sounds_title">Docking sounds</string>
@@ -8292,8 +8315,6 @@
<!-- Summary describing external storage for applications [CHAR LIMIT=25] -->
<string name="storage_type_external">External storage</string>
- <!-- Title for data usage screen when entered from app info [CHAR LIMIT=30] -->
- <string name="app_data_usage">App data usage</string>
<!-- Summary for data usage preference [CHAR LIMIT=15] -->
<string name="data_summary_format"><xliff:g id="size" example="30.00MB">%1$s</xliff:g> used since <xliff:g id="date" example="Jan 12">%2$s</xliff:g></string>
@@ -9076,6 +9097,12 @@
<!-- Summary of condition that do not disturb is on [CHAR LIMIT=36] -->
<string name="condition_zen_summary">Impacts what you hear and see</string>
+ <!-- Title of condition that battery saver is on [CHAR LIMIT=30] -->
+ <string name="condition_battery_title">Battery Saver is on</string>
+
+ <!-- Summary of condition that battery saver is on [CHAR LIMIT=NONE] -->
+ <string name="condition_battery_summary">Features restricted</string>
+
<!-- Title of condition that cellular data is off [CHAR LIMIT=50] -->
<string name="condition_cellular_title">Mobile data is off</string>
@@ -9455,10 +9482,14 @@
<string name="notification_log_details_parcel">parcel size</string>
<!-- Notification log debug tool: notification ashmem size -->
<string name="notification_log_details_ashmem">ashmem</string>
+ <!-- Notification log debug tool: header: notification alert info -->
+ <string name="notification_log_details_alerted">notification alerted</string>
<!-- Notification log debug tool: header: notification sound info -->
<string name="notification_log_details_sound">sound</string>
<!-- Notification log debug tool: header: notification vibration info -->
<string name="notification_log_details_vibrate">vibrate</string>
+ <!-- Notification log debug tool: header: notification vibration info -->
+ <string name="notification_log_details_vibrate_pattern">pattern</string>
<!-- Notification log debug tool: the word 'default' -->
<string name="notification_log_details_default">default</string>
<!-- Notification log debug tool: the word 'none' -->
@@ -10036,12 +10067,24 @@
<!-- UI debug setting: ANGLE enabled app has been set [CHAR LIMIT=NONE] -->
<string name="angle_enabled_app_set">ANGLE enabled application: <xliff:g id="app_name" example="com.company.app">%1$s</xliff:g></string>
- <!-- UI debug setting: select an app to use updated graphics driver [CHAR LIMIT=100] -->
- <string name="updated_gfx_driver_dev_opt_in_app">Select app to use updated graphics driver</string>
- <!-- UI debug setting: no app selected to use updated GPU driver [CHAR LIMIT=100] -->
- <string name="updated_gfx_driver_dev_opt_in_app_not_set">No selected app to use updated graphics driver</string>
- <!-- UI debug setting: app selected to use updated graphics driver [CHAR LIMIT=NONE] -->
- <string name="updated_gfx_driver_dev_opt_in_app_set">Opt in application: <xliff:g id="app_name" example="com.company.app">%1$s</xliff:g></string>
+ <!-- Title for Game Update Packages dashboard where developers can configure apps to use GUP or not [CHAR LIMIT=50] -->
+ <string name="gup_dashboard_title">Game Update Packages Preferences</string>
+ <!-- Summary for Game Update Packages dashboard [CHAR LIMIT=50] -->
+ <string name="gup_dashboard_summary">Modify Game Update Packages settings</string>
+ <!-- Title for Game Update Packages preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_title">Select Graphics Driver</string>
+ <!-- The default value for Game Update Packages preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_default">Default</string>
+ <!-- The gup value for Game Update Packages preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_gup">Game Update Packages</string>
+ <!-- The native value for Game Update Packages preference [CHAR LIMIT=50] -->
+ <string name="gup_app_preference_native">Native Graphics Driver</string>
+ <!-- All the values for Game Update Packages preference [CHAR LIMIT=50] -->
+ <string-array name="gup_app_preference_values">
+ <item>@string/gup_app_preference_default</item>
+ <item>@string/gup_app_preference_gup</item>
+ <item>@string/gup_app_preference_native</item>
+ </string-array>
<!-- Slices Strings -->
@@ -10340,9 +10383,9 @@
<string name="see_less">See less</string>
<!-- Title for Network connection request Dialog [CHAR LIMIT=30] -->
- <string name="network_connection_request_dialog_title">Choose device</string>
+ <string name="network_connection_request_dialog_title">Choose a device</string>
<!-- Message for Network connection timeout Dialog [CHAR LIMIT=NONE] -->
- <string name="network_connection_timeout_dialog_message">No devices found. Make sure the device is turned on and available to connect.</string>
+ <string name="network_connection_timeout_dialog_message">No devices found. Make sure devices are turned on and available to connect.</string>
<!-- OK button for Network connection timeout Dialog [CHAR LIMIT=30] -->
<string name="network_connection_timeout_dialog_ok">Try again</string>
<!-- Message for Network connection error state Dialog [CHAR LIMIT=NONE] -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 15ec46d..1668b37 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -121,7 +121,7 @@
<item name="android:paddingStart">8dip</item>
<item name="android:textSize">14sp</item>
<item name="android:textAlignment">viewStart</item>
- <item name="android:textAppearance">@android:style/TextAppearance.Material.Body1</item>
+ <item name="android:textAppearance">@*android:style/TextAppearance.DeviceDefault.Body1</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
@@ -129,13 +129,13 @@
<item name="android:paddingStart">8dip</item>
<item name="android:textSize">12sp</item>
<item name="android:textAlignment">viewStart</item>
- <item name="android:textAppearance">@android:style/TextAppearance.Material.Body1</item>
+ <item name="android:textAppearance">@*android:style/TextAppearance.DeviceDefault.Body1</item>
<item name="android:textColor">?android:attr/colorError</item>
</style>
<style name="wifi_item_content">
<item name="android:textAlignment">viewStart</item>
- <item name="android:textAppearance">@android:style/TextAppearance.Material.Subhead</item>
+ <item name="android:textAppearance">@*android:style/TextAppearance.DeviceDefault.Subhead</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:minHeight">@dimen/min_tap_target_size</item>
</style>
@@ -174,30 +174,13 @@
<item name="android:background">#ff000000</item>
</style>
- <style name="SecurityPreferenceButtonContainer"
- parent="@android:style/Widget.Material.Light.SegmentedButton">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:weightSum">2</item>
- <item name="android:dividerPadding">8dip</item>
- </style>
-
- <style name="SecurityPreferenceButton"
- parent="@android:style/Widget.Material.Light.Button.Borderless">
- <item name="android:layout_width">0dip</item>
- <item name="android:layout_weight">1</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:ellipsize">marquee</item>
- <item name="android:singleLine">true</item>
- </style>
-
- <style name="SetupWizardButton.Negative" parent="@style/SuwGlifButton.Secondary">
+ <style name="SetupWizardButton.Negative" parent="@style/SudGlifButton.Secondary">
<!-- Negative margin to offset for padding of the button itself. We want the label to be
aligned with the text above it -->
<item name="android:layout_marginStart">-16dp</item>
</style>
- <style name="SetupWizardButton.Positive" parent="@style/SuwGlifButton.Primary"/>
+ <style name="SetupWizardButton.Positive" parent="@style/SudGlifButton.Primary"/>
<style name="AccentColorHighlightBorderlessButton">
<item name="android:colorControlHighlight">?android:attr/colorAccent</item>
@@ -206,13 +189,13 @@
<style name="vpn_label">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
+ <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Small</item>
</style>
<style name="vpn_value">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
- <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+ <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
<item name="android:singleLine">true</item>
<item name="android:textAlignment">viewStart</item>
<item name="android:minHeight">@dimen/min_tap_target_size</item>
@@ -222,10 +205,10 @@
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingStart">8dip</item>
- <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
+ <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Small</item>
</style>
- <style name="TextAppearance" parent="android:TextAppearance.Material"/>
+ <style name="TextAppearance" parent="android:TextAppearance.DeviceDefault"/>
<style name="TextAppearance.info_label">
<item name="android:textSize">14sp</item>
@@ -242,14 +225,14 @@
<item name="android:textStyle">normal</item>
</style>
- <style name="TextAppearance.PasswordEntry" parent="android:TextAppearance.Material">
+ <style name="TextAppearance.PasswordEntry" parent="android:TextAppearance.DeviceDefault">
<item name="android:gravity">center</item>
<item name="android:singleLine">true</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:textSize">24sp</item>
</style>
- <style name="TextAppearance.CryptKeeper_PasswordEntry" parent="android:TextAppearance.Material">
+ <style name="TextAppearance.CryptKeeper_PasswordEntry" parent="android:TextAppearance.DeviceDefault">
<item name="android:gravity">center_horizontal</item>
<item name="android:background">@null</item>
<item name="android:textCursorDrawable">@null</item>
@@ -257,22 +240,22 @@
<item name="android:imeOptions">flagForceAscii|actionDone</item>
</style>
- <style name="TextAppearance.Medium" parent="@android:style/TextAppearance.Material.Medium"/>
- <style name="TextAppearance.Small" parent="@android:style/TextAppearance.Material.Small"/>
+ <style name="TextAppearance.Medium" parent="@android:style/TextAppearance.DeviceDefault.Medium"/>
+ <style name="TextAppearance.Small" parent="@android:style/TextAppearance.DeviceDefault.Small"/>
<style name="TextAppearance.Switch"
parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
<item name="android:textSize">16sp</item>
</style>
<style name="TextAppearance.CategoryTitle"
- parent="@android:style/TextAppearance.Material.Body2">
+ parent="@*android:style/TextAppearance.DeviceDefault.Body2">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
- <style name="TextAppearance.TileTitle" parent="@android:style/TextAppearance.Material.Subhead"/>
+ <style name="TextAppearance.TileTitle" parent="@*android:style/TextAppearance.DeviceDefault.Subhead"/>
<style name="TextAppearance.SuggestionTitle"
- parent="@android:style/TextAppearance.Material.Subhead">
+ parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
<item name="android:textSize">16sp</item>
</style>
@@ -280,18 +263,8 @@
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
- <style name="TextAppearance.FingerprintErrorText"
- parent="android:TextAppearance.Material.Body1">
- <item name="android:textColor">?android:attr/colorError</item>
- </style>
-
- <style name="TextAppearance.FaceErrorText"
- parent="android:TextAppearance.Material.Body1">
- <item name="android:textColor">?android:attr/colorError</item>
- </style>
-
- <style name="TextAppearance.ConfirmDeviceCredentialsErrorText"
- parent="android:TextAppearance.Material.Body1">
+ <style name="TextAppearance.ErrorText"
+ parent="@*android:TextAppearance.DeviceDefault.Body1">
<item name="android:textColor">?android:attr/colorError</item>
</style>
@@ -301,29 +274,29 @@
</style>
<style name="TextAppearance.RemoveDialogContent"
- parent="@android:style/TextAppearance.Material">
+ parent="@android:style/TextAppearance.DeviceDefault">
<item name="android:textSize">16sp</item>
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="TextAppearance.SearchBar"
- parent="@android:style/TextAppearance.Material.Widget.Toolbar.Subtitle">
+ parent="@*android:style/TextAppearance.DeviceDefault.Widget.Toolbar.Subtitle">
<item name="android:textSize">@dimen/search_bar_text_size</item>
</style>
<style name="TextAppearance.SuggestionHeader"
- parent="@android:style/TextAppearance.Material.Subhead">
+ parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
<item name="android:textSize">14sp</item>
<item name="android:textColor">?android:attr/colorAccent</item>
</style>
<style name="TextAppearance.ConditionCardTitle"
- parent="@android:style/TextAppearance.Material.Body2">
+ parent="@*android:style/TextAppearance.DeviceDefault.Body2">
<item name="android:textSize">16sp</item>
</style>
<style name="TextAppearance.ConditionCardSummary"
- parent="@android:style/TextAppearance.Material.Body1">
+ parent="@*android:style/TextAppearance.DeviceDefault.Body1">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
@@ -338,7 +311,7 @@
</style>
<style name="TextAppearance.ContextualCardDismissalText"
- parent="@android:style/TextAppearance.Material.Body1">
+ parent="@*android:style/TextAppearance.DeviceDefault.Body1">
<item name="android:fontFamily">@*android:string/config_headlineFontFamilyMedium</item>
<item name="android:textSize">16sp</item>
</style>
@@ -377,13 +350,13 @@
<item name="android:gravity">center_vertical</item>
</style>
- <style name="FingerprintHeaderStyle" parent="android:style/TextAppearance.Material.Subhead">
+ <style name="FingerprintHeaderStyle" parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
<item name="android:paddingTop">16dp</item>
<item name="android:textColor">@color/primary_dark_material_light</item>
<item name="android:lineSpacingMultiplier">1.2</item>
</style>
- <style name="FaceHeaderStyle" parent="android:style/TextAppearance.Material.Subhead">
+ <style name="FaceHeaderStyle" parent="@*android:style/TextAppearance.DeviceDefault.Subhead">
<item name="android:paddingTop">16dp</item>
<item name="android:textColor">@color/primary_dark_material_light</item>
<item name="android:lineSpacingMultiplier">1.2</item>
@@ -438,13 +411,13 @@
<style name="device_info_dialog_label">
<item name="android:textAlignment">viewStart</item>
- <item name="android:textAppearance">@android:style/TextAppearance.Material.Body1</item>
+ <item name="android:textAppearance">@*android:style/TextAppearance.DeviceDefault.Body1</item>
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="device_info_dialog_value">
<item name="android:textAlignment">viewStart</item>
- <item name="android:textAppearance">@android:style/TextAppearance.Material.Body2</item>
+ <item name="android:textAppearance">@*android:style/TextAppearance.DeviceDefault.Body2</item>
<item name="android:paddingBottom">24dp</item>
</style>
@@ -481,11 +454,13 @@
<style name="ConditionFullCardBorderlessButton"
parent="@style/ConditionCardBorderlessButton">
- <item name="android:textAlignment">viewEnd</item>
+ <item name="android:minWidth">24dp</item>
+ <item name="android:layout_marginStart">20dp</item>
</style>
<style name="ContextualCardDismissalButton"
parent="android:Widget.DeviceDefault.Button.Borderless.Colored">
+ <item name="android:minHeight">16dp</item>
<item name="android:textAllCaps">false</item>
</style>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index 6b05a7c..c7fafad 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -39,7 +39,7 @@
<item name="wifi_friction">@drawable/wifi_friction</item>
<item name="side_margin">@dimen/settings_side_margin</item>
- <item name="suwListItemIconColor">?android:attr/colorAccent</item>
+ <item name="sudListItemIconColor">?android:attr/colorAccent</item>
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Widget.ActionBar</item>
@@ -180,7 +180,7 @@
<item name="android:windowNoTitle">true</item>
</style>
- <style name="Theme.Settings.HomeBase" parent="Theme.AppCompat.DayNight.NoActionBar">
+ <style name="Theme.Settings.HomeBase" parent="Theme.Settings.NoActionBar">
<item name="colorPrimary">@*android:color/primary_device_default_settings_light</item>
<item name="colorAccent">@*android:color/accent_device_default_light</item>
<item name="preferenceTheme">@style/PreferenceTheme</item>
diff --git a/res/values/themes_suw.xml b/res/values/themes_suw.xml
index e0d25c9..9bb67cf 100644
--- a/res/values/themes_suw.xml
+++ b/res/values/themes_suw.xml
@@ -17,7 +17,7 @@
<!-- SUW related themes -->
<resources>
- <style name="GlifTheme" parent="SuwThemeGlif.DayNight">
+ <style name="GlifTheme" parent="SudThemeGlif.DayNight">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -36,7 +36,7 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
- <style name="GlifTheme.Light" parent="SuwThemeGlif.Light">
+ <style name="GlifTheme.Light" parent="SudThemeGlif.Light">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/ThemeOverlay.AlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -55,7 +55,7 @@
<item name="*android:colorError">@color/glif_error_color</item>
</style>
- <style name="GlifV2Theme" parent="SuwThemeGlifV2.DayNight">
+ <style name="GlifV2Theme" parent="SudThemeGlifV2.DayNight">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -74,7 +74,7 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
- <style name="GlifV2Theme.Light" parent="SuwThemeGlifV2.Light">
+ <style name="GlifV2Theme.Light" parent="SudThemeGlifV2.Light">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -93,7 +93,7 @@
<item name="*android:colorError">@color/glif_error_color</item>
</style>
- <style name="GlifV3Theme" parent="SuwThemeGlifV3.DayNight">
+ <style name="GlifV3Theme" parent="SudThemeGlifV3.DayNight">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
@@ -112,7 +112,7 @@
<item name="*android:lockPatternStyle">@style/LockPatternStyle.Setup</item>
</style>
- <style name="GlifV3Theme.Light" parent="SuwThemeGlifV3.Light">
+ <style name="GlifV3Theme.Light" parent="SudThemeGlifV3.Light">
<!-- For all AndroidX Alert Dialogs -->
<item name="alertDialogTheme">@style/GlifV2ThemeAlertDialog.Light</item>
<item name="android:windowBackground">?android:attr/colorBackground</item>
diff --git a/res/xml/date_time_prefs.xml b/res/xml/date_time_prefs.xml
index edda1ba..e8af64c 100644
--- a/res/xml/date_time_prefs.xml
+++ b/res/xml/date_time_prefs.xml
@@ -58,7 +58,7 @@
<com.android.settingslib.RestrictedPreference
android:fragment="com.android.settings.datetime.timezone.TimeZoneSettings"
android:key="timezone"
- android:title="@string/date_time_set_timezone"
+ android:title="@string/date_time_set_timezone_title"
android:summary="@string/summary_placeholder"
settings:userRestriction="no_config_date_time" />
</PreferenceCategory>
diff --git a/res/xml/development_settings.xml b/res/xml/development_settings.xml
index be45cd0..a5e26f6 100644
--- a/res/xml/development_settings.xml
+++ b/res/xml/development_settings.xml
@@ -191,6 +191,13 @@
android:title="@string/enable_gpu_debug_layers"
android:summary="@string/enable_gpu_debug_layers_summary" />
+ <Preference
+ android:key="gup_dashboard"
+ android:title="@string/gup_dashboard_title"
+ android:summary="@string/gup_dashboard_summary"
+ android:fragment="com.android.settings.development.gup.GupDashboard"
+ settings:searchable="false" />
+
</PreferenceCategory>
<PreferenceCategory
@@ -424,10 +431,6 @@
android:summary="%s"
android:title="@string/simulate_color_space" />
- <Preference android:key="updated_gfx_driver_dev_opt_in_app"
- android:summary="@string/updated_gfx_driver_dev_opt_in_app_summary"
- android:title="@string/updated_gfx_driver_dev_opt_in_app" />
-
</PreferenceCategory>
<PreferenceCategory
diff --git a/res/xml/display_settings.xml b/res/xml/display_settings.xml
index 50a5649..76b3d2e 100644
--- a/res/xml/display_settings.xml
+++ b/res/xml/display_settings.xml
@@ -79,6 +79,11 @@
settings:controller="com.android.settings.display.ColorModePreferenceController"
settings:keywords="@string/keywords_color_mode" />
+ <SwitchPreference
+ android:key="display_white_balance"
+ android:title="@string/display_white_balance_title"
+ settings:controller="com.android.settings.display.DisplayWhiteBalancePreferenceController" />
+
<Preference
android:key="font_size"
android:title="@string/title_font_size"
diff --git a/res/xml/gup_settings.xml b/res/xml/gup_settings.xml
new file mode 100644
index 0000000..43ba39b
--- /dev/null
+++ b/res/xml/gup_settings.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 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.
+ -->
+
+<PreferenceScreen
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res-auto"
+ android:key="gup_settings"
+ android:title="@string/gup_dashboard_title">
+
+ <PreferenceCategory
+ android:key="gup_category"
+ android:title="@string/gup_app_preference_title"
+ settings:controller="com.android.settings.development.gup.GupPreferenceController">
+ </PreferenceCategory>
+
+</PreferenceScreen>
diff --git a/res/xml/my_device_info.xml b/res/xml/my_device_info.xml
index 3960103..d669977 100644
--- a/res/xml/my_device_info.xml
+++ b/res/xml/my_device_info.xml
@@ -102,8 +102,7 @@
settings:keywords="@string/keywords_model_and_hardware"
android:summary="@string/summary_placeholder"
settings:allowDynamicSummaryInSlice="true"
- settings:controller=
- "com.android.settings.deviceinfo.DeviceModelPreferenceController"/>
+ settings:controller="com.android.settings.deviceinfo.DeviceModelPreferenceController"/>
<!-- IMEI -->
<Preference
@@ -111,7 +110,8 @@
android:order="22"
android:title="@string/status_imei"
settings:keywords="@string/keywords_imei_info"
- android:summary="@string/summary_placeholder"/>
+ android:summary="@string/summary_placeholder"
+ settings:controller="com.android.settings.deviceinfo.imei.ImeiInfoPreferenceController"/>
<!-- Android version -->
<Preference
diff --git a/res/xml/prevent_ringing_gesture_settings.xml b/res/xml/prevent_ringing_gesture_settings.xml
index 62f0223..4b0edc3 100644
--- a/res/xml/prevent_ringing_gesture_settings.xml
+++ b/res/xml/prevent_ringing_gesture_settings.xml
@@ -26,8 +26,11 @@
app:animation="@raw/gesture_prevent_ringing"
app:preview="@drawable/gesture_prevent_ringing" />
+ <com.android.settingslib.widget.LayoutPreference
+ android:key="gesture_prevent_ringing_switch"
+ android:layout="@layout/styled_switch_bar" />
+
<PreferenceCategory
android:key="gesture_prevent_ringing_category"
- android:title="@string/gesture_prevent_ringing_title">
- </PreferenceCategory>
+ android:title="@string/gesture_prevent_ringing_title" />
</PreferenceScreen>
\ No newline at end of file
diff --git a/res/xml/privacy_dashboard_settings.xml b/res/xml/privacy_dashboard_settings.xml
index 79e2e71..a580f5f 100644
--- a/res/xml/privacy_dashboard_settings.xml
+++ b/res/xml/privacy_dashboard_settings.xml
@@ -19,7 +19,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="privacy_dashboard_page"
- android:title="@string/privacy_dashboard_title">
+ android:title="@string/privacy_dashboard_title"
+ settings:initialExpandedChildrenCount="3">
<!-- App permissions -->
<Preference
@@ -30,13 +31,6 @@
<intent android:action="android.intent.action.MANAGE_PERMISSIONS"/>
</Preference>
- <!-- On lock screen notifications -->
- <com.android.settings.RestrictedListPreference
- android:key="privacy_lock_screen_notifications"
- android:title="@string/lock_screen_notifications_title"
- android:summary="@string/summary_placeholder"
- settings:searchable="false"/>
-
<!-- Show passwords -->
<SwitchPreference
android:key="show_password"
@@ -44,6 +38,13 @@
android:summary="@string/show_password_summary"
settings:controller="com.android.settings.security.ShowPasswordPreferenceController"/>
+ <!-- On lock screen notifications -->
+ <com.android.settings.RestrictedListPreference
+ android:key="privacy_lock_screen_notifications"
+ android:title="@string/lock_screen_notifications_title"
+ android:summary="@string/summary_placeholder"
+ settings:searchable="false"/>
+
<!-- Privacy Service -->
<PreferenceCategory
android:key="privacy_services"/>
diff --git a/src/com/android/settings/BandMode.java b/src/com/android/settings/BandMode.java
index 5be82f6..bae8860 100644
--- a/src/com/android/settings/BandMode.java
+++ b/src/com/android/settings/BandMode.java
@@ -73,13 +73,8 @@
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
-
setContentView(R.layout.band_mode);
- setTitle(getString(R.string.band_mode_title));
- getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
- WindowManager.LayoutParams.WRAP_CONTENT);
-
mPhone = PhoneFactory.getDefaultPhone();
mBandList = (ListView) findViewById(R.id.band);
diff --git a/src/com/android/settings/EncryptionInterstitial.java b/src/com/android/settings/EncryptionInterstitial.java
index 8cae26b..6060892 100644
--- a/src/com/android/settings/EncryptionInterstitial.java
+++ b/src/com/android/settings/EncryptionInterstitial.java
@@ -40,6 +40,8 @@
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settings.password.ChooseLockSettingsHelper;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
import com.google.android.setupdesign.GlifLayout;
import java.util.List;
@@ -86,11 +88,8 @@
layout.setFitsSystemWindows(false);
}
- public static class EncryptionInterstitialFragment extends InstrumentedFragment
- implements View.OnClickListener {
+ public static class EncryptionInterstitialFragment extends InstrumentedFragment {
- private View mRequirePasswordToDecrypt;
- private View mDontRequirePasswordToDecrypt;
private boolean mPasswordRequired;
private Intent mUnlockMethodIntent;
private int mRequestedPasswordQuality;
@@ -110,8 +109,6 @@
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mRequirePasswordToDecrypt = view.findViewById(R.id.encrypt_require_password);
- mDontRequirePasswordToDecrypt = view.findViewById(R.id.encrypt_dont_require_password);
final boolean forFingerprint = getActivity().getIntent().getBooleanExtra(
ChooseLockSettingsHelper.EXTRA_KEY_FOR_FINGERPRINT, false);
final boolean forFace = getActivity().getIntent()
@@ -147,14 +144,30 @@
TextView message = (TextView) getActivity().findViewById(R.id.encryption_message);
message.setText(msgId);
- mRequirePasswordToDecrypt.setOnClickListener(this);
- mDontRequirePasswordToDecrypt.setOnClickListener(this);
-
setRequirePasswordState(getActivity().getIntent().getBooleanExtra(
EXTRA_REQUIRE_PASSWORD, true));
GlifLayout layout = (GlifLayout) view;
layout.setHeaderText(getActivity().getTitle());
+
+ final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
+ buttonFooterMixin.setSecondaryButton(
+ new FooterButton.Builder(getContext())
+ .setText(R.string.encryption_interstitial_no)
+ .setListener(this::onNoButtonClicked)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
+ );
+
+ buttonFooterMixin.setPrimaryButton(
+ new FooterButton.Builder(getContext())
+ .setText(R.string.encryption_interstitial_yes)
+ .setListener(this::onYesButtonClicked)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
+ );
}
protected void startLockIntent() {
@@ -176,26 +189,25 @@
}
}
- @Override
- public void onClick(View view) {
- if (view == mRequirePasswordToDecrypt) {
- final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
- if (accEn && !mPasswordRequired) {
- setRequirePasswordState(false); // clear the UI state
- AccessibilityWarningDialogFragment.newInstance(mRequestedPasswordQuality)
- .show(
- getChildFragmentManager(),
- AccessibilityWarningDialogFragment.TAG);
- } else {
- setRequirePasswordState(true);
- startLockIntent();
- }
+ private void onYesButtonClicked(View view) {
+ final boolean accEn = AccessibilityManager.getInstance(getActivity()).isEnabled();
+ if (accEn && !mPasswordRequired) {
+ setRequirePasswordState(false); // clear the UI state
+ AccessibilityWarningDialogFragment.newInstance(mRequestedPasswordQuality)
+ .show(
+ getChildFragmentManager(),
+ AccessibilityWarningDialogFragment.TAG);
} else {
- setRequirePasswordState(false);
+ setRequirePasswordState(true);
startLockIntent();
}
}
+ private void onNoButtonClicked(View view) {
+ setRequirePasswordState(false);
+ startLockIntent();
+ }
+
private void setRequirePasswordState(boolean required) {
mPasswordRequired = required;
}
diff --git a/src/com/android/settings/MasterClear.java b/src/com/android/settings/MasterClear.java
index 61a247d..c03d499 100644
--- a/src/com/android/settings/MasterClear.java
+++ b/src/com/android/settings/MasterClear.java
@@ -419,12 +419,12 @@
final TemplateLayout layout = mContentView.findViewById(R.id.setup_wizard_layout);
final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
buttonFooterMixin.setPrimaryButton(
- new FooterButton(
- getActivity(),
- R.string.master_clear_button_text,
- mInitiateListener,
- ButtonType.OTHER,
- R.style.SuwGlifButton_Primary)
+ new FooterButton.Builder(getActivity())
+ .setText(R.string.master_clear_button_text)
+ .setListener(mInitiateListener)
+ .setButtonType(ButtonType.OTHER)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
);
mInitiateButton = buttonFooterMixin.getPrimaryButton();
}
diff --git a/src/com/android/settings/MasterClearConfirm.java b/src/com/android/settings/MasterClearConfirm.java
index b2bf838..cbd4924 100644
--- a/src/com/android/settings/MasterClearConfirm.java
+++ b/src/com/android/settings/MasterClearConfirm.java
@@ -156,12 +156,12 @@
final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
buttonFooterMixin.setPrimaryButton(
- new FooterButton(
- getActivity(),
- R.string.master_clear_button_text,
- mFinalClickListener,
- ButtonType.OTHER,
- R.style.SuwGlifButton_Primary)
+ new FooterButton.Builder(getActivity())
+ .setText(R.string.master_clear_button_text)
+ .setListener(mFinalClickListener)
+ .setButtonType(ButtonType.OTHER)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
);
}
diff --git a/src/com/android/settings/accounts/AccountFeatureProvider.java b/src/com/android/settings/accounts/AccountFeatureProvider.java
index fd65095..ef14fa0 100644
--- a/src/com/android/settings/accounts/AccountFeatureProvider.java
+++ b/src/com/android/settings/accounts/AccountFeatureProvider.java
@@ -23,5 +23,4 @@
public interface AccountFeatureProvider {
String getAccountType();
Account[] getAccounts(Context context);
- Intent getAccountSettingsDeeplinkIntent();
}
diff --git a/src/com/android/settings/accounts/AccountFeatureProviderImpl.java b/src/com/android/settings/accounts/AccountFeatureProviderImpl.java
index 2e0f432..90b581b 100644
--- a/src/com/android/settings/accounts/AccountFeatureProviderImpl.java
+++ b/src/com/android/settings/accounts/AccountFeatureProviderImpl.java
@@ -2,7 +2,6 @@
import android.accounts.Account;
import android.content.Context;
-import android.content.Intent;
public class AccountFeatureProviderImpl implements AccountFeatureProvider {
@Override
@@ -14,9 +13,4 @@
public Account[] getAccounts(Context context) {
return new Account[0];
}
-
- @Override
- public Intent getAccountSettingsDeeplinkIntent() {
- return null;
- }
}
diff --git a/src/com/android/settings/accounts/AvatarViewMixin.java b/src/com/android/settings/accounts/AvatarViewMixin.java
index 35a3cbf..43531b3 100644
--- a/src/com/android/settings/accounts/AvatarViewMixin.java
+++ b/src/com/android/settings/accounts/AvatarViewMixin.java
@@ -40,6 +40,7 @@
import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.utils.ThreadUtils;
+import java.net.URISyntaxException;
import java.util.List;
/**
@@ -57,7 +58,6 @@
private static final String KEY_AVATAR_BITMAP = "account_avatar";
private static final String KEY_ACCOUNT_NAME = "account_name";
private static final String EXTRA_ACCOUNT_NAME = "extra.accountName";
- private static final int REQUEST_CODE = 1013;
private final Context mContext;
private final ImageView mAvatarView;
@@ -69,23 +69,32 @@
mContext = activity.getApplicationContext();
mAvatarView = avatarView;
mAvatarView.setOnClickListener(v -> {
- final Intent intent = FeatureFactory.getFactory(mContext)
- .getAccountFeatureProvider()
- .getAccountSettingsDeeplinkIntent();
-
- if (intent == null) {
+ Intent intent;
+ try {
+ final String uri = mContext.getResources().getString(
+ R.string.config_account_intent_uri);
+ intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
+ } catch (URISyntaxException e) {
+ Log.w(TAG, "Error parsing avatar mixin intent, skipping", e);
return;
}
if (!TextUtils.isEmpty(mAccountName)) {
- //TODO(b/117509285) launch the new page of the MeCard
intent.putExtra(EXTRA_ACCOUNT_NAME, mAccountName);
}
+ final List<ResolveInfo> matchedIntents =
+ mContext.getPackageManager().queryIntentActivities(intent,
+ PackageManager.MATCH_SYSTEM_ONLY);
+ if (matchedIntents.isEmpty()) {
+ Log.w(TAG, "Cannot find any matching action VIEW_ACCOUNT intent.");
+ return;
+ }
+
// Here may have two different UI while start the activity.
// It will display adding account UI when device has no any account.
// It will display account information page when intent added the specified account.
- activity.startActivityForResult(intent, REQUEST_CODE);
+ activity.startActivity(intent);
});
mAvatarImage = new MutableLiveData<>();
diff --git a/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java b/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java
index 59166dd..c7cab15 100644
--- a/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java
+++ b/src/com/android/settings/applications/defaultapps/RolesPreferenceController.java
@@ -16,31 +16,44 @@
package com.android.settings.applications.defaultapps;
+import android.app.role.RoleManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.icu.text.ListFormatter;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.preference.Preference;
import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.applications.AppUtils;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* STOPSHIP(b/110557011): Remove once the new UI is ready.
*/
public class RolesPreferenceController extends BasePreferenceController {
- private Intent mIntent;
+ private final PackageManager mPackageManager;
+ private final RoleManager mRoleManager;
+
+ private final Intent mIntent;
public RolesPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
- PackageManager packageManager = context.getPackageManager();
- String packageName = packageManager.getPermissionControllerPackageName();
+ mPackageManager = context.getPackageManager();
+ mRoleManager = context.getSystemService(RoleManager.class);
+
+ final String packageName = mPackageManager.getPermissionControllerPackageName();
if (packageName != null) {
mIntent = new Intent(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
.setPackage(packageName);
+ } else {
+ mIntent = null;
}
}
@@ -59,4 +72,34 @@
}
return false;
}
+
+ @Override
+ public CharSequence getSummary() {
+ final List<CharSequence> defaultAppLabels = new ArrayList<>();
+ final CharSequence defaultBrowserLabel = getDefaultAppLabel(RoleManager.ROLE_BROWSER);
+ if(!TextUtils.isEmpty(defaultBrowserLabel)) {
+ defaultAppLabels.add(defaultBrowserLabel);
+ }
+ final CharSequence defaultPhoneLabel = getDefaultAppLabel(RoleManager.ROLE_DIALER);
+ if(!TextUtils.isEmpty(defaultPhoneLabel)) {
+ defaultAppLabels.add(defaultPhoneLabel);
+ }
+ final CharSequence defaultSmsLabel = getDefaultAppLabel(RoleManager.ROLE_SMS);
+ if(!TextUtils.isEmpty(defaultSmsLabel)) {
+ defaultAppLabels.add(defaultSmsLabel);
+ }
+ if (defaultAppLabels.isEmpty()) {
+ return null;
+ }
+ return ListFormatter.getInstance().format(defaultAppLabels);
+ }
+
+ private CharSequence getDefaultAppLabel(String roleName) {
+ final List<String> packageNames = mRoleManager.getRoleHolders(roleName);
+ if (packageNames.isEmpty()) {
+ return null;
+ }
+ final String packageName = packageNames.get(0);
+ return AppUtils.getApplicationLabel(mPackageManager, packageName);
+ }
}
diff --git a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
index 0ddc1fc..79e699d 100644
--- a/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/BiometricEnrollIntroduction.java
@@ -150,7 +150,8 @@
getNextButton().setVisibility(View.VISIBLE);
} else {
mErrorText.setText(errorMsg);
- getNextButton().setVisibility(View.GONE);
+ getNextButton().setText(getResources().getString(R.string.done));
+ getNextButton().setVisibility(View.VISIBLE);
}
}
@@ -162,8 +163,13 @@
@Override
protected void onNextButtonClick(View view) {
- // Lock thingy is already set up, launch directly to the next page
- launchNextEnrollingActivity(mToken);
+ if (checkMaxEnrolled() == 0) {
+ // Lock thingy is already set up, launch directly to the next page
+ launchNextEnrollingActivity(mToken);
+ } else {
+ setResult(RESULT_FINISHED);
+ finish();
+ }
}
private void launchChooseLock() {
@@ -211,7 +217,7 @@
updatePasswordQuality();
mToken = data.getByteArrayExtra(
ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
return;
} else {
setResult(result, data);
@@ -220,13 +226,13 @@
} else if (requestCode == CONFIRM_REQUEST) {
if (resultCode == RESULT_OK && data != null) {
mToken = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
} else {
setResult(result, data);
finish();
}
} else if (requestCode == LEARN_MORE_REQUEST) {
- overridePendingTransition(R.anim.suw_slide_back_in, R.anim.suw_slide_back_out);
+ overridePendingTransition(R.anim.sud_slide_back_in, R.anim.sud_slide_back_out);
}
super.onActivityResult(requestCode, resultCode, data);
}
diff --git a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
index 7ad2d17..12ffc6b 100644
--- a/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/BiometricsEnrollEnrolling.java
@@ -111,7 +111,7 @@
intent.putExtra(Intent.EXTRA_USER_ID, mUserId);
}
startActivity(intent);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
finish();
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
index 8cc7133..2323afc 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollEnrolling.java
@@ -93,12 +93,12 @@
mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setSecondaryButton(
- new FooterButton(
- this,
- R.string.security_settings_face_enroll_enrolling_skip,
- this::onSkipButtonClick,
- FooterButton.ButtonType.SKIP,
- R.style.SuwGlifButton_Secondary)
+ new FooterButton.Builder(this)
+ .setText(R.string.security_settings_face_enroll_enrolling_skip)
+ .setListener(this::onSkipButtonClick)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
);
if (!getIntent().getBooleanExtra(BiometricEnrollBase.EXTRA_KEY_REQUIRE_DIVERSITY, true)) {
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
index f0ff523..c347d0f 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollFinish.java
@@ -39,12 +39,12 @@
mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setPrimaryButton(
- new FooterButton(
- this,
- R.string.security_settings_face_enroll_done,
- this::onNextButtonClick,
- FooterButton.ButtonType.NEXT,
- R.style.SuwGlifButton_Primary)
+ new FooterButton.Builder(this)
+ .setText(R.string.security_settings_face_enroll_done)
+ .setListener(this::onNextButtonClick)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
);
}
diff --git a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
index a90cf5d..ba5a85e 100644
--- a/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/face/FaceEnrollIntroduction.java
@@ -62,21 +62,21 @@
mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setSecondaryButton(
- new FooterButton(
- this,
- R.string.security_settings_face_enroll_introduction_cancel,
- this::onCancelButtonClick,
- FooterButton.ButtonType.SKIP,
- R.style.SuwGlifButton_Secondary)
+ new FooterButton.Builder(this)
+ .setText(R.string.security_settings_face_enroll_introduction_cancel)
+ .setListener(this::onCancelButtonClick)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
);
mButtonFooterMixin.setPrimaryButton(
- new FooterButton(
- this,
- R.string.wizard_next,
- this::onNextButtonClick,
- FooterButton.ButtonType.NEXT,
- R.style.SuwGlifButton_Primary)
+ new FooterButton.Builder(this)
+ .setText(R.string.wizard_next)
+ .setListener(this::onNextButtonClick)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
);
}
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index 8eabf00..eb5e02b 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -51,11 +51,10 @@
public class FaceSettings extends DashboardFragment {
private static final String TAG = "FaceSettings";
- private static final String KEY_LAUNCHED_CONFIRM = "key_launched_confirm";
+ private static final String KEY_TOKEN = "key_token";
private FaceManager mFaceManager;
private int mUserId;
- private boolean mLaunchedConfirm;
private byte[] mToken;
private FaceSettingsAttentionPreferenceController mAttentionController;
@@ -86,7 +85,7 @@
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putBoolean(KEY_LAUNCHED_CONFIRM, mLaunchedConfirm);
+ outState.putByteArray(KEY_TOKEN, mToken);
}
@Override
@@ -98,10 +97,10 @@
Intent.EXTRA_USER_ID, UserHandle.myUserId());
if (savedInstanceState != null) {
- mLaunchedConfirm = savedInstanceState.getBoolean(KEY_LAUNCHED_CONFIRM, false);
+ mToken = savedInstanceState.getByteArray(KEY_TOKEN);
}
- if (!mLaunchedConfirm) {
+ if (mToken == null) {
final long challenge = mFaceManager.generateChallenge();
ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);
if (!helper.launchConfirmationActivity(CONFIRM_REQUEST,
@@ -114,6 +113,14 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ if (mToken != null) {
+ mAttentionController.setToken(mToken);
+ }
+ }
+
+ @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CONFIRM_REQUEST) {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
index 5953c10..4c1ca62 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollEnrolling.java
@@ -139,12 +139,12 @@
mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setSecondaryButton(
- new FooterButton(
- this,
- R.string.security_settings_fingerprint_enroll_enrolling_skip,
- this::onSkipButtonClick,
- FooterButton.ButtonType.SKIP,
- R.style.SuwGlifButton_Secondary)
+ new FooterButton.Builder(this)
+ .setText(R.string.security_settings_fingerprint_enroll_enrolling_skip)
+ .setListener(this::onSkipButtonClick)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
);
final LayerDrawable fingerprintDrawable = (LayerDrawable) mProgressBar.getBackground();
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
index b8a0f40..72e115b 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFindSensor.java
@@ -49,12 +49,12 @@
setContentView(getContentView());
mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setSecondaryButton(
- new FooterButton(
- this,
- R.string.skip_label,
- this::onSkipButtonClick,
- FooterButton.ButtonType.SKIP,
- R.style.SuwGlifButton_Secondary)
+ new FooterButton.Builder(this)
+ .setText(R.string.skip_label)
+ .setListener(this::onSkipButtonClick)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
);
setHeaderText(R.string.security_settings_fingerprint_enroll_find_sensor_title);
@@ -155,7 +155,7 @@
if (requestCode == CONFIRM_REQUEST) {
if (resultCode == RESULT_OK && data != null) {
mToken = data.getByteArrayExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN);
- overridePendingTransition(R.anim.suw_slide_next_in, R.anim.suw_slide_next_out);
+ overridePendingTransition(R.anim.sud_slide_next_in, R.anim.sud_slide_next_out);
getIntent().putExtra(ChooseLockSettingsHelper.EXTRA_KEY_CHALLENGE_TOKEN, mToken);
startLookingForFingerprint();
} else {
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
index 76f1d1f..4cf3a46 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollFinish.java
@@ -44,21 +44,20 @@
mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setSecondaryButton(
- new FooterButton(
- this,
- R.string.fingerprint_enroll_button_add,
- null,
- FooterButton.ButtonType.SKIP,
- R.style.SuwGlifButton_Secondary)
+ new FooterButton.Builder(this)
+ .setText(R.string.fingerprint_enroll_button_add)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
);
mButtonFooterMixin.setPrimaryButton(
- new FooterButton(
- this,
- R.string.security_settings_fingerprint_enroll_done,
- this::onNextButtonClick,
- FooterButton.ButtonType.NEXT,
- R.style.SuwGlifButton_Primary)
+ new FooterButton.Builder(this)
+ .setText(R.string.security_settings_fingerprint_enroll_done)
+ .setListener(this::onNextButtonClick)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
);
}
diff --git a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
index 4eca87d..f603e24 100644
--- a/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
+++ b/src/com/android/settings/biometrics/fingerprint/FingerprintEnrollIntroduction.java
@@ -49,21 +49,21 @@
mButtonFooterMixin = getLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setSecondaryButton(
- new FooterButton(
- this,
- R.string.security_settings_face_enroll_introduction_cancel,
- this::onCancelButtonClick,
- FooterButton.ButtonType.SKIP,
- R.style.SuwGlifButton_Secondary)
+ new FooterButton.Builder(this)
+ .setText(R.string.security_settings_face_enroll_introduction_cancel)
+ .setListener(this::onCancelButtonClick)
+ .setButtonType(FooterButton.ButtonType.SKIP)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
);
mButtonFooterMixin.setPrimaryButton(
- new FooterButton(
- this,
- R.string.wizard_next,
- this::onNextButtonClick,
- FooterButton.ButtonType.NEXT,
- R.style.SuwGlifButton_Primary)
+ new FooterButton.Builder(this)
+ .setText(R.string.wizard_next)
+ .setListener(this::onNextButtonClick)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
);
}
diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
index eab2a28..2ea3371 100644
--- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
+++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java
@@ -52,8 +52,6 @@
LocalBluetoothProfileManager.ServiceListener {
private static final String TAG = "BluetoothDeviceUpdater";
private static final boolean DBG = true;
- private static final String BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY =
- "persist.bluetooth.showdeviceswithoutnames";
protected final DevicePreferenceCallback mDevicePreferenceCallback;
protected final Map<BluetoothDevice, Preference> mPreferenceMap;
@@ -62,8 +60,6 @@
@VisibleForTesting
protected LocalBluetoothManager mLocalManager;
- private final boolean mShowDeviceWithoutNames;
-
@VisibleForTesting
final GearPreference.OnGearClickListener mDeviceProfilesListener = pref -> {
launchDeviceDetails(pref);
@@ -79,8 +75,6 @@
DevicePreferenceCallback devicePreferenceCallback, LocalBluetoothManager localManager) {
mFragment = fragment;
mDevicePreferenceCallback = devicePreferenceCallback;
- mShowDeviceWithoutNames = SystemProperties.getBoolean(
- BLUETOOTH_SHOW_DEVICES_WITHOUT_NAMES_PROPERTY, false);
mPreferenceMap = new HashMap<>();
mLocalManager = localManager;
}
@@ -223,7 +217,7 @@
if (!mPreferenceMap.containsKey(device)) {
BluetoothDevicePreference btPreference =
new BluetoothDevicePreference(mPrefContext, cachedDevice,
- mShowDeviceWithoutNames);
+ true /* showDeviceWithoutNames */);
btPreference.setOnGearClickListener(mDeviceProfilesListener);
if (this instanceof Preference.OnPreferenceClickListener) {
btPreference.setOnPreferenceClickListener(
diff --git a/src/com/android/settings/datausage/AppDataUsageActivity.java b/src/com/android/settings/datausage/AppDataUsageActivity.java
index 2b8e42d..82a3a45 100644
--- a/src/com/android/settings/datausage/AppDataUsageActivity.java
+++ b/src/com/android/settings/datausage/AppDataUsageActivity.java
@@ -62,7 +62,7 @@
args.putParcelable(AppDataUsage.ARG_APP_ITEM, appItem);
intent.putExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
intent.putExtra(EXTRA_SHOW_FRAGMENT, AppDataUsage.class.getName());
- intent.putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.app_data_usage);
+ intent.putExtra(EXTRA_SHOW_FRAGMENT_TITLE_RESID, R.string.data_usage_app_summary_title);
super.onCreate(savedInstanceState);
}
diff --git a/src/com/android/settings/datausage/DataUsageList.java b/src/com/android/settings/datausage/DataUsageList.java
index 326b0d4..3369e5e 100644
--- a/src/com/android/settings/datausage/DataUsageList.java
+++ b/src/com/android/settings/datausage/DataUsageList.java
@@ -419,7 +419,7 @@
new SubSettingLauncher(getContext())
.setDestination(AppDataUsage.class.getName())
- .setTitleRes(R.string.app_data_usage)
+ .setTitleRes(R.string.data_usage_app_summary_title)
.setArguments(args)
.setSourceMetricsCategory(getMetricsCategory())
.launch();
diff --git a/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java b/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java
index 824c102..97ed5ac 100644
--- a/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java
+++ b/src/com/android/settings/datausage/UnrestrictedDataAccessPreference.java
@@ -82,7 +82,7 @@
if (mDataUsageState.isDataSaverBlacklisted) {
// app is blacklisted, launch App Data Usage screen
AppInfoDashboardFragment.startAppInfoFragment(AppDataUsage.class,
- R.string.app_data_usage,
+ R.string.data_usage_app_summary_title,
null /* arguments */,
mParentFragment,
mEntry);
diff --git a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
index e65d2ad..564f2c3 100644
--- a/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
+++ b/src/com/android/settings/development/DevelopmentOptionsActivityRequestCodes.java
@@ -31,6 +31,4 @@
int REQUEST_CODE_ANGLE_DRIVER_PKGS = 4;
int REQUEST_CODE_ANGLE_DRIVER_VALUES = 5;
-
- int REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP = 6;
}
diff --git a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
index aa9918c..725a195 100644
--- a/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
+++ b/src/com/android/settings/development/DevelopmentSettingsDashboardFragment.java
@@ -423,7 +423,6 @@
controllers.add(new SelectDebugAppPreferenceController(context, fragment));
controllers.add(new WaitForDebuggerPreferenceController(context));
controllers.add(new EnableGpuDebugLayersPreferenceController(context));
- controllers.add(new UpdatedGfxDriverDevOptInPreferenceController(context, fragment));
controllers.add(new VerifyAppsOverUsbPreferenceController(context));
controllers.add(new LogdSizePreferenceController(context));
controllers.add(new LogPersistPreferenceController(context, fragment, lifecycle));
diff --git a/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceController.java b/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceController.java
deleted file mode 100644
index ad2131e..0000000
--- a/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceController.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright 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.development;
-
-import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes
- .REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.ApplicationInfo;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-import androidx.annotation.VisibleForTesting;
-import androidx.preference.Preference;
-
-import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.development.DeveloperOptionsPreferenceController;
-
-// TODO(b/119221883): Need to override isAvailable() to return false when updatable graphics driver is not supported.
-public class UpdatedGfxDriverDevOptInPreferenceController
- extends DeveloperOptionsPreferenceController
- implements PreferenceControllerMixin, OnActivityResultListener {
-
- private static final String UPDATED_GFX_DRIVER_DEV_OPT_IN_APP_KEY =
- "updated_gfx_driver_dev_opt_in_app";
-
- private final DevelopmentSettingsDashboardFragment mFragment;
- private final PackageManager mPackageManager;
-
- public UpdatedGfxDriverDevOptInPreferenceController(Context context,
- DevelopmentSettingsDashboardFragment fragment) {
- super(context);
- mFragment = fragment;
- mPackageManager = mContext.getPackageManager();
- }
-
- @Override
- public String getPreferenceKey() {
- return UPDATED_GFX_DRIVER_DEV_OPT_IN_APP_KEY;
- }
-
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (UPDATED_GFX_DRIVER_DEV_OPT_IN_APP_KEY.equals(preference.getKey())) {
- // pass it on to settings
- final Intent intent = getActivityStartIntent();
- mFragment.startActivityForResult(intent,
- REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP);
- return true;
- }
- return false;
- }
-
- @Override
- public void updateState(Preference preference) {
- updatePreferenceSummary();
- }
-
- @Override
- public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode != REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP
- || resultCode != Activity.RESULT_OK) {
- return false;
- }
- Settings.Global.putString(mContext.getContentResolver(),
- Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, data.getAction());
- updatePreferenceSummary();
- return true;
- }
-
- @Override
- protected void onDeveloperOptionsSwitchDisabled() {
- super.onDeveloperOptionsSwitchDisabled();
- mPreference.setSummary(mContext.getResources().getString(
- R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
-
- @VisibleForTesting
- Intent getActivityStartIntent() {
- Intent intent = new Intent(mContext, AppPicker.class);
- intent.putExtra(AppPicker.EXTRA_NON_SYSTEM, true /* value */);
- return intent;
- }
-
- private void updatePreferenceSummary() {
- final String updatedGfxDriverDevOptInApp = Settings.Global.getString(
- mContext.getContentResolver(), Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP);
- if (updatedGfxDriverDevOptInApp != null && !updatedGfxDriverDevOptInApp.isEmpty()) {
- mPreference.setSummary(mContext.getResources().getString(
- R.string.updated_gfx_driver_dev_opt_in_app_set,
- getAppLabel(updatedGfxDriverDevOptInApp)));
- } else {
- mPreference.setSummary(mContext.getResources().getString(
- R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
- }
-
- private String getAppLabel(String applicationPackageName) {
- try {
- final ApplicationInfo ai = mPackageManager.getApplicationInfo(applicationPackageName,
- PackageManager.GET_DISABLED_COMPONENTS);
- final CharSequence lab = mPackageManager.getApplicationLabel(ai);
- return lab != null ? lab.toString() : applicationPackageName;
- } catch (PackageManager.NameNotFoundException e) {
- return applicationPackageName;
- }
- }
-}
diff --git a/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java b/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java
index d27af64..33de9c3 100644
--- a/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java
+++ b/src/com/android/settings/development/featureflags/FeatureFlagPersistent.java
@@ -37,6 +37,7 @@
static {
PERSISTENT_FLAGS = new HashSet<>();
PERSISTENT_FLAGS.add(FeatureFlags.HEARING_AID_SETTINGS);
+ PERSISTENT_FLAGS.add(FeatureFlags.NETWORK_INTERNET_V2);
}
public static boolean isEnabled(Context context, String feature) {
diff --git a/src/com/android/settings/development/gup/GupDashboard.java b/src/com/android/settings/development/gup/GupDashboard.java
new file mode 100644
index 0000000..31f01dd
--- /dev/null
+++ b/src/com/android/settings/development/gup/GupDashboard.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 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.development.gup;
+
+import android.content.Context;
+import android.provider.SearchIndexableResource;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.search.BaseSearchIndexProvider;
+import com.android.settings.search.Indexable;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.core.lifecycle.Lifecycle;
+import com.android.settingslib.development.DevelopmentSettingsEnabler;
+import com.android.settingslib.search.SearchIndexable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@SearchIndexable
+public class GupDashboard extends DashboardFragment {
+ private static final String TAG = "GupDashboard";
+
+ @Override
+ public int getMetricsCategory() {
+ return MetricsProto.MetricsEvent.SETTINGS_GUP_DASHBOARD;
+ }
+
+ @Override
+ protected String getLogTag() {
+ return TAG;
+ }
+
+ @Override
+ protected int getPreferenceScreenResId() {
+ return R.xml.gup_settings;
+ }
+
+ @Override
+ public int getHelpResource() {
+ return 0;
+ }
+
+ public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+ @Override
+ public List<SearchIndexableResource> getXmlResourcesToIndex(
+ Context context, boolean enabled) {
+ final List<SearchIndexableResource> result = new ArrayList<>();
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.gup_settings;
+ result.add(sir);
+ return result;
+ }
+
+ @Override
+ protected boolean isPageSearchEnabled(Context context) {
+ return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context);
+ }
+ };
+}
diff --git a/src/com/android/settings/development/gup/GupPreferenceController.java b/src/com/android/settings/development/gup/GupPreferenceController.java
new file mode 100644
index 0000000..7623144
--- /dev/null
+++ b/src/com/android/settings/development/gup/GupPreferenceController.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright 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.development.gup;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.provider.Settings;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.ListPreference;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settingslib.development.DevelopmentSettingsEnabler;
+
+import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+public class GupPreferenceController
+ extends BasePreferenceController implements Preference.OnPreferenceChangeListener {
+ private final CharSequence[] mEntryList;
+ private final String mPreferenceTitle;
+ private final String mPreferenceDefault;
+ private final String mPreferenceGup;
+ private final String mPreferenceNative;
+
+ private final List<AppInfo> mAppInfos;
+ private final Set<String> mDevOptInApps;
+ private final Set<String> mDevOptOutApps;
+
+ public GupPreferenceController(Context context, String key) {
+ super(context, key);
+
+ final Resources resources = context.getResources();
+ mEntryList = resources.getStringArray(R.array.gup_app_preference_values);
+ mPreferenceTitle = resources.getString(R.string.gup_app_preference_title);
+ mPreferenceDefault = resources.getString(R.string.gup_app_preference_default);
+ mPreferenceGup = resources.getString(R.string.gup_app_preference_gup);
+ mPreferenceNative = resources.getString(R.string.gup_app_preference_native);
+
+ // TODO: Move this task to background if there's potential ANR/Jank.
+ // Update the UI when all the app infos are ready.
+ mAppInfos = getAppInfos(context);
+
+ final ContentResolver contentResolver = context.getContentResolver();
+ mDevOptInApps =
+ getGlobalSettingsString(contentResolver, Settings.Global.GUP_DEV_OPT_IN_APPS);
+ mDevOptOutApps =
+ getGlobalSettingsString(contentResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(mContext)
+ ? AVAILABLE
+ : DISABLED_DEPENDENT_SETTING;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ final PreferenceGroup preferenceGroup =
+ (PreferenceGroup) screen.findPreference(getPreferenceKey());
+ if (preferenceGroup == null) {
+ return;
+ }
+
+ for (AppInfo appInfo : mAppInfos) {
+ preferenceGroup.addPreference(
+ createListPreference(appInfo.info.packageName, appInfo.label));
+ }
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ final ListPreference listPref = (ListPreference) preference;
+ final String value = newValue.toString();
+ final String packageName = preference.getKey();
+
+ // When user choose a new preference, update both Sets for
+ // opt-in and opt-out apps. Then set the new summary text.
+ if (value.equals(mPreferenceNative)) {
+ mDevOptInApps.remove(packageName);
+ mDevOptOutApps.add(packageName);
+ listPref.setSummary(mPreferenceNative);
+ } else if (value.equals(mPreferenceGup)) {
+ mDevOptInApps.add(packageName);
+ mDevOptOutApps.remove(packageName);
+ listPref.setSummary(mPreferenceGup);
+ } else {
+ mDevOptInApps.remove(packageName);
+ mDevOptOutApps.remove(packageName);
+ listPref.setSummary(mPreferenceDefault);
+ }
+
+ // Push the updated Sets for opt-in and opt-out apps to
+ // corresponding Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
+ Settings.Global.putString(mContext.getContentResolver(),
+ Settings.Global.GUP_DEV_OPT_IN_APPS, String.join(",", mDevOptInApps));
+ Settings.Global.putString(mContext.getContentResolver(),
+ Settings.Global.GUP_DEV_OPT_OUT_APPS, String.join(",", mDevOptOutApps));
+
+ return true;
+ }
+
+ // AppInfo class to achieve loading the application label only once
+ class AppInfo {
+ AppInfo(PackageManager packageManager, ApplicationInfo applicationInfo) {
+ info = applicationInfo;
+ label = packageManager.getApplicationLabel(applicationInfo).toString();
+ }
+ final ApplicationInfo info;
+ final String label;
+ }
+
+ // List of non-system packages that are installed for the current user.
+ private List<AppInfo> getAppInfos(Context context) {
+ final PackageManager packageManager = context.getPackageManager();
+ final List<ApplicationInfo> applicationInfos =
+ packageManager.getInstalledApplications(0 /* flags */);
+
+ final List<AppInfo> appInfos = new ArrayList<>();
+ for (ApplicationInfo applicationInfo : applicationInfos) {
+ if ((applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
+ appInfos.add(new AppInfo(packageManager, applicationInfo));
+ }
+ }
+
+ Collections.sort(appInfos, appInfoComparator);
+
+ return appInfos;
+ }
+
+ // Parse the raw comma separated package names into a String Set
+ private Set<String> getGlobalSettingsString(ContentResolver contentResolver, String name) {
+ final String settingsValue = Settings.Global.getString(contentResolver, name);
+ if (settingsValue == null) {
+ return new HashSet<>();
+ }
+
+ final Set<String> valueSet = new HashSet<>(Arrays.asList(settingsValue.split(",")));
+ valueSet.remove("");
+
+ return valueSet;
+ }
+
+ private final Comparator<AppInfo> appInfoComparator = new Comparator<AppInfo>() {
+ public final int compare(AppInfo a, AppInfo b) {
+ return Collator.getInstance().compare(a.label, b.label);
+ }
+ };
+
+ @VisibleForTesting
+ protected ListPreference createListPreference(String packageName, String appName) {
+ final ListPreference listPreference = new ListPreference(mContext);
+
+ listPreference.setKey(packageName);
+ listPreference.setTitle(appName);
+ listPreference.setDialogTitle(mPreferenceTitle);
+ listPreference.setEntries(mEntryList);
+ listPreference.setEntryValues(mEntryList);
+
+ // Initialize preference default and summary with the opt in/out choices
+ // from Settings.Global.GUP_DEV_OPT_(IN|OUT)_APPS
+ if (mDevOptOutApps.contains(packageName)) {
+ listPreference.setValue(mPreferenceNative);
+ listPreference.setSummary(mPreferenceNative);
+ } else if (mDevOptInApps.contains(packageName)) {
+ listPreference.setValue(mPreferenceGup);
+ listPreference.setSummary(mPreferenceGup);
+ } else {
+ listPreference.setValue(mPreferenceDefault);
+ listPreference.setSummary(mPreferenceDefault);
+ }
+
+ listPreference.setOnPreferenceChangeListener(this);
+
+ return listPreference;
+ }
+}
diff --git a/src/com/android/settings/deviceinfo/StorageWizardBase.java b/src/com/android/settings/deviceinfo/StorageWizardBase.java
index 9950d3f..db0d0d0 100644
--- a/src/com/android/settings/deviceinfo/StorageWizardBase.java
+++ b/src/com/android/settings/deviceinfo/StorageWizardBase.java
@@ -96,20 +96,20 @@
mButtonFooterMixin = getGlifLayout().getMixin(ButtonFooterMixin.class);
mButtonFooterMixin.setSecondaryButton(
- new FooterButton(
- this,
- R.string.wizard_back,
- this::onNavigateBack,
- FooterButton.ButtonType.OTHER,
- R.style.SuwGlifButton_Secondary)
+ new FooterButton.Builder(this)
+ .setText(R.string.wizard_back)
+ .setListener(this::onNavigateBack)
+ .setButtonType(FooterButton.ButtonType.OTHER)
+ .setTheme(R.style.SudGlifButton_Secondary)
+ .build()
);
mButtonFooterMixin.setPrimaryButton(
- new FooterButton(
- this,
- R.string.wizard_next,
- this::onNavigateNext,
- FooterButton.ButtonType.NEXT,
- R.style.SuwGlifButton_Primary)
+ new FooterButton.Builder(this)
+ .setText(R.string.wizard_next)
+ .setListener(this::onNavigateNext)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
);
mBack = mButtonFooterMixin.getSecondaryButton();
mNext = mButtonFooterMixin.getPrimaryButton();
diff --git a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
index 19b6975..e836d1f 100644
--- a/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
+++ b/src/com/android/settings/deviceinfo/aboutphone/MyDeviceInfoFragment.java
@@ -79,8 +79,9 @@
@Override
public void onAttach(Context context) {
super.onAttach(context);
- use(FirmwareVersionPreferenceController.class).setHost(this /*parent*/);
+ use(FirmwareVersionPreferenceController.class).setHost(this /* parent */);
use(DeviceModelPreferenceController.class).setHost(this /* parent */);
+ use(ImeiInfoPreferenceController.class).setHost(this /* parent */);
mBuildNumberPreferenceController = use(BuildNumberPreferenceController.class);
mBuildNumberPreferenceController.setHost(this /* parent */);
}
@@ -121,7 +122,6 @@
}
controllers.add(deviceNamePreferenceController);
controllers.add(new SimStatusPreferenceController(context, fragment));
- controllers.add(new ImeiInfoPreferenceController(context, fragment));
controllers.add(new IpAddressPreferenceController(context, lifecycle));
controllers.add(new WifiMacAddressPreferenceController(context, lifecycle));
controllers.add(new BluetoothAddressPreferenceController(context, lifecycle));
@@ -197,7 +197,7 @@
@Override
public List<AbstractPreferenceController> createPreferenceControllers(
Context context) {
- return buildPreferenceControllers(context, null /*activity */,
+ return buildPreferenceControllers(context, null /* activity */,
null /* fragment */, null /* lifecycle */);
}
};
diff --git a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
index 7d12d43..b7b67b7 100644
--- a/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceController.java
@@ -23,9 +23,12 @@
import androidx.fragment.app.Fragment;
import androidx.preference.Preference;
+import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.slices.Copyable;
-public class FirmwareVersionPreferenceController extends BasePreferenceController {
+public class FirmwareVersionPreferenceController extends BasePreferenceController implements
+ Copyable {
private Fragment mFragment;
@@ -61,4 +64,10 @@
public boolean isSliceable() {
return true;
}
+
+ @Override
+ public void copy() {
+ Copyable.setCopyContent(mContext, getSummary(),
+ mContext.getText(R.string.firmware_version));
+ }
}
diff --git a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
index 66d68a6..96ff83c 100644
--- a/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
+++ b/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceController.java
@@ -19,6 +19,7 @@
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
import android.content.Context;
+import android.os.UserManager;
import android.telephony.TelephonyManager;
import androidx.annotation.VisibleForTesting;
@@ -27,8 +28,9 @@
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settingslib.deviceinfo.AbstractSimStatusImeiInfoPreferenceController;
+import com.android.settings.core.BasePreferenceController;
+import com.android.settings.slices.Copyable;
+import com.android.settingslib.Utils;
import java.util.ArrayList;
import java.util.List;
@@ -36,39 +38,30 @@
/**
* Controller that manages preference for single and multi sim devices.
*/
-public class ImeiInfoPreferenceController extends
- AbstractSimStatusImeiInfoPreferenceController implements PreferenceControllerMixin {
-
- private static final String KEY_IMEI_INFO = "imei_info";
+public class ImeiInfoPreferenceController extends BasePreferenceController implements Copyable {
private final boolean mIsMultiSim;
private final TelephonyManager mTelephonyManager;
private final List<Preference> mPreferenceList = new ArrayList<>();
- private final Fragment mFragment;
+ private Fragment mFragment;
- public ImeiInfoPreferenceController(Context context, Fragment fragment) {
- super(context);
-
- mFragment = fragment;
+ public ImeiInfoPreferenceController(Context context, String key) {
+ super(context, key);
mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
mIsMultiSim = mTelephonyManager.getPhoneCount() > 1;
}
- @Override
- public String getPreferenceKey() {
- return KEY_IMEI_INFO;
+ public void setHost(Fragment fragment) {
+ mFragment = fragment;
}
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
final Preference preference = screen.findPreference(getPreferenceKey());
- if (!isAvailable() || preference == null || !preference.isVisible()) {
- return;
- }
mPreferenceList.add(preference);
- updatePreference(preference, 0 /* sim slot */);
+ updatePreference(preference, 0 /* simSlot */);
final int imeiPreferenceOrder = preference.getOrder();
// Add additional preferences for each sim in the device
@@ -76,7 +69,7 @@
simSlotNumber++) {
final Preference multiSimPreference = createNewPreference(screen.getContext());
multiSimPreference.setOrder(imeiPreferenceOrder + simSlotNumber);
- multiSimPreference.setKey(KEY_IMEI_INFO + simSlotNumber);
+ multiSimPreference.setKey(getPreferenceKey() + simSlotNumber);
screen.addPreference(multiSimPreference);
mPreferenceList.add(multiSimPreference);
updatePreference(multiSimPreference, simSlotNumber);
@@ -84,6 +77,13 @@
}
@Override
+ public CharSequence getSummary() {
+ final int phoneType = mTelephonyManager.getPhoneType();
+ return phoneType == PHONE_TYPE_CDMA ? mTelephonyManager.getMeid()
+ : mTelephonyManager.getImei();
+ }
+
+ @Override
public boolean handlePreferenceTreeClick(Preference preference) {
final int simSlot = mPreferenceList.indexOf(preference);
if (simSlot == -1) {
@@ -94,6 +94,22 @@
return true;
}
+ @Override
+ public int getAvailabilityStatus() {
+ return mContext.getSystemService(UserManager.class).isAdminUser()
+ && !Utils.isWifiOnly(mContext) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ }
+
+ @Override
+ public boolean isSliceable() {
+ return true;
+ }
+
+ @Override
+ public void copy() {
+ Copyable.setCopyContent(mContext, getSummary(), mContext.getText(R.string.status_imei));
+ }
+
private void updatePreference(Preference preference, int simSlot) {
final int phoneType = mTelephonyManager.getPhoneType();
if (phoneType == PHONE_TYPE_CDMA) {
diff --git a/src/com/android/settings/display/DisplayWhiteBalancePreferenceController.java b/src/com/android/settings/display/DisplayWhiteBalancePreferenceController.java
new file mode 100644
index 0000000..f1363a3
--- /dev/null
+++ b/src/com/android/settings/display/DisplayWhiteBalancePreferenceController.java
@@ -0,0 +1,46 @@
+/*
+ * 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.display;
+
+import android.content.Context;
+import android.hardware.display.ColorDisplayManager;
+import android.os.UserHandle;
+import android.provider.Settings.Secure;
+import com.android.settings.core.TogglePreferenceController;
+
+public class DisplayWhiteBalancePreferenceController extends TogglePreferenceController {
+
+ public DisplayWhiteBalancePreferenceController(Context context, String key) {
+ super(context, key);
+ }
+
+ @Override
+ public int getAvailabilityStatus() {
+ return ColorDisplayManager.isDisplayWhiteBalanceAvailable(mContext) ?
+ AVAILABLE : DISABLED_FOR_USER;
+ }
+
+ @Override
+ public boolean isChecked() {
+ return Secure.getIntForUser(mContext.getContentResolver(),
+ Secure.DISPLAY_WHITE_BALANCE_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
+ }
+
+ @Override
+ public boolean setChecked(boolean isChecked) {
+ Secure.putIntForUser(mContext.getContentResolver(), Secure.DISPLAY_WHITE_BALANCE_ENABLED,
+ isChecked ? 1 : 0, UserHandle.USER_CURRENT);
+ return true;
+ }
+}
diff --git a/src/com/android/settings/display/TimeoutListPreference.java b/src/com/android/settings/display/TimeoutListPreference.java
index f9a731d..5ed427f 100644
--- a/src/com/android/settings/display/TimeoutListPreference.java
+++ b/src/com/android/settings/display/TimeoutListPreference.java
@@ -26,6 +26,7 @@
import android.util.Log;
import android.view.View;
+import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog.Builder;
import com.android.settings.R;
@@ -33,18 +34,18 @@
import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
+import java.util.List;
public class TimeoutListPreference extends RestrictedListPreference {
private static final String TAG = "TimeoutListPreference";
private EnforcedAdmin mAdmin;
- private final CharSequence[] mInitialEntries;
- private final CharSequence[] mInitialValues;
+ private CharSequence[] mInitialEntries;
+ private CharSequence[] mInitialValues;
public TimeoutListPreference(Context context, AttributeSet attrs) {
super(context, attrs);
- mInitialEntries = getEntries();
- mInitialValues = getEntryValues();
+ updateInitialValues();
}
@Override
@@ -65,13 +66,8 @@
if (mAdmin != null) {
View footerView = dialog.findViewById(R.id.admin_disabled_other_options);
footerView.findViewById(R.id.admin_more_details_link).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
- getContext(), mAdmin);
- }
- });
+ view -> RestrictedLockUtils.sendShowAdminSupportDetailsIntent(
+ getContext(), mAdmin));
}
}
@@ -89,8 +85,8 @@
maxTimeout = Long.MAX_VALUE;
}
- ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
- ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
+ final ArrayList<CharSequence> revisedEntries = new ArrayList<>();
+ final ArrayList<CharSequence> revisedValues = new ArrayList<>();
for (int i = 0; i < mInitialValues.length; ++i) {
long timeout = Long.parseLong(mInitialValues[i].toString());
if (timeout <= maxTimeout) {
@@ -101,7 +97,7 @@
// If there are no possible options for the user, then set this preference as disabled
// by admin, otherwise remove the padlock in case it was set earlier.
- if (revisedValues.size() == 0) {
+ if (revisedValues.isEmpty()) {
setDisabledByAdmin(admin);
return;
} else {
@@ -117,7 +113,7 @@
setValue(String.valueOf(userPreference));
} else if (revisedValues.size() > 0
&& Long.parseLong(revisedValues.get(revisedValues.size() - 1).toString())
- == maxTimeout) {
+ == maxTimeout) {
// If the last one happens to be the same as the max timeout, select that
setValue(String.valueOf(maxTimeout));
} else {
@@ -128,4 +124,36 @@
}
}
}
+
+ @VisibleForTesting
+ void updateInitialValues() {
+ // Read default list of candidate values.
+ final CharSequence[] entries = getEntries();
+ final CharSequence[] values = getEntryValues();
+ // Filter out values based on config
+ final List<CharSequence> revisedEntries = new ArrayList<>();
+ final List<CharSequence> revisedValues = new ArrayList<>();
+ final long maxTimeout = getContext().getResources().getInteger(
+ R.integer.max_lock_after_timeout_ms);
+ if (entries == null || values == null) {
+ return;
+ }
+ Log.d(TAG, "max timeout: " + maxTimeout);
+ for (int i = 0; i < values.length; ++i) {
+ long timeout = Long.parseLong(values[i].toString());
+ if (timeout <= maxTimeout) {
+ Log.d(TAG, "keeping timeout: " + values[i]);
+ revisedEntries.add(entries[i]);
+ revisedValues.add(values[i]);
+ } else {
+ Log.d(TAG, "Dropping timeout: " + values[i]);
+ }
+ }
+
+ // Store final candidates in initial value lists.
+ mInitialEntries = revisedEntries.toArray(new CharSequence[0]);
+ setEntries(mInitialEntries);
+ mInitialValues = revisedValues.toArray(new CharSequence[0]);
+ setEntryValues(mInitialValues);
+ }
}
diff --git a/src/com/android/settings/display/TimeoutPreferenceController.java b/src/com/android/settings/display/TimeoutPreferenceController.java
index 60b7e24..c1c5069 100644
--- a/src/com/android/settings/display/TimeoutPreferenceController.java
+++ b/src/com/android/settings/display/TimeoutPreferenceController.java
@@ -13,8 +13,6 @@
*/
package com.android.settings.display;
-import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
-
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.UserHandle;
@@ -60,7 +58,7 @@
public void updateState(Preference preference) {
final TimeoutListPreference timeoutListPreference = (TimeoutListPreference) preference;
final long currentTimeout = Settings.System.getLong(mContext.getContentResolver(),
- SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
+ Settings.System.SCREEN_OFF_TIMEOUT, FALLBACK_SCREEN_TIMEOUT_VALUE);
timeoutListPreference.setValue(String.valueOf(currentTimeout));
final DevicePolicyManager dpm =
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
@@ -86,7 +84,8 @@
public boolean onPreferenceChange(Preference preference, Object newValue) {
try {
int value = Integer.parseInt((String) newValue);
- Settings.System.putInt(mContext.getContentResolver(), SCREEN_OFF_TIMEOUT, value);
+ Settings.System.putInt(mContext.getContentResolver(),
+ Settings.System.SCREEN_OFF_TIMEOUT, value);
updateTimeoutPreferenceDescription((TimeoutListPreference) preference, value);
} catch (NumberFormatException e) {
Log.e(TAG, "could not persist screen timeout setting", e);
@@ -94,7 +93,7 @@
return true;
}
- public static CharSequence getTimeoutDescription(
+ private static CharSequence getTimeoutDescription(
long currentTimeout, CharSequence[] entries, CharSequence[] values) {
if (currentTimeout < 0 || entries == null || values == null
|| values.length != entries.length) {
diff --git a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
index 48f4cc1..3064d4f 100644
--- a/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
+++ b/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceController.java
@@ -21,8 +21,10 @@
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.icu.text.NumberFormat;
import android.os.BatteryManager;
import android.os.PowerManager;
+import android.text.TextUtils;
import android.widget.TextView;
import androidx.annotation.VisibleForTesting;
@@ -83,7 +85,7 @@
@Override
public void displayPreference(PreferenceScreen screen) {
super.displayPreference(screen);
- mBatteryLayoutPref = (LayoutPreference) screen.findPreference(getPreferenceKey());
+ mBatteryLayoutPref = screen.findPreference(getPreferenceKey());
mBatteryMeterView = mBatteryLayoutPref
.findViewById(R.id.battery_header_icon);
mBatteryPercentText = mBatteryLayoutPref.findViewById(R.id.battery_percent);
@@ -107,7 +109,7 @@
}
public void updateHeaderPreference(BatteryInfo info) {
- mBatteryPercentText.setText(Utils.formatPercentage(info.batteryLevel));
+ mBatteryPercentText.setText(formatBatteryPercentageText(info.batteryLevel));
if (info.remainingLabel == null) {
mSummary1.setText(info.statusLabel);
} else {
@@ -133,6 +135,11 @@
mBatteryMeterView.setBatteryLevel(batteryLevel);
mBatteryMeterView.setCharging(!discharging);
mBatteryMeterView.setPowerSave(mPowerManager.isPowerSaveMode());
- mBatteryPercentText.setText(Utils.formatPercentage(batteryLevel));
+ mBatteryPercentText.setText(formatBatteryPercentageText(batteryLevel));
+ }
+
+ private CharSequence formatBatteryPercentageText(int batteryLevel) {
+ return TextUtils.expandTemplate(mContext.getText(R.string.battery_header_title_alternate),
+ NumberFormat.getIntegerInstance().format(batteryLevel));
}
}
diff --git a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
index cb9bf4f..8f037ce 100644
--- a/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/PreventRingingGesturePreferenceController.java
@@ -46,7 +46,7 @@
OnResume, OnPause, OnCreate, PreferenceControllerMixin {
@VisibleForTesting static final String KEY_VIBRATE = "prevent_ringing_option_vibrate";
- @VisibleForTesting static final String KEY_NONE = "prevent_ringing_option_none";
+
@VisibleForTesting static final String KEY_MUTE = "prevent_ringing_option_mute";
private final String KEY_VIDEO_PAUSED = "key_video_paused";
@@ -57,9 +57,8 @@
private VideoPreference mVideoPreference;
private boolean mVideoPaused;
- private PreferenceCategory mPreferenceCategory;
+ @VisibleForTesting PreferenceCategory mPreferenceCategory;
@VisibleForTesting RadioButtonPreference mVibratePref;
- @VisibleForTesting RadioButtonPreference mNonePref;
@VisibleForTesting RadioButtonPreference mMutePref;
private SettingObserver mSettingObserver;
@@ -80,7 +79,6 @@
mPreferenceCategory = (PreferenceCategory) screen.findPreference(getPreferenceKey());
mVibratePref = makeRadioPreference(KEY_VIBRATE, R.string.prevent_ringing_option_vibrate);
mMutePref = makeRadioPreference(KEY_MUTE, R.string.prevent_ringing_option_mute);
- mNonePref = makeRadioPreference(KEY_NONE, R.string.prevent_ringing_option_none);
if (mPreferenceCategory != null) {
mSettingObserver = new SettingObserver(mPreferenceCategory);
@@ -124,19 +122,21 @@
public void updateState(Preference preference) {
int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE);
-
final boolean isVibrate = preventRingingSetting == Settings.Secure.VOLUME_HUSH_VIBRATE;
final boolean isMute = preventRingingSetting == Settings.Secure.VOLUME_HUSH_MUTE;
- final boolean isOff = preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF
- || (!isVibrate && !isMute);
if (mVibratePref != null && mVibratePref.isChecked() != isVibrate) {
mVibratePref.setChecked(isVibrate);
}
if (mMutePref != null && mMutePref.isChecked() != isMute) {
mMutePref.setChecked(isMute);
}
- if (mNonePref != null && mNonePref.isChecked() != isOff) {
- mNonePref.setChecked(isOff);
+
+ if (preventRingingSetting == Settings.Secure.VOLUME_HUSH_OFF) {
+ mVibratePref.setEnabled(false);
+ mMutePref.setEnabled(false);
+ } else {
+ mVibratePref.setEnabled(true);
+ mMutePref.setEnabled(true);
}
}
@@ -173,13 +173,12 @@
private int keyToSetting(String key) {
switch (key) {
- case KEY_NONE:
- return Settings.Secure.VOLUME_HUSH_OFF;
case KEY_MUTE:
return Settings.Secure.VOLUME_HUSH_MUTE;
case KEY_VIBRATE:
- default:
return Settings.Secure.VOLUME_HUSH_VIBRATE;
+ default:
+ return Settings.Secure.VOLUME_HUSH_OFF;
}
}
diff --git a/src/com/android/settings/gestures/PreventRingingGestureSettings.java b/src/com/android/settings/gestures/PreventRingingGestureSettings.java
index 3e8ae85..420a019 100644
--- a/src/com/android/settings/gestures/PreventRingingGestureSettings.java
+++ b/src/com/android/settings/gestures/PreventRingingGestureSettings.java
@@ -35,7 +35,6 @@
public class PreventRingingGestureSettings extends DashboardFragment {
private static final String TAG = "RingingGestureSettings";
- private static final String KEY_PREVENT_RINGING = "gesture_prevent_ringing";
@Override
public void onAttach(Context context) {
@@ -51,6 +50,7 @@
Lifecycle lifecycle) {
List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new PreventRingingGesturePreferenceController(context, lifecycle));
+ controllers.add(new PreventRingingSwitchPreferenceController(context));
return controllers;
}
diff --git a/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
new file mode 100644
index 0000000..b94cfff
--- /dev/null
+++ b/src/com/android/settings/gestures/PreventRingingSwitchPreferenceController.java
@@ -0,0 +1,125 @@
+/*
+ * 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.gestures;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.database.ContentObserver;
+import android.net.Uri;
+import android.os.Handler;
+import android.provider.Settings;
+import android.widget.Switch;
+
+import androidx.annotation.VisibleForTesting;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settings.core.PreferenceControllerMixin;
+import com.android.settings.widget.SwitchBar;
+import com.android.settingslib.core.AbstractPreferenceController;
+import com.android.settingslib.widget.LayoutPreference;
+
+public class PreventRingingSwitchPreferenceController extends AbstractPreferenceController
+ implements PreferenceControllerMixin, SwitchBar.OnSwitchChangeListener {
+
+ private static final String KEY = "gesture_prevent_ringing_switch";
+ private final Context mContext;
+ private SettingObserver mSettingObserver;
+
+ @VisibleForTesting SwitchBar mSwitch;
+
+ public PreventRingingSwitchPreferenceController(Context context) {
+ super(context);
+ mContext = context;
+ }
+
+ @Override
+ public String getPreferenceKey() {
+ return KEY;
+ }
+
+ @Override
+ public void displayPreference(PreferenceScreen screen) {
+ super.displayPreference(screen);
+ if (isAvailable()) {
+ LayoutPreference pref = (LayoutPreference) screen.findPreference(getPreferenceKey());
+ if (pref != null) {
+ mSettingObserver = new SettingObserver(pref);
+ mSwitch = pref.findViewById(R.id.switch_bar);
+ if (mSwitch != null) {
+ mSwitch.addOnSwitchChangeListener(this);
+ mSwitch.show();
+ }
+ }
+ }
+ }
+
+ public void setChecked(boolean isChecked) {
+ if (mSwitch != null) {
+ mSwitch.setChecked(isChecked);
+ }
+ }
+
+ @Override
+ public void updateState(Preference preference) {
+ int preventRingingSetting = Settings.Secure.getInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE);
+ setChecked(preventRingingSetting != Settings.Secure.VOLUME_HUSH_OFF);
+ }
+
+ @Override
+ public boolean isAvailable() {
+ return mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled);
+ }
+
+ @Override
+ public void onSwitchChanged(Switch switchView, boolean isChecked) {
+ Settings.Secure.putInt(mContext.getContentResolver(),
+ Settings.Secure.VOLUME_HUSH_GESTURE, isChecked ? Settings.Secure.VOLUME_HUSH_VIBRATE
+ : Settings.Secure.VOLUME_HUSH_OFF);
+ }
+
+ private class SettingObserver extends ContentObserver {
+ private final Uri VOLUME_HUSH_GESTURE = Settings.Secure.getUriFor(
+ Settings.Secure.VOLUME_HUSH_GESTURE);
+
+ private final Preference mPreference;
+
+ public SettingObserver(Preference preference) {
+ super(new Handler());
+ mPreference = preference;
+ }
+
+ public void register(ContentResolver cr) {
+ cr.registerContentObserver(VOLUME_HUSH_GESTURE, false, this);
+ }
+
+ public void unregister(ContentResolver cr) {
+ cr.unregisterContentObserver(this);
+ }
+
+ @Override
+ public void onChange(boolean selfChange, Uri uri) {
+ super.onChange(selfChange, uri);
+ if (uri == null || VOLUME_HUSH_GESTURE.equals(uri)) {
+ updateState(mPreference);
+ }
+ }
+ }
+}
diff --git a/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceController.java b/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceController.java
index 1f1630e..2b61ec8 100644
--- a/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceController.java
+++ b/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceController.java
@@ -53,7 +53,7 @@
@Override
public int getAvailabilityStatus() {
// No hardware support for this Gesture
- if (!getAmbientConfig().wakeLockScreenGestureAvailable()) {
+ if (!getAmbientConfig().wakeScreenGestureAvailable()) {
return UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/homepage/SettingsHomepageActivity.java b/src/com/android/settings/homepage/SettingsHomepageActivity.java
index d3f11a0..d40006f 100644
--- a/src/com/android/settings/homepage/SettingsHomepageActivity.java
+++ b/src/com/android/settings/homepage/SettingsHomepageActivity.java
@@ -19,6 +19,7 @@
import android.content.Intent;
import android.os.Bundle;
import android.util.FeatureFlagUtils;
+import android.view.View;
import android.widget.ImageView;
import android.widget.Toolbar;
@@ -47,6 +48,7 @@
return;
}
+ updateWindowProperties();
setContentView(R.layout.settings_homepage_container);
final Toolbar toolbar = findViewById(R.id.search_action_bar);
@@ -73,4 +75,15 @@
}
fragmentTransaction.commit();
}
+
+ private void updateWindowProperties() {
+ final View decorView = getWindow().getDecorView();
+ decorView.setSystemUiVisibility(
+ decorView.getSystemUiVisibility() |
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
+ View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ );
+
+ getWindow().setStatusBarColor(getResources().getColor(R.color.homepage_status_bar_color));
+ }
}
\ No newline at end of file
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
index 88478e3..49e2a76 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLoader.java
@@ -107,12 +107,12 @@
}
}
}
- return getFinalDisplayableCards(result);
+ return getDisplayableCards(result);
}
// Get final displayed cards and log what cards will be displayed/hidden
@VisibleForTesting
- List<ContextualCard> getFinalDisplayableCards(List<ContextualCard> candidates) {
+ List<ContextualCard> getDisplayableCards(List<ContextualCard> candidates) {
final List<ContextualCard> eligibleCards = filterEligibleCards(candidates);
final List<ContextualCard> visibleCards = new ArrayList<>();
final List<ContextualCard> hiddenCards = new ArrayList<>();
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java b/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java
index a4a8419..90974f6 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardLookupTable.java
@@ -84,7 +84,11 @@
LegacySuggestionContextualCardController.class,
LegacySuggestionContextualCardRenderer.class));
add(new ControllerRendererMapping(CardType.SLICE,
- SliceContextualCardRenderer.VIEW_TYPE,
+ SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH,
+ SliceContextualCardController.class,
+ SliceContextualCardRenderer.class));
+ add(new ControllerRendererMapping(CardType.SLICE,
+ SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH,
SliceContextualCardController.class,
SliceContextualCardRenderer.class));
add(new ControllerRendererMapping(CardType.CONDITIONAL_FOOTER,
diff --git a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
index 067de7c..12088f8 100644
--- a/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
+++ b/src/com/android/settings/homepage/contextualcards/ContextualCardManager.java
@@ -17,6 +17,7 @@
package com.android.settings.homepage.contextualcards;
import static com.android.settings.homepage.contextualcards.ContextualCardLoader.CARD_CONTENT_LOADER_ID;
+import static com.android.settings.intelligence.ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE;
import static java.util.stream.Collectors.groupingBy;
@@ -172,7 +173,8 @@
//replace with the new data
mContextualCards.clear();
- mContextualCards.addAll(sortCards(allCards));
+ final List<ContextualCard> sortedCards = sortCards(allCards);
+ mContextualCards.addAll(assignCardWidth(sortedCards));
loadCardControllers();
@@ -224,6 +226,24 @@
mListener = listener;
}
+ @VisibleForTesting
+ List<ContextualCard> assignCardWidth(List<ContextualCard> cards) {
+ final List<ContextualCard> result = new ArrayList<>(cards);
+ // Shows as half cards if 2 suggestion type of cards are next to each other.
+ // Shows as full card if 1 suggestion type of card lives alone.
+ for (int index = 1; index < result.size(); index++) {
+ final ContextualCard previous = result.get(index - 1);
+ final ContextualCard current = result.get(index);
+ if (current.getCategory() == SUGGESTION_VALUE
+ && previous.getCategory() == SUGGESTION_VALUE) {
+ result.set(index - 1, previous.mutate().setIsHalfWidth(true).build());
+ result.set(index, current.mutate().setIsHalfWidth(true).build());
+ index++;
+ }
+ }
+ return result;
+ }
+
private List<ContextualCard> getCardsToKeep(List<ContextualCard> cards) {
if (mSavedCards != null) {
//screen rotate
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionController.java b/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionController.java
new file mode 100644
index 0000000..bce7c5d
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionController.java
@@ -0,0 +1,108 @@
+/*
+ * 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.homepage.contextualcards.conditional;
+
+import android.content.Context;
+import android.os.PowerManager;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+import com.android.settings.core.SubSettingLauncher;
+import com.android.settings.fuelgauge.BatterySaverReceiver;
+import com.android.settings.fuelgauge.batterysaver.BatterySaverSettings;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settingslib.fuelgauge.BatterySaverUtils;
+
+import java.util.Objects;
+
+public class BatterySaverConditionController implements ConditionalCardController,
+ BatterySaverReceiver.BatterySaverListener {
+ static final int ID = Objects.hash("BatterySaverConditionController");
+
+ private final Context mAppContext;
+ private final ConditionManager mConditionManager;
+ private final BatterySaverReceiver mReceiver;
+ private final PowerManager mPowerManager;
+
+ public BatterySaverConditionController(Context appContext, ConditionManager conditionManager) {
+ mAppContext = appContext;
+ mConditionManager = conditionManager;
+ mPowerManager = appContext.getSystemService(PowerManager.class);
+ mReceiver = new BatterySaverReceiver(appContext);
+ mReceiver.setBatterySaverListener(this);
+ }
+
+ @Override
+ public long getId() {
+ return ID;
+ }
+
+ @Override
+ public boolean isDisplayable() {
+ return mPowerManager.isPowerSaveMode();
+ }
+
+ @Override
+ public void onPrimaryClick(Context context) {
+ new SubSettingLauncher(context)
+ .setDestination(BatterySaverSettings.class.getName())
+ .setSourceMetricsCategory(MetricsProto.MetricsEvent.DASHBOARD_SUMMARY)
+ .setTitleRes(R.string.battery_saver)
+ .launch();
+ }
+
+ @Override
+ public void onActionClick() {
+ BatterySaverUtils.setPowerSaveMode(mAppContext, false,
+ /*needFirstTimeWarning*/ false);
+ }
+
+ @Override
+ public ContextualCard buildContextualCard() {
+ return new ConditionalContextualCard.Builder()
+ .setConditionId(ID)
+ .setMetricsConstant(MetricsProto.MetricsEvent.SETTINGS_CONDITION_BATTERY_SAVER)
+ .setActionText(mAppContext.getText(R.string.condition_turn_off))
+ .setName(mAppContext.getPackageName() + "/"
+ + mAppContext.getText(R.string.condition_battery_title))
+ .setTitleText(mAppContext.getText(R.string.condition_battery_title).toString())
+ .setSummaryText(mAppContext.getText(R.string.condition_battery_summary).toString())
+ .setIconDrawable(mAppContext.getDrawable(R.drawable.ic_battery_saver_accent_24dp))
+ .setIsHalfWidth(true)
+ .build();
+ }
+
+ @Override
+ public void startMonitoringStateChange() {
+ mReceiver.setListening(true);
+ }
+
+ @Override
+ public void stopMonitoringStateChange() {
+ mReceiver.setListening(false);
+ }
+
+ @Override
+ public void onPowerSaveModeChanged() {
+ mConditionManager.onConditionChanged();
+ }
+
+ @Override
+ public void onBatteryChanged(boolean pluggedIn) {
+
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
index 834ebbc..b477d52 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardController.java
@@ -40,7 +40,7 @@
*/
public class ConditionContextualCardController implements ContextualCardController,
ConditionListener, LifecycleObserver, OnStart, OnStop {
- public static final int EXPANDING_THRESHOLD = 2;
+ public static final int EXPANDING_THRESHOLD = 0;
private static final double UNSUPPORTED_RANKING = -99999.0;
private static final String TAG = "ConditionCtxCardCtrl";
diff --git a/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java b/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java
index 39f4903..c741b98 100644
--- a/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java
+++ b/src/com/android/settings/homepage/contextualcards/conditional/ConditionManager.java
@@ -154,6 +154,7 @@
mCardControllers.add(new AirplaneModeConditionController(mAppContext, this /* manager */));
mCardControllers.add(
new BackgroundDataConditionController(mAppContext, this /* manager */));
+ mCardControllers.add(new BatterySaverConditionController(mAppContext, this /* manager */));
mCardControllers.add(new CellularDataConditionController(mAppContext, this /* manager */));
mCardControllers.add(new DndConditionCardController(mAppContext, this /* manager */));
mCardControllers.add(new HotspotConditionController(mAppContext, this /* manager */));
diff --git a/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java b/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSlice.java
similarity index 96%
rename from src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java
rename to src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSlice.java
index 5271e12..41095a4 100644
--- a/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySlice.java
+++ b/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSlice.java
@@ -42,15 +42,15 @@
/**
* Utility class to build a Battery Slice, and handle all associated actions.
*/
-public class BatterySlice implements CustomSliceable {
- private static final String TAG = "BatterySlice";
+public class BatteryInfoSlice implements CustomSliceable {
+ private static final String TAG = "BatteryInfoSlice";
private final Context mContext;
private BatteryInfo mBatteryInfo;
private boolean mIsBatteryInfoLoading;
- public BatterySlice(Context context) {
+ public BatteryInfoSlice(Context context) {
mContext = context;
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
index ab1b4c9..c0cfb3f 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSlice.java
@@ -25,7 +25,6 @@
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
-import android.util.Log;
import androidx.annotation.VisibleForTesting;
import androidx.annotation.WorkerThread;
@@ -49,6 +48,7 @@
import com.android.settings.slices.SliceBuilderUtils;
import com.android.settingslib.utils.ThreadUtils;
+import java.util.Arrays;
import java.util.List;
public class BatteryFixSlice implements CustomSliceable {
@@ -58,6 +58,11 @@
@VisibleForTesting
static final String KEY_CURRENT_TIPS_TYPE = "current_tip_type";
+ private static final List<Integer> UNIMPORTANT_BATTERY_TIPS = Arrays.asList(
+ BatteryTip.TipType.SUMMARY,
+ BatteryTip.TipType.BATTERY_SAVER
+ );
+
private static final String TAG = "BatteryFixSlice";
private final Context mContext;
@@ -78,12 +83,12 @@
.setAccentColor(-1);
// TipType.SUMMARY is battery good
- if (readBatteryTipAvailabilityCache(mContext) == BatteryTip.TipType.SUMMARY) {
+ if (UNIMPORTANT_BATTERY_TIPS.contains(readBatteryTipAvailabilityCache(mContext))) {
return buildBatteryGoodSlice(sliceBuilder, true);
}
- final List<BatteryTip> batteryTips = SliceBackgroundWorker.getInstance(mContext,
- this).getResults();
+ final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
+ final List<BatteryTip> batteryTips = worker != null ? worker.getResults() : null;
if (batteryTips == null) {
// Because we need wait slice background worker return data
@@ -91,19 +96,21 @@
}
for (BatteryTip batteryTip : batteryTips) {
- if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
- final IconCompat icon = IconCompat.createWithResource(mContext, batteryTip.getIconId());
- final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(),
- icon,
- ListBuilder.ICON_IMAGE,
- batteryTip.getTitle(mContext));
- sliceBuilder.addRow(new RowBuilder()
- .setTitleItem(icon, ListBuilder.ICON_IMAGE)
- .setTitle(batteryTip.getTitle(mContext))
- .setSubtitle(batteryTip.getSummary(mContext))
- .setPrimaryAction(primaryAction));
- break;
+ if (batteryTip.getState() == BatteryTip.StateType.INVISIBLE) {
+ continue;
}
+ final IconCompat icon = IconCompat.createWithResource(mContext,
+ batteryTip.getIconId());
+ final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(),
+ icon,
+ ListBuilder.ICON_IMAGE,
+ batteryTip.getTitle(mContext));
+ sliceBuilder.addRow(new RowBuilder()
+ .setTitleItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle(batteryTip.getTitle(mContext))
+ .setSubtitle(batteryTip.getSummary(mContext))
+ .setPrimaryAction(primaryAction));
+ break;
}
return sliceBuilder.build();
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
index 6a75274..b2bec7f 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSlice.java
@@ -273,7 +273,7 @@
private SliceAction buildBluetoothDetailDeepLinkAction(CachedBluetoothDevice bluetoothDevice) {
return SliceAction.createDeeplink(
getBluetoothDetailIntent(bluetoothDevice),
- IconCompat.createWithResource(mContext, R.drawable.ic_settings),
+ IconCompat.createWithResource(mContext, R.drawable.ic_settings_24dp),
ListBuilder.ICON_IMAGE,
bluetoothDevice.getName());
}
@@ -287,9 +287,7 @@
final CharSequence title = mContext.getText(R.string.bluetooth_pairing_pref_title);
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_menu_add);
final SliceAction sliceAction = SliceAction.createDeeplink(
- getPairNewDeviceIntent(),
- IconCompat.createWithResource(mContext, R.drawable.ic_settings),
- ListBuilder.ICON_IMAGE, title);
+ getPairNewDeviceIntent(), icon, ListBuilder.ICON_IMAGE, title);
return new ListBuilder.RowBuilder()
.setTitleItem(icon, ListBuilder.ICON_IMAGE)
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
index 7ca6e9a..5a43f66 100644
--- a/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRenderer.java
@@ -26,7 +26,6 @@
import android.widget.Button;
import android.widget.ViewFlipper;
-import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
@@ -35,40 +34,40 @@
import androidx.lifecycle.OnLifecycleEvent;
import androidx.recyclerview.widget.RecyclerView;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
-import androidx.slice.widget.EventInfo;
import androidx.slice.widget.SliceLiveData;
-import androidx.slice.widget.SliceView;
import com.android.settings.R;
import com.android.settings.homepage.contextualcards.CardContentProvider;
import com.android.settings.homepage.contextualcards.ContextualCard;
-import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
import com.android.settings.homepage.contextualcards.ContextualCardRenderer;
import com.android.settings.homepage.contextualcards.ControllerRendererPool;
-import com.android.settings.overlay.FeatureFactory;
import java.util.Map;
import java.util.Set;
/**
- * Card renderer for {@link ContextualCard} built as slices.
+ * Card renderer for {@link ContextualCard} built as slice full card or slice half card.
*/
-public class SliceContextualCardRenderer implements ContextualCardRenderer,
- SliceView.OnSliceActionListener, LifecycleObserver {
- public static final int VIEW_TYPE = R.layout.homepage_slice_tile;
+public class SliceContextualCardRenderer implements ContextualCardRenderer, LifecycleObserver {
+ public static final int VIEW_TYPE_FULL_WIDTH = R.layout.homepage_slice_tile;
+ public static final int VIEW_TYPE_HALF_WIDTH = R.layout.homepage_slice_half_tile;
private static final String TAG = "SliceCardRenderer";
@VisibleForTesting
final Map<Uri, LiveData<Slice>> mSliceLiveDataMap;
@VisibleForTesting
- final Set<SliceViewHolder> mFlippedCardSet;
+ final Set<RecyclerView.ViewHolder> mFlippedCardSet;
private final Context mContext;
private final LifecycleOwner mLifecycleOwner;
private final ControllerRendererPool mControllerRendererPool;
private final Set<ContextualCard> mCardSet;
+ private final SliceFullCardRendererHelper mFullCardHelper;
+ private final SliceHalfCardRendererHelper mHalfCardHelper;
+
+ //TODO(b/121303357): Remove isHalfWidth field from SliceContextualCardRenderer class.
+ private boolean mIsHalfWidth;
public SliceContextualCardRenderer(Context context, LifecycleOwner lifecycleOwner,
ControllerRendererPool controllerRendererPool) {
@@ -79,21 +78,26 @@
mCardSet = new ArraySet<>();
mFlippedCardSet = new ArraySet<>();
mLifecycleOwner.getLifecycle().addObserver(this);
+ mFullCardHelper = new SliceFullCardRendererHelper(context);
+ mHalfCardHelper = new SliceHalfCardRendererHelper(context);
}
@Override
public int getViewType(boolean isHalfWidth) {
- return VIEW_TYPE;
+ mIsHalfWidth = isHalfWidth;
+ return isHalfWidth? VIEW_TYPE_HALF_WIDTH : VIEW_TYPE_FULL_WIDTH;
}
@Override
public RecyclerView.ViewHolder createViewHolder(View view) {
- return new SliceViewHolder(view);
+ if (mIsHalfWidth) {
+ return mHalfCardHelper.createViewHolder(view);
+ }
+ return mFullCardHelper.createViewHolder(view);
}
@Override
public void bindView(RecyclerView.ViewHolder holder, ContextualCard card) {
- final SliceViewHolder cardHolder = (SliceViewHolder) holder;
final Uri uri = card.getSliceUri();
//TODO(b/120629936): Take this out once blank card issue is fixed.
Log.d(TAG, "bindView - uri = " + uri);
@@ -103,10 +107,6 @@
return;
}
- cardHolder.sliceView.setScrollable(false);
- cardHolder.sliceView.setTag(uri);
- //TODO(b/114009676): We will soon have a field to decide what slice mode we should set.
- cardHolder.sliceView.setMode(SliceView.MODE_LARGE);
LiveData<Slice> sliceLiveData = mSliceLiveDataMap.get(uri);
if (sliceLiveData == null) {
@@ -125,82 +125,58 @@
//TODO(b/120629936): Take this out once blank card issue is fixed.
Log.d(TAG, "Slice callback - uri = " + slice.getUri());
}
- cardHolder.sliceView.setSlice(slice);
+ if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
+ mHalfCardHelper.bindView(holder, card, slice);
+ } else {
+ mFullCardHelper.bindView(holder, card, slice, mCardSet);
+ }
});
- // Set this listener so we can log the interaction users make on the slice
- cardHolder.sliceView.setOnSliceActionListener(this);
-
- // Customize slice view for Settings
- cardHolder.sliceView.showTitleItems(true);
- if (card.isLargeCard()) {
- cardHolder.sliceView.showHeaderDivider(true);
- cardHolder.sliceView.showActionDividers(true);
+ if (holder.getItemViewType() == VIEW_TYPE_HALF_WIDTH) {
+ initDismissalActions(holder, card, R.id.content);
+ } else {
+ initDismissalActions(holder, card, R.id.slice_view);
}
-
- initDismissalActions(cardHolder, card);
}
- private void initDismissalActions(SliceViewHolder cardHolder, ContextualCard card) {
- cardHolder.sliceView.setOnLongClickListener(v -> {
- cardHolder.viewFlipper.showNext();
- mFlippedCardSet.add(cardHolder);
+ private void initDismissalActions(RecyclerView.ViewHolder holder, ContextualCard card,
+ int initialViewId) {
+ // initialView is the first view in the ViewFlipper.
+ final View initialView = holder.itemView.findViewById(initialViewId);
+ initialView.setOnLongClickListener(v -> {
+ flipCardToDismissalView(holder);
+ mFlippedCardSet.add(holder);
return true;
});
- final Button btnKeep = cardHolder.itemView.findViewById(R.id.keep);
+ final Button btnKeep = holder.itemView.findViewById(R.id.keep);
btnKeep.setOnClickListener(v -> {
- cardHolder.resetCard();
- mFlippedCardSet.remove(cardHolder);
+ mFlippedCardSet.remove(holder);
+ resetCardView(holder);
});
- final Button btnRemove = cardHolder.itemView.findViewById(R.id.remove);
+ final Button btnRemove = holder.itemView.findViewById(R.id.remove);
btnRemove.setOnClickListener(v -> {
mControllerRendererPool.getController(mContext, card.getCardType()).onDismissed(card);
- cardHolder.resetCard();
- mFlippedCardSet.remove(cardHolder);
+ mFlippedCardSet.remove(holder);
+ resetCardView(holder);
mSliceLiveDataMap.get(card.getSliceUri()).removeObservers(mLifecycleOwner);
});
}
- @Override
- public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
- //TODO(b/79698338): Log user interaction
-
- // sliceItem.getSlice().getUri() is like
- // content://android.settings.slices/action/wifi/_gen/0/_gen/0
- // contextualCard.getSliceUri() is prefix of sliceItem.getSlice().getUri()
- for (ContextualCard card : mCardSet) {
- if (sliceItem.getSlice().getUri().toString().startsWith(
- card.getSliceUri().toString())) {
- ContextualCardFeatureProvider contexualCardFeatureProvider =
- FeatureFactory.getFactory(mContext)
- .getContextualCardFeatureProvider(mContext);
- contexualCardFeatureProvider.logContextualCardClick(card,
- eventInfo.rowIndex, eventInfo.actionType);
- break;
- }
- }
- }
-
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
public void onStop() {
- mFlippedCardSet.stream().forEach(holder -> holder.resetCard());
+ mFlippedCardSet.stream().forEach(holder -> resetCardView(holder));
mFlippedCardSet.clear();
}
- public static class SliceViewHolder extends RecyclerView.ViewHolder {
- public final SliceView sliceView;
- public final ViewFlipper viewFlipper;
+ private void resetCardView(RecyclerView.ViewHolder holder) {
+ final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
+ viewFlipper.setDisplayedChild(0 /* whichChild */);
+ }
- public SliceViewHolder(View view) {
- super(view);
- sliceView = view.findViewById(R.id.slice_view);
- viewFlipper = view.findViewById(R.id.view_flipper);
- }
-
- public void resetCard() {
- viewFlipper.setDisplayedChild(0);
- }
+ private void flipCardToDismissalView(RecyclerView.ViewHolder holder) {
+ final ViewFlipper viewFlipper = holder.itemView.findViewById(R.id.view_flipper);
+ viewFlipper.showNext();
}
}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
new file mode 100644
index 0000000..ef0a67d
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelper.java
@@ -0,0 +1,99 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import android.content.Context;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceItem;
+import androidx.slice.widget.EventInfo;
+import androidx.slice.widget.SliceView;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
+
+import java.util.Set;
+
+/**
+ * Card renderer helper for {@link ContextualCard} built as slice full card.
+ */
+class SliceFullCardRendererHelper implements SliceView.OnSliceActionListener {
+ private static final String TAG = "SliceFCRendererHelper";
+
+ private final Context mContext;
+
+ private Set<ContextualCard> mCardSet;
+
+ SliceFullCardRendererHelper(Context context) {
+ mContext = context;
+ }
+
+ RecyclerView.ViewHolder createViewHolder(View view) {
+ return new SliceViewHolder(view);
+ }
+
+ void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice,
+ Set<ContextualCard> cardSet) {
+ final SliceViewHolder cardHolder = (SliceViewHolder) holder;
+ cardHolder.sliceView.setScrollable(false);
+ cardHolder.sliceView.setTag(card.getSliceUri());
+ //TODO(b/114009676): We will soon have a field to decide what slice mode we should set.
+ cardHolder.sliceView.setMode(SliceView.MODE_LARGE);
+ cardHolder.sliceView.setSlice(slice);
+ mCardSet = cardSet;
+ // Set this listener so we can log the interaction users make on the slice
+ cardHolder.sliceView.setOnSliceActionListener(this);
+
+ // Customize slice view for Settings
+ cardHolder.sliceView.showTitleItems(true);
+ if (card.isLargeCard()) {
+ cardHolder.sliceView.showHeaderDivider(true);
+ cardHolder.sliceView.showActionDividers(true);
+ }
+ }
+
+ @Override
+ public void onSliceAction(@NonNull EventInfo eventInfo, @NonNull SliceItem sliceItem) {
+ // sliceItem.getSlice().getUri() is like
+ // content://android.settings.slices/action/wifi/_gen/0/_gen/0
+ // contextualCard.getSliceUri() is prefix of sliceItem.getSlice().getUri()
+ final ContextualCardFeatureProvider contextualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
+ for (ContextualCard card : mCardSet) {
+ if (sliceItem.getSlice().getUri().toString().startsWith(
+ card.getSliceUri().toString())) {
+ contextualCardFeatureProvider.logContextualCardClick(card, eventInfo.rowIndex,
+ eventInfo.actionType);
+ break;
+ }
+ }
+ }
+
+ static class SliceViewHolder extends RecyclerView.ViewHolder {
+ public final SliceView sliceView;
+
+ public SliceViewHolder(View view) {
+ super(view);
+ sliceView = view.findViewById(R.id.slice_view);
+ }
+ }
+}
diff --git a/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
new file mode 100644
index 0000000..24d654d
--- /dev/null
+++ b/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelper.java
@@ -0,0 +1,85 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import android.app.PendingIntent;
+import android.content.Context;
+import android.util.Log;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceMetadata;
+import androidx.slice.core.SliceAction;
+import androidx.slice.widget.EventInfo;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.ContextualCardFeatureProvider;
+import com.android.settings.overlay.FeatureFactory;
+
+/**
+ * Card renderer helper for {@link ContextualCard} built as slice half card.
+ */
+class SliceHalfCardRendererHelper {
+ private static final String TAG = "SliceHCRendererHelper";
+
+ private final Context mContext;
+
+ SliceHalfCardRendererHelper(Context context) {
+ mContext = context;
+ }
+
+ RecyclerView.ViewHolder createViewHolder(View view) {
+ return new HalfCardViewHolder(view);
+ }
+
+ void bindView(RecyclerView.ViewHolder holder, ContextualCard card, Slice slice) {
+ final HalfCardViewHolder view = (HalfCardViewHolder) holder;
+ final SliceMetadata sliceMetadata = SliceMetadata.from(mContext, slice);
+ final SliceAction primaryAction = sliceMetadata.getPrimaryAction();
+ view.icon.setImageDrawable(primaryAction.getIcon().loadDrawable(mContext));
+ view.title.setText(primaryAction.getTitle());
+ view.content.setOnClickListener(v -> {
+ try {
+ primaryAction.getAction().send();
+ } catch (PendingIntent.CanceledException e) {
+ Log.w(TAG, "Failed to start intent " + primaryAction.getTitle());
+ }
+ final ContextualCardFeatureProvider contextualCardFeatureProvider =
+ FeatureFactory.getFactory(mContext).getContextualCardFeatureProvider(mContext);
+ contextualCardFeatureProvider.logContextualCardClick(card, 0 /* row */,
+ EventInfo.ACTION_TYPE_CONTENT);
+ });
+ }
+
+ static class HalfCardViewHolder extends RecyclerView.ViewHolder {
+ public final LinearLayout content;
+ public final ImageView icon;
+ public final TextView title;
+
+ public HalfCardViewHolder(View itemView) {
+ super(itemView);
+ content = itemView.findViewById(R.id.content);
+ icon = itemView.findViewById(android.R.id.icon);
+ title = itemView.findViewById(android.R.id.title);
+ }
+ }
+}
diff --git a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
index 5bfc584..1fd1986 100644
--- a/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
+++ b/src/com/android/settings/location/AppLocationPermissionPreferenceController.java
@@ -6,9 +6,10 @@
import android.content.Context;
import android.location.LocationManager;
-import android.permission.RuntimePermissionPresenter;
+import android.permission.PermissionControllerManager;
import android.provider.Settings;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
@@ -24,9 +25,11 @@
private static final String KEY_APP_LEVEL_PERMISSIONS = "app_level_permissions";
/** Total number of apps that has location permission. */
- private int mNumTotal = -1;
+ @VisibleForTesting
+ int mNumTotal = -1;
/** Total number of apps that has background location permission. */
- private int mNumBackground = -1;
+ @VisibleForTesting
+ int mNumBackground = -1;
private final LocationManager mLocationManager;
private Preference mPreference;
@@ -70,7 +73,9 @@
if (!mLocationManager.isLocationEnabled()) {
return;
}
- RuntimePermissionPresenter.getInstance(mContext).countPermissionApps(
+ PermissionControllerManager permController =
+ mContext.getSystemService(PermissionControllerManager.class);
+ permController.countPermissionApps(
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), false, false,
(numApps) -> {
mNumTotal = numApps;
@@ -79,7 +84,7 @@
}
}, null);
- RuntimePermissionPresenter.getInstance(mContext).countPermissionApps(
+ permController.countPermissionApps(
Collections.singletonList(ACCESS_BACKGROUND_LOCATION), true, false,
(numApps) -> {
mNumBackground = numApps;
diff --git a/src/com/android/settings/location/TopLevelLocationPreferenceController.java b/src/com/android/settings/location/TopLevelLocationPreferenceController.java
index d0bd9a9..6d7789f 100644
--- a/src/com/android/settings/location/TopLevelLocationPreferenceController.java
+++ b/src/com/android/settings/location/TopLevelLocationPreferenceController.java
@@ -1,6 +1,5 @@
package com.android.settings.location;
-import static android.Manifest.permission.ACCESS_BACKGROUND_LOCATION;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
@@ -9,8 +8,9 @@
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
-import android.permission.RuntimePermissionPresenter;
+import android.permission.PermissionControllerManager;
+import androidx.annotation.VisibleForTesting;
import androidx.preference.Preference;
import com.android.settings.R;
@@ -20,7 +20,6 @@
import com.android.settingslib.core.lifecycle.events.OnStop;
import java.util.Arrays;
-import java.util.Collections;
public class TopLevelLocationPreferenceController extends BasePreferenceController implements
LifecycleObserver, OnStart, OnStop {
@@ -56,6 +55,12 @@
}
}
+ @VisibleForTesting
+ void setLocationAppCount(int numApps) {
+ mNumTotal = numApps;
+ refreshSummary(mPreference);
+ }
+
@Override
public void updateState(Preference preference) {
super.updateState(preference);
@@ -65,11 +70,10 @@
if (!mLocationManager.isLocationEnabled()) {
return;
}
- RuntimePermissionPresenter.getInstance(mContext).countPermissionApps(
+ mContext.getSystemService(PermissionControllerManager.class).countPermissionApps(
Arrays.asList(ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION), false, false,
(numApps) -> {
- mNumTotal = numApps;
- refreshSummary(preference);
+ setLocationAppCount(numApps);
}, null);
}
diff --git a/src/com/android/settings/network/ApnSettings.java b/src/com/android/settings/network/ApnSettings.java
index 2b47c70..ac3b1f6 100755
--- a/src/com/android/settings/network/ApnSettings.java
+++ b/src/com/android/settings/network/ApnSettings.java
@@ -61,7 +61,8 @@
import java.util.ArrayList;
-public class ApnSettings extends RestrictedSettingsFragment {
+public class ApnSettings extends RestrictedSettingsFragment
+ implements Preference.OnPreferenceChangeListener {
static final String TAG = "ApnSettings";
public static final String EXTRA_POSITION = "position";
@@ -313,6 +314,7 @@
pref.setKey(key);
pref.setTitle(name);
pref.setPersistent(false);
+ pref.setOnPreferenceChangeListener(this);
pref.setSubId(subId);
if (mHidePresetApnDetails && edited == Telephony.Carriers.UNEDITED) {
pref.setHideDetails();
@@ -386,6 +388,7 @@
startActivity(intent);
}
+ @Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
Log.d(TAG, "onPreferenceChange(): Preference - " + preference
+ ", newValue - " + newValue + ", newValue type - "
diff --git a/src/com/android/settings/network/NetworkDashboardFragment.java b/src/com/android/settings/network/NetworkDashboardFragment.java
index 7d94bba..c2b4a2b 100644
--- a/src/com/android/settings/network/NetworkDashboardFragment.java
+++ b/src/com/android/settings/network/NetworkDashboardFragment.java
@@ -21,7 +21,6 @@
import android.app.Dialog;
import android.content.Context;
import android.provider.SearchIndexableResource;
-import android.util.FeatureFlagUtils;
import android.util.Log;
import androidx.appcompat.app.AlertDialog;
@@ -31,6 +30,7 @@
import com.android.settings.R;
import com.android.settings.core.FeatureFlags;
import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.development.featureflags.FeatureFlagPersistent;
import com.android.settings.network.MobilePlanPreferenceController.MobilePlanPreferenceHost;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.wifi.WifiMasterSwitchPreferenceController;
@@ -61,7 +61,7 @@
@Override
protected int getPreferenceScreenResId() {
- if (FeatureFlagUtils.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
+ if (FeatureFlagPersistent.isEnabled(getContext(), FeatureFlags.NETWORK_INTERNET_V2)) {
return R.xml.network_and_internet_v2;
} else {
return R.xml.network_and_internet;
@@ -72,7 +72,7 @@
public void onAttach(Context context) {
super.onAttach(context);
- if (FeatureFlagUtils.isEnabled(context, FeatureFlags.NETWORK_INTERNET_V2)) {
+ if (FeatureFlagPersistent.isEnabled(context, FeatureFlags.NETWORK_INTERNET_V2)) {
use(MultiNetworkHeaderController.class).init(getSettingsLifecycle());
}
use(AirplaneModePreferenceController.class).setFragment(this);
diff --git a/src/com/android/settings/network/telephony/MobileDataDialogFragment.java b/src/com/android/settings/network/telephony/MobileDataDialogFragment.java
index be2da04..276d1fb 100644
--- a/src/com/android/settings/network/telephony/MobileDataDialogFragment.java
+++ b/src/com/android/settings/network/telephony/MobileDataDialogFragment.java
@@ -17,6 +17,7 @@
package com.android.settings.network.telephony;
import android.app.Dialog;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
@@ -109,8 +110,7 @@
@Override
public int getMetricsCategory() {
- //TODO(b/114749736): add metric id for this fragment
- return 0;
+ return SettingsEnums.MOBILE_DATA_DIALOG;
}
@Override
diff --git a/src/com/android/settings/network/telephony/MobileNetworkSettings.java b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
index 623b6de..6e5dece 100644
--- a/src/com/android/settings/network/telephony/MobileNetworkSettings.java
+++ b/src/com/android/settings/network/telephony/MobileNetworkSettings.java
@@ -196,7 +196,6 @@
}
}
- //TODO(b/114749736): update search provider
public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
diff --git a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
index f60f927..0326f42 100644
--- a/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
+++ b/src/com/android/settings/network/telephony/PreferredNetworkModePreferenceController.java
@@ -116,8 +116,6 @@
}
private int getPreferredNetworkModeSummaryResId(int NetworkMode) {
- //TODO(b/114749736): refactor it to "Preferred network mode: <Mode>", instead of building
- // string for each type...
switch (NetworkMode) {
case TelephonyManager.NETWORK_MODE_TDSCDMA_GSM_WCDMA:
return R.string.preferred_network_mode_tdscdma_gsm_wcdma_summary;
diff --git a/src/com/android/settings/network/telephony/RoamingDialogFragment.java b/src/com/android/settings/network/telephony/RoamingDialogFragment.java
index 4c82686..c349c1a 100644
--- a/src/com/android/settings/network/telephony/RoamingDialogFragment.java
+++ b/src/com/android/settings/network/telephony/RoamingDialogFragment.java
@@ -17,6 +17,7 @@
import android.app.AlertDialog;
import android.app.Dialog;
+import android.app.settings.SettingsEnums;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
@@ -78,8 +79,7 @@
@Override
public int getMetricsCategory() {
- //TODO(b/114749736): add category for roaming dialog
- return 0;
+ return SettingsEnums.MOBILE_ROAMING_DIALOG;
}
@Override
diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
index 48fb710..ec9a841 100644
--- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
+++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java
@@ -72,7 +72,7 @@
&& MobileNetworkUtils.isWifiCallingEnabled(mContext,
SubscriptionManager.getPhoneId(mSubId))
? AVAILABLE
- : CONDITIONALLY_UNAVAILABLE;
+ : UNSUPPORTED_ON_DEVICE;
}
@Override
diff --git a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
index 181faa5..b784dc5 100644
--- a/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
+++ b/src/com/android/settings/nfc/AndroidBeamPreferenceController.java
@@ -16,6 +16,7 @@
package com.android.settings.nfc;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.nfc.NfcAdapter;
import androidx.preference.PreferenceScreen;
@@ -54,6 +55,10 @@
@Override
@AvailabilityStatus
public int getAvailabilityStatus() {
+ PackageManager pm = mContext.getPackageManager();
+ if (!pm.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)) {
+ return UNSUPPORTED_ON_DEVICE;
+ }
return mNfcAdapter != null
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
diff --git a/src/com/android/settings/notification/NotificationStation.java b/src/com/android/settings/notification/NotificationStation.java
index d3ebc08..116980f 100644
--- a/src/com/android/settings/notification/NotificationStation.java
+++ b/src/com/android/settings/notification/NotificationStation.java
@@ -16,10 +16,13 @@
package com.android.settings.notification;
+import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;
+
import android.app.Activity;
import android.app.ActivityManager;
import android.app.INotificationManager;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
@@ -354,28 +357,53 @@
getString(R.string.notification_log_details_group_summary)));
}
}
- sb.append("\n")
- .append(bold(getString(R.string.notification_log_details_sound)))
- .append(delim);
- if (0 != (n.defaults & Notification.DEFAULT_SOUND)) {
- sb.append(getString(R.string.notification_log_details_default));
- } else if (n.sound != null) {
- sb.append(n.sound.toString());
- } else {
- sb.append(getString(R.string.notification_log_details_none));
- }
- sb.append("\n")
- .append(bold(getString(R.string.notification_log_details_vibrate)))
- .append(delim);
- if (0 != (n.defaults & Notification.DEFAULT_VIBRATE)) {
- sb.append(getString(R.string.notification_log_details_default));
- } else if (n.vibrate != null) {
- for (int vi=0;vi<n.vibrate.length;vi++) {
- if (vi > 0) sb.append(',');
- sb.append(String.valueOf(n.vibrate[vi]));
+ if (info.active) {
+ // mRanking only applies to active notifications
+ if (mRanking != null && mRanking.getRanking(sbn.getKey(), rank)) {
+ if (rank.getLastAudiblyAlertedMillis() > 0) {
+ sb.append("\n")
+ .append(bold(getString(R.string.notification_log_details_alerted)));
+ }
}
- } else {
- sb.append(getString(R.string.notification_log_details_none));
+ }
+ try {
+ NotificationChannel channel = mNoMan.getNotificationChannelForPackage(
+ sbn.getPackageName(), sbn.getUid(), n.getChannelId(), false);
+ sb.append("\n")
+ .append(bold(getString(R.string.notification_log_details_sound)))
+ .append(delim);
+ if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
+
+ if (0 != (n.defaults & Notification.DEFAULT_SOUND)) {
+ sb.append(getString(R.string.notification_log_details_default));
+ } else if (n.sound != null) {
+ sb.append(n.sound.toString());
+ } else {
+ sb.append(getString(R.string.notification_log_details_none));
+ }
+ } else {
+ sb.append(String.valueOf(channel.getSound()));
+ }
+ sb.append("\n")
+ .append(bold(getString(R.string.notification_log_details_vibrate)))
+ .append(delim);
+ if (channel.getImportance() == IMPORTANCE_UNSPECIFIED) {
+ if (0 != (n.defaults & Notification.DEFAULT_VIBRATE)) {
+ sb.append(getString(R.string.notification_log_details_default));
+ } else if (n.vibrate != null) {
+ sb.append(getString(R.string.notification_log_details_vibrate_pattern));
+ } else {
+ sb.append(getString(R.string.notification_log_details_none));
+ }
+ } else {
+ if (channel.getVibrationPattern() != null) {
+ sb.append(getString(R.string.notification_log_details_vibrate_pattern));
+ } else {
+ sb.append(getString(R.string.notification_log_details_none));
+ }
+ }
+ } catch (RemoteException e) {
+ Log.d(TAG, "cannot read channel info", e);
}
sb.append("\n")
.append(bold(getString(R.string.notification_log_details_visibility)))
diff --git a/src/com/android/settings/notification/RedactionInterstitial.java b/src/com/android/settings/notification/RedactionInterstitial.java
index 32dc52d..11861e0 100644
--- a/src/com/android/settings/notification/RedactionInterstitial.java
+++ b/src/com/android/settings/notification/RedactionInterstitial.java
@@ -32,7 +32,6 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
@@ -46,9 +45,12 @@
import com.android.settings.SetupRedactionInterstitial;
import com.android.settings.SetupWizardUtils;
import com.android.settings.Utils;
-import com.android.settingslib.RestrictedLockUtils;
import com.android.settingslib.RestrictedLockUtilsInternal;
+import com.google.android.setupcompat.item.FooterButton;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+import com.google.android.setupdesign.GlifLayout;
+
public class RedactionInterstitial extends SettingsActivity {
@Override
@@ -91,7 +93,7 @@
}
public static class RedactionInterstitialFragment extends SettingsPreferenceFragment
- implements RadioGroup.OnCheckedChangeListener, View.OnClickListener {
+ implements RadioGroup.OnCheckedChangeListener {
private RadioGroup mRadioGroup;
private RestrictedRadioButton mShowAllButton;
@@ -130,19 +132,24 @@
((RadioButton) view.findViewById(R.id.hide_all)).setVisibility(View.GONE);
}
- final Button button = (Button) view.findViewById(R.id.redaction_done_button);
- button.setOnClickListener(this);
+ final GlifLayout layout = view.findViewById(R.id.setup_wizard_layout);
+ final ButtonFooterMixin buttonFooterMixin = layout.getMixin(ButtonFooterMixin.class);
+ buttonFooterMixin.setPrimaryButton(
+ new FooterButton.Builder(getContext())
+ .setText(R.string.app_notifications_dialog_done)
+ .setListener(this::onDoneButtonClicked)
+ .setButtonType(FooterButton.ButtonType.NEXT)
+ .setTheme(R.style.SudGlifButton_Primary)
+ .build()
+ );
}
- @Override
- public void onClick(View v) {
- if (v.getId() == R.id.redaction_done_button) {
- SetupRedactionInterstitial.setEnabled(getContext(), false);
- final RedactionInterstitial activity = (RedactionInterstitial) getActivity();
- if (activity != null) {
- activity.setResult(RESULT_OK, null);
- finish();
- }
+ private void onDoneButtonClicked(View view) {
+ SetupRedactionInterstitial.setEnabled(getContext(), false);
+ final RedactionInterstitial activity = (RedactionInterstitial) getActivity();
+ if (activity != null) {
+ activity.setResult(RESULT_OK, null);
+ finish();
}
}
diff --git a/src/com/android/settings/password/ChooseLockPattern.java b/src/com/android/settings/password/ChooseLockPattern.java
index 1c9e3ff..2738a26 100644
--- a/src/com/android/settings/password/ChooseLockPattern.java
+++ b/src/com/android/settings/password/ChooseLockPattern.java
@@ -476,7 +476,7 @@
R.layout.choose_lock_pattern, container, false);
layout.setHeaderText(getActivity().getTitle());
if (getResources().getBoolean(R.bool.config_lock_pattern_minimal_ui)) {
- View iconView = layout.findViewById(R.id.suw_layout_icon);
+ View iconView = layout.findViewById(R.id.suc_layout_icon);
if (iconView != null) {
iconView.setVisibility(View.GONE);
}
@@ -494,7 +494,7 @@
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
- mTitleText = view.findViewById(R.id.suw_layout_title);
+ mTitleText = view.findViewById(R.id.suc_layout_title);
mHeaderText = (TextView) view.findViewById(R.id.headerText);
mDefaultHeaderColorList = mHeaderText.getTextColors();
mMessageText = view.findViewById(R.id.message);
diff --git a/src/com/android/settings/password/ConfirmLockPassword.java b/src/com/android/settings/password/ConfirmLockPassword.java
index 45b8129..b5bca15 100644
--- a/src/com/android/settings/password/ConfirmLockPassword.java
+++ b/src/com/android/settings/password/ConfirmLockPassword.java
@@ -135,7 +135,7 @@
mHeaderTextView = (TextView) view.findViewById(R.id.headerText);
if (mHeaderTextView == null) {
- mHeaderTextView = view.findViewById(R.id.suw_layout_title);
+ mHeaderTextView = view.findViewById(R.id.suc_layout_title);
}
mDetailsTextView = (TextView) view.findViewById(R.id.detailsText);
mErrorTextView = (TextView) view.findViewById(R.id.errorText);
diff --git a/src/com/android/settings/password/SetupChooseLockGeneric.java b/src/com/android/settings/password/SetupChooseLockGeneric.java
index 8cd40d5..a0f8bae 100644
--- a/src/com/android/settings/password/SetupChooseLockGeneric.java
+++ b/src/com/android/settings/password/SetupChooseLockGeneric.java
@@ -86,7 +86,7 @@
GlifPreferenceLayout layout = (GlifPreferenceLayout) view;
layout.setDividerItemDecoration(new SettingsDividerItemDecoration(getContext()));
layout.setDividerInset(getContext().getResources().getDimensionPixelSize(
- R.dimen.suw_items_glif_text_divider_inset));
+ R.dimen.sud_items_glif_text_divider_inset));
layout.setIcon(getContext().getDrawable(R.drawable.ic_lock));
diff --git a/src/com/android/settings/slices/Copyable.java b/src/com/android/settings/slices/Copyable.java
index 12159d1..a480063 100644
--- a/src/com/android/settings/slices/Copyable.java
+++ b/src/com/android/settings/slices/Copyable.java
@@ -16,6 +16,15 @@
package com.android.settings.slices;
+import static android.content.Context.CLIPBOARD_SERVICE;
+
+import android.content.ClipData;
+import android.content.ClipboardManager;
+import android.content.Context;
+import android.widget.Toast;
+
+import com.android.settings.R;
+
/**
* Provide the copy ability for preference controller to copy the data to the clipboard.
*/
@@ -25,4 +34,18 @@
* It is highly recommended to show the toast to notify users when implemented this function.
*/
void copy();
+
+ /**
+ * Set the copy content to the clipboard and show the toast.
+ */
+ static void setCopyContent(Context context, CharSequence copyContent,
+ CharSequence messageTitle) {
+ final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(
+ CLIPBOARD_SERVICE);
+ final ClipData clip = ClipData.newPlainText("text", copyContent);
+ clipboard.setPrimaryClip(clip);
+
+ final String toast = context.getString(R.string.copyable_slice_toast, messageTitle);
+ Toast.makeText(context, toast, Toast.LENGTH_SHORT).show();
+ }
}
diff --git a/src/com/android/settings/slices/CustomSliceManager.java b/src/com/android/settings/slices/CustomSliceManager.java
index bb47df2..24ee680 100644
--- a/src/com/android/settings/slices/CustomSliceManager.java
+++ b/src/com/android/settings/slices/CustomSliceManager.java
@@ -23,7 +23,7 @@
import androidx.annotation.VisibleForTesting;
import com.android.settings.flashlight.FlashlightSlice;
-import com.android.settings.homepage.contextualcards.deviceinfo.BatterySlice;
+import com.android.settings.homepage.contextualcards.deviceinfo.BatteryInfoSlice;
import com.android.settings.homepage.contextualcards.deviceinfo.DataUsageSlice;
import com.android.settings.homepage.contextualcards.deviceinfo.DeviceInfoSlice;
import com.android.settings.homepage.contextualcards.deviceinfo.EmergencyInfoSlice;
@@ -106,7 +106,7 @@
private void addSlices() {
mUriMap.put(CustomSliceRegistry.BATTERY_FIX_SLICE_URI, BatteryFixSlice.class);
- mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatterySlice.class);
+ mUriMap.put(CustomSliceRegistry.BATTERY_INFO_SLICE_URI, BatteryInfoSlice.class);
mUriMap.put(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI, BluetoothDevicesSlice.class);
mUriMap.put(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI, ContextualWifiSlice.class);
mUriMap.put(CustomSliceRegistry.DATA_USAGE_SLICE_URI, DataUsageSlice.class);
diff --git a/src/com/android/settings/slices/SliceBackgroundWorker.java b/src/com/android/settings/slices/SliceBackgroundWorker.java
index 8b68f05..284fd23 100644
--- a/src/com/android/settings/slices/SliceBackgroundWorker.java
+++ b/src/com/android/settings/slices/SliceBackgroundWorker.java
@@ -17,6 +17,7 @@
package com.android.settings.slices;
import android.annotation.MainThread;
+import android.annotation.Nullable;
import android.content.Context;
import android.net.Uri;
import android.util.ArrayMap;
@@ -58,20 +59,29 @@
mUri = uri;
}
- public Uri getUri() {
+ protected Uri getUri() {
return mUri;
}
/**
+ * Returns the singleton instance of the {@link SliceBackgroundWorker} for specified {@link Uri}
+ * if exists
+ */
+ @Nullable
+ public static SliceBackgroundWorker getInstance(Uri uri) {
+ return LIVE_WORKERS.get(uri);
+ }
+
+ /**
* Returns the singleton instance of the {@link SliceBackgroundWorker} for specified {@link
* CustomSliceable}
*/
- public static SliceBackgroundWorker getInstance(Context context, CustomSliceable sliceable) {
+ static SliceBackgroundWorker getInstance(Context context, CustomSliceable sliceable) {
final Uri uri = sliceable.getUri();
- final Class<? extends SliceBackgroundWorker> workerClass =
- sliceable.getBackgroundWorkerClass();
- SliceBackgroundWorker worker = LIVE_WORKERS.get(uri);
+ SliceBackgroundWorker worker = getInstance(uri);
if (worker == null) {
+ final Class<? extends SliceBackgroundWorker> workerClass =
+ sliceable.getBackgroundWorkerClass();
worker = createInstance(context, uri, workerClass);
LIVE_WORKERS.put(uri, worker);
}
diff --git a/src/com/android/settings/slices/SlicePreference.java b/src/com/android/settings/slices/SlicePreference.java
index 98719f7..37a53f4 100644
--- a/src/com/android/settings/slices/SlicePreference.java
+++ b/src/com/android/settings/slices/SlicePreference.java
@@ -33,12 +33,17 @@
public SlicePreference(Context context, AttributeSet attrs) {
super(context, attrs, R.attr.slicePreferenceStyle);
- mSliceView = findViewById(R.id.slice_view);
+ init();
}
public SlicePreference(Context context, AttributeSet attrs, int defStyleAttr) {
- super(context, attrs, R.attr.slicePreferenceStyle);
+ super(context, attrs, defStyleAttr);
+ init();
+ }
+
+ private void init() {
mSliceView = findViewById(R.id.slice_view);
+ mSliceView.showTitleItems(true);
}
public void onSliceUpdated(Slice slice) {
diff --git a/src/com/android/settings/widget/VideoPreference.java b/src/com/android/settings/widget/VideoPreference.java
index d5d4f5e..fd215d8 100644
--- a/src/com/android/settings/widget/VideoPreference.java
+++ b/src/com/android/settings/widget/VideoPreference.java
@@ -54,6 +54,7 @@
private float mAspectRadio = 1.0f;
private int mPreviewResource;
private boolean mViewVisible;
+ private Surface mSurface;
public VideoPreference(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -68,17 +69,12 @@
.authority(context.getPackageName())
.appendPath(String.valueOf(animation))
.build();
- mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
+ mPreviewResource = attributes.getResourceId(
+ R.styleable.VideoPreference_preview, 0);
+ initMediaPlayer();
if (mMediaPlayer != null && mMediaPlayer.getDuration() > 0) {
setVisible(true);
setLayoutResource(R.layout.video_preference);
-
- mPreviewResource = attributes.getResourceId(
- R.styleable.VideoPreference_preview, 0);
-
- mMediaPlayer.setOnSeekCompleteListener(mp -> mVideoReady = true);
-
- mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
mAnimationAvailable = true;
updateAspectRatio();
} else {
@@ -127,9 +123,8 @@
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int width,
int height) {
if (mMediaPlayer != null) {
- mMediaPlayer.setSurface(new Surface(surfaceTexture));
- mVideoReady = false;
- mMediaPlayer.seekTo(0);
+ mSurface = new Surface(surfaceTexture);
+ mMediaPlayer.setSurface(mSurface);
}
}
@@ -168,26 +163,40 @@
@Override
public void onDetached() {
- if (mMediaPlayer != null) {
- mMediaPlayer.stop();
- mMediaPlayer.reset();
- mMediaPlayer.release();
- }
+ releaseMediaPlayer();
super.onDetached();
}
public void onViewVisible(boolean videoPaused) {
mViewVisible = true;
mVideoPaused = videoPaused;
- if (mVideoReady && mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
- mMediaPlayer.seekTo(0);
- }
+ initMediaPlayer();
}
public void onViewInvisible() {
mViewVisible = false;
- if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
- mMediaPlayer.pause();
+ releaseMediaPlayer();
+ }
+
+ private void initMediaPlayer() {
+ if (mMediaPlayer == null) {
+ mMediaPlayer = MediaPlayer.create(mContext, mVideoPath);
+ mMediaPlayer.seekTo(0);
+ mMediaPlayer.setOnSeekCompleteListener(mp -> mVideoReady = true);
+ mMediaPlayer.setOnPreparedListener(mediaPlayer -> mediaPlayer.setLooping(true));
+ if (mSurface != null) {
+ mMediaPlayer.setSurface(mSurface);
+ }
+ }
+ }
+
+ private void releaseMediaPlayer() {
+ if (mMediaPlayer != null) {
+ mMediaPlayer.stop();
+ mMediaPlayer.reset();
+ mMediaPlayer.release();
+ mMediaPlayer = null;
+ mVideoReady = false;
}
}
@@ -197,7 +206,6 @@
@VisibleForTesting
void updateAspectRatio() {
- mAspectRadio = mMediaPlayer.getVideoWidth() / (float)mMediaPlayer.getVideoHeight();
+ mAspectRadio = mMediaPlayer.getVideoWidth() / (float) mMediaPlayer.getVideoHeight();
}
-
}
diff --git a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
index 30c2cd9..06e36e5 100644
--- a/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
+++ b/src/com/android/settings/wifi/NetworkRequestDialogFragment.java
@@ -66,9 +66,15 @@
/** Message sent to us to stop scanning wifi and pop up timeout dialog. */
private static final int MESSAGE_STOP_SCAN_WIFI_LIST = 0;
+ /** Message sent to us to finish activity. */
+ private static final int MESSAGE_FINISH_ACTIVITY = 1;
+
/** Spec defines there should be 5 wifi ap on the list at most. */
private static final int MAX_NUMBER_LIST_ITEM = 5;
+ /** Holding time to let user be aware that selected wifi ap is connected */
+ private static final int DELAY_TIME_USER_AWARE_CONNECTED_MS = 1 * 1000;
+
/** Delayed time to stop scanning wifi. */
private static final int DELAY_TIME_STOP_SCAN_MS = 30 * 1000;
@@ -154,7 +160,9 @@
public void onCancel(@NonNull DialogInterface dialog) {
super.onCancel(dialog);
// Finishes the activity when user clicks back key or outside of the dialog.
- getActivity().finish();
+ if (getActivity() != null) {
+ getActivity().finish();
+ }
}
@Override
@@ -176,6 +184,8 @@
@Override
public void onDestroy() {
super.onDestroy();
+
+ mHandler.removeMessages(MESSAGE_FINISH_ACTIVITY);
if (mFilterWifiTracker != null) {
mFilterWifiTracker.onDestroy();
mFilterWifiTracker = null;
@@ -206,7 +216,10 @@
switch (msg.what) {
case MESSAGE_STOP_SCAN_WIFI_LIST:
removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
- stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
+ stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.TIME_OUT);
+ break;
+ case MESSAGE_FINISH_ACTIVITY:
+ stopScanningAndMaybePopErrorDialog(/* ERROR_DIALOG_TYPE */ null);
break;
default:
// Do nothing.
@@ -215,18 +228,29 @@
}
};
- protected void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
+ protected void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
// Dismisses current dialog.
- dismiss();
+ final Dialog dialog = getDialog();
+ if (dialog != null && dialog.isShowing()) {
+ dismiss();
+ }
- // Throws new timeout dialog.
- final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
- .newInstance();
- final Bundle bundle = new Bundle();
- bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
- fragment.setArguments(bundle);
- fragment.show(getActivity().getSupportFragmentManager(),
- NetworkRequestDialogFragment.class.getSimpleName());
+ if (type == null) {
+ // If no error, finishes activity.
+ if (getActivity() != null) {
+ getActivity().finish();
+ }
+ } else {
+ // Throws error dialog.
+ final NetworkRequestErrorDialogFragment fragment = NetworkRequestErrorDialogFragment
+ .newInstance();
+ final Bundle bundle = new Bundle();
+ bundle.putSerializable(NetworkRequestErrorDialogFragment.DIALOG_TYPE, type);
+ fragment.setArguments(bundle);
+ fragment.show(getActivity().getSupportFragmentManager(),
+ NetworkRequestDialogFragment.class.getSimpleName());
+ }
+
}
@Override
@@ -283,7 +307,7 @@
@Override
public void onAbort() {
- stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
+ stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
}
@Override
@@ -294,10 +318,13 @@
@Override
public void onMatch(List<ScanResult> scanResults) {
- mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
- renewAccessPointList(scanResults);
+ // Shouldn't need to renew cached list, since input result is empty.
+ if (scanResults != null && scanResults.size() > 0) {
+ mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
+ renewAccessPointList(scanResults);
- notifyAdapterRefresh();
+ notifyAdapterRefresh();
+ }
}
// Updates internal AccessPoint list from WifiTracker. scanResults are used to update key list
@@ -328,13 +355,24 @@
@Override
public void onUserSelectionConnectSuccess(WifiConfiguration wificonfiguration) {
- // Dismisses current dialog, since connection is success.
- dismiss();
+ // Removes the progress icon.
+ final Dialog dialog = getDialog();
+ if (dialog != null) {
+ final View view = dialog.findViewById(R.id.network_request_title_progress);
+ if (view != null) {
+ view.setVisibility(View.GONE);
+ }
+ }
+
+ // Posts delay to finish self since connection is success.
+ mHandler.removeMessages(MESSAGE_STOP_SCAN_WIFI_LIST);
+ mHandler.sendEmptyMessageDelayed(MESSAGE_FINISH_ACTIVITY,
+ DELAY_TIME_USER_AWARE_CONNECTED_MS);
}
@Override
public void onUserSelectionConnectFailure(WifiConfiguration wificonfiguration) {
- stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
+ stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE.ABORT);
}
private final class FilterWifiTracker {
diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java
index 95e912d..eddae06 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -240,7 +240,7 @@
mAddPreference.setIcon(R.drawable.ic_menu_add);
mAddPreference.setTitle(R.string.wifi_add_network);
if (WifiDppUtils.isSharingNetworkEnabled(getContext())) {
- mAddPreference.setButtonIcon(R.drawable.ic_qrcode_24dp);
+ mAddPreference.setButtonIcon(R.drawable.ic_scan_24dp);
mAddPreference.setButtonOnClickListener((View v) -> {
// Launch QR code scanner to join a network.
getContext().startActivity(
diff --git a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
index f3e8fc1..fe71991 100644
--- a/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
+++ b/src/com/android/settings/wifi/details/WifiDetailPreferenceController.java
@@ -549,8 +549,8 @@
* Show QR code to share the network represented by this preference.
*/
public void launchQRCodeGenerator() {
- Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntent(mAccessPoint.getSsidStr(),
- mAccessPoint.getSecurityString(/* concise */ false));
+ Intent intent = WifiDppUtils.getConfiguratorQrCodeGeneratorIntent(mContext, mWifiManager,
+ mAccessPoint);
mContext.startActivity(intent);
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
index 8d6aa68..0821ec0 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppAddDeviceFragment.java
@@ -16,7 +16,19 @@
package com.android.settings.wifi.dpp;
+import android.app.ActionBar;
+import android.app.Activity;
+import android.content.Context;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageView;
+import android.widget.ProgressBar;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -26,9 +38,46 @@
* to the Wi-Fi network.
*/
public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
- @Override
- protected int getLayout() {
- return R.layout.wifi_dpp_add_device_fragment;
+ private static final String TAG = "WifiDppAddDeviceFragment";
+
+ private ImageView mWifiApPictureView;
+ private Button mChooseDifferentNetwork;
+ private Button mButtonLeft;
+ private Button mButtonRight;
+
+ private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
+ @Override
+ public void onEnrolleeSuccess(int newNetworkId) {
+ // Do nothing
+ }
+
+ @Override
+ public void onConfiguratorSuccess(int code) {
+ // Update success UI.
+ mTitle.setText(R.string.wifi_dpp_wifi_shared_with_device);
+ mSummary.setVisibility(View.INVISIBLE);
+ mChooseDifferentNetwork.setVisibility(View.INVISIBLE);
+ mButtonLeft.setText(R.string.wifi_dpp_add_another_device);
+ mButtonLeft.setOnClickListener(v -> getFragmentManager().popBackStack());
+ mButtonRight.setText(R.string.done);
+ mButtonRight.setOnClickListener(v -> getActivity().finish());
+ }
+
+ @Override
+ public void onFailure(int code) {
+ Log.d(TAG, "DppStatusCallback.onFailure " + code);
+
+ // Update fail UI.
+ mTitle.setText(R.string.wifi_dpp_could_not_add_device);
+ mSummary.setVisibility(View.INVISIBLE);
+ mChooseDifferentNetwork.setVisibility(View.INVISIBLE);
+ mButtonRight.setText(R.string.retry);
+ }
+
+ @Override
+ public void onProgress(int code) {
+ // Do nothing
+ }
}
@Override
@@ -37,7 +86,90 @@
}
@Override
- public void onActivityCreated (Bundle savedInstanceState) {
+ public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
+
+ final ActionBar actionBar = getActivity().getActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ }
+
+ @Override
+ public final View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.wifi_dpp_add_device_fragment, container,
+ /* attachToRoot */ false);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ final WifiQrCode wifiQrCode = ((WifiDppConfiguratorActivity) getActivity())
+ .getWifiDppQrCode();
+ final String information = wifiQrCode.getInformation();
+ if (TextUtils.isEmpty(information)) {
+ mTitle.setText(R.string.wifi_dpp_device_found);
+ } else {
+ mTitle.setText(information);
+ }
+
+ final WifiNetworkConfig wifiNetworkConfig = ((WifiDppConfiguratorActivity) getActivity())
+ .getWifiNetworkConfig();
+ if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
+ throw new IllegalStateException("Invalid Wi-Fi network for configuring");
+ }
+ mSummary.setText(getString(R.string.wifi_dpp_add_device_to_wifi,
+ wifiNetworkConfig.getSsid()));
+
+ mWifiApPictureView = view.findViewById(R.id.wifi_ap_picture_view);
+
+ mChooseDifferentNetwork = view.findViewById(R.id.choose_different_network);
+ mChooseDifferentNetwork.setOnClickListener(v ->
+ mClickChooseDifferentNetworkListener.onClickChooseDifferentNetwork());
+
+ mButtonLeft = view.findViewById(R.id.button_left);
+ mButtonLeft.setText(R.string.cancel);
+ mButtonLeft.setOnClickListener(v -> {
+ getActivity().setResult(Activity.RESULT_CANCELED);
+ getActivity().finish();
+ });
+
+ mButtonRight = view.findViewById(R.id.button_right);
+ mButtonRight.setText(R.string.wifi_dpp_share_wifi);
+ mButtonRight.setOnClickListener(v -> startWifiDppInitiator());
+ }
+
+ private void startWifiDppInitiator() {
+ final WifiQrCode wifiQrCode = ((WifiDppConfiguratorActivity) getActivity())
+ .getWifiDppQrCode();
+ final String qrCode = wifiQrCode.getQrCode();
+ final int networkId =
+ ((WifiDppConfiguratorActivity) getActivity()).getWifiNetworkConfig().getNetworkId();
+ final WifiManager wifiManager = getContext().getSystemService(WifiManager.class);
+
+ wifiManager.startDppAsConfiguratorInitiator(qrCode, networkId,
+ WifiManager.DPP_NETWORK_ROLE_STA, /* handler */ null, new DppStatusCallback());
+ }
+
+ // Container Activity must implement this interface
+ public interface OnClickChooseDifferentNetworkListener {
+ public void onClickChooseDifferentNetwork();
+ }
+ OnClickChooseDifferentNetworkListener mClickChooseDifferentNetworkListener;
+
+ @Override
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ mClickChooseDifferentNetworkListener = (OnClickChooseDifferentNetworkListener) context;
+ }
+
+ @Override
+ public void onDetach() {
+ mClickChooseDifferentNetworkListener = null;
+
+ super.onDetach();
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
index 66bc349..8037e23 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppChooseSavedWifiNetworkFragment.java
@@ -16,7 +16,14 @@
package com.android.settings.wifi.dpp;
+import android.app.ActionBar;
+import android.app.Activity;
import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ListView;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -26,10 +33,9 @@
* {@code WifiDppConfiguratorActivity} to start with this fragment to choose a saved Wi-Fi network.
*/
public class WifiDppChooseSavedWifiNetworkFragment extends WifiDppQrCodeBaseFragment {
- @Override
- protected int getLayout() {
- return R.layout.wifi_dpp_choose_saved_wifi_network_fragment;
- }
+ private ListView mSavedWifiNetworkList;
+ private Button mButtonLeft;
+ private Button mButtonRight;
@Override
public int getMetricsCategory() {
@@ -37,7 +43,38 @@
}
@Override
- public void onActivityCreated (Bundle savedInstanceState) {
+ public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
+
+ final ActionBar actionBar = getActivity().getActionBar();
+ if (actionBar != null) {
+ actionBar.hide();
+ }
+ }
+
+ @Override
+ public final View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.wifi_dpp_choose_saved_wifi_network_fragment, container,
+ /* attachToRoot */ false);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ mTitle.setText(R.string.wifi_dpp_choose_network);
+ mSummary.setText(R.string.wifi_dpp_choose_network_to_connect_device);
+
+ mButtonLeft = view.findViewById(R.id.button_left);
+ mButtonLeft.setText(R.string.cancel);
+ mButtonLeft.setOnClickListener(v -> {
+ Activity activity = getActivity();
+ activity.setResult(Activity.RESULT_CANCELED);
+ activity.finish();
+ });
+
+ mButtonRight = view.findViewById(R.id.button_right);
+ mButtonRight.setVisibility(View.GONE);
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
index 6c95f09..97ee71a 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivity.java
@@ -22,6 +22,7 @@
import android.os.Bundle;
import android.util.Log;
+import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
@@ -44,26 +45,40 @@
* {@code WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY}
* {@code WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID}
*
- * For intent action {@code ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK}, specify Wi-Fi (DPP)
+ * For intent action {@code ACTION_PROCESS_WIFI_DPP_QR_CODE}, specify Wi-Fi (DPP)
* QR code in {@code WifiDppUtils.EXTRA_QR_CODE}
*/
public class WifiDppConfiguratorActivity extends InstrumentedActivity implements
WifiNetworkConfig.Retriever,
- WifiDppQrCodeGeneratorFragment.OnQrCodeGeneratorFragmentAddButtonClickedListener {
+ WifiDppQrCodeGeneratorFragment.OnQrCodeGeneratorFragmentAddButtonClickedListener,
+ WifiDppQrCodeScannerFragment.OnScanWifiDppSuccessListener,
+ WifiDppQrCodeScannerFragment.OnScanZxingWifiFormatSuccessListener,
+ WifiDppAddDeviceFragment.OnClickChooseDifferentNetworkListener {
private static final String TAG = "WifiDppConfiguratorActivity";
public static final String ACTION_CONFIGURATOR_QR_CODE_SCANNER =
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_SCANNER";
public static final String ACTION_CONFIGURATOR_QR_CODE_GENERATOR =
"android.settings.WIFI_DPP_CONFIGURATOR_QR_CODE_GENERATOR";
- public static final String ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK =
- "android.settings.WIFI_DPP_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK";
+ public static final String ACTION_PROCESS_WIFI_DPP_QR_CODE =
+ "android.settings.PROCESS_WIFI_DPP_QR_CODE";
+
+ // Key for Bundle usage
+ private static final String KEY_QR_CODE = "key_qr_code";
+ private static final String KEY_WIFI_SECURITY = "key_wifi_security";
+ private static final String KEY_WIFI_SSID = "key_wifi_ssid";
+ private static final String KEY_WIFI_PRESHARED_KEY = "key_wifi_preshared_key";
+ private static final String KEY_WIFI_HIDDEN_SSID = "key_wifi_hidden_ssid";
+ private static final String KEY_WIFI_NETWORK_ID = "key_wifi_network_id";
private FragmentManager mFragmentManager;
/** The Wi-Fi network which will be configured */
private WifiNetworkConfig mWifiNetworkConfig;
+ /** The Wi-Fi DPP QR code from intent ACTION_PROCESS_WIFI_DPP_QR_CODE */
+ private WifiQrCode mWifiDppQrCode;
+
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
@@ -73,6 +88,21 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ if (savedInstanceState != null) {
+ String qrCode = savedInstanceState.getString(KEY_QR_CODE);
+
+ mWifiDppQrCode = getValidWifiDppQrCodeOrNull(qrCode);
+
+ String security = savedInstanceState.getString(KEY_WIFI_SECURITY);
+ String ssid = savedInstanceState.getString(KEY_WIFI_SSID);
+ String preSharedKey = savedInstanceState.getString(KEY_WIFI_PRESHARED_KEY);
+ boolean hiddenSsid = savedInstanceState.getBoolean(KEY_WIFI_HIDDEN_SSID);
+ int networkId = savedInstanceState.getInt(KEY_WIFI_NETWORK_ID);
+
+ mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid,
+ preSharedKey, hiddenSsid, networkId);
+ }
+
setContentView(R.layout.wifi_dpp_activity);
mFragmentManager = getSupportFragmentManager();
@@ -107,8 +137,14 @@
showQrCodeGeneratorFragment();
}
break;
- case ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK:
- showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
+ case ACTION_PROCESS_WIFI_DPP_QR_CODE:
+ String qrCode = intent.getStringExtra(WifiDppUtils.EXTRA_QR_CODE);
+ mWifiDppQrCode = getValidWifiDppQrCodeOrNull(qrCode);
+ if (mWifiDppQrCode == null) {
+ cancelActivity = true;
+ } else {
+ showChooseSavedWifiNetworkFragment(/* addToBackStack */ false);
+ }
break;
default:
cancelActivity = true;
@@ -127,8 +163,8 @@
return;
}
- WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
- FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+ final WifiDppQrCodeScannerFragment fragment = new WifiDppQrCodeScannerFragment();
+ final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
WifiDppUtils.TAG_FRAGMENT_QR_CODE_SCANNER);
@@ -145,8 +181,8 @@
return;
}
- WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
- FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+ final WifiDppQrCodeGeneratorFragment fragment = new WifiDppQrCodeGeneratorFragment();
+ final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
WifiDppUtils.TAG_FRAGMENT_QR_CODE_GENERATOR);
@@ -160,9 +196,9 @@
return;
}
- WifiDppChooseSavedWifiNetworkFragment fragment =
+ final WifiDppChooseSavedWifiNetworkFragment fragment =
new WifiDppChooseSavedWifiNetworkFragment();
- FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+ final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment,
WifiDppUtils.TAG_FRAGMENT_CHOOSE_SAVED_WIFI_NETWORK);
@@ -172,13 +208,51 @@
fragmentTransaction.commit();
}
+ private void showAddDeviceFragment(boolean addToBackStack) {
+ // Avoid to replace the same fragment during configuration change
+ if (mFragmentManager.findFragmentByTag(
+ WifiDppUtils.TAG_FRAGMENT_ADD_DEVICE) != null) {
+ return;
+ }
+
+ final WifiDppAddDeviceFragment fragment =
+ new WifiDppAddDeviceFragment();
+ final FragmentTransaction fragmentTransaction = mFragmentManager.beginTransaction();
+
+ fragmentTransaction.replace(R.id.fragment_container, fragment,
+ WifiDppUtils.TAG_FRAGMENT_ADD_DEVICE);
+ if (addToBackStack) {
+ fragmentTransaction.addToBackStack(/* name */ null);
+ }
+ fragmentTransaction.commit();
+ }
+
+ private WifiQrCode getValidWifiDppQrCodeOrNull(String qrCode) {
+ WifiQrCode wifiQrCode;
+ try {
+ wifiQrCode = new WifiQrCode(qrCode);
+ } catch(IllegalArgumentException e) {
+ return null;
+ }
+
+ if (WifiQrCode.SCHEME_DPP.equals(wifiQrCode.getScheme())) {
+ return wifiQrCode;
+ }
+
+ return null;
+ }
+
@Override
public WifiNetworkConfig getWifiNetworkConfig() {
return mWifiNetworkConfig;
}
- @Override
- public boolean setWifiNetworkConfig(WifiNetworkConfig config) {
+ public WifiQrCode getWifiDppQrCode() {
+ return mWifiDppQrCode;
+ }
+
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected boolean setWifiNetworkConfig(WifiNetworkConfig config) {
if(!WifiNetworkConfig.isValidConfig(config)) {
return false;
} else {
@@ -187,8 +261,22 @@
}
}
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected boolean setWifiDppQrCode(WifiQrCode wifiQrCode) {
+ if (wifiQrCode == null) {
+ return false;
+ }
+
+ if (!WifiQrCode.SCHEME_DPP.equals(wifiQrCode.getScheme())) {
+ return false;
+ }
+
+ mWifiDppQrCode = new WifiQrCode(wifiQrCode.getQrCode());
+ return true;
+ }
+
@Override
- public boolean onNavigateUp(){
+ public boolean onNavigateUp() {
Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
if (fragment instanceof WifiDppQrCodeGeneratorFragment) {
setResult(Activity.RESULT_CANCELED);
@@ -201,7 +289,44 @@
return false;
}
- @Override public void onQrCodeGeneratorFragmentAddButtonClicked() {
+ @Override
+ public void onQrCodeGeneratorFragmentAddButtonClicked() {
showQrCodeScannerFragment(/* addToBackStack */ true);
}
+
+ @Override
+ public void onScanWifiDppSuccess(WifiQrCode wifiQrCode) {
+ mWifiDppQrCode = wifiQrCode;
+
+ showAddDeviceFragment(/* addToBackStack */ true);
+ }
+
+ @Override
+ public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig) {
+ // Do nothing, it's impossible to be a configurator without a Wi-Fi DPP QR code
+ }
+
+ @Override
+ public void onClickChooseDifferentNetwork() {
+ mWifiNetworkConfig = null;
+
+ showChooseSavedWifiNetworkFragment(/* addToBackStack */ true);
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ if (mWifiDppQrCode != null) {
+ outState.putString(KEY_QR_CODE, mWifiDppQrCode.getQrCode());
+ }
+
+ if (mWifiNetworkConfig != null) {
+ outState.putString(KEY_WIFI_SECURITY, mWifiNetworkConfig.getSecurity());
+ outState.putString(KEY_WIFI_SSID, mWifiNetworkConfig.getSsid());
+ outState.putString(KEY_WIFI_PRESHARED_KEY, mWifiNetworkConfig.getPreSharedKey());
+ outState.putBoolean(KEY_WIFI_HIDDEN_SSID, mWifiNetworkConfig.getHiddenSsid());
+ outState.putInt(KEY_WIFI_NETWORK_ID, mWifiNetworkConfig.getNetworkId());
+ }
+
+ super.onSaveInstanceState(outState);
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
index 920e736..3a1b6bc 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivity.java
@@ -16,9 +16,13 @@
package com.android.settings.wifi.dpp;
+import android.content.Context;
+import android.net.wifi.WifiConfiguration;
+import android.provider.Settings;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
+import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
@@ -30,13 +34,18 @@
import com.android.settings.core.InstrumentedActivity;
import com.android.settings.R;
+import java.util.List;
+
/**
* To provision "this" device with specified Wi-Fi network.
*
* To use intent action {@code ACTION_ENROLLEE_QR_CODE_SCANNER}, specify the SSID string of the
* Wi-Fi network to be provisioned in {@code WifiDppUtils.EXTRA_WIFI_SSID}.
*/
-public class WifiDppEnrolleeActivity extends InstrumentedActivity {
+public class WifiDppEnrolleeActivity extends InstrumentedActivity implements
+ WifiManager.ActionListener,
+ WifiDppQrCodeScannerFragment.OnScanWifiDppSuccessListener,
+ WifiDppQrCodeScannerFragment.OnScanZxingWifiFormatSuccessListener {
private static final String TAG = "WifiDppEnrolleeActivity";
public static final String ACTION_ENROLLEE_QR_CODE_SCANNER =
@@ -44,6 +53,39 @@
private FragmentManager mFragmentManager;
+ private class DppStatusCallback extends android.net.wifi.DppStatusCallback {
+ @Override
+ public void onEnrolleeSuccess(int newNetworkId) {
+ // Connect to the new network.
+ final WifiManager wifiManager = getSystemService(WifiManager.class);
+ final List<WifiConfiguration> wifiConfigs = wifiManager.getPrivilegedConfiguredNetworks();
+ for (WifiConfiguration wifiConfig : wifiConfigs) {
+ if (wifiConfig.networkId == newNetworkId) {
+ wifiManager.connect(wifiConfig, WifiDppEnrolleeActivity.this);
+ return;
+ }
+ }
+ Log.e(TAG, "Invalid networkId " + newNetworkId);
+ WifiDppEnrolleeActivity.this.onFailure(WifiManager.ERROR_AUTHENTICATING);
+ }
+
+ @Override
+ public void onConfiguratorSuccess(int code) {
+ // Do nothing
+ }
+
+ @Override
+ public void onFailure(int code) {
+ //TODO(b/122429170): Show DPP enrollee error state UI
+ Log.d(TAG, "DppStatusCallback.onFailure " + code);
+ }
+
+ @Override
+ public void onProgress(int code) {
+ // Do nothing
+ }
+ }
+
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_ENROLLEE;
@@ -101,4 +143,33 @@
finish();
return true;
}
+
+ @Override
+ public void onScanWifiDppSuccess(WifiQrCode wifiQrCode) {
+ final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
+ wifiManager.startDppAsEnrolleeInitiator(wifiQrCode.getQrCode(), /* handler */ null,
+ new DppStatusCallback());
+ }
+
+ @Override
+ public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig) {
+ wifiNetworkConfig.connect(/* context */ this, /* listener */ this);
+ }
+
+ @Override
+ public void onSuccess() {
+ startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
+ setResult(Activity.RESULT_OK);
+ finish();
+ }
+
+ @Override
+ public void onFailure(int reason) {
+ Log.d(TAG, "Wi-Fi connect onFailure reason - " + reason);
+
+ final Fragment fragment = mFragmentManager.findFragmentById(R.id.fragment_container);
+ if (fragment instanceof WifiDppQrCodeScannerFragment) {
+ ((WifiDppQrCodeScannerFragment)fragment).showErrorMessage(true);
+ }
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
index 6792dee..4ac5850 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeBaseFragment.java
@@ -17,25 +17,16 @@
package com.android.settings.wifi.dpp;
import android.os.Bundle;
-import android.view.LayoutInflater;
import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
import android.widget.ImageView;
-import android.widget.ListView;
-import android.widget.ProgressBar;
import android.widget.TextView;
import com.android.settings.core.InstrumentedFragment;
import com.android.settings.R;
/**
- * TODO: b/120645817 should refine code to only initiate UI component in each child fragment.
- */
-
-/**
* There are below 4 fragments for Wi-Fi DPP UI flow, to reduce redundant code of UI components,
- * this parent fragment instantiates all UI components and provides setting APIs for them.
+ * this parent fragment instantiates common UI components
*
* {@code WifiDppQrCodeScannerFragment}
* {@code WifiDppQrCodeGeneratorFragment}
@@ -43,128 +34,16 @@
* {@code WifiDppAddDeviceFragment}
*/
public abstract class WifiDppQrCodeBaseFragment extends InstrumentedFragment {
- private ImageView mHeaderIcon;
- private TextView mTitle;
- private TextView mDescription;
-
- private TextView mErrorMessage; //optional, for WifiDppQrCodeScannerFragment
- private ListView mSavedWifiNetworkList; //optional, for WifiDppChooseSavedWifiNetworkFragment
- private ProgressBar mProgressBar; //optional, for WifiDppAddDeviceFragment
- private ImageView mWifiApPictureView; //optional, for WifiDppAddDeviceFragment
- private TextView mChooseDifferentNetwork;//optional, for WifiDppAddDeviceFragment
-
- private Button mButtonLeft; //optional, for WifiDppChooseSavedWifiNetworkFragment,
- // WifiDppAddDeviceFragment
- private Button mButtonRight; //optional, for WifiDppChooseSavedWifiNetworkFragment,
- // WifiDppAddDeviceFragment
-
- abstract protected int getLayout();
+ protected ImageView mHeaderIcon;
+ protected TextView mTitle;
+ protected TextView mSummary;
@Override
- public final void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
- @Override
- public final View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- View view = inflater.inflate(getLayout(), container, false);
- initView(view);
- return view;
- }
-
- private void initView(View view) {
- mHeaderIcon = view.findViewById(R.id.header_icon);
- mTitle = view.findViewById(R.id.title);
- mDescription = view.findViewById(R.id.description);
- mErrorMessage = view.findViewById(R.id.error_message);
-
- mSavedWifiNetworkList = view.findViewById(R.id.saved_wifi_network_list);
-
- mProgressBar = view.findViewById(R.id.progress_bar);
- mWifiApPictureView = view.findViewById(R.id.wifi_ap_picture_view);
- mChooseDifferentNetwork = view.findViewById(R.id.choose_different_network);
-
- mButtonLeft = view.findViewById(R.id.button_left);
- mButtonRight = view.findViewById(R.id.button_right);
- }
-
- protected void setHeaderIconImageResource(int resId) {
- mHeaderIcon.setImageResource(resId);
- }
-
- protected void setTitle(String title) {
- mTitle.setText(title);
- }
-
- protected void setDescription(String description) {
- mDescription.setText(description);
- }
-
- /** optional, for WifiDppQrCodeScannerFragment */
- protected void setErrorMessage(String errorMessage) {
- if (mErrorMessage != null) {
- mErrorMessage.setText(errorMessage);
- }
- }
-
- /**
- * optional, for WifiDppChooseSavedWifiNetworkFragment,
- * WifiDppAddDeviceFragment
- */
- protected void setLeftButtonText(String text) {
- if (mButtonLeft != null) {
- mButtonLeft.setText(text);
- }
- }
-
- /**
- * optional, for WifiDppChooseSavedWifiNetworkFragment,
- * WifiDppAddDeviceFragment
- */
- protected void setRightButtonText(String text) {
- if (mButtonRight != null) {
- mButtonRight.setText(text);
- }
- }
-
- /**
- * optional, for WifiDppChooseSavedWifiNetworkFragment,
- * WifiDppAddDeviceFragment
- */
- protected void hideLeftButton() {
- if (mButtonLeft != null) {
- mButtonLeft.setVisibility(View.INVISIBLE);
- }
- }
-
- /**
- * optional, for WifiDppChooseSavedWifiNetworkFragment,
- * WifiDppAddDeviceFragment
- */
- protected void hideRightButton() {
- if (mButtonRight != null) {
- mButtonRight.setVisibility(View.INVISIBLE);
- }
- }
-
- /**
- * optional, for WifiDppChooseSavedWifiNetworkFragment,
- * WifiDppAddDeviceFragment
- */
- protected void setLeftButtonOnClickListener(View.OnClickListener listener) {
- if (mButtonLeft != null) {
- mButtonLeft.setOnClickListener(listener);
- }
- }
-
- /**
- * optional, for WifiDppChooseSavedWifiNetworkFragment,
- * WifiDppAddDeviceFragment
- */
- protected void setRightButtonOnClickListener(View.OnClickListener listener) {
- if (mButtonRight != null) {
- mButtonRight.setOnClickListener(listener);
- }
+ mHeaderIcon = view.findViewById(android.R.id.icon);
+ mTitle = view.findViewById(android.R.id.title);
+ mSummary = view.findViewById(android.R.id.summary);
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
index 81def9b..f4bbcc1 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeGeneratorFragment.java
@@ -18,23 +18,32 @@
import android.app.ActionBar;
import android.content.Context;
+import android.graphics.Bitmap;
import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
+import com.android.settings.wifi.qrcode.QrCodeGenerator;
+
+import com.google.zxing.WriterException;
/**
* After sharing a saved Wi-Fi network, {@code WifiDppConfiguratorActivity} start with this fragment
* to generate a Wi-Fi DPP QR code for other device to initiate as an enrollee.
*/
public class WifiDppQrCodeGeneratorFragment extends WifiDppQrCodeBaseFragment {
- @Override
- protected int getLayout() {
- return R.layout.wifi_dpp_qrcode_generator_fragment;
- }
+ private static final String TAG = "WifiDppQrCodeGeneratorFragment";
+
+ private ImageView mQrCodeView;
+ private String mQrCode;
@Override
public int getMetricsCategory() {
@@ -51,18 +60,8 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- setHeaderIconImageResource(R.drawable.ic_qrcode_24dp);
- WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
- .getWifiNetworkConfig();
- if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
- throw new IllegalArgumentException("Invalid Wi-Fi network for configuring");
- }
- setTitle(getString(R.string.wifi_dpp_share_wifi));
- setDescription(getString(R.string.wifi_dpp_scan_qr_code_with_another_device,
- wifiNetworkConfig.getSsid()));
-
setHasOptionsMenu(true);
- ActionBar actionBar = getActivity().getActionBar();
+ final ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.show();
@@ -102,4 +101,42 @@
return super.onOptionsItemSelected(menuItem);
}
}
+
+ @Override
+ public final View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.wifi_dpp_qrcode_generator_fragment, container,
+ /* attachToRoot */ false);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+
+ mQrCodeView = view.findViewById(R.id.qrcode_view);
+
+ mHeaderIcon.setImageResource(R.drawable.ic_qrcode_24dp);
+ WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
+ .getWifiNetworkConfig();
+ if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
+ throw new IllegalStateException("Invalid Wi-Fi network for configuring");
+ }
+ mTitle.setText(R.string.wifi_dpp_share_wifi);
+ mSummary.setText(getString(R.string.wifi_dpp_scan_qr_code_with_another_device,
+ wifiNetworkConfig.getSsid()));
+
+ mQrCode = wifiNetworkConfig.getQrCode();
+ setQrCode();
+ }
+
+ private void setQrCode() {
+ try {
+ final int qrcodeSize = getContext().getResources().getDimensionPixelSize(
+ R.dimen.qrcode_size);
+ final Bitmap bmp = QrCodeGenerator.encodeQrCode(mQrCode, qrcodeSize);
+ mQrCodeView.setImageBitmap(bmp);
+ } catch (WriterException e) {
+ Log.e(TAG, "Error generatting QR code bitmap " + e);
+ }
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
index 8cd3c562..21534dc 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppQrCodeScannerFragment.java
@@ -16,7 +16,6 @@
package com.android.settings.wifi.dpp;
-import android.annotation.Nullable;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Context;
@@ -25,13 +24,18 @@
import android.graphics.Rect;
import android.graphics.SurfaceTexture;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
import android.text.TextUtils;
import android.util.Size;
+import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.TextureView;
import android.view.TextureView.SurfaceTextureListener;
import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto;
import com.android.settings.R;
@@ -41,37 +45,78 @@
public class WifiDppQrCodeScannerFragment extends WifiDppQrCodeBaseFragment implements
SurfaceTextureListener,
QrCamera.ScannerCallback {
+ private static final String TAG = "WifiDppQrCodeScannerFragment";
+
+ /** Message sent to hide error message */
+ private static final int MESSAGE_HIDE_ERROR_MESSAGE = 1;
+
+ /** Message sent to show error message */
+ private static final int MESSAGE_SHOW_ERROR_MESSAGE = 2;
+
+ /** Message sent to manipulate Wi-Fi DPP QR code */
+ private static final int MESSAGE_SCAN_WIFI_DPP_SUCCESS = 3;
+
+ /** Message sent to manipulate ZXing Wi-Fi QR code */
+ private static final int MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS = 4;
+
+ private static final long SHOW_ERROR_MESSAGE_INTERVAL = 2000;
+ private static final long SHOW_SUCCESS_SQUARE_INTERVAL = 1000;
+
+ // Key for Bundle usage
+ private static final String KEY_PUBLIC_URI = "key_public_uri";
+ private static final String KEY_IS_CONFIGURATOR_MODE = "key_is_configurator_mode";
+
private QrCamera mCamera;
private TextureView mTextureView;
private QrDecorateView mDecorateView;
+ private TextView mErrorMessage;
/** true if the fragment working for configurator, false enrollee*/
- private final boolean mConfiguratorMode;
+ private boolean mIsConfiguratorMode;
/** The SSID of the Wi-Fi network which the user specify to enroll */
private String mSsid;
+ /** QR code data scanned by camera */
+ private WifiQrCode mWifiQrCode;
+
@Override
- protected int getLayout() {
- return R.layout.wifi_dpp_qrcode_scanner_fragment;
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ if (savedInstanceState != null) {
+ mIsConfiguratorMode = savedInstanceState.getBoolean(KEY_IS_CONFIGURATOR_MODE);
+ }
}
@Override
public int getMetricsCategory() {
- if (mConfiguratorMode) {
+ if (mIsConfiguratorMode) {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_CONFIGURATOR;
} else {
return MetricsProto.MetricsEvent.SETTINGS_WIFI_DPP_ENROLLEE;
}
}
+ // Container Activity must implement this interface
+ public interface OnScanWifiDppSuccessListener {
+ public void onScanWifiDppSuccess(WifiQrCode wifiQrCode);
+ }
+ OnScanWifiDppSuccessListener mScanWifiDppSuccessListener;
+
+ // Container Activity must implement this interface
+ public interface OnScanZxingWifiFormatSuccessListener {
+ public void onScanZxingWifiFormatSuccess(WifiNetworkConfig wifiNetworkConfig);
+ }
+ OnScanZxingWifiFormatSuccessListener mScanZxingWifiFormatSuccessListener;
+
/**
* Configurator container activity of the fragment should create instance with this constructor.
*/
public WifiDppQrCodeScannerFragment() {
super();
- mConfiguratorMode = true;
+ mIsConfiguratorMode = true;
}
/**
@@ -81,7 +126,7 @@
public WifiDppQrCodeScannerFragment(String ssid) {
super();
- mConfiguratorMode = false;
+ mIsConfiguratorMode = false;
mSsid = ssid;
}
@@ -89,30 +134,7 @@
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
- setHeaderIconImageResource(R.drawable.ic_scan_24dp);
-
- if (mConfiguratorMode) {
- setTitle(getString(R.string.wifi_dpp_add_device_to_network));
-
- WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
- .getWifiNetworkConfig();
- if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
- throw new IllegalArgumentException("Invalid Wi-Fi network for configuring");
- }
- setDescription(getString(R.string.wifi_dpp_center_qr_code, wifiNetworkConfig.getSsid()));
- } else {
- setTitle(getString(R.string.wifi_dpp_scan_qr_code));
-
- String description;
- if (TextUtils.isEmpty(mSsid)) {
- description = getString(R.string.wifi_dpp_scan_qr_code_join_unknown_network, mSsid);
- } else {
- description = getString(R.string.wifi_dpp_scan_qr_code_join_network, mSsid);
- }
- setDescription(description);
- }
-
- ActionBar actionBar = getActivity().getActionBar();
+ final ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.show();
@@ -120,13 +142,61 @@
}
@Override
- public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+ public void onAttach(Context context) {
+ super.onAttach(context);
+
+ mScanWifiDppSuccessListener = (OnScanWifiDppSuccessListener) context;
+ mScanZxingWifiFormatSuccessListener = (OnScanZxingWifiFormatSuccessListener) context;
+ }
+
+ @Override
+ public void onDetach() {
+ mScanWifiDppSuccessListener = null;
+ mScanZxingWifiFormatSuccessListener = null;
+
+ super.onDetach();
+ }
+
+ @Override
+ public final View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ return inflater.inflate(R.layout.wifi_dpp_qrcode_scanner_fragment, container,
+ /* attachToRoot */ false);
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mTextureView = (TextureView) view.findViewById(R.id.preview_view);
mTextureView.setSurfaceTextureListener(this);
mDecorateView = (QrDecorateView) view.findViewById(R.id.decorate_view);
+
+ mHeaderIcon.setImageResource(R.drawable.ic_scan_24dp);
+ if (mIsConfiguratorMode) {
+ mTitle.setText(R.string.wifi_dpp_add_device_to_network);
+
+ WifiNetworkConfig wifiNetworkConfig = ((WifiNetworkConfig.Retriever) getActivity())
+ .getWifiNetworkConfig();
+ if (!WifiNetworkConfig.isValidConfig(wifiNetworkConfig)) {
+ throw new IllegalStateException("Invalid Wi-Fi network for configuring");
+ }
+ mSummary.setText(getString(R.string.wifi_dpp_center_qr_code,
+ wifiNetworkConfig.getSsid()));
+ } else {
+ mTitle.setText(R.string.wifi_dpp_scan_qr_code);
+
+ String description;
+ if (TextUtils.isEmpty(mSsid)) {
+ description = getString(R.string.wifi_dpp_scan_qr_code_join_unknown_network, mSsid);
+ } else {
+ description = getString(R.string.wifi_dpp_scan_qr_code_join_network, mSsid);
+ }
+ mSummary.setText(description);
+ }
+
+ mErrorMessage = view.findViewById(R.id.error_message);
}
@Override
@@ -173,10 +243,71 @@
}
@Override
+ public boolean isValid(String qrCode) {
+ try {
+ mWifiQrCode = new WifiQrCode(qrCode);
+ } catch (IllegalArgumentException e) {
+ mHandler.sendEmptyMessage(MESSAGE_SHOW_ERROR_MESSAGE);
+ return false;
+ }
+
+ final String scheme = mWifiQrCode.getScheme();
+
+ // When SSID is specified for enrollee, avoid to connect to the Wi-Fi of different SSID
+ if (!mIsConfiguratorMode && WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG.equals(scheme)) {
+ final String ssidQrCode = mWifiQrCode.getWifiNetworkConfig().getSsid();
+ if (!TextUtils.isEmpty(mSsid) && !mSsid.equals(ssidQrCode)) {
+ mHandler.sendEmptyMessage(MESSAGE_SHOW_ERROR_MESSAGE);
+ return false;
+ }
+ }
+
+ // It's impossible to provision other device with ZXing Wi-Fi Network config format
+ if (mIsConfiguratorMode && WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG.equals(scheme)) {
+ mHandler.sendEmptyMessage(MESSAGE_SHOW_ERROR_MESSAGE);
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * This method is only called when QrCamera.ScannerCallback.isValid returns true;
+ */
+ @Override
public void handleSuccessfulResult(String qrCode) {
+ switch (mWifiQrCode.getScheme()) {
+ case WifiQrCode.SCHEME_DPP:
+ handleWifiDpp();
+ break;
+
+ case WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG:
+ handleZxingWifiFormat();
+ break;
+
+ default:
+ // continue below
+ }
+ }
+
+ private void handleWifiDpp() {
destroyCamera();
mDecorateView.setFocused(true);
- // TODO(b/120243131): Add a network by Wi-Fi Network config shared via QR code.
+
+ Message message = mHandler.obtainMessage(MESSAGE_SCAN_WIFI_DPP_SUCCESS);
+ message.obj = new WifiQrCode(mWifiQrCode.getQrCode());
+
+ mHandler.sendMessageDelayed(message, SHOW_SUCCESS_SQUARE_INTERVAL);
+ }
+
+ private void handleZxingWifiFormat() {
+ destroyCamera();
+ mDecorateView.setFocused(true);
+
+ Message message = mHandler.obtainMessage(MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS);
+ message.obj = new WifiQrCode(mWifiQrCode.getQrCode()).getWifiNetworkConfig();
+
+ mHandler.sendMessageDelayed(message, SHOW_SUCCESS_SQUARE_INTERVAL);
}
@Override
@@ -198,4 +329,54 @@
mCamera = null;
}
}
+
+ public void showErrorMessage(boolean show) {
+ mErrorMessage.setVisibility(show ? View.VISIBLE : View.INVISIBLE);
+
+ if (show) {
+ mHandler.removeMessages(MESSAGE_HIDE_ERROR_MESSAGE);
+ mHandler.sendEmptyMessageDelayed(MESSAGE_HIDE_ERROR_MESSAGE,
+ SHOW_ERROR_MESSAGE_INTERVAL);
+ }
+ }
+
+ private final Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ switch (msg.what) {
+ case MESSAGE_HIDE_ERROR_MESSAGE:
+ showErrorMessage(false);
+ break;
+
+ case MESSAGE_SHOW_ERROR_MESSAGE:
+ showErrorMessage(true);
+ break;
+
+ case MESSAGE_SCAN_WIFI_DPP_SUCCESS:
+ if (mScanWifiDppSuccessListener == null) {
+ return;
+ }
+ mScanWifiDppSuccessListener.onScanWifiDppSuccess((WifiQrCode)msg.obj);
+ break;
+
+ case MESSAGE_SCAN_ZXING_WIFI_FORMAT_SUCCESS:
+ if (mScanZxingWifiFormatSuccessListener == null) {
+ return;
+ }
+ mScanZxingWifiFormatSuccessListener.onScanZxingWifiFormatSuccess(
+ (WifiNetworkConfig)msg.obj);
+ break;
+
+ default:
+ return;
+ }
+ }
+ };
+
+ @Override
+ public void onSaveInstanceState(Bundle outState) {
+ outState.putBoolean(KEY_IS_CONFIGURATOR_MODE, mIsConfiguratorMode);
+
+ super.onSaveInstanceState(outState);
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiDppUtils.java b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
index cc75d44..0205ec1 100644
--- a/src/com/android/settings/wifi/dpp/WifiDppUtils.java
+++ b/src/com/android/settings/wifi/dpp/WifiDppUtils.java
@@ -18,9 +18,15 @@
import android.content.Context;
import android.content.Intent;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiManager;
import android.text.TextUtils;
import android.util.FeatureFlagUtils;
+import com.android.settingslib.wifi.AccessPoint;
+
+import java.util.List;
+
/**
* Here are the items shared by both WifiDppConfiguratorActivity & WifiDppEnrolleeActivity
*/
@@ -58,6 +64,9 @@
/** The data corresponding to {@code WifiConfiguration} hiddenSSID */
public static final String EXTRA_WIFI_HIDDEN_SSID = "hiddenSsid";
+ /** The data corresponding to {@code WifiConfiguration} networkId */
+ public static final String EXTRA_WIFI_NETWORK_ID = "networkId";
+
/** @see WifiQrCode */
public static final String EXTRA_QR_CODE = "qrCode";
@@ -84,23 +93,86 @@
return intent;
}
+ private static String getPresharedKey(WifiManager wifiManager, WifiConfiguration config) {
+ String preSharedKey = config.preSharedKey;
+
+ final List<WifiConfiguration> wifiConfigs = wifiManager.getPrivilegedConfiguredNetworks();
+ for (WifiConfiguration wifiConfig : wifiConfigs) {
+ if (wifiConfig.networkId == config.networkId) {
+ preSharedKey = wifiConfig.preSharedKey;
+ break;
+ }
+ }
+
+ return preSharedKey;
+ }
+
+ private static String removeFirstAndLastDoubleQuotes(String str) {
+ if (TextUtils.isEmpty(str)) {
+ return str;
+ }
+
+ int begin = 0;
+ int end = str.length() - 1;
+ if (str.charAt(begin) == '\"') {
+ begin++;
+ }
+ if (str.charAt(end) == '\"') {
+ end--;
+ }
+ return str.substring(begin, end+1);
+ }
+
+ private static String getSecurityString(AccessPoint accessPoint) {
+ switch(accessPoint.getSecurity()) {
+ case AccessPoint.SECURITY_WEP:
+ return "WEP";
+ case AccessPoint.SECURITY_PSK:
+ return "WPA";
+ default:
+ return "nopass";
+ }
+ }
+
/**
* Returns an intent to launch QR code generator.
*
- * @param ssid The data corresponding to {@code WifiConfiguration} SSID
- * @param Security The data is from {@code AccessPoint.securityToString}
+ * @param context The context to use for the content resolver
+ * @param wifiManager An instance of {@link WifiManager}
+ * @param accessPoint An instance of {@link AccessPoint}
* @return Intent for launching QR code generator
*/
- public static Intent getConfiguratorQrCodeGeneratorIntent(String ssid, String Security) {
- //TODO: b/118794858#comment6 should put password & hideSsid in intent extra
- final Intent intent = new Intent(
- WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
+ public static Intent getConfiguratorQrCodeGeneratorIntent(Context context,
+ WifiManager wifiManager, AccessPoint accessPoint) {
+ final Intent intent = new Intent(context, WifiDppConfiguratorActivity.class);
+ intent.setAction(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
+
+ final WifiConfiguration wifiConfig = accessPoint.getConfig();
+ final String ssid = removeFirstAndLastDoubleQuotes(wifiConfig.SSID);
+ final String security = getSecurityString(accessPoint);
+ String preSharedKey = wifiConfig.preSharedKey;
+
+ if (preSharedKey != null) {
+ // When the value of this key is read, the actual key is not returned, just a "*".
+ // Call privileged system API to obtain actual key.
+ preSharedKey = removeFirstAndLastDoubleQuotes(getPresharedKey(wifiManager, wifiConfig));
+ }
+
if (!TextUtils.isEmpty(ssid)) {
intent.putExtra(EXTRA_WIFI_SSID, ssid);
}
- if (!TextUtils.isEmpty(Security)) {
- intent.putExtra(EXTRA_WIFI_SECURITY, Security);
+ if (!TextUtils.isEmpty(security)) {
+ intent.putExtra(EXTRA_WIFI_SECURITY, security);
}
+ if (!TextUtils.isEmpty(preSharedKey)) {
+ intent.putExtra(EXTRA_WIFI_PRE_SHARED_KEY, preSharedKey);
+ }
+ if (wifiConfig.networkId == WifiConfiguration.INVALID_NETWORK_ID) {
+ throw new IllegalArgumentException("Invalid network ID");
+ } else {
+ intent.putExtra(EXTRA_WIFI_NETWORK_ID, wifiConfig.networkId);
+ }
+
return intent;
}
}
diff --git a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
index bb64e05..915e90d 100644
--- a/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
+++ b/src/com/android/settings/wifi/dpp/WifiNetworkConfig.java
@@ -16,10 +16,21 @@
package com.android.settings.wifi.dpp;
+import static com.android.settings.wifi.dpp.WifiQrCode.SECURITY_NO_PASSWORD;
+import static com.android.settings.wifi.dpp.WifiQrCode.SECURITY_WEP;
+import static com.android.settings.wifi.dpp.WifiQrCode.SECURITY_WPA;
+
+import android.content.Context;
import android.content.Intent;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiConfiguration.AuthAlgorithm;
+import android.net.wifi.WifiConfiguration.KeyMgmt;
+import android.net.wifi.WifiManager;
import android.text.TextUtils;
+import android.util.Log;
import androidx.annotation.Keep;
+import androidx.annotation.VisibleForTesting;
/**
* Wraps the parameters of ZXing reader library's Wi-Fi Network config format.
@@ -30,36 +41,30 @@
* EXTRA_QR_CODE
*/
public class WifiNetworkConfig {
- // Ignores password if security is NO_PASSWORD or absent
- public static final String NO_PASSWORD = "nopass";
+ private static final String TAG = "WifiNetworkConfig";
private String mSecurity;
private String mSsid;
private String mPreSharedKey;
private boolean mHiddenSsid;
+ private int mNetworkId;
- private WifiNetworkConfig(String security, String ssid, String preSharedKey,
- boolean hiddenSsid) {
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected WifiNetworkConfig(String security, String ssid, String preSharedKey,
+ boolean hiddenSsid, int networkId) {
mSecurity = security;
mSsid = ssid;
mPreSharedKey = preSharedKey;
mHiddenSsid = hiddenSsid;
+ mNetworkId = networkId;
}
public WifiNetworkConfig(WifiNetworkConfig config) {
- if (config.mSecurity != null) {
- mSecurity = new String(config.mSecurity);
- }
-
- if (config.mSsid != null) {
- mSsid = new String(config.mSsid);
- }
-
- if (config.mPreSharedKey != null) {
- mPreSharedKey = new String(config.mPreSharedKey);
- }
-
+ mSecurity = config.mSecurity;
+ mSsid = config.mSsid;
+ mPreSharedKey = config.mPreSharedKey;
mHiddenSsid = config.mHiddenSsid;
+ mNetworkId = config.mNetworkId;
}
/**
@@ -68,7 +73,6 @@
*/
public interface Retriever {
public WifiNetworkConfig getWifiNetworkConfig();
- public boolean setWifiNetworkConfig(WifiNetworkConfig config);
}
/**
@@ -82,17 +86,19 @@
String ssid = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_SSID);
String preSharedKey = intent.getStringExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY);
boolean hiddenSsid = intent.getBooleanExtra(WifiDppUtils.EXTRA_WIFI_HIDDEN_SSID, false);
+ int networkId = intent.getIntExtra(WifiDppUtils.EXTRA_WIFI_NETWORK_ID,
+ WifiConfiguration.INVALID_NETWORK_ID);
- return getValidConfigOrNull(security, ssid, preSharedKey, hiddenSsid);
+ return getValidConfigOrNull(security, ssid, preSharedKey, hiddenSsid, networkId);
}
public static WifiNetworkConfig getValidConfigOrNull(String security, String ssid,
- String preSharedKey, boolean hiddenSsid) {
+ String preSharedKey, boolean hiddenSsid, int networkId) {
if (!isValidConfig(security, ssid, preSharedKey, hiddenSsid)) {
return null;
}
- return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid);
+ return new WifiNetworkConfig(security, ssid, preSharedKey, hiddenSsid, networkId);
}
public static boolean isValidConfig(WifiNetworkConfig config) {
@@ -106,7 +112,7 @@
public static boolean isValidConfig(String security, String ssid, String preSharedKey,
boolean hiddenSsid) {
- if (!TextUtils.isEmpty(security) && !NO_PASSWORD.equals(security)) {
+ if (!TextUtils.isEmpty(security) && !SECURITY_NO_PASSWORD.equals(security)) {
if (TextUtils.isEmpty(preSharedKey)) {
return false;
}
@@ -119,6 +125,51 @@
return true;
}
+ /**
+ * Escaped special characters "\", ";", ":", "," with a backslash
+ * See https://github.com/zxing/zxing/wiki/Barcode-Contents
+ */
+ private String escapeSpecialCharacters(String str) {
+ if (TextUtils.isEmpty(str)) {
+ return str;
+ }
+
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < str.length(); i++) {
+ char ch = str.charAt(i);
+ if (ch =='\\' || ch == ',' || ch == ';' || ch == ':') {
+ buf.append('\\');
+ }
+ buf.append(ch);
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * Construct a barcode string for WiFi network login.
+ * See https://en.wikipedia.org/wiki/QR_code#WiFi_network_login
+ */
+ public String getQrCode() {
+ final String empty = "";
+ String barcode = new StringBuilder("WIFI:")
+ .append("S:")
+ .append(escapeSpecialCharacters(mSsid))
+ .append(";")
+ .append("T:")
+ .append(TextUtils.isEmpty(mSecurity) ? empty : mSecurity)
+ .append(";")
+ .append("P:")
+ .append(TextUtils.isEmpty(mPreSharedKey) ? empty
+ : escapeSpecialCharacters(mPreSharedKey))
+ .append(";")
+ .append("H:")
+ .append(mHiddenSsid)
+ .append(";;")
+ .toString();
+ return barcode;
+ }
+
@Keep
public String getSecurity() {
return mSecurity;
@@ -138,4 +189,83 @@
public boolean getHiddenSsid() {
return mHiddenSsid;
}
+
+ @Keep
+ public int getNetworkId() {
+ return mNetworkId;
+ }
+
+ public void connect(Context context, WifiManager.ActionListener listener) {
+ WifiConfiguration wifiConfiguration = getWifiConfigurationOrNull();
+ if (wifiConfiguration == null) {
+ if (listener != null) {
+ listener.onFailure(WifiManager.ERROR);
+ }
+ return;
+ }
+
+ WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
+ wifiManager.connect(wifiConfiguration, listener);
+ }
+
+ /**
+ * This is a simplified method from {@code WifiConfigController.getConfig()}
+ */
+ private WifiConfiguration getWifiConfigurationOrNull() {
+ if (!isValidConfig(this)) {
+ return null;
+ }
+
+ final WifiConfiguration wifiConfiguration = new WifiConfiguration();
+ wifiConfiguration.SSID = addQuotationIfNeeded(mSsid);
+ wifiConfiguration.hiddenSSID = mHiddenSsid;
+ wifiConfiguration.networkId = mNetworkId;
+
+ if (TextUtils.isEmpty(mSecurity) || SECURITY_NO_PASSWORD.equals(mSecurity)) {
+ wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);
+ return wifiConfiguration;
+ }
+
+ if (mSecurity.startsWith(SECURITY_WEP)) {
+ wifiConfiguration.allowedKeyManagement.set(KeyMgmt.NONE);
+ wifiConfiguration.allowedAuthAlgorithms.set(AuthAlgorithm.OPEN);
+ wifiConfiguration.allowedAuthAlgorithms.set(AuthAlgorithm.SHARED);
+
+ // WEP-40, WEP-104, and 256-bit WEP (WEP-232?)
+ final int length = mPreSharedKey.length();
+ if ((length == 10 || length == 26 || length == 58)
+ && mPreSharedKey.matches("[0-9A-Fa-f]*")) {
+ wifiConfiguration.wepKeys[0] = mPreSharedKey;
+ } else {
+ wifiConfiguration.wepKeys[0] = addQuotationIfNeeded(mPreSharedKey);
+ }
+ } else if (mSecurity.startsWith(SECURITY_WPA)) {
+ wifiConfiguration.allowedKeyManagement.set(KeyMgmt.WPA_PSK);
+
+ if (mPreSharedKey.matches("[0-9A-Fa-f]{64}")) {
+ wifiConfiguration.preSharedKey = mPreSharedKey;
+ } else {
+ wifiConfiguration.preSharedKey = addQuotationIfNeeded(mPreSharedKey);
+ }
+ } else {
+ Log.w(TAG, "Unsupported security");
+ return null;
+ }
+
+ return wifiConfiguration;
+ }
+
+ private String addQuotationIfNeeded(String input) {
+ if (TextUtils.isEmpty(input)) {
+ return "";
+ }
+
+ if (input.length() >= 2 && input.startsWith("\"") && input.endsWith("\"")) {
+ return input;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("\"").append(input).append("\"");
+ return sb.toString();
+ }
}
diff --git a/src/com/android/settings/wifi/dpp/WifiQrCode.java b/src/com/android/settings/wifi/dpp/WifiQrCode.java
index ebc39c3..b60289f 100644
--- a/src/com/android/settings/wifi/dpp/WifiQrCode.java
+++ b/src/com/android/settings/wifi/dpp/WifiQrCode.java
@@ -17,12 +17,13 @@
package com.android.settings.wifi.dpp;
import android.content.Intent;
+import android.net.wifi.WifiConfiguration;
import android.text.TextUtils;
-import androidx.annotation.Keep;
import androidx.annotation.VisibleForTesting;
-import java.util.regex.Matcher;
+import java.util.Arrays;
+import java.util.List;
import java.util.regex.Pattern;
/**
@@ -47,7 +48,6 @@
* H true Optional. True if the network SSID is hidden.
*
*/
-@Keep
public class WifiQrCode {
public static final String SCHEME_DPP = "DPP";
public static final String SCHEME_ZXING_WIFI_NETWORK_CONFIG = "WIFI";
@@ -62,7 +62,12 @@
public static final String PREFIX_ZXING_PASSWORD = "P:";
public static final String PREFIX_ZXING_HIDDEN_SSID = "H:";
- public static final String SUFFIX_QR_CODE = ";";
+ public static final String DELIMITER_QR_CODE = ";";
+
+ // Ignores password if security is SECURITY_NO_PASSWORD or absent
+ public static final String SECURITY_NO_PASSWORD = "nopass";
+ public static final String SECURITY_WEP = "WEP";
+ public static final String SECURITY_WPA = "WPA";
private String mQrCode;
@@ -79,7 +84,6 @@
// Data from parsed ZXing reader library's Wi-Fi Network config format
private WifiNetworkConfig mWifiNetworkConfig;
- @Keep
public WifiQrCode(String qrCode) throws IllegalArgumentException {
if (TextUtils.isEmpty(qrCode)) {
throw new IllegalArgumentException("Empty QR code");
@@ -100,22 +104,27 @@
/** Parses Wi-Fi DPP QR code string */
private void parseWifiDppQrCode(String qrCode) throws IllegalArgumentException {
- String publicKey = getSubStringOrNull(qrCode, PREFIX_DPP_PUBLIC_KEY, SUFFIX_QR_CODE);
+ List keyValueList = getKeyValueList(qrCode, PREFIX_DPP, DELIMITER_QR_CODE);
+
+ String publicKey = getValueOrNull(keyValueList, PREFIX_DPP_PUBLIC_KEY);
if (TextUtils.isEmpty(publicKey)) {
throw new IllegalArgumentException("Invalid format");
}
mPublicKey = publicKey;
- mInformation = getSubStringOrNull(qrCode, PREFIX_DPP_INFORMATION, SUFFIX_QR_CODE);
+ mInformation = getValueOrNull(keyValueList, PREFIX_DPP_INFORMATION);
}
/** Parses ZXing reader library's Wi-Fi Network config format */
private void parseZxingWifiQrCode(String qrCode) throws IllegalArgumentException {
- String security = getSubStringOrNull(qrCode, PREFIX_ZXING_SECURITY, SUFFIX_QR_CODE);
- String ssid = getSubStringOrNull(qrCode, PREFIX_ZXING_SSID, SUFFIX_QR_CODE);
- String password = getSubStringOrNull(qrCode, PREFIX_ZXING_PASSWORD, SUFFIX_QR_CODE);
- String hiddenSsidString = getSubStringOrNull(qrCode, PREFIX_ZXING_HIDDEN_SSID,
- SUFFIX_QR_CODE);
+ List keyValueList = getKeyValueList(qrCode, PREFIX_ZXING_WIFI_NETWORK_CONFIG,
+ DELIMITER_QR_CODE);
+
+ String security = getValueOrNull(keyValueList, PREFIX_ZXING_SECURITY);
+ String ssid = getValueOrNull(keyValueList, PREFIX_ZXING_SSID);
+ String password = getValueOrNull(keyValueList, PREFIX_ZXING_PASSWORD);
+ String hiddenSsidString = getValueOrNull(keyValueList, PREFIX_ZXING_HIDDEN_SSID);
+
boolean hiddenSsid = "true".equalsIgnoreCase(hiddenSsidString);
//"\", ";", "," and ":" are escaped with a backslash "\", should remove at first
@@ -124,7 +133,7 @@
password = removeBackSlash(password);
mWifiNetworkConfig = WifiNetworkConfig.getValidConfigOrNull(security, ssid, password,
- hiddenSsid);
+ hiddenSsid, WifiConfiguration.INVALID_NETWORK_ID);
if (mWifiNetworkConfig == null) {
throw new IllegalArgumentException("Invalid format");
@@ -132,33 +141,36 @@
}
/**
- * Gets the substring between prefix & suffix from input.
+ * Splits key/value pairs from qrCode
*
- * @param prefix the string before the returned substring
- * @param suffix the string after the returned substring
- * @return null if not exists, non-null otherwise
+ * @param qrCode the QR code raw string
+ * @param prefixQrCode the string before all key/value pairs in qrCode
+ * @param delimiter the string to split key/value pairs, can't contain a backslash
+ * @return a list contains string of key/value (e.g. K:key1)
*/
- private static String getSubStringOrNull(String input, String prefix, String suffix) {
- StringBuilder sb = new StringBuilder();
- String regex = sb.append(prefix).append("(.*?)").append(suffix).toString();
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(input);
+ private List<String> getKeyValueList(String qrCode, String prefixQrCode,
+ String delimiter) {
+ String keyValueString = qrCode.substring(prefixQrCode.length());
- if (!matcher.find()) {
- return null;
- }
+ // Should not treat \delimiter as a delimiter
+ String regex = "(?<!\\\\)" + Pattern.quote(delimiter);
- String target = matcher.group(1);
- if (TextUtils.isEmpty(target)) {
- return null;
- }
-
- return target;
+ List<String> result = Arrays.asList(keyValueString.split(regex));
+ return result;
}
- @Keep
+ private String getValueOrNull(List<String> keyValueList, String prefix) {
+ for (String keyValue : keyValueList) {
+ if (keyValue.startsWith(prefix)) {
+ return keyValue.substring(prefix.length());
+ }
+ }
+
+ return null;
+ }
+
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
- protected static String removeBackSlash(String input) {
+ protected String removeBackSlash(String input) {
if (input == null) {
return null;
}
@@ -183,7 +195,6 @@
return sb.toString();
}
- @Keep
public String getQrCode() {
return mQrCode;
}
@@ -194,25 +205,22 @@
* SCHEME_DPP for standard Wi-Fi device provision protocol; SCHEME_ZXING_WIFI_NETWORK_CONFIG
* for ZXing reader library' Wi-Fi Network config format
*/
- @Keep
public String getScheme() {
return mScheme;
}
/** Available when {@code getScheme()} returns SCHEME_DPP */
- @Keep
- public String getPublicKey() {
+ @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
+ protected String getPublicKey() {
return mPublicKey;
}
/** May be available when {@code getScheme()} returns SCHEME_DPP */
- @Keep
public String getInformation() {
return mInformation;
}
/** Available when {@code getScheme()} returns SCHEME_ZXING_WIFI_NETWORK_CONFIG */
- @Keep
public WifiNetworkConfig getWifiNetworkConfig() {
if (mWifiNetworkConfig == null) {
return null;
diff --git a/src/com/android/settings/wifi/qrcode/QrCamera.java b/src/com/android/settings/wifi/qrcode/QrCamera.java
index c60c30e..af366bc 100644
--- a/src/com/android/settings/wifi/qrcode/QrCamera.java
+++ b/src/com/android/settings/wifi/qrcode/QrCamera.java
@@ -152,6 +152,15 @@
* @param transform The transform to apply to the content of preview
*/
void setTransform(Matrix transform);
+
+ /**
+ * Verify QR code is valid or not. The camera will stop scanning if this callback returns
+ * true.
+ *
+ * @param qrCode The result QR code after decoding.
+ * @return Returns true if qrCode hold valid information.
+ */
+ boolean isValid(String qrCode);
}
private void setCameraParameter() {
@@ -245,7 +254,9 @@
mReader.reset();
}
if (qrCode != null) {
- return qrCode.getText();
+ if (mScannerCallback.isValid(qrCode.getText())) {
+ return qrCode.getText();
+ }
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
diff --git a/src/com/android/settings/wifi/qrcode/QrDecorateView.java b/src/com/android/settings/wifi/qrcode/QrDecorateView.java
index 253bdb8..6952a63 100644
--- a/src/com/android/settings/wifi/qrcode/QrDecorateView.java
+++ b/src/com/android/settings/wifi/qrcode/QrDecorateView.java
@@ -17,10 +17,13 @@
package com.android.settings.wifi.qrcode;
import android.content.Context;
+import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.util.AttributeSet;
@@ -33,11 +36,26 @@
* Draws the lines at the corner of the inner frame.
*/
public class QrDecorateView extends View {
- private static final float CORNER_STROKE_WIDTH = 3f; // 3dp
- private static final float CORNER_LINE_LENGTH = 20f; // 20dp
+ private static final float CORNER_STROKE_WIDTH = 4f; // 4dp
+ private static final float CORNER_LINE_LENGTH = 264f; // 264dp
+ private static final float CORNER_RADIUS = 16f; // 16dp
- final private Paint mPaint;
- private RectF mFrame;
+ final private int mCornerColor;
+ final private int mFocusedCornerColor;
+ final private int mBackgroundColor;
+
+ final private Paint mStrokePaint;
+ final private Paint mTransparentPaint;
+ final private Paint mBackgroundPaint;
+
+ final private float mRadius;
+
+ private Bitmap mMaskBitmap;
+ private Canvas mMaskCanvas;
+
+ private RectF mOuterFrame;
+ private RectF mInnerFrame;
+
private boolean mFocused;
public QrDecorateView(Context context) {
@@ -54,78 +72,66 @@
public QrDecorateView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
- final float strokeWidth = TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP,
- CORNER_STROKE_WIDTH,
- getResources().getDisplayMetrics()
- );
- mPaint = new Paint();
- mPaint.setStrokeWidth(strokeWidth);
+
mFocused = false;
+ mRadius = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, CORNER_RADIUS,
+ getResources().getDisplayMetrics());
+
+ mCornerColor = context.getResources().getColor(R.color.qr_corner_line_color);
+ mFocusedCornerColor = context.getResources().getColor(R.color.qr_focused_corner_line_color);
+ mBackgroundColor = context.getResources().getColor(R.color.qr_background_color);
+
+ mStrokePaint = new Paint();
+ mStrokePaint.setAntiAlias(true);
+
+ mTransparentPaint = new Paint();
+ mTransparentPaint.setAntiAlias(true);
+ mTransparentPaint.setColor(getResources().getColor(android.R.color.transparent));
+ mTransparentPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
+
+ mBackgroundPaint = new Paint();
+ mBackgroundPaint.setColor(mBackgroundColor);
+ }
+
+ @Override
+ protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
+ super.onLayout(changed, left, top, right, bottom);
+
+ if(mMaskBitmap == null) {
+ mMaskBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
+ mMaskCanvas = new Canvas(mMaskBitmap);
+ }
+
+ calculateFramePos();
}
@Override
protected void onDraw(Canvas canvas) {
- calculateFramePos();
- final float cornerLineLength = TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP,
- CORNER_LINE_LENGTH,
- getResources().getDisplayMetrics()
- );
- mPaint.setColor(mFocused ? Color.GREEN : Color.WHITE);
- drawCorner(mFrame, cornerLineLength, canvas);
- super.onDraw(canvas);
- }
+ // Set frame line color.
+ mStrokePaint.setColor(mFocused ? mFocusedCornerColor : mCornerColor);
+ // Draw background color.
+ mMaskCanvas.drawColor(mBackgroundColor);
+ // Draw outer corner.
+ mMaskCanvas.drawRoundRect(mOuterFrame, mRadius, mRadius, mStrokePaint);
+ // Draw inner transparent corner.
+ mMaskCanvas.drawRoundRect(mInnerFrame, mRadius, mRadius, mTransparentPaint);
- private void drawCorner(RectF frame, float lineLength, Canvas canvas) {
- final float strokeWidth = TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP,
- CORNER_STROKE_WIDTH,
- getResources().getDisplayMetrics()
- );
- // Draw top-left corner.
- canvas.drawLine(
- frame.left - strokeWidth / 2,
- frame.top,
- frame.left + lineLength,
- frame.top,
- mPaint);
- canvas.drawLine(frame.left, frame.top, frame.left, frame.top + lineLength, mPaint);
- // Draw top-right corner.
- canvas.drawLine(
- frame.right + strokeWidth / 2,
- frame.top,
- frame.right - lineLength,
- frame.top,
- mPaint);
- canvas.drawLine(frame.right, frame.top, frame.right, frame.top + lineLength, mPaint);
- // Draw bottom-left corner.
- canvas.drawLine(
- frame.left - strokeWidth / 2,
- frame.bottom,
- frame.left + lineLength,
- frame.bottom,
- mPaint);
- canvas.drawLine(frame.left, frame.bottom, frame.left, frame.bottom - lineLength, mPaint);
- // Draw bottom-right corner.
- canvas.drawLine(
- frame.right + strokeWidth / 2,
- frame.bottom,
- frame.right - lineLength,
- frame.bottom,
- mPaint);
- canvas.drawLine(frame.right, frame.bottom, frame.right, frame.bottom - lineLength, mPaint);
+ canvas.drawBitmap(mMaskBitmap, 0, 0, mBackgroundPaint);
+ super.onDraw(canvas);
}
private void calculateFramePos() {
final int centralX = getWidth() / 2;
final int centralY = getHeight() / 2;
- final float halfFrameWidth = getWidth() / 3;
- mFrame = new RectF(
- centralX - halfFrameWidth,
- centralY - halfFrameWidth,
- centralX + halfFrameWidth,
- centralY + halfFrameWidth);
+ final float cornerLineLength = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+ CORNER_LINE_LENGTH, getResources().getDisplayMetrics()) / 2;
+ final float strokeWidth = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+ CORNER_STROKE_WIDTH, getResources().getDisplayMetrics()) / 2;
+
+ mOuterFrame = new RectF(centralX - cornerLineLength, centralY - cornerLineLength,
+ centralX + cornerLineLength, centralY + cornerLineLength);
+ mInnerFrame = new RectF(mOuterFrame.left + strokeWidth, mOuterFrame.top + strokeWidth,
+ mOuterFrame.right - strokeWidth, mOuterFrame.bottom - strokeWidth);
}
// Draws green lines if focued. Otherwise, draws white lines.
diff --git a/src/com/android/settings/wifi/slice/WifiSlice.java b/src/com/android/settings/wifi/slice/WifiSlice.java
index 4d3a95a..35bb89f 100644
--- a/src/com/android/settings/wifi/slice/WifiSlice.java
+++ b/src/com/android/settings/wifi/slice/WifiSlice.java
@@ -105,8 +105,8 @@
return listBuilder.build();
}
- final List<AccessPoint> results =
- SliceBackgroundWorker.getInstance(mContext, this).getResults();
+ final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
+ final List<AccessPoint> results = worker != null ? worker.getResults() : null;
// Need a loading text when results are not ready.
boolean needLoadingRow = results == null;
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
index fb2ce97..c0a3fa7 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSSIDPreferenceController.java
@@ -53,10 +53,8 @@
final WifiConfiguration config = mWifiManager.getWifiApConfiguration();
if (config != null) {
mSSID = config.SSID;
- Log.d(TAG, "Updating SSID in Preference, " + mSSID);
} else {
mSSID = DEFAULT_SSID;
- Log.d(TAG, "Updating to default SSID in Preference, " + mSSID);
}
((ValidatedEditTextPreference) mPreference).setValidator(this);
updateSsidDisplay((EditTextPreference) mPreference);
diff --git a/src/com/android/settings/wifi/tether/WifiTetherSettings.java b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
index c98fbdb..5f23f0c 100644
--- a/src/com/android/settings/wifi/tether/WifiTetherSettings.java
+++ b/src/com/android/settings/wifi/tether/WifiTetherSettings.java
@@ -178,6 +178,8 @@
controllers.add(new WifiTetherSecurityPreferenceController(context, listener));
controllers.add(new WifiTetherPasswordPreferenceController(context, listener));
controllers.add(new WifiTetherApBandPreferenceController(context, listener));
+ controllers.add(
+ new WifiTetherAutoOffPreferenceController(context, KEY_WIFI_TETHER_AUTO_OFF));
return controllers;
}
diff --git a/tests/robotests/Android.mk b/tests/robotests/Android.mk
index 01218cb..50133d9 100644
--- a/tests/robotests/Android.mk
+++ b/tests/robotests/Android.mk
@@ -25,6 +25,7 @@
$(SETTINGS_AOSP_PATH)/res
LOCAL_STATIC_ANDROID_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout \
androidx.slice_slice-builders \
androidx.slice_slice-core \
androidx.slice_slice-view \
@@ -42,6 +43,7 @@
ims-common
LOCAL_STATIC_JAVA_LIBRARIES := \
+ androidx-constraintlayout_constraintlayout-solver \
androidx.lifecycle_lifecycle-runtime \
androidx.lifecycle_lifecycle-extensions \
guava \
diff --git a/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml b/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
index 83eb781..595cfb4 100644
--- a/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
+++ b/tests/robotests/res/layout-mcc999/fingerprint_enroll_find_sensor.xml
@@ -46,7 +46,7 @@
</FrameLayout>
<LinearLayout
- style="@style/SuwContentFrame"
+ style="@style/SudContentFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
@@ -54,10 +54,10 @@
android:clipChildren="false">
<TextView
- style="@style/SuwDescription.Glif"
+ style="@style/SudDescription.Glif"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginTop="@dimen/suw_description_glif_margin_top"
+ android:layout_marginTop="@dimen/sud_description_glif_margin_top"
android:text="@string/security_settings_fingerprint_enroll_find_sensor_message"/>
<View
@@ -66,7 +66,7 @@
android:layout_weight="1"/>
<Button
- style="@style/SuwGlifButton.Secondary"
+ style="@style/SudGlifButton.Secondary"
android:id="@+id/next_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/tests/robotests/res/layout/preference.xml b/tests/robotests/res/layout/preference.xml
index 3f73161..7ac733f 100644
--- a/tests/robotests/res/layout/preference.xml
+++ b/tests/robotests/res/layout/preference.xml
@@ -30,7 +30,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
- android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
android:textColor="?android:attr/textColorPrimary"
android:ellipsize="marquee"
android:fadingEdge="horizontal" />
@@ -43,7 +43,7 @@
android:layout_alignStart="@android:id/title"
android:visibility="gone"
android:textAlignment="viewStart"
- android:textAppearance="@android:style/TextAppearance.Material.Body1"
+ android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Body1"
android:textColor="?android:attr/textColorSecondary"
android:maxLines="10" />
diff --git a/tests/robotests/res/values-mcc999/config.xml b/tests/robotests/res/values-mcc999/config.xml
index 101a6b8..59028d3 100644
--- a/tests/robotests/res/values-mcc999/config.xml
+++ b/tests/robotests/res/values-mcc999/config.xml
@@ -88,4 +88,7 @@
<!-- Email address for the homepage contextual cards feedback -->
<string name="config_contextual_card_feedback_email" translatable="false">test@test.test</string>
+
+ <!-- Max allowed value for screen timeout, in milliseconds -->
+ <integer name="max_lock_after_timeout_ms">1700000</integer>
</resources>
diff --git a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
index 7b4fb6f..6a2348c 100644
--- a/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
+++ b/tests/robotests/src/com/android/settings/accounts/AvatarViewMixinTest.java
@@ -30,6 +30,7 @@
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.ProviderInfo;
@@ -167,12 +168,22 @@
assertThat(bundle.getString("account_name")).isEqualTo(DUMMY_ACCOUNT);
}
+ @Test
+ public void onClickAvatar_withEmptyUri_startActivityShouldNotBeExecuted() {
+ final SettingsHomepageActivity activity = spy((SettingsHomepageActivity) mController.get());
+ final AvatarViewMixin avatarViewMixin = new AvatarViewMixin(activity, mImageView);
+
+ mImageView.performClick();
+
+ verify(activity, never()).startActivity(any(Intent.class));
+ }
+
@Implements(value = AccountFeatureProviderImpl.class)
public static class ShadowAccountFeatureProviderImpl {
@Implementation
protected Account[] getAccounts(Context context) {
- return new Account[] {new Account(DUMMY_ACCOUNT, DUMMY_DOMAIN)};
+ return new Account[]{new Account(DUMMY_ACCOUNT, DUMMY_DOMAIN)};
}
}
}
diff --git a/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java
index 5bf2b7e..92468a0 100644
--- a/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/applications/defaultapps/RolesPreferenceControllerTest.java
@@ -19,13 +19,17 @@
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.app.role.RoleManager;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.provider.Settings;
@@ -41,32 +45,59 @@
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
+import java.util.Collections;
+
@RunWith(RobolectricTestRunner.class)
public class RolesPreferenceControllerTest {
private static final String PREFERENCE_KEY = "roles";
private static final String DIFFERENT_PREFERENCE_KEY = "different";
+
private static final String PERMISSION_CONTROLLER_PACKAGE_NAME =
"com.android.permissioncontroller";
+ private static final String BROWSER_PACKAGE_NAME = "com.example.browser1";
+ private static final String DIALER_PACKAGE_NAME = "com.example.dialer1";
+ private static final String SMS_PACKAGE_NAME = "com.example.sms1";
+
@Mock
private Context mContext;
@Mock
private PackageManager mPackageManager;
+ @Mock
+ private RoleManager mRoleManager;
+ @Mock
+ private ApplicationInfo mBrowserApplicationInfo;
+ @Mock
+ private ApplicationInfo mDialerApplicationInfo;
+ @Mock
+ private ApplicationInfo mSmsApplicationInfo;
@Before
- public void setUp() {
+ public void setUp() throws PackageManager.NameNotFoundException {
MockitoAnnotations.initMocks(this);
+
when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mContext.getSystemService(RoleManager.class)).thenReturn(mRoleManager);
+
+ when(mBrowserApplicationInfo.loadLabel(mPackageManager)).thenReturn("Browser1");
+ when(mPackageManager.getApplicationInfo(eq(BROWSER_PACKAGE_NAME), anyInt())).thenReturn(
+ mBrowserApplicationInfo);
+ when(mDialerApplicationInfo.loadLabel(mPackageManager)).thenReturn("Phone1");
+ when(mPackageManager.getApplicationInfo(eq(DIALER_PACKAGE_NAME), anyInt())).thenReturn(
+ mDialerApplicationInfo);
+ when(mSmsApplicationInfo.loadLabel(mPackageManager)).thenReturn("Sms1");
+ when(mPackageManager.getApplicationInfo(eq(SMS_PACKAGE_NAME), anyInt())).thenReturn(
+ mSmsApplicationInfo);
}
@Test
public void getAvailabilityStatus_noPermissionController_shouldReturnUnsupportedOnDevice() {
when(mPackageManager.getPermissionControllerPackageName()).thenReturn(null);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
- assertThat(controller.getAvailabilityStatus())
+ assertThat(preferenceController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.UNSUPPORTED_ON_DEVICE);
}
@@ -74,10 +105,10 @@
public void getAvailabilityStatus_hasPermissionController_shouldReturnAvailableUnsearchable() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
- assertThat(controller.getAvailabilityStatus())
+ assertThat(preferenceController.getAvailabilityStatus())
.isEqualTo(BasePreferenceController.AVAILABLE_UNSEARCHABLE);
}
@@ -85,34 +116,34 @@
public void handlePreferenceTreeClick_differentKey_shouldReturnFalse() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(DIFFERENT_PREFERENCE_KEY);
- assertThat(controller.handlePreferenceTreeClick(preference)).isFalse();
+ assertThat(preferenceController.handlePreferenceTreeClick(preference)).isFalse();
}
@Test
public void handlePreferenceTreeClick_sameKey_shouldReturnTrue() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(PREFERENCE_KEY);
- assertThat(controller.handlePreferenceTreeClick(preference)).isTrue();
+ assertThat(preferenceController.handlePreferenceTreeClick(preference)).isTrue();
}
@Test
public void handlePreferenceTreeClick_noPermissionController_shouldNotStartActivity() {
when(mPackageManager.getPermissionControllerPackageName()).thenReturn(null);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(PREFERENCE_KEY);
- controller.handlePreferenceTreeClick(preference);
+ preferenceController.handlePreferenceTreeClick(preference);
verify(mContext, never()).startActivity(any(Intent.class));
}
@@ -121,11 +152,11 @@
public void handlePreferenceTreeClick_hasPermissionController_shouldStartActivityWithIntent() {
when(mPackageManager.getPermissionControllerPackageName())
.thenReturn(PERMISSION_CONTROLLER_PACKAGE_NAME);
- RolesPreferenceController controller = new RolesPreferenceController(mContext,
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
PREFERENCE_KEY);
Preference preference = mock(Preference.class);
when(preference.getKey()).thenReturn(PREFERENCE_KEY);
- controller.handlePreferenceTreeClick(preference);
+ preferenceController.handlePreferenceTreeClick(preference);
ArgumentCaptor<Intent> intent = ArgumentCaptor.forClass(Intent.class);
verify(mContext).startActivity(intent.capture());
@@ -133,4 +164,112 @@
.isEqualTo(Settings.ACTION_MANAGE_DEFAULT_APPS_SETTINGS);
assertThat(intent.getValue().getPackage()).isEqualTo(PERMISSION_CONTROLLER_PACKAGE_NAME);
}
+
+ @Test
+ public void getSummary_allAvailable_shouldReturnAll() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1, Phone1, and Sms1");
+ }
+
+ @Test
+ public void getSummary_browserAndDialerAvailable_shouldReturnBrowserAndDialer() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1 and Phone1");
+ }
+
+ @Test
+ public void getSummary_browserAndSmsAvailable_shouldReturnBrowserAndSms() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1 and Sms1");
+ }
+
+ @Test
+ public void getSummary_dialerAndSmsAvailable_shouldReturnDialerAndSms() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Phone1 and Sms1");
+ }
+
+ @Test
+ public void getSummary_browserAvailable_shouldReturnBrowser() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.singletonList(BROWSER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Browser1");
+ }
+
+ @Test
+ public void getSummary_dialerAvailable_shouldReturnDialer() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.singletonList(DIALER_PACKAGE_NAME));
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Phone1");
+ }
+
+ @Test
+ public void getSummary_smsAvailable_shouldReturnSms() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(
+ Collections.singletonList(SMS_PACKAGE_NAME));
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isEqualTo("Sms1");
+ }
+
+ @Test
+ public void getSummary_noneAvailable_shouldReturnNull() {
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_BROWSER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_DIALER)).thenReturn(
+ Collections.emptyList());
+ when(mRoleManager.getRoleHolders(RoleManager.ROLE_SMS)).thenReturn(Collections.emptyList());
+ RolesPreferenceController preferenceController = new RolesPreferenceController(mContext,
+ PREFERENCE_KEY);
+
+ assertThat(preferenceController.getSummary()).isNull();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
index 4deec56..4504d84 100644
--- a/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
+++ b/tests/robotests/src/com/android/settings/bluetooth/BluetoothSliceBuilderTest.java
@@ -25,14 +25,12 @@
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import org.junit.Before;
import org.junit.Test;
@@ -60,7 +58,10 @@
@Test
public void getBluetoothSlice_correctSliceContent() {
final Slice BluetoothSlice = BluetoothSliceBuilder.getSlice(mContext);
+
final SliceMetadata metadata = SliceMetadata.from(mContext, BluetoothSlice);
+ assertThat(metadata.getTitle()).isEqualTo(
+ mContext.getString(R.string.bluetooth_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
@@ -69,9 +70,6 @@
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_bluetooth);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
-
- final List<SliceItem> sliceItems = BluetoothSlice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.bluetooth_settings_title));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceControllerTest.java
deleted file mode 100644
index e92f1a5..0000000
--- a/tests/robotests/src/com/android/settings/development/UpdatedGfxDriverDevOptInPreferenceControllerTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 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.development;
-
-import static com.android.settings.development.DevelopmentOptionsActivityRequestCodes.REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP;
-import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.Activity;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-
-import androidx.preference.Preference;
-import androidx.preference.PreferenceScreen;
-
-import com.android.settings.R;
-
-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 UpdatedGfxDriverDevOptInPreferenceControllerTest {
-
- @Mock
- private PreferenceScreen mPreferenceScreen;
- @Mock
- private DevelopmentSettingsDashboardFragment mFragment;
-
- private Context mContext;
- private Preference mPreference;
- private UpdatedGfxDriverDevOptInPreferenceController mController;
-
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- mContext = RuntimeEnvironment.application;
- mController = spy(new UpdatedGfxDriverDevOptInPreferenceController(mContext, mFragment));
- mPreference = new Preference(mContext);
- mPreference.setKey(mController.getPreferenceKey());
-
- when(mPreferenceScreen.findPreference(mController.getPreferenceKey()))
- .thenReturn(mPreference);
- mController.displayPreference(mPreferenceScreen);
- }
-
- @Test
- public void handlePreferenceTreeClick_preferenceClicked_launchActivity() {
- final Intent activityStartIntent = new Intent(mContext, AppPicker.class);
- doReturn(activityStartIntent).when(mController).getActivityStartIntent();
- mController.handlePreferenceTreeClick(mPreference);
-
- verify(mFragment).startActivityForResult(activityStartIntent,
- REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP);
- }
-
- @Test
- public void updateState_foobarAppSelected_shouldUpdateSummaryWithUpdatedDriverDevOptInAppLabel() {
- final String selectedApp = "foobar";
- final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putString(contentResolver,
- Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, selectedApp);
- mController.updateState(mPreference);
-
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_set, selectedApp));
- }
-
- @Test
- public void updateState_noAppSelected_shouldUpdateSummaryWithNoAppSelected() {
- final String selectedApp = null;
- final ContentResolver contentResolver = mContext.getContentResolver();
- Settings.Global.putString(contentResolver,
- Settings.Global.UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, selectedApp);
- mController.updateState(mPreference);
-
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
-
- @Test
- public void onActivityResult_foobarAppSelected_shouldUpdateSummaryWithUpdatedDriverDevOptInLabel() {
- Intent activityResultIntent = new Intent(mContext, AppPicker.class);
- final String appLabel = "foobar";
- activityResultIntent.setAction(appLabel);
- final boolean result = mController
- .onActivityResult(REQUEST_CODE_UPDATED_GFX_DRIVER_DEV_OPT_IN_APP, Activity.RESULT_OK,
- activityResultIntent);
-
- assertThat(result).isTrue();
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_set, appLabel));
- }
-
- @Test
- public void onActivityResult_badRequestCode_shouldReturnFalse() {
- assertThat(mController.onActivityResult(
- -1 /* requestCode */, -1 /* resultCode */, null /* intent */)).isFalse();
- }
-
- @Test
- public void onDeveloperOptionsSwitchDisabled_shouldDisablePreference() {
- mController.onDeveloperOptionsSwitchDisabled();
-
- assertThat(mPreference.isEnabled()).isFalse();
- assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.updated_gfx_driver_dev_opt_in_app_not_set));
- }
-}
diff --git a/tests/robotests/src/com/android/settings/development/gup/GupDashboardTest.java b/tests/robotests/src/com/android/settings/development/gup/GupDashboardTest.java
new file mode 100644
index 0000000..17278ef
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/gup/GupDashboardTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 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.development.gup;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import com.android.internal.logging.nano.MetricsProto;
+import com.android.settings.R;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class GupDashboardTest {
+ private GupDashboard mDashboard;
+
+ @Before
+ public void setUp() {
+ mDashboard = new GupDashboard();
+ }
+
+ @Test
+ public void getHelpResource_shouldReturn0() {
+ assertThat(mDashboard.getHelpResource()).isEqualTo(0);
+ }
+
+ @Test
+ public void getMetricesCategory_shouldReturnGupDashboard() {
+ assertThat(mDashboard.getMetricsCategory())
+ .isEqualTo(MetricsProto.MetricsEvent.SETTINGS_GUP_DASHBOARD);
+ }
+
+ @Test
+ public void getPreferenceScreen_shouldReturnGupSettings() {
+ assertThat(mDashboard.getPreferenceScreenResId())
+ .isEqualTo(R.xml.gup_settings);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/development/gup/GupPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/development/gup/GupPreferenceControllerTest.java
new file mode 100644
index 0000000..62e3475
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/development/gup/GupPreferenceControllerTest.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright 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.development.gup;
+
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+import static com.android.settings.core.BasePreferenceController.DISABLED_DEPENDENT_SETTING;
+import static com.android.settings.testutils.ApplicationTestUtils.buildInfo;
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
+
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.provider.Settings;
+
+import androidx.preference.ListPreference;
+import androidx.preference.PreferenceCategory;
+import androidx.preference.PreferenceGroup;
+import androidx.preference.PreferenceManager;
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+
+import java.util.Arrays;
+
+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 GupPreferenceControllerTest {
+ private static final int DEFAULT = 0;
+ private static final int GUP = 1;
+ private static final int NATIVE = 2;
+ private static final String TEST_APP_NAME = "testApp";
+ private static final String TEST_PKG_NAME = "testPkg";
+
+ // Pre-installed Apps in the Mock PackageManager
+ private static final String APP_1 = "app1";
+ private static final String APP_2 = "app2";
+ private static final String APP_3 = "app3";
+
+ @Mock
+ private PackageManager mPackageManager;
+ @Mock
+ private PreferenceScreen mScreen;
+
+ private Context mContext;
+ private PreferenceGroup mGroup;
+ private PreferenceManager mPreferenceManager;
+ private ContentResolver mResolver;
+ private GupPreferenceController mController;
+ private CharSequence[] mValueList;
+ private String mDialogTitle;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mResolver = mContext.getContentResolver();
+ mValueList = mContext.getResources().getStringArray(R.array.gup_app_preference_values);
+ mDialogTitle = mContext.getResources().getString(R.string.gup_app_preference_title);
+ }
+
+ @Test
+ public void getAvailability_developmentSettingsEnabled_available() {
+ loadDefaultConfig();
+ Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 1);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
+ }
+
+ @Test
+ public void getAvailability_developmentSettingsDisabled_disabledDependentSetting() {
+ loadDefaultConfig();
+ Settings.Global.putInt(mResolver, Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(DISABLED_DEPENDENT_SETTING);
+ }
+
+ @Test
+ public void displayPreference_shouldAddTwoPreferencesAndSortAscendingly() {
+ mockPackageManager();
+ loadDefaultConfig();
+
+ // Only non-system app has preference
+ assertThat(mGroup.getPreferenceCount()).isEqualTo(2);
+ assertThat(mGroup.getPreference(0).getKey()).isEqualTo(APP_1);
+ assertThat(mGroup.getPreference(1).getKey()).isEqualTo(APP_3);
+ }
+
+ @Test
+ public void createPreference_configDefault_shouldSetDefaultAttributes() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+
+ assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
+ assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
+ assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
+ assertThat(preference.getEntries()).isEqualTo(mValueList);
+ assertThat(preference.getEntryValues()).isEqualTo(mValueList);
+ assertThat(preference.getEntry()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
+ }
+
+ @Test
+ public void createPreference_configGup_shouldSetGupAttributes() {
+ loadConfig(TEST_PKG_NAME, "");
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+
+ assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
+ assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
+ assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
+ assertThat(preference.getEntries()).isEqualTo(mValueList);
+ assertThat(preference.getEntryValues()).isEqualTo(mValueList);
+ assertThat(preference.getEntry()).isEqualTo(mValueList[GUP]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[GUP]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
+ }
+
+ @Test
+ public void createPreference_configNative_shouldSetNativeAttributes() {
+ loadConfig("", TEST_PKG_NAME);
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+
+ assertThat(preference.getKey()).isEqualTo(TEST_PKG_NAME);
+ assertThat(preference.getTitle()).isEqualTo(TEST_APP_NAME);
+ assertThat(preference.getDialogTitle()).isEqualTo(mDialogTitle);
+ assertThat(preference.getEntries()).isEqualTo(mValueList);
+ assertThat(preference.getEntryValues()).isEqualTo(mValueList);
+ assertThat(preference.getEntry()).isEqualTo(mValueList[NATIVE]);
+ assertThat(preference.getValue()).isEqualTo(mValueList[NATIVE]);
+ assertThat(preference.getSummary()).isEqualTo(mValueList[NATIVE]);
+ }
+
+ @Test
+ public void onPreferenceChange_selectDefault_shouldUpdateAttributesAndSettingsGlobal() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+ mController.onPreferenceChange(preference, mValueList[DEFAULT]);
+
+ assertThat(preference.getSummary()).isEqualTo(mValueList[DEFAULT]);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
+ .isEqualTo("");
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
+ .isEqualTo("");
+ }
+
+ @Test
+ public void onPreferenceChange_selectGup_shouldUpdateAttributesAndSettingsGlobal() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+ mController.onPreferenceChange(preference, mValueList[GUP]);
+
+ assertThat(preference.getSummary()).isEqualTo(mValueList[GUP]);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
+ .isEqualTo(TEST_PKG_NAME);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
+ .isEqualTo("");
+ }
+
+ @Test
+ public void onPreferenceChange_selectNative_shouldUpdateAttributesAndSettingsGlobal() {
+ loadDefaultConfig();
+ final ListPreference preference =
+ mController.createListPreference(TEST_PKG_NAME, TEST_APP_NAME);
+ mController.onPreferenceChange(preference, mValueList[NATIVE]);
+
+ assertThat(preference.getSummary()).isEqualTo(mValueList[NATIVE]);
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS))
+ .isEqualTo("");
+ assertThat(Settings.Global.getString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS))
+ .isEqualTo(TEST_PKG_NAME);
+ }
+
+ private void mockPackageManager() {
+ final int uid = mContext.getUserId();
+ final ApplicationInfo app1 = buildInfo(uid, APP_1, 0 /* flags */, 0 /* targetSdkVersion */);
+ final ApplicationInfo app2 =
+ buildInfo(uid, APP_2, ApplicationInfo.FLAG_SYSTEM, 0 /* targetSdkVersion */);
+ final ApplicationInfo app3 = buildInfo(uid, APP_3, 0 /* flags */, 0 /* targetSdkVersion */);
+
+ when(mPackageManager.getInstalledApplications(0 /* flags */))
+ .thenReturn(Arrays.asList(app3, app2, app1));
+ when(mPackageManager.getApplicationLabel(app1)).thenReturn(APP_1);
+ when(mPackageManager.getApplicationLabel(app2)).thenReturn(APP_2);
+ when(mPackageManager.getApplicationLabel(app3)).thenReturn(APP_3);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ }
+
+ private void loadDefaultConfig() { loadConfig("", ""); }
+
+ private void loadConfig(String optIn, String optOut) {
+ Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_IN_APPS, optIn);
+ Settings.Global.putString(mResolver, Settings.Global.GUP_DEV_OPT_OUT_APPS, optOut);
+
+ mController = new GupPreferenceController(mContext, "testKey");
+ mGroup = spy(new PreferenceCategory(mContext));
+ final PreferenceManager preferenceManager = new PreferenceManager(mContext);
+ when(mGroup.getPreferenceManager()).thenReturn(preferenceManager);
+ when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mGroup);
+ mController.displayPreference(mScreen);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
index fc674f0b..0c74525 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/firmwareversion/FirmwareVersionPreferenceControllerTest.java
@@ -16,8 +16,11 @@
package com.android.settings.deviceinfo.firmwareversion;
+import static android.content.Context.CLIPBOARD_SERVICE;
+
import static com.google.common.truth.Truth.assertThat;
+import android.content.ClipboardManager;
import android.content.Context;
import android.os.Build;
@@ -108,6 +111,17 @@
assertThat(mController.isSliceable()).isTrue();
}
+ @Test
+ public void copy_shouldCopyVersionNumberToClipboard() {
+ mController.copy();
+
+ final Context context = RuntimeEnvironment.application;
+ final ClipboardManager clipboard = (ClipboardManager) context.getSystemService(
+ CLIPBOARD_SERVICE);
+ final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
+ assertThat(data.toString()).isEqualTo(Build.VERSION.RELEASE);
+ }
+
@Implements(FirmwareVersionDialogFragment.class)
public static class ShadowFirmwareVersionDialogFragment {
diff --git a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
index e56baa1..69bc494 100644
--- a/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/deviceinfo/imei/ImeiInfoPreferenceControllerTest.java
@@ -16,9 +16,14 @@
package com.android.settings.deviceinfo.imei;
+import static android.content.Context.CLIPBOARD_SERVICE;
import static android.telephony.TelephonyManager.PHONE_TYPE_CDMA;
import static android.telephony.TelephonyManager.PHONE_TYPE_GSM;
+import static com.android.settings.core.BasePreferenceController.AVAILABLE;
+
+import static com.google.common.truth.Truth.assertThat;
+
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
@@ -26,6 +31,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+import android.content.ClipboardManager;
import android.content.Context;
import android.os.UserManager;
import android.telephony.TelephonyManager;
@@ -71,8 +77,9 @@
MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
doReturn(mUserManager).when(mContext).getSystemService(UserManager.class);
- mController = spy(new ImeiInfoPreferenceController(mContext, mFragment));
- doReturn(true).when(mController).isAvailable();
+ mController = spy(new ImeiInfoPreferenceController(mContext, "imei_info"));
+ mController.setHost(mFragment);
+ doReturn(AVAILABLE).when(mController).getAvailabilityStatus();
when(mScreen.getContext()).thenReturn(mContext);
doReturn(mSecondSimPreference).when(mController).createNewPreference(mContext);
ReflectionHelpers.setField(mController, "mTelephonyManager", mTelephonyManager);
@@ -156,7 +163,7 @@
@Test
public void handlePreferenceTreeClick_shouldStartDialogFragment() {
when(mFragment.getChildFragmentManager())
- .thenReturn(mock(FragmentManager.class, Answers.RETURNS_DEEP_STUBS));
+ .thenReturn(mock(FragmentManager.class, Answers.RETURNS_DEEP_STUBS));
when(mPreference.getTitle()).thenReturn("SomeTitle");
mController.displayPreference(mScreen);
@@ -164,4 +171,19 @@
verify(mFragment).getChildFragmentManager();
}
+
+ @Test
+ public void copy_shouldCopyImeiToClipboard() {
+ ReflectionHelpers.setField(mController, "mIsMultiSim", false);
+ final String meid = "125132215123";
+ when(mTelephonyManager.getPhoneType()).thenReturn(PHONE_TYPE_CDMA);
+ when(mTelephonyManager.getMeid()).thenReturn(meid);
+
+ mController.copy();
+
+ final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
+ CLIPBOARD_SERVICE);
+ final CharSequence data = clipboard.getPrimaryClip().getItemAt(0).getText();
+ assertThat(data.toString()).isEqualTo(meid);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/display/DisplayWhiteBalancePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/display/DisplayWhiteBalancePreferenceControllerTest.java
new file mode 100644
index 0000000..0ce72fb
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/display/DisplayWhiteBalancePreferenceControllerTest.java
@@ -0,0 +1,78 @@
+package com.android.settings.display;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.provider.Settings;
+import android.provider.Settings.Secure;
+import com.android.settings.testutils.shadow.SettingsShadowResources;
+import org.junit.After;
+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 = {
+ SettingsShadowResources.class
+})
+public class DisplayWhiteBalancePreferenceControllerTest {
+
+ private Context mContext;
+ private DisplayWhiteBalancePreferenceController mController;
+
+ @After
+ public void tearDown() {
+ SettingsShadowResources.reset();
+ }
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mController = new DisplayWhiteBalancePreferenceController(mContext, "display_white_balance");
+ }
+
+ @Test
+ public void isAvailable_configuredAvailable() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.bool.config_displayWhiteBalanceAvailable, true);
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void isAvailable_configuredUnavailable() {
+ SettingsShadowResources.overrideResource(
+ com.android.internal.R.bool.config_displayWhiteBalanceAvailable, false);
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void setChecked_true() {
+ mController.setChecked(true);
+ assertThat(Settings.Secure
+ .getInt(mContext.getContentResolver(), Secure.DISPLAY_WHITE_BALANCE_ENABLED, 0) == 1)
+ .isTrue();
+ }
+
+ @Test
+ public void setChecked_false() {
+ mController.setChecked(false);
+ assertThat(Settings.Secure
+ .getInt(mContext.getContentResolver(), Secure.DISPLAY_WHITE_BALANCE_ENABLED, 0) == 1)
+ .isFalse();
+ }
+
+ @Test
+ public void isChecked_true() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Secure.DISPLAY_WHITE_BALANCE_ENABLED, 1);
+ assertThat(mController.isChecked()).isTrue();
+ }
+
+ @Test
+ public void isChecked_false() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Secure.DISPLAY_WHITE_BALANCE_ENABLED, 0);
+ assertThat(mController.isChecked()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java b/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java
index 55fcdac..7b67f0f 100644
--- a/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/display/TimeoutListPreferenceTest.java
@@ -17,11 +17,11 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.Mockito.mock;
import static org.robolectric.RuntimeEnvironment.application;
import android.util.AttributeSet;
+import com.android.settings.R;
import com.android.settings.testutils.shadow.ShadowUserManager;
import com.android.settingslib.RestrictedLockUtils;
@@ -69,4 +69,23 @@
// should set to largest allowed value, which is 5 minute
assertThat(mPreference.getValue()).isEqualTo("300000");
}
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void newInstance_hasLowTimeoutConfig_shouldRemoveLongTimeouts() {
+ final AttributeSet attributeSet = Robolectric.buildAttributeSet().build();
+ final TimeoutListPreference pref = new TimeoutListPreference(application, attributeSet);
+ final long maxTimeout = application.getResources().getInteger(
+ R.integer.max_lock_after_timeout_ms);
+ pref.setEntries(R.array.screen_timeout_entries);
+ pref.setEntryValues(R.array.screen_timeout_values);
+
+ pref.updateInitialValues();
+
+ final CharSequence[] values = pref.getEntryValues();
+ for (CharSequence value : values) {
+ long timeout = Long.parseLong(value.toString());
+ assertThat(timeout).isAtMost(maxTimeout);
+ }
+ }
}
diff --git a/tests/robotests/src/com/android/settings/flashlight/FlashlightSliceTest.java b/tests/robotests/src/com/android/settings/flashlight/FlashlightSliceTest.java
index fe7a685..224d2ee 100644
--- a/tests/robotests/src/com/android/settings/flashlight/FlashlightSliceTest.java
+++ b/tests/robotests/src/com/android/settings/flashlight/FlashlightSliceTest.java
@@ -23,14 +23,12 @@
import android.provider.Settings;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import org.junit.Before;
import org.junit.Test;
@@ -57,13 +55,13 @@
public void getFlashlightSlice_correctData() {
Settings.Secure.putInt(
mContext.getContentResolver(), Settings.Secure.FLASHLIGHT_AVAILABLE, 1);
+
final Slice slice = new FlashlightSlice(mContext).getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.power_flashlight));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.power_flashlight));
}
}
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
index b22821b..5be7274 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryHeaderPreferenceControllerTest.java
@@ -140,8 +140,9 @@
assertThat(((BatteryMeterView) mBatteryLayoutPref.findViewById(
R.id.battery_header_icon)).getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
- assertThat(((TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent)).getText())
- .isEqualTo("60%");
+ assertThat(((TextView) mBatteryLayoutPref.findViewById(R.id.battery_percent))
+ .getText().toString())
+ .isEqualTo("60 %");
}
@Test
@@ -195,7 +196,7 @@
assertThat(mBatteryMeterView.getBatteryLevel()).isEqualTo(BATTERY_LEVEL);
assertThat(mBatteryMeterView.getCharging()).isTrue();
- assertThat(mBatteryPercentText.getText()).isEqualTo("60%");
+ assertThat(mBatteryPercentText.getText().toString()).isEqualTo("60 %");
assertThat(mSummary.getText()).isEqualTo(BATTERY_STATUS);
assertThat(mSummary2.getText()).isEqualTo(BATTERY_STATUS);
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java
index 84fef5d..956d8bf 100644
--- a/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingGesturePreferenceControllerTest.java
@@ -18,44 +18,47 @@
import static com.google.common.truth.Truth.assertThat;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import android.content.Context;
import android.content.res.Resources;
-import android.preference.PreferenceCategory;
import android.provider.Settings;
-import androidx.preference.PreferenceScreen;
+import androidx.preference.Preference;
+import androidx.preference.PreferenceCategory;
import com.android.settings.widget.RadioButtonPreference;
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 PreventRingingGesturePreferenceControllerTest {
-
private Context mContext;
private Resources mResources;
private PreventRingingGesturePreferenceController mController;
+ @Mock
+ private Preference mPreference;
+
@Before
public void setUp() {
+ MockitoAnnotations.initMocks(this);
mContext = spy(RuntimeEnvironment.application);
mResources = mock(Resources.class);
when(mContext.getResources()).thenReturn(mResources);
when(mResources.getBoolean(com.android.internal.R.bool.config_volumeHushGestureEnabled))
.thenReturn(true);
mController = new PreventRingingGesturePreferenceController(mContext, null);
+ mController.mPreferenceCategory = new PreferenceCategory(mContext);
mController.mVibratePref = new RadioButtonPreference(mContext);
- mController.mNonePref = new RadioButtonPreference(mContext);
mController.mMutePref = new RadioButtonPreference(mContext);
}
@@ -79,9 +82,10 @@
public void testUpdateState_mute() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
Settings.Secure.VOLUME_HUSH_MUTE);
- mController.updateState(null);
+ mController.updateState(mPreference);
+ assertThat(mController.mVibratePref.isEnabled()).isTrue();
+ assertThat(mController.mMutePref.isEnabled()).isTrue();
assertThat(mController.mVibratePref.isChecked()).isFalse();
- assertThat(mController.mNonePref.isChecked()).isFalse();
assertThat(mController.mMutePref.isChecked()).isTrue();
}
@@ -89,9 +93,21 @@
public void testUpdateState_vibrate() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
Settings.Secure.VOLUME_HUSH_VIBRATE);
- mController.updateState(null);
+ mController.updateState(mPreference);
+ assertThat(mController.mVibratePref.isEnabled()).isTrue();
+ assertThat(mController.mMutePref.isEnabled()).isTrue();
assertThat(mController.mVibratePref.isChecked()).isTrue();
- assertThat(mController.mNonePref.isChecked()).isFalse();
+ assertThat(mController.mMutePref.isChecked()).isFalse();
+ }
+
+ @Test
+ public void testUpdateState_off() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_OFF);
+ mController.updateState(mPreference);
+ assertThat(mController.mVibratePref.isEnabled()).isFalse();
+ assertThat(mController.mMutePref.isEnabled()).isFalse();
+ assertThat(mController.mVibratePref.isChecked()).isFalse();
assertThat(mController.mMutePref.isChecked()).isFalse();
}
@@ -99,9 +115,8 @@
public void testUpdateState_other() {
Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
7);
- mController.updateState(null);
+ mController.updateState(mPreference);
assertThat(mController.mVibratePref.isChecked()).isFalse();
- assertThat(mController.mNonePref.isChecked()).isTrue();
assertThat(mController.mMutePref.isChecked()).isFalse();
}
@@ -132,19 +147,4 @@
Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_OFF));
}
-
- @Test
- public void testRadioButtonClicked_off() {
- RadioButtonPreference rbPref = new RadioButtonPreference(mContext);
- rbPref.setKey(PreventRingingGesturePreferenceController.KEY_NONE);
-
- Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
- Settings.Secure.VOLUME_HUSH_MUTE);
-
- mController.onRadioButtonClicked(rbPref);
-
- assertThat(Settings.Secure.VOLUME_HUSH_OFF).isEqualTo(
- Settings.Secure.getInt(mContext.getContentResolver(),
- Settings.Secure.VOLUME_HUSH_GESTURE, Settings.Secure.VOLUME_HUSH_VIBRATE));
- }
}
diff --git a/tests/robotests/src/com/android/settings/gestures/PreventRingingSwitchPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/PreventRingingSwitchPreferenceControllerTest.java
new file mode 100644
index 0000000..5f221f5
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/gestures/PreventRingingSwitchPreferenceControllerTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.gestures;
+
+import static com.google.common.truth.Truth.assertThat;
+
+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.content.res.Resources;
+import android.provider.Settings;
+
+import androidx.preference.Preference;
+
+import com.android.settings.widget.SwitchBar;
+
+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 PreventRingingSwitchPreferenceControllerTest {
+ private Context mContext;
+ private Resources mResources;
+ private PreventRingingSwitchPreferenceController mController;
+ private Preference mPreference = mock(Preference.class);
+
+ @Before
+ public void setUp() {
+ mContext = spy(RuntimeEnvironment.application);
+ mResources = mock(Resources.class);
+ when(mContext.getResources()).thenReturn(mResources);
+ when(mResources.getBoolean(com.android.internal.R.bool.config_volumeHushGestureEnabled))
+ .thenReturn(true);
+ mController = new PreventRingingSwitchPreferenceController(mContext);
+ mController.mSwitch = mock(SwitchBar.class);
+ }
+
+ @Test
+ public void testIsAvailable_configIsTrue_shouldReturnTrue() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled)).thenReturn(true);
+
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void testIsAvailable_configIsFalse_shouldReturnFalse() {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_volumeHushGestureEnabled)).thenReturn(false);
+
+ assertThat(mController.isAvailable()).isFalse();
+ }
+
+ @Test
+ public void testOn_updateState_hushOff() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_OFF);
+ mController.updateState(mPreference);
+ verify(mController.mSwitch, times(1)).setChecked(false);
+ }
+
+ @Test
+ public void testOn_updateState_hushVibrate() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_VIBRATE);
+ mController.updateState(mPreference);
+ verify(mController.mSwitch, times(1)).setChecked(true);
+ }
+
+ @Test
+ public void testOn_updateState_hushMute() {
+ Settings.Secure.putInt(mContext.getContentResolver(), Settings.Secure.VOLUME_HUSH_GESTURE,
+ Settings.Secure.VOLUME_HUSH_MUTE);
+ mController.updateState(mPreference);
+ verify(mController.mSwitch, times(1)).setChecked(true);
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceControllerTest.java
index 10a3d90..cd21351 100644
--- a/tests/robotests/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/gestures/WakeLockScreenGesturePreferenceControllerTest.java
@@ -71,7 +71,7 @@
@Test
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
- when(mAmbientDisplayConfiguration.wakeLockScreenGestureAvailable()).thenReturn(false);
+ when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(false);
final int availabilityStatus = mController.getAvailabilityStatus();
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
@@ -79,7 +79,7 @@
@Test
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
- when(mAmbientDisplayConfiguration.wakeLockScreenGestureAvailable()).thenReturn(true);
+ when(mAmbientDisplayConfiguration.wakeScreenGestureAvailable()).thenReturn(true);
final int availabilityStatus = mController.getAvailabilityStatus();
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
index c62a6bb..c47fa38 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardLoaderTest.java
@@ -29,16 +29,16 @@
import com.android.settings.slices.CustomSliceRegistry;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
@RunWith(RobolectricTestRunner.class)
public class ContextualCardLoaderTest {
@@ -82,29 +82,29 @@
}
@Test
- public void getFinalDisplayableCards_twoEligibleCards_shouldShowAll() {
+ public void getDisplayableCards_twoEligibleCards_shouldShowAll() {
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
.collect(Collectors.toList());
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(cards);
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
assertThat(result).hasSize(cards.size());
}
@Test
- public void getFinalDisplayableCards_fiveEligibleCardsNoLarge_shouldShowDefaultCardCount() {
+ public void getDisplayableCards_fiveEligibleCardsNoLarge_shouldShowDefaultCardCount() {
final List<ContextualCard> fiveCards = getContextualCardListWithNoLargeCard();
doReturn(fiveCards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(
fiveCards);
assertThat(result).hasSize(DEFAULT_CARD_COUNT);
}
@Test
- public void getFinalDisplayableCards_threeEligibleCardsOneLarge_shouldShowThreeCards() {
+ public void getDisplayableCards_threeEligibleCardsOneLarge_shouldShowThreeCards() {
final List<ContextualCard> cards = getContextualCardList().stream().limit(2)
.collect(Collectors.toList());
cards.add(new ContextualCard.Builder()
@@ -115,18 +115,18 @@
.build());
doReturn(cards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(cards);
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(cards);
assertThat(result).hasSize(3);
}
@Test
- public void getFinalDisplayableCards_threeEligibleCardsTwoLarge_shouldShowTwoCards() {
+ public void getDisplayableCards_threeEligibleCardsTwoLarge_shouldShowTwoCards() {
final List<ContextualCard> threeCards = getContextualCardList().stream().limit(3)
.collect(Collectors.toList());
doReturn(threeCards).when(mContextualCardLoader).filterEligibleCards(any(List.class));
- final List<ContextualCard> result = mContextualCardLoader.getFinalDisplayableCards(
+ final List<ContextualCard> result = mContextualCardLoader.getDisplayableCards(
threeCards);
assertThat(result).hasSize(2);
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
index c405ffc..3fc8e06 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/ContextualCardManagerTest.java
@@ -32,6 +32,8 @@
import com.android.settings.homepage.contextualcards.conditional.ConditionFooterContextualCard;
import com.android.settings.homepage.contextualcards.conditional.ConditionHeaderContextualCard;
import com.android.settings.homepage.contextualcards.conditional.ConditionalContextualCard;
+import com.android.settings.intelligence.ContextualCardProto;
+import com.android.settings.slices.CustomSliceRegistry;
import org.junit.Before;
import org.junit.Test;
@@ -203,6 +205,134 @@
assertThat(actualCards).containsExactlyElementsIn(expectedCards);
}
+
+ @Test
+ public void assignCardWidth_noSuggestionCards_shouldNotHaveHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE
+ );
+ final List<ContextualCard> noSuggestionCards = buildCategoriedCards(getContextualCardList(),
+ categories);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(noSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (ContextualCard card : result) {
+ assertThat(card.isHalfWidth()).isFalse();
+ }
+ }
+
+ @Test
+ public void assignCardWidth_oneSuggestionCards_shouldNotHaveHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE
+ );
+ final List<ContextualCard> oneSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(oneSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (ContextualCard card : result) {
+ assertThat(card.isHalfWidth()).isFalse();
+ }
+ }
+
+ @Test
+ public void assignCardWidth_twoConsecutiveSuggestionCards_shouldHaveTwoHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE
+ );
+ final List<ContextualCard> twoConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+ final List<Boolean> expectedValues = Arrays.asList(false, false, true, true, false);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ twoConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (int i = 0; i < result.size(); i++) {
+ assertThat(result.get(i).isHalfWidth()).isEqualTo(expectedValues.get(i));
+ }
+ }
+
+ @Test
+ public void assignCardWidth_twoNonConsecutiveSuggestionCards_shouldNotHaveHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE
+ );
+ final List<ContextualCard> twoNonConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ twoNonConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (ContextualCard card : result) {
+ assertThat(card.isHalfWidth()).isFalse();
+ }
+ }
+
+ @Test
+ public void assignCardWidth_threeConsecutiveSuggestionCards_shouldHaveTwoHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE
+ );
+ final List<ContextualCard> threeConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+ final List<Boolean> expectedValues = Arrays.asList(false, true, true, false, false);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ threeConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (int i = 0; i < result.size(); i++) {
+ assertThat(result.get(i).isHalfWidth()).isEqualTo(expectedValues.get(i));
+ }
+ }
+
+ @Test
+ public void assignCardWidth_fourConsecutiveSuggestionCards_shouldHaveFourHalfCards() {
+ final List<Integer> categories = Arrays.asList(
+ ContextualCardProto.ContextualCard.Category.IMPORTANT_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE,
+ ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE
+ );
+ final List<ContextualCard> fourConsecutiveSuggestionCards = buildCategoriedCards(
+ getContextualCardList(), categories);
+ final List<Boolean> expectedValues = Arrays.asList(false, true, true, true, true);
+
+ final List<ContextualCard> result = mManager.assignCardWidth(
+ fourConsecutiveSuggestionCards);
+
+ assertThat(result).hasSize(5);
+ for (int i = 0; i < result.size(); i++) {
+ assertThat(result.get(i).isHalfWidth()).isEqualTo(expectedValues.get(i));
+ }
+ }
+
private ContextualCard buildContextualCard(String sliceUri) {
return new ContextualCard.Builder()
.setName(TEST_SLICE_NAME)
@@ -210,4 +340,45 @@
.setSliceUri(Uri.parse(sliceUri))
.build();
}
+
+ private List<ContextualCard> buildCategoriedCards(List<ContextualCard> cards,
+ List<Integer> categories) {
+ final List<ContextualCard> result = new ArrayList<>();
+ for (int i = 0; i < cards.size(); i++) {
+ result.add(cards.get(i).mutate().setCategory(categories.get(i)).build());
+ }
+ return result;
+ }
+
+ private List<ContextualCard> getContextualCardList() {
+ final List<ContextualCard> cards = new ArrayList<>();
+ cards.add(new ContextualCard.Builder()
+ .setName("test_wifi")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.CONTEXTUAL_WIFI_SLICE_URI)
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_flashlight")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(
+ Uri.parse("content://com.android.settings.test.slices/action/flashlight"))
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_connected")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.BLUETOOTH_DEVICES_SLICE_URI)
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_gesture")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(Uri.parse(
+ "content://com.android.settings.test.slices/action/gesture_pick_up"))
+ .build());
+ cards.add(new ContextualCard.Builder()
+ .setName("test_battery")
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(CustomSliceRegistry.BATTERY_INFO_SLICE_URI)
+ .build());
+ return cards;
+ }
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java
new file mode 100644
index 0000000..e4ca6c0
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/BatterySaverConditionControllerTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.homepage.contextualcards.conditional;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+
+import android.content.Context;
+import android.content.IntentFilter;
+import android.os.PowerManager;
+
+import com.android.settings.fuelgauge.BatterySaverReceiver;
+
+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;
+import org.robolectric.Shadows;
+import org.robolectric.shadows.ShadowPowerManager;
+
+@RunWith(RobolectricTestRunner.class)
+public class BatterySaverConditionControllerTest {
+ @Mock
+ private ConditionManager mConditionManager;
+
+ private ShadowPowerManager mPowerManager;
+ private Context mContext;
+ private BatterySaverConditionController mController;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mPowerManager = Shadows.shadowOf(mContext.getSystemService(PowerManager.class));
+ mController = new BatterySaverConditionController(mContext, mConditionManager);
+ }
+
+ @Test
+ public void startMonitor_shouldRegisterReceiver() {
+ mController.startMonitoringStateChange();
+
+ verify(mContext).registerReceiver(any(BatterySaverReceiver.class), any(IntentFilter.class));
+ }
+
+ @Test
+ public void stopMonitor_shouldUnregisterReceiver() {
+ mController.startMonitoringStateChange();
+ mController.stopMonitoringStateChange();
+
+ verify(mContext).unregisterReceiver(any(BatterySaverReceiver.class));
+ }
+
+ @Test
+ public void isDisplayable_PowerSaverOn_true() {
+ mPowerManager.setIsPowerSaveMode(true);
+
+ assertThat(mController.isDisplayable()).isTrue();
+ }
+
+ @Test
+ public void isDisplayable_PowerSaverOff_false() {
+ mPowerManager.setIsPowerSaveMode(false);
+
+ assertThat(mController.isDisplayable()).isFalse();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
index 566ca07..4553f7c 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/conditional/ConditionContextualCardControllerTest.java
@@ -112,7 +112,8 @@
}
@Test
- public void getConditionalCards_hasOneConditionCard_shouldGetOneFullWidthCard() {
+ public void getConditionalCards_hasOneConditionCardAndExpanded_shouldGetOneFullWidthCard() {
+ mController.setIsExpanded(true);
final Map<Integer, List<ContextualCard>> conditionalCards =
mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(1));
@@ -120,11 +121,24 @@
assertThat(conditionalCards.get(CardType.CONDITIONAL)).hasSize(1);
assertThat(conditionalCards.get(CardType.CONDITIONAL).get(0).isHalfWidth()).isFalse();
assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isNotEmpty();
+ }
+
+ @Test
+ public void getConditionalCards_hasOneConditionCardAndCollapsed_shouldGetConditionalHeader() {
+ mController.setIsExpanded(false);
+ final Map<Integer, List<ContextualCard>> conditionalCards =
+ mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(1));
+
+ assertThat(conditionalCards).hasSize(3);
+ assertThat(conditionalCards.get(CardType.CONDITIONAL)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isNotEmpty();
assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isEmpty();
}
@Test
- public void getConditionalCards_hasTwoConditionCards_shouldGetTwoHalfWidthCards() {
+ public void getConditionalCards_hasTwoConditionCardsAndExpanded_shouldGetTwoHalfWidthCards() {
+ mController.setIsExpanded(true);
final Map<Integer, List<ContextualCard>> conditionalCards =
mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(2));
@@ -134,6 +148,18 @@
assertThat(card.isHalfWidth()).isTrue();
}
assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isNotEmpty();
+ }
+
+ @Test
+ public void getConditionalCards_hasTwoConditionCardsAndCollapsed_shouldGetConditionalHeader() {
+ mController.setIsExpanded(false);
+ final Map<Integer, List<ContextualCard>> conditionalCards =
+ mController.buildConditionalCardsWithFooterOrHeader(generateConditionCards(2));
+
+ assertThat(conditionalCards).hasSize(3);
+ assertThat(conditionalCards.get(CardType.CONDITIONAL)).isEmpty();
+ assertThat(conditionalCards.get(CardType.CONDITIONAL_HEADER)).isNotEmpty();
assertThat(conditionalCards.get(CardType.CONDITIONAL_FOOTER)).isEmpty();
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSliceTest.java
similarity index 76%
rename from tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySliceTest.java
rename to tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSliceTest.java
index 4699587..ff276d6 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatterySliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/BatteryInfoSliceTest.java
@@ -26,14 +26,12 @@
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import org.junit.Before;
import org.junit.Test;
@@ -41,13 +39,11 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import java.util.List;
-
@RunWith(RobolectricTestRunner.class)
-public class BatterySliceTest {
+public class BatteryInfoSliceTest {
private Context mContext;
- private BatterySlice mBatterySlice;
+ private BatteryInfoSlice mBatteryInfoSlice;
@Before
public void setUp() {
@@ -56,22 +52,24 @@
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
- mBatterySlice = spy(new BatterySlice(mContext));
+ mBatteryInfoSlice = spy(new BatteryInfoSlice(mContext));
}
@Test
public void getSlice_shouldBeCorrectSliceContent() {
- doNothing().when(mBatterySlice).loadBatteryInfo();
- doReturn("10%").when(mBatterySlice).getBatteryPercentString();
- doReturn("test").when(mBatterySlice).getSummary();
- final Slice slice = mBatterySlice.getSlice();
+ doNothing().when(mBatteryInfoSlice).loadBatteryInfo();
+ doReturn("10%").when(mBatteryInfoSlice).getBatteryPercentString();
+ doReturn("test").when(mBatteryInfoSlice).getSummary();
+
+ final Slice slice = mBatteryInfoSlice.getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(
+ mContext.getString(R.string.power_usage_summary_title));
+
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_battery);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.power_usage_summary_title));
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
index 1a3be6c..588b7aa 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DataUsageSliceTest.java
@@ -69,24 +69,31 @@
ShadowDataUsageUtils.HAS_SIM = true;
doReturn(DATA_USAGE_TITLE).when(mDataUsageSlice).getDataUsageText(any());
doReturn(DATA_USAGE_SUMMARY).when(mDataUsageSlice).getCycleTime(any());
+
final Slice slice = mDataUsageSlice.getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(
+ mContext.getString(R.string.data_usage_summary_title));
+
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_data_usage);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.data_usage_summary_title));
}
@Test
public void getSlice_hasNoSim_shouldShowNoSimCard() {
ShadowDataUsageUtils.HAS_SIM = false;
- final Slice slice = mDataUsageSlice.getSlice();
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.data_usage_summary_title));
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.no_sim_card));
+ final Slice slice = mDataUsageSlice.getSlice();
+
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(
+ mContext.getString(R.string.data_usage_summary_title));
+
+ final List<SliceItem> sliceItems = slice.getItems();
+ SliceTester.assertAnySliceItemContainsTitle(sliceItems,
+ mContext.getString(R.string.no_sim_card));
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java
index c1d7329..ddc7218 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/DeviceInfoSliceTest.java
@@ -70,24 +70,30 @@
final String phoneNumber = "1111111111";
doReturn(mSubscriptionInfo).when(mDeviceInfoSlice).getFirstSubscriptionInfo();
doReturn(phoneNumber).when(mDeviceInfoSlice).getPhoneNumber();
+
final Slice slice = mDeviceInfoSlice.getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
+
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_info_outline_24dp);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.device_info_label));
- SliceTester.assertTitle(sliceItems, phoneNumber);
+ SliceTester.assertAnySliceItemContainsTitle(sliceItems, phoneNumber);
}
@Test
public void getSlice_hasNoSubscriptionInfo_shouldShowUnknown() {
final Slice slice = mDeviceInfoSlice.getSlice();
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.device_info_label));
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.device_info_default));
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.device_info_label));
+
+ final List<SliceItem> sliceItems = slice.getItems();
+ SliceTester.assertAnySliceItemContainsTitle(sliceItems,
+ mContext.getString(R.string.device_info_default));
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSliceTest.java
index dc125e2..a758a94 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/deviceinfo/StorageSliceTest.java
@@ -26,14 +26,12 @@
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
import org.junit.Before;
@@ -42,8 +40,6 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
-import java.util.List;
-
@RunWith(RobolectricTestRunner.class)
public class StorageSliceTest {
private static final String USED_BYTES_TEXT = "test used bytes";
@@ -68,14 +64,15 @@
doReturn(info).when(mStorageSlice).getPrivateStorageInfo();
doReturn(USED_BYTES_TEXT).when(mStorageSlice).getStorageUsedText(any());
doReturn(SUMMARY_TEXT).when(mStorageSlice).getStorageSummaryText(any());
+
final Slice slice = mStorageSlice.getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_label));
+
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_homepage_storage);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedIcon.toString());
-
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.storage_label));
}
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java
index ff08c6a..1c299cb 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BatteryFixSliceTest.java
@@ -26,6 +26,8 @@
import android.content.Context;
import android.content.SharedPreferences;
+import androidx.slice.Slice;
+import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.widget.SliceLiveData;
@@ -55,11 +57,13 @@
public class BatteryFixSliceTest {
private Context mContext;
+ private BatteryFixSlice mSlice;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
+ mSlice = new BatteryFixSlice(mContext);
// Set-up specs for SliceMetadata.
SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
@@ -71,7 +75,7 @@
}
@Test
- public void readBatteryTipfromPref_readCorrectValue() {
+ public void readBatteryTipFromPref_readCorrectValue() {
int target = 111;
final SharedPreferences.Editor editor = mContext.getSharedPreferences(PREFS,
MODE_PRIVATE).edit();
@@ -90,7 +94,7 @@
public void updateBatteryTipAvailabilityCache_writeCorrectValue() {
final List<BatteryTip> tips = new ArrayList<>();
tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
- tips.add(new EarlyWarningTip(BatteryTip.StateType.HANDLED, false));
+ tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
ShadowBatteryTipLoader.setBatteryTips(tips);
BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
@@ -99,6 +103,23 @@
BatteryTip.TipType.BATTERY_SAVER);
}
+ @Test
+ @Config(shadows = {
+ ShadowBatteryStatsHelperLoader.class,
+ ShadowBatteryTipLoader.class
+ })
+ public void getSlice_unimportantSlice_shouldSkip() {
+ final List<BatteryTip> tips = new ArrayList<>();
+ tips.add(new LowBatteryTip(BatteryTip.StateType.INVISIBLE, false, ""));
+ tips.add(new EarlyWarningTip(BatteryTip.StateType.NEW, false));
+ ShadowBatteryTipLoader.setBatteryTips(tips);
+
+ BatteryFixSlice.updateBatteryTipAvailabilityCache(mContext);
+ final Slice slice = mSlice.getSlice();
+
+ assertThat(SliceMetadata.from(mContext, slice).isErrorSlice()).isTrue();
+ }
+
@Implements(BatteryStatsHelperLoader.class)
public static class ShadowBatteryStatsHelperLoader {
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
index 12ae707..bc34fd5 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothDevicesSliceTest.java
@@ -106,8 +106,8 @@
final Slice slice = mBluetoothDevicesSlice.getSlice();
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.bluetooth_devices));
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_devices));
}
@Test
@@ -118,7 +118,7 @@
final Slice slice = mBluetoothDevicesSlice.getSlice();
final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, BLUETOOTH_MOCK_TITLE);
+ SliceTester.assertAnySliceItemContainsTitle(sliceItems, BLUETOOTH_MOCK_TITLE);
}
@Test
@@ -129,7 +129,7 @@
final Slice slice = mBluetoothDevicesSlice.getSlice();
final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems,
+ SliceTester.assertAnySliceItemContainsTitle(sliceItems,
mContext.getString(R.string.bluetooth_pairing_pref_title));
}
@@ -139,8 +139,9 @@
final Slice slice = mBluetoothDevicesSlice.getSlice();
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.no_bluetooth_devices));
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(
+ mContext.getString(R.string.no_bluetooth_devices));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/LowStorageSliceTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/LowStorageSliceTest.java
index 3bd29b9..99f2723 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/LowStorageSliceTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/LowStorageSliceTest.java
@@ -23,12 +23,11 @@
import android.content.Context;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
+import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import com.android.settingslib.deviceinfo.PrivateStorageInfo;
import com.android.settingslib.deviceinfo.StorageVolumeProvider;
@@ -43,8 +42,6 @@
import org.robolectric.annotation.Implements;
import org.robolectric.annotation.Resetter;
-import java.util.List;
-
@RunWith(RobolectricTestRunner.class)
public class LowStorageSliceTest {
@@ -73,8 +70,8 @@
final Slice slice = mLowStorageSlice.getSlice();
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.storage_menu_free));
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_menu_free));
}
@Test
@@ -94,8 +91,8 @@
final Slice slice = mLowStorageSlice.getSlice();
- final List<SliceItem> sliceItems = slice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.storage_settings));
+ final SliceMetadata metadata = SliceMetadata.from(mContext, slice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.storage_settings));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
index 0b87525..4d9a21d 100644
--- a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceContextualCardRendererTest.java
@@ -79,17 +79,6 @@
}
@Test
- public void bindView_shouldSetScrollableToFalse() {
- RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
-
- mRenderer.bindView(viewHolder, buildContextualCard(TEST_SLICE_URI));
-
- assertThat(
- ((SliceContextualCardRenderer.SliceViewHolder) viewHolder).sliceView.isScrollable
- ()).isFalse();
- }
-
- @Test
public void bindView_invalidScheme_sliceShouldBeNull() {
final Uri sliceUri = Uri.parse("contet://com.android.settings.slices/action/flashlight");
RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
@@ -97,7 +86,7 @@
mRenderer.bindView(viewHolder, buildContextualCard(sliceUri));
assertThat(
- ((SliceContextualCardRenderer.SliceViewHolder) viewHolder).sliceView.getSlice())
+ ((SliceFullCardRendererHelper.SliceViewHolder) viewHolder).sliceView.getSlice())
.isNull();
}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java
new file mode 100644
index 0000000..9172300d
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceFullCardRendererHelperTest.java
@@ -0,0 +1,151 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_FULL_WIDTH;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.net.Uri;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceProvider;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
+import androidx.slice.widget.SliceLiveData;
+import androidx.slice.widget.SliceView;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.slices.SliceFullCardRendererHelper.SliceViewHolder;
+import com.android.settings.intelligence.ContextualCardProto;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.Collections;
+
+@RunWith(RobolectricTestRunner.class)
+public class SliceFullCardRendererHelperTest {
+
+ private static final Uri TEST_SLICE_URI = Uri.parse("content://test/test");
+
+ private Activity mActivity;
+ private SliceFullCardRendererHelper mHelper;
+
+ @Before
+ public void setUp() {
+ // Set-up specs for SliceMetadata.
+ SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ mActivity = Robolectric.buildActivity(Activity.class).create().get();
+ mActivity.setTheme(R.style.Theme_Settings_Home);
+ mHelper = new SliceFullCardRendererHelper(mActivity);
+ }
+
+ @Test
+ public void createViewHolder_shouldAlwaysReturnSliceViewHolder() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ assertThat(viewHolder).isInstanceOf(SliceViewHolder.class);
+ }
+
+ @Test
+ public void bindView_shouldSetScrollableToFalse() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.isScrollable()).isFalse();
+ }
+
+ @Test
+ public void bindView_shouldSetTagToSliceUri() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+ final ContextualCard card = buildContextualCard();
+
+ mHelper.bindView(viewHolder, card, buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.getTag()).isEqualTo(card.getSliceUri());
+ }
+
+ @Test
+ public void bindView_shouldSetModeToLarge() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.getMode()).isEqualTo(
+ SliceView.MODE_LARGE);
+ }
+
+ @Test
+ public void bindView_shouldSetSlice() {
+ final RecyclerView.ViewHolder viewHolder = getSliceViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice(), Collections.emptySet());
+
+ assertThat(((SliceViewHolder) viewHolder).sliceView.getSlice().getUri()).isEqualTo(
+ TEST_SLICE_URI);
+ }
+
+ private RecyclerView.ViewHolder getSliceViewHolder() {
+ final RecyclerView recyclerView = new RecyclerView(mActivity);
+ recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
+ final View view = LayoutInflater.from(mActivity).inflate(VIEW_TYPE_FULL_WIDTH, recyclerView,
+ false);
+ return mHelper.createViewHolder(view);
+ }
+
+ private ContextualCard buildContextualCard() {
+ return new ContextualCard.Builder()
+ .setName("test_name")
+ .setCategory(ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE)
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(TEST_SLICE_URI)
+ .setIsHalfWidth(false /* isHalfWidth */)
+ .build();
+ }
+
+ private Slice buildSlice() {
+ final String title = "test_title";
+ final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
+ final PendingIntent pendingIntent = PendingIntent.getActivity(
+ mActivity,
+ title.hashCode() /* requestCode */,
+ new Intent("test action"),
+ 0 /* flags */);
+ final SliceAction action
+ = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
+ return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY)
+ .addRow(new ListBuilder.RowBuilder()
+ .addEndItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle(title)
+ .setPrimaryAction(action))
+ .build();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelperTest.java b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelperTest.java
new file mode 100644
index 0000000..c38697e
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/homepage/contextualcards/slices/SliceHalfCardRendererHelperTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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.homepage.contextualcards.slices;
+
+import static com.android.settings.homepage.contextualcards.slices.SliceContextualCardRenderer.VIEW_TYPE_HALF_WIDTH;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.app.Activity;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.net.Uri;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import androidx.core.graphics.drawable.IconCompat;
+import androidx.recyclerview.widget.LinearLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+import androidx.slice.Slice;
+import androidx.slice.SliceProvider;
+import androidx.slice.builders.ListBuilder;
+import androidx.slice.builders.SliceAction;
+import androidx.slice.widget.SliceLiveData;
+
+import com.android.settings.R;
+import com.android.settings.homepage.contextualcards.ContextualCard;
+import com.android.settings.homepage.contextualcards.slices.SliceHalfCardRendererHelper.HalfCardViewHolder;
+import com.android.settings.intelligence.ContextualCardProto;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class SliceHalfCardRendererHelperTest {
+
+ private static final Uri TEST_SLICE_URI = Uri.parse("content://test/test");
+
+ private Activity mActivity;
+ private SliceHalfCardRendererHelper mHelper;
+
+ @Before
+ public void setUp() {
+ // Set-up specs for SliceMetadata.
+ SliceProvider.setSpecs(SliceLiveData.SUPPORTED_SPECS);
+ mActivity = Robolectric.buildActivity(Activity.class).create().get();
+ mActivity.setTheme(R.style.Theme_Settings_Home);
+ mHelper = new SliceHalfCardRendererHelper(mActivity);
+ }
+
+ @Test
+ public void createViewHolder_shouldAlwaysReturnCustomViewHolder() {
+ final RecyclerView.ViewHolder viewHolder = getHalfCardViewHolder();
+
+ assertThat(viewHolder).isInstanceOf(HalfCardViewHolder.class);
+ }
+
+ @Test
+ public void bindView_shouldSetTitle() {
+ final RecyclerView.ViewHolder viewHolder = getHalfCardViewHolder();
+
+ mHelper.bindView(viewHolder, buildContextualCard(), buildSlice());
+
+ assertThat(((HalfCardViewHolder) viewHolder).title.getText()).isEqualTo("test_title");
+ }
+
+ private RecyclerView.ViewHolder getHalfCardViewHolder() {
+ final RecyclerView recyclerView = new RecyclerView(mActivity);
+ recyclerView.setLayoutManager(new LinearLayoutManager(mActivity));
+ final View view = LayoutInflater.from(mActivity).inflate(VIEW_TYPE_HALF_WIDTH, recyclerView,
+ false);
+
+ return mHelper.createViewHolder(view);
+ }
+
+ private ContextualCard buildContextualCard() {
+ return new ContextualCard.Builder()
+ .setName("test_name")
+ .setCategory(ContextualCardProto.ContextualCard.Category.SUGGESTION_VALUE)
+ .setCardType(ContextualCard.CardType.SLICE)
+ .setSliceUri(TEST_SLICE_URI)
+ .setIsHalfWidth(false /* isHalfWidth */)
+ .build();
+ }
+
+ private Slice buildSlice() {
+ final String title = "test_title";
+ final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
+ final PendingIntent pendingIntent = PendingIntent.getActivity(
+ mActivity,
+ title.hashCode() /* requestCode */,
+ new Intent("test action"),
+ 0 /* flags */);
+ final SliceAction action
+ = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
+ return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY)
+ .addRow(new ListBuilder.RowBuilder()
+ .addEndItem(icon, ListBuilder.ICON_IMAGE)
+ .setTitle(title)
+ .setPrimaryAction(action))
+ .build();
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
index 6379e44..bddd5fe 100644
--- a/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/AppLocationPermissionPreferenceControllerTest.java
@@ -3,10 +3,12 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
+import android.location.LocationManager;
import android.provider.Settings;
import androidx.lifecycle.LifecycleOwner;
+import com.android.settings.R;
import com.android.settingslib.core.lifecycle.Lifecycle;
import org.junit.Before;
@@ -27,6 +29,7 @@
private LifecycleOwner mLifecycleOwner;
private Lifecycle mLifecycle;
+ private LocationManager mLocationManager;
@Before
public void setUp() {
@@ -35,6 +38,7 @@
mLifecycleOwner = () -> mLifecycle;
mLifecycle = new Lifecycle(mLifecycleOwner);
mController = new AppLocationPermissionPreferenceController(mContext, mLifecycle);
+ mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
}
@Test
@@ -52,4 +56,40 @@
assertThat(mController.isAvailable()).isTrue();
}
+
+ @Test
+ public void getSummary_whenLocationIsOff_shouldReturnStringForOff() {
+ mLocationManager.setLocationEnabledForUser(false, android.os.Process.myUserHandle());
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.location_app_permission_summary_location_off));
+ }
+
+ @Test
+ public void getSummary_whenLocationIsOn_shouldReturnLoadingString() {
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.location_settings_loading_app_permission_stats));
+ }
+
+ @Test
+ public void getSummary_whenLocationAppCountIsOne_shouldShowSingularString() {
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+ mController.mNumBackground = 1;
+ mController.mNumTotal = 1;
+
+ assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getQuantityString(
+ R.plurals.location_app_permission_summary_location_on, 1, 1, 1));
+ }
+
+ @Test
+ public void getSummary_whenLocationAppCountIsGreaterThanOne_shouldShowPluralString() {
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+ mController.mNumBackground = 5;
+ mController.mNumTotal = 10;
+
+ assertThat(mController.getSummary()).isEqualTo(mContext.getResources().getQuantityString(
+ R.plurals.location_app_permission_summary_location_on, 5, 5, 10));
+ }
}
diff --git a/tests/robotests/src/com/android/settings/location/LocationSliceTest.java b/tests/robotests/src/com/android/settings/location/LocationSliceTest.java
index 427307d..0618cd9 100644
--- a/tests/robotests/src/com/android/settings/location/LocationSliceTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationSliceTest.java
@@ -6,14 +6,12 @@
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import org.junit.Before;
import org.junit.Test;
@@ -39,7 +37,10 @@
@Test
public void getLocationSlice_correctSliceContent() {
final Slice LocationSlice = new LocationSlice(mContext).getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, LocationSlice);
+ assertThat(metadata.getTitle()).isEqualTo(
+ mContext.getString(R.string.location_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).isEmpty();
@@ -48,8 +49,5 @@
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_signal_location);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
-
- final List<SliceItem> sliceItems = LocationSlice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.location_settings_title));
}
}
diff --git a/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
new file mode 100644
index 0000000..3b33558
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/location/RecentLocationAccessPreferenceControllerTest.java
@@ -0,0 +1,145 @@
+/*
+ * 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.location;
+
+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.when;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import androidx.preference.PreferenceScreen;
+
+import com.android.settings.R;
+import com.android.settingslib.location.RecentLocationAccesses;
+import com.android.settingslib.widget.LayoutPreference;
+
+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;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@RunWith(RobolectricTestRunner.class)
+public class RecentLocationAccessPreferenceControllerTest {
+ @Mock
+ private LayoutPreference mLayoutPreference;
+ @Mock
+ private PreferenceScreen mScreen;
+ @Mock
+ private RecentLocationAccesses mRecentLocationApps;
+
+ private Context mContext;
+ private RecentLocationAccessPreferenceController mController;
+ private View mAppEntitiesHeaderView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+ mContext = spy(RuntimeEnvironment.application);
+ mController = spy(
+ new RecentLocationAccessPreferenceController(mContext, mRecentLocationApps));
+ final String key = mController.getPreferenceKey();
+ mAppEntitiesHeaderView = LayoutInflater.from(mContext).inflate(
+ R.layout.app_entities_header, null /* root */);
+ when(mScreen.findPreference(key)).thenReturn(mLayoutPreference);
+ when(mLayoutPreference.getKey()).thenReturn(key);
+ when(mLayoutPreference.getContext()).thenReturn(mContext);
+ when(mLayoutPreference.findViewById(R.id.app_entities_header)).thenReturn(
+ mAppEntitiesHeaderView);
+ }
+
+ /** Verifies the title text, details text are correct, and the click listener is set. */
+ @Test
+ public void updateState_whenAppListIsEmpty_shouldDisplayTitleTextAndDetailsText() {
+ doReturn(new ArrayList<>()).when(mRecentLocationApps).getAppListSorted();
+ mController.displayPreference(mScreen);
+ mController.updateState(mLayoutPreference);
+
+ final TextView title = mAppEntitiesHeaderView.findViewById(R.id.header_title);
+ assertThat(title.getText()).isEqualTo(
+ mContext.getText(R.string.location_category_recent_location_access));
+ final TextView details = mAppEntitiesHeaderView.findViewById(R.id.header_details);
+ assertThat(details.getText()).isEqualTo(
+ mContext.getText(R.string.location_recent_location_access_view_details));
+ assertThat(details.hasOnClickListeners()).isTrue();
+ }
+
+ @Test
+ public void updateState_whenAppListMoreThanThree_shouldDisplayTopThreeApps() {
+ final List<RecentLocationAccesses.Access> accesses = createMockAccesses(6);
+ doReturn(accesses).when(mRecentLocationApps).getAppListSorted();
+ mController.displayPreference(mScreen);
+ mController.updateState(mLayoutPreference);
+
+ // The widget can display the top 3 apps from the list when there're more than 3.
+ final View app1View = mAppEntitiesHeaderView.findViewById(R.id.app1_view);
+ final ImageView appIconView1 = app1View.findViewById(R.id.app_icon);
+ final TextView appTitle1 = app1View.findViewById(R.id.app_title);
+ final TextView appSummary1 = app1View.findViewById(R.id.app_summary);
+
+ assertThat(app1View.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(appIconView1.getDrawable()).isNotNull();
+ assertThat(appTitle1.getText()).isEqualTo("appTitle0");
+ assertThat(appSummary1.getText()).isEqualTo("appSummary0");
+
+ final View app2View = mAppEntitiesHeaderView.findViewById(R.id.app2_view);
+ final ImageView appIconView2 = app2View.findViewById(R.id.app_icon);
+ final TextView appTitle2 = app2View.findViewById(R.id.app_title);
+ final TextView appSummary2 = app2View.findViewById(R.id.app_summary);
+
+ assertThat(app2View.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(appIconView2.getDrawable()).isNotNull();
+ assertThat(appTitle2.getText()).isEqualTo("appTitle1");
+ assertThat(appSummary2.getText()).isEqualTo("appSummary1");
+
+ final View app3View = mAppEntitiesHeaderView.findViewById(R.id.app3_view);
+ final ImageView appIconView3 = app3View.findViewById(R.id.app_icon);
+ final TextView appTitle3 = app3View.findViewById(R.id.app_title);
+ final TextView appSummary3 = app3View.findViewById(R.id.app_summary);
+
+ assertThat(app3View.getVisibility()).isEqualTo(View.VISIBLE);
+ assertThat(appIconView3.getDrawable()).isNotNull();
+ assertThat(appTitle3.getText()).isEqualTo("appTitle2");
+ assertThat(appSummary3.getText()).isEqualTo("appSummary2");
+ }
+
+ private List<RecentLocationAccesses.Access> createMockAccesses(int count) {
+ final List<RecentLocationAccesses.Access> accesses = new ArrayList<>();
+ for (int i = 0; i < count; i++) {
+ final Drawable icon = mock(Drawable.class);
+ // Add mock accesses
+ final RecentLocationAccesses.Access access = new RecentLocationAccesses.Access(
+ "packageName", android.os.Process.myUserHandle(), icon,
+ "appTitle" + i, "appSummary" + i, 1000 - i);
+ accesses.add(access);
+ }
+ return accesses;
+ }
+}
diff --git a/tests/robotests/src/com/android/settings/location/TopLevelLocationPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/TopLevelLocationPreferenceControllerTest.java
new file mode 100644
index 0000000..68e7f88
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/location/TopLevelLocationPreferenceControllerTest.java
@@ -0,0 +1,86 @@
+/*
+ * 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.location;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Context;
+import android.location.LocationManager;
+
+import com.android.settings.R;
+
+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 TopLevelLocationPreferenceControllerTest {
+ private static final String PREFERENCE_KEY = "top_level_location";
+ private Context mContext;
+ private TopLevelLocationPreferenceController mController;
+ private LocationManager mLocationManager;
+
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mController = new TopLevelLocationPreferenceController(mContext, PREFERENCE_KEY);
+ mLocationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE);
+ }
+
+ @Test
+ public void isAvailable_byDefault_shouldReturnTrue() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
+
+ @Test
+ public void getSummary_whenLocationIsOff_shouldReturnStringForOff() {
+ mLocationManager.setLocationEnabledForUser(false, android.os.Process.myUserHandle());
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.location_settings_summary_location_off));
+ }
+
+ @Test
+ public void getSummary_whenLocationIsOn_shouldShowLoadingString() {
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.location_settings_loading_app_permission_stats));
+ }
+
+ @Test
+ public void getSummary_whenLocationAppCountIsOne_shouldShowSingularString() {
+ final int LOCATION_APP_COUNT = 1;
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+ mController.setLocationAppCount(LOCATION_APP_COUNT);
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getResources().getQuantityString(
+ R.plurals.location_settings_summary_location_on,
+ LOCATION_APP_COUNT, LOCATION_APP_COUNT));
+ }
+
+ @Test
+ public void getSummary_whenLocationAppCountIsGreaterThanOne_shouldShowPluralString() {
+ final int LOCATION_APP_COUNT = 5;
+ mLocationManager.setLocationEnabledForUser(true, android.os.Process.myUserHandle());
+ mController.setLocationAppCount(LOCATION_APP_COUNT);
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getResources().getQuantityString(
+ R.plurals.location_settings_summary_location_on,
+ LOCATION_APP_COUNT, LOCATION_APP_COUNT));
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
index 452e9b1..c0b1dab 100644
--- a/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/network/telephony/WifiCallingPreferenceControllerTest.java
@@ -32,6 +32,7 @@
import com.android.ims.ImsConfig;
import com.android.ims.ImsManager;
+import com.android.settings.core.BasePreferenceController;
import org.junit.Before;
import org.junit.Test;
@@ -109,4 +110,12 @@
assertThat(mPreferenceCategory.isVisible()).isFalse();
}
+
+ @Test
+ public void getAvailabilityStatus_noWiFiCalling_shouldReturnUnsupported() {
+ mController.init(SubscriptionManager.INVALID_SUBSCRIPTION_ID);
+
+ assertThat(mController.getAvailabilityStatus()).isEqualTo(
+ BasePreferenceController.UNSUPPORTED_ON_DEVICE);
+ }
}
diff --git a/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java
index 8ed9dcc..cd70d66 100644
--- a/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/nfc/AndroidBeamPreferenceControllerTest.java
@@ -22,6 +22,7 @@
import static org.mockito.Mockito.when;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.nfc.NfcAdapter;
import android.nfc.NfcManager;
import android.os.UserHandle;
@@ -57,6 +58,8 @@
private UserManager mUserManager;
@Mock
private PreferenceScreen mScreen;
+ @Mock
+ private PackageManager mPackageManager;
private RestrictedPreference mAndroidBeamPreference;
private AndroidBeamPreferenceController mAndroidBeamController;
@@ -78,6 +81,8 @@
mAndroidBeamPreference = new RestrictedPreference(RuntimeEnvironment.application);
when(mScreen.findPreference(mAndroidBeamController.getPreferenceKey())).thenReturn(
mAndroidBeamPreference);
+ when(mContext.getPackageManager()).thenReturn(mPackageManager);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)).thenReturn(true);
Settings.Global.putString(mContext.getContentResolver(),
Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS,
@@ -95,6 +100,13 @@
}
@Test
+ public void isAvailable_noNfcFeature_shouldReturnFalse() {
+ when(mNfcAdapter.isEnabled()).thenReturn(true);
+ when(mPackageManager.hasSystemFeature(PackageManager.FEATURE_NFC_BEAM)).thenReturn(false);
+ assertThat(mAndroidBeamController.isAvailable()).isFalse();
+ }
+
+ @Test
public void isAvailable_noNfcAdapter_shouldReturnFalse() {
ReflectionHelpers.setField(mAndroidBeamController, "mNfcAdapter", null);
assertThat(mAndroidBeamController.isAvailable()).isFalse();
diff --git a/tests/robotests/src/com/android/settings/notification/ZenModeSliceBuilderTest.java b/tests/robotests/src/com/android/settings/notification/ZenModeSliceBuilderTest.java
index bc9e370..ac185ac 100644
--- a/tests/robotests/src/com/android/settings/notification/ZenModeSliceBuilderTest.java
+++ b/tests/robotests/src/com/android/settings/notification/ZenModeSliceBuilderTest.java
@@ -26,14 +26,12 @@
import android.provider.Settings;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import com.android.settings.testutils.shadow.ShadowNotificationManager;
import org.junit.Before;
@@ -62,16 +60,16 @@
@Test
public void getZenModeSlice_correctSliceContent() {
final Slice dndSlice = ZenModeSliceBuilder.getSlice(mContext);
+
final SliceMetadata metadata = SliceMetadata.from(mContext, dndSlice);
+ assertThat(metadata.getTitle()).isEqualTo(
+ mContext.getString(R.string.zen_mode_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction primaryAction = metadata.getPrimaryAction();
assertThat(primaryAction.getIcon()).isNull();
-
- final List<SliceItem> sliceItems = dndSlice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.zen_mode_settings_title));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
index a6a6355..6b1029c 100644
--- a/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
+++ b/tests/robotests/src/com/android/settings/password/ChooseLockPatternTest.java
@@ -107,7 +107,7 @@
ChooseLockPatternFragment fragment = (ChooseLockPatternFragment)
activity.getSupportFragmentManager().findFragmentById(R.id.main_content);
- View iconView = fragment.getView().findViewById(R.id.suw_layout_icon);
+ View iconView = fragment.getView().findViewById(R.id.suc_layout_icon);
assertThat(iconView.getVisibility()).isEqualTo(View.GONE);
}
diff --git a/tests/robotests/src/com/android/settings/testutils/SliceTester.java b/tests/robotests/src/com/android/settings/testutils/SliceTester.java
index c0ffdcd..17edb6e 100644
--- a/tests/robotests/src/com/android/settings/testutils/SliceTester.java
+++ b/tests/robotests/src/com/android/settings/testutils/SliceTester.java
@@ -79,8 +79,7 @@
assertThat(primaryPendingIntent).isEqualTo(
SliceBuilderUtils.getContentPendingIntent(context, sliceData));
- final List<SliceItem> sliceItems = slice.getItems();
- assertTitle(sliceItems, sliceData.getTitle());
+ assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
@@ -122,8 +121,7 @@
assertThat(primaryPendingIntent).isEqualTo(
SliceBuilderUtils.getContentPendingIntent(context, sliceData));
- final List<SliceItem> sliceItems = slice.getItems();
- assertTitle(sliceItems, sliceData.getTitle());
+ assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
@@ -160,8 +158,7 @@
assertThat(primaryPendingIntent).isEqualTo(
SliceBuilderUtils.getContentPendingIntent(context, sliceData));
- final List<SliceItem> sliceItems = slice.getItems();
- assertTitle(sliceItems, sliceData.getTitle());
+ assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
@@ -197,8 +194,7 @@
assertThat(primaryPendingIntent).isEqualTo(
SliceBuilderUtils.getContentPendingIntent(context, sliceData));
- final List<SliceItem> sliceItems = slice.getItems();
- assertTitle(sliceItems, sliceData.getTitle());
+ assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
@@ -230,14 +226,18 @@
assertThat(primaryPendingIntent).isEqualTo(SliceBuilderUtils.getContentPendingIntent(
context, sliceData));
- final List<SliceItem> sliceItems = slice.getItems();
- assertTitle(sliceItems, sliceData.getTitle());
+ assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
- // TODO(b/120592507): Clean up method of SliceTester
- public static void assertTitle(List<SliceItem> sliceItems, String title) {
+ /**
+ * Assert any slice item contains title.
+ *
+ * @param sliceItems All slice items of a Slice.
+ * @param title Title for asserting.
+ */
+ public static void assertAnySliceItemContainsTitle(List<SliceItem> sliceItems, String title) {
boolean hasTitle = false;
for (SliceItem item : sliceItems) {
List<SliceItem> titleItems = SliceQuery.findAll(item, FORMAT_TEXT, HINT_TITLE,
@@ -256,7 +256,6 @@
assertThat(hasTitle).isTrue();
}
- // TODO(b/120592507): Clean up method of SliceTester
private static void assertKeywords(SliceMetadata metadata, SliceData data) {
final List<String> keywords = metadata.getSliceKeywords();
final Set<String> expectedKeywords = Arrays.stream(data.getKeywords().split(","))
@@ -266,4 +265,4 @@
expectedKeywords.add(data.getScreenTitle().toString());
assertThat(keywords).containsExactlyElementsIn(expectedKeywords);
}
-}
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
index 396b9df..4cd6be4 100644
--- a/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
+++ b/tests/robotests/src/com/android/settings/widget/VideoPreferenceTest.java
@@ -92,4 +92,13 @@
verify(mMediaPlayer, never()).start();
}
+
+ @Test
+ public void onViewInvisible_shouldReleaseMediaplayer() {
+ mVideoPreference.onViewVisible(false);
+
+ mVideoPreference.onViewInvisible();
+
+ verify(mMediaPlayer).release();
+ }
}
diff --git a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
index e64fae7..17516e9 100644
--- a/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/NetworkRequestDialogFragmentTest.java
@@ -111,14 +111,17 @@
ShadowLooper.getShadowMainLooper().runToEndOfTasks();
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
+ assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.TIME_OUT);
}
class FakeNetworkRequestDialogFragment extends NetworkRequestDialogFragment {
boolean bCalledStopAndPop = false;
+ ERROR_DIALOG_TYPE errorType = null;
@Override
- public void stopScanningAndPopErrorDialog(ERROR_DIALOG_TYPE type) {
+ public void stopScanningAndMaybePopErrorDialog(ERROR_DIALOG_TYPE type) {
bCalledStopAndPop = true;
+ errorType = type;
}
}
@@ -150,22 +153,28 @@
@Test
public void updateAccessPointList_onUserSelectionConnectSuccess_shouldCloseTheDialog() {
- List<AccessPoint> accessPointList = createAccessPointList();
- when(networkRequestDialogFragment.getAccessPointList()).thenReturn(accessPointList);
- networkRequestDialogFragment.show(mActivity.getSupportFragmentManager(), null);
- AlertDialog alertDialog = ShadowAlertDialogCompat.getLatestAlertDialog();
- assertThat(alertDialog.isShowing()).isTrue();
+ // Assert
+ FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
+ FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
- // Test if config would update list.
+ List<AccessPoint> accessPointList = createAccessPointList();
+ when(spyFakeFragment.getAccessPointList()).thenReturn(accessPointList);
+
+ spyFakeFragment.show(mActivity.getSupportFragmentManager(), null);
+
+ // Action
WifiConfiguration config = new WifiConfiguration();
config.SSID = "Test AP 3";
- networkRequestDialogFragment.onUserSelectionConnectSuccess(config);
+ spyFakeFragment.onUserSelectionConnectSuccess(config);
- assertThat(alertDialog.isShowing()).isFalse();
+ // Check
+ ShadowLooper.getShadowMainLooper().runToEndOfTasks();
+ assertThat(fakeFragment.bCalledStopAndPop).isTrue();
+ assertThat(fakeFragment.errorType).isNull();
}
@Test
- public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallTimeoutDialog() {
+ public void updateAccessPointList_onUserSelectionConnectFailure_shouldCallAbortDialog() {
FakeNetworkRequestDialogFragment fakeFragment = new FakeNetworkRequestDialogFragment();
FakeNetworkRequestDialogFragment spyFakeFragment = spy(fakeFragment);
List<AccessPoint> accessPointList = createAccessPointList();
@@ -181,6 +190,7 @@
fakeFragment.onUserSelectionConnectFailure(config);
assertThat(fakeFragment.bCalledStopAndPop).isTrue();
+ assertThat(fakeFragment.errorType).isEqualTo(ERROR_DIALOG_TYPE.ABORT);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
index 8bbb2be..20c5838 100644
--- a/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/details/WifiPrivacyPreferenceControllerTest.java
@@ -38,8 +38,8 @@
@RunWith(RobolectricTestRunner.class)
public class WifiPrivacyPreferenceControllerTest {
- private static final int PRIVACY_RANDOMIZED = 0;
- private static final int PRIVACY_TRUSTED = 1;
+ private static final int PRIVACY_RANDOMIZED = WifiConfiguration.RANDOMIZATION_PERSISTENT;
+ private static final int PRIVACY_TRUSTED = WifiConfiguration.RANDOMIZATION_NONE;
@Mock
private WifiConfiguration mWifiConfiguration;
@@ -47,6 +47,7 @@
private WifiPrivacyPreferenceController mPreferenceController;
private Context mContext;
private DropDownPreference mDropDownPreference;
+ private String[] perferenceString;
@Before
public void setUp() {
@@ -59,6 +60,8 @@
mDropDownPreference = new DropDownPreference(mContext);
mDropDownPreference.setEntries(R.array.wifi_privacy_entries);
mDropDownPreference.setEntryValues(R.array.wifi_privacy_values);
+
+ perferenceString = mContext.getResources().getStringArray(R.array.wifi_privacy_entries);
}
@Test
@@ -67,7 +70,8 @@
mPreferenceController.updateState(mDropDownPreference);
- assertThat(mDropDownPreference.getEntry()).isEqualTo("Trusted");
+
+ assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[PRIVACY_TRUSTED]);
}
@Test
@@ -76,7 +80,7 @@
mPreferenceController.updateState(mDropDownPreference);
- assertThat(mDropDownPreference.getEntry()).isEqualTo("Default (use randomized MAC)");
+ assertThat(mDropDownPreference.getEntry()).isEqualTo(perferenceString[PRIVACY_RANDOMIZED]);
}
@Test
diff --git a/tests/robotests/src/com/android/settings/wifi/dpp/WifiNetworkConfigTest.java b/tests/robotests/src/com/android/settings/wifi/dpp/WifiNetworkConfigTest.java
new file mode 100644
index 0000000..1b7c0a8
--- /dev/null
+++ b/tests/robotests/src/com/android/settings/wifi/dpp/WifiNetworkConfigTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.wifi.dpp;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.content.Intent;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+
+@RunWith(RobolectricTestRunner.class)
+public class WifiNetworkConfigTest {
+ private WifiNetworkConfig mWifiConfig;
+
+ @Before
+ public void setUp() {
+ Intent intent = new Intent();
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "Pixel:_ABCD;");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WPA");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "\\012345678,");
+ mWifiConfig = WifiNetworkConfig.getValidConfigOrNull(intent);
+ }
+
+ @Test
+ public void testInitConfig_IntentReceived_QRCodeValue() {
+ String qrcode = mWifiConfig.getQrCode();
+ assertThat(qrcode).isEqualTo("WIFI:S:Pixel\\:_ABCD\\;;T:WPA;P:\\\\012345678\\,;H:false;;");
+ }
+}
\ No newline at end of file
diff --git a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
index 0ef0273..a57fefc 100644
--- a/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/qrcode/QrCameraTest.java
@@ -85,6 +85,11 @@
public void setTransform(Matrix transform) {
// Do nothing
}
+
+ @Override
+ public boolean isValid(String qrCode) {
+ return true;
+ }
}
private ScannerTestCallback mScannerCallback;
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
index bf5fba8..b7f713d 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/ContextualWifiSliceTest.java
@@ -29,14 +29,12 @@
import androidx.core.graphics.drawable.IconCompat;
import androidx.slice.Slice;
-import androidx.slice.SliceItem;
import androidx.slice.SliceMetadata;
import androidx.slice.SliceProvider;
import androidx.slice.core.SliceAction;
import androidx.slice.widget.SliceLiveData;
import com.android.settings.R;
-import com.android.settings.testutils.SliceTester;
import org.junit.Before;
import org.junit.Test;
@@ -87,7 +85,9 @@
mWifiManager.connect(config, null /* listener */);
final Slice wifiSlice = mWifiSlice.getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
@@ -96,8 +96,5 @@
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_wireless);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
-
- final List<SliceItem> sliceItems = wifiSlice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.wifi_settings));
}
}
diff --git a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
index 3c78749..ae352cc 100644
--- a/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/slice/WifiSliceTest.java
@@ -81,7 +81,9 @@
@Test
public void getWifiSlice_shouldHaveTitleAndToggle() {
final Slice wifiSlice = mWifiSlice.getSlice();
+
final SliceMetadata metadata = SliceMetadata.from(mContext, wifiSlice);
+ assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.wifi_settings));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
@@ -90,9 +92,6 @@
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext,
R.drawable.ic_settings_wireless);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
-
- final List<SliceItem> sliceItems = wifiSlice.getItems();
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.wifi_settings));
}
@Test
@@ -119,7 +118,8 @@
// All AP rows + title row
assertThat(rows).isEqualTo(DEFAULT_EXPANDED_ROW_COUNT + 1);
// Has scanning text
- SliceTester.assertTitle(sliceItems, mContext.getString(R.string.wifi_empty_list_wifi_on));
+ SliceTester.assertAnySliceItemContainsTitle(sliceItems,
+ mContext.getString(R.string.wifi_empty_list_wifi_on));
}
@Test
diff --git a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
index 40d651e..cdc74b3 100644
--- a/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
+++ b/tests/robotests/src/com/android/settings/wifi/tether/WifiTetherSettingsTest.java
@@ -35,6 +35,9 @@
import android.os.UserManager;
import android.widget.TextView;
+import androidx.fragment.app.FragmentActivity;
+import androidx.preference.PreferenceScreen;
+
import com.android.settings.testutils.FakeFeatureFactory;
import com.android.settings.testutils.shadow.ShadowWifiManager;
@@ -51,15 +54,13 @@
import java.util.ArrayList;
import java.util.List;
-import androidx.fragment.app.FragmentActivity;
-import androidx.preference.PreferenceScreen;
-
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowWifiManager.class})
public class WifiTetherSettingsTest {
private static final String[] WIFI_REGEXS = {"wifi_regexs"};
private Context mContext;
+ private WifiTetherSettings mWifiTetherSettings;
@Mock
private ConnectivityManager mConnectivityManager;
@@ -75,6 +76,8 @@
.when(mContext).getSystemService(Context.CONNECTIVITY_SERVICE);
doReturn(WIFI_REGEXS).when(mConnectivityManager).getTetherableWifiRegexs();
doReturn(mUserManager).when(mContext).getSystemService(Context.USER_SERVICE);
+
+ mWifiTetherSettings = new WifiTetherSettings();
}
@Test
@@ -136,6 +139,15 @@
verify(screen).removeAll();
}
+ @Test
+ public void createPreferenceControllers_hasAutoOffPreference() {
+ assertThat(mWifiTetherSettings.createPreferenceControllers(mContext)
+ .stream()
+ .filter(controller -> controller instanceof WifiTetherAutoOffPreferenceController)
+ .count())
+ .isEqualTo(1);
+ }
+
private void setupIsTetherAvailable(boolean returnValue) {
when(mConnectivityManager.isTetheringSupported()).thenReturn(true);
diff --git a/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java b/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java
index d47cd0d..eefd1eb 100644
--- a/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java
+++ b/tests/uitests/src/com/android/settings/ui/StorageWizardTest.java
@@ -86,7 +86,7 @@
InstrumentationRegistry.getContext().startActivity(buildInitIntent());
// Activity: pick option to use as internal
- waitFor(By.res(PACKAGE, "suw_layout_title").text(containsIgnoringCase("How will you use")));
+ waitFor(By.res(PACKAGE, "suc_layout_title").text(containsIgnoringCase("How will you use")));
waitFor(By.res(PACKAGE, "storage_wizard_init_internal")).click();
// Dialog: acknowledge that we're formatting the card
@@ -94,15 +94,15 @@
waitFor(By.clickable(true).text(containsIgnoringCase("Format"))).click();
// Activity: ack storage device is slow
- waitForLong(By.res(PACKAGE, "suw_layout_title").textContains("Slow"));
+ waitForLong(By.res(PACKAGE, "suc_layout_title").textContains("Slow"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
// Activity: choose to move content
- waitForLong(By.res(PACKAGE, "suw_layout_title").textContains("Move content"));
+ waitForLong(By.res(PACKAGE, "suc_layout_title").textContains("Move content"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
// Activity: yay, we're done!
- waitForLong(By.res(PACKAGE, "suw_layout_title").textContains("ready to use"));
+ waitForLong(By.res(PACKAGE, "suc_layout_title").textContains("ready to use"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
}
@@ -114,11 +114,11 @@
InstrumentationRegistry.getContext().startActivity(buildInitIntent());
// Activity: pick option to use as external
- waitFor(By.res(PACKAGE, "suw_layout_title").textContains("How will you use"));
+ waitFor(By.res(PACKAGE, "suc_layout_title").textContains("How will you use"));
waitFor(By.res(PACKAGE, "storage_wizard_init_external")).click();
// Activity: yay, we're done!
- waitFor(By.res(PACKAGE, "suw_layout_title").textContains("ready to use"));
+ waitFor(By.res(PACKAGE, "suc_layout_title").textContains("ready to use"));
waitFor(By.res(PACKAGE, "storage_next_button")).click();
}
diff --git a/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java b/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java
index 9a6b754..3b4abfe 100644
--- a/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java
+++ b/tests/unit/src/com/android/settings/EncryptionInterstitialTest.java
@@ -35,6 +35,9 @@
import androidx.test.filters.MediumTest;
import androidx.test.runner.AndroidJUnit4;
+import com.google.android.setupcompat.PartnerCustomizationLayout;
+import com.google.android.setupcompat.template.ButtonFooterMixin;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -63,10 +66,11 @@
@Test
public void clickYes_shouldRequirePassword() {
- mInstrumentation.startActivitySync(
+ final Activity activity = mInstrumentation.startActivitySync(
new Intent(mContext, EncryptionInterstitial.class)
.putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent")));
- onView(withId(R.id.encrypt_require_password)).perform(click());
+ final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getPrimaryButtonView().performClick();
mActivityMonitor.waitForActivityWithTimeout(1000);
assertEquals(1, mActivityMonitor.getHits());
@@ -77,10 +81,11 @@
@Test
public void clickNo_shouldNotRequirePassword() {
- mInstrumentation.startActivitySync(
+ final Activity activity = mInstrumentation.startActivitySync(
new Intent(mContext, EncryptionInterstitial.class)
.putExtra("extra_unlock_method_intent", new Intent("test.unlock.intent")));
- onView(withId(R.id.encrypt_dont_require_password)).perform(click());
+ final PartnerCustomizationLayout layout = activity.findViewById(R.id.setup_wizard_layout);
+ layout.getMixin(ButtonFooterMixin.class).getSecondaryButtonView().performClick();
mActivityMonitor.waitForActivityWithTimeout(1000);
assertEquals(1, mActivityMonitor.getHits());
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
index 235f182..215b7e2 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppConfiguratorActivityTest.java
@@ -19,6 +19,7 @@
import static com.google.common.truth.Truth.assertThat;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import androidx.test.rule.ActivityTestRule;
import androidx.test.runner.AndroidJUnit4;
@@ -29,6 +30,10 @@
@RunWith(AndroidJUnit4.class)
public class WifiDppConfiguratorActivityTest {
+ // Valid Wi-Fi DPP QR code & it's parameters
+ private static final String VALID_WIFI_DPP_QR_CODE = "DPP:I:SN=4774LH2b4044;M:010203040506;K:"
+ + "MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;";
+
@Rule
public final ActivityTestRule<WifiDppConfiguratorActivity> mActivityRule =
new ActivityTestRule<>(WifiDppConfiguratorActivity.class);
@@ -38,6 +43,7 @@
Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
mActivityRule.launchActivity(intent);
@@ -50,6 +56,7 @@
WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_GENERATOR);
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
mActivityRule.launchActivity(intent);
@@ -59,7 +66,8 @@
@Test
public void launchActivity_chooseSavedWifiNetwork_shouldNotAutoFinish() {
Intent intent = new Intent(
- WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_CHOOSE_SAVED_WIFI_NETWORK);
+ WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
+ intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
mActivityRule.launchActivity(intent);
@@ -80,4 +88,75 @@
assertThat(activity instanceof WifiDppQrCodeGeneratorFragment
.OnQrCodeGeneratorFragmentAddButtonClickedListener).isEqualTo(true);
}
+
+ @Test
+ public void testActivity_shouldImplementsOnScanWifiDppSuccessCallback() {
+ WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
+
+ assertThat(activity instanceof WifiDppQrCodeScannerFragment
+ .OnScanWifiDppSuccessListener).isEqualTo(true);
+ }
+
+ @Test
+ public void testActivity_shouldImplementsOnScanZxingWifiFormatSuccessCallback() {
+ WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
+
+ assertThat(activity instanceof WifiDppQrCodeScannerFragment
+ .OnScanZxingWifiFormatSuccessListener).isEqualTo(true);
+ }
+
+ @Test
+ public void testActivity_shouldImplementsOnClickChooseDifferentNetworkCallback() {
+ WifiDppConfiguratorActivity activity = mActivityRule.getActivity();
+
+ assertThat(activity instanceof WifiDppAddDeviceFragment
+ .OnClickChooseDifferentNetworkListener).isEqualTo(true);
+ }
+
+ @Test
+ public void rotateScreen_shouldGetCorrectWifiDppQrCode() {
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_WIFI_DPP_QR_CODE);
+ Intent intent = new Intent(WifiDppConfiguratorActivity.ACTION_CONFIGURATOR_QR_CODE_SCANNER);
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SECURITY, "WEP");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_SSID, "GoogleGuest");
+ intent.putExtra(WifiDppUtils.EXTRA_WIFI_PRE_SHARED_KEY, "password");
+
+ // setWifiDppQrCode and check if getWifiDppQrCode correctly after rotation
+ mActivityRule.launchActivity(intent);
+ mActivityRule.getActivity().setWifiDppQrCode(wifiQrCode);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ WifiQrCode restoredWifiDppQrCode = mActivityRule.getActivity().getWifiDppQrCode();
+
+ assertThat(restoredWifiDppQrCode).isNotNull();
+ assertThat(restoredWifiDppQrCode.getQrCode()).isEqualTo(VALID_WIFI_DPP_QR_CODE);
+ }
+
+ @Test
+ public void rotateScreen_shouldGetCorrectWifiNetworkConfig() {
+ WifiNetworkConfig wifiNetworkConfig = new WifiNetworkConfig("WPA", "WifiSsid", "password",
+ /* hiddenSsid */ false, /* networkId */ 0);
+ Intent intent = new Intent(
+ WifiDppConfiguratorActivity.ACTION_PROCESS_WIFI_DPP_QR_CODE);
+ intent.putExtra(WifiDppUtils.EXTRA_QR_CODE, VALID_WIFI_DPP_QR_CODE);
+
+ // setWifiNetworkConfig and check if getWifiNetworkConfig correctly after rotation
+ mActivityRule.launchActivity(intent);
+ mActivityRule.getActivity().setWifiNetworkConfig(wifiNetworkConfig);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ mActivityRule.getActivity().setRequestedOrientation(
+ ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ WifiNetworkConfig restoredWifiNetworkConfig =
+ mActivityRule.getActivity().getWifiNetworkConfig();
+
+ assertThat(restoredWifiNetworkConfig).isNotNull();
+ assertThat(restoredWifiNetworkConfig.getSecurity()).isEqualTo("WPA");
+ assertThat(restoredWifiNetworkConfig.getSsid()).isEqualTo("WifiSsid");
+ assertThat(restoredWifiNetworkConfig.getPreSharedKey()).isEqualTo("password");
+ assertThat(restoredWifiNetworkConfig.getHiddenSsid()).isFalse();
+ assertThat(restoredWifiNetworkConfig.getNetworkId()).isEqualTo(0);
+ }
}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java
new file mode 100644
index 0000000..283da13
--- /dev/null
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiDppEnrolleeActivityTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.wifi.dpp;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import androidx.test.rule.ActivityTestRule;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class WifiDppEnrolleeActivityTest {
+ @Rule
+ public final ActivityTestRule<WifiDppEnrolleeActivity> mActivityRule =
+ new ActivityTestRule<>(WifiDppEnrolleeActivity.class);
+
+ @Test
+ public void testActivity_shouldImplementsOnScanWifiDppSuccessCallback() {
+ WifiDppEnrolleeActivity activity = mActivityRule.getActivity();
+
+ assertThat(activity instanceof WifiDppQrCodeScannerFragment
+ .OnScanWifiDppSuccessListener).isEqualTo(true);
+ }
+
+ @Test
+ public void testActivity_shouldImplementsOnScanZxingWifiFormatSuccessCallback() {
+ WifiDppEnrolleeActivity activity = mActivityRule.getActivity();
+
+ assertThat(activity instanceof WifiDppQrCodeScannerFragment
+ .OnScanZxingWifiFormatSuccessListener).isEqualTo(true);
+ }
+}
diff --git a/tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodetest.java b/tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodeTest.java
similarity index 83%
rename from tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodetest.java
rename to tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodeTest.java
index 775ca48..3595597 100644
--- a/tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodetest.java
+++ b/tests/unit/src/com/android/settings/wifi/dpp/WifiQrCodeTest.java
@@ -29,7 +29,7 @@
@SmallTest
@RunWith(AndroidJUnit4.class)
-public class WifiQrCodetest {
+public class WifiQrCodeTest {
// Valid Wi-Fi DPP QR code & it's parameters
private static final String VALID_WIFI_DPP_QR_CODE = "DPP:I:SN=4774LH2b4044;M:010203040506;K:"
+ "MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;";
@@ -57,6 +57,13 @@
private static final String SSID_OF_VALID_ZXING_WIFI_QR_CODE = "mynetwork";
private static final String PASSWORD_OF_VALID_ZXING_WIFI_QR_CODE = "mypass";
+ // Valid ZXing reader library's Wi-Fi Network config format - escaped characters
+ private static final String VALID_ZXING_WIFI_QR_CODE_SPECIAL_CHARACTERS =
+ "WIFI:T:WPA;S:mynetwork;P:m\\;y\\:p\\\\a\\,ss;H:true;;";
+
+ private static final String PASSWORD_OF_VALID_ZXING_WIFI_QR_CODE_SPECIAL_CHARACTERS =
+ "m;y:p\\a,ss";
+
// Invalid scheme QR code
private static final String INVALID_SCHEME_QR_CODE = "BT:T:WPA;S:mynetwork;P:mypass;H:true;;";
@@ -118,19 +125,35 @@
assertEquals(WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG, wifiQrCode.getScheme());
assertNotNull(config);
- assertNull(config.getSecurity());
+ assertEquals("", config.getSecurity());
assertEquals(SSID_OF_VALID_ZXING_WIFI_QR_CODE, config.getSsid());
- assertNull(config.getPreSharedKey());
+ assertEquals("", config.getPreSharedKey());
assertEquals(false, config.getHiddenSsid());
}
@Test
+ public void parseValidZxingWifiQrCode_specialCharacters() {
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_ZXING_WIFI_QR_CODE_SPECIAL_CHARACTERS);
+ WifiNetworkConfig config = wifiQrCode.getWifiNetworkConfig();
+
+ assertEquals(WifiQrCode.SCHEME_ZXING_WIFI_NETWORK_CONFIG, wifiQrCode.getScheme());
+ assertNotNull(config);
+ assertEquals(SECURITY_OF_VALID_ZXING_WIFI_QR_CODE, config.getSecurity());
+ assertEquals(SSID_OF_VALID_ZXING_WIFI_QR_CODE, config.getSsid());
+ assertEquals(PASSWORD_OF_VALID_ZXING_WIFI_QR_CODE_SPECIAL_CHARACTERS,
+ config.getPreSharedKey());
+ assertEquals(true, config.getHiddenSsid());
+ }
+
+ @Test
public void testRemoveBackSlash() {
- assertEquals("\\", WifiQrCode.removeBackSlash("\\\\"));
- assertEquals("ab", WifiQrCode.removeBackSlash("a\\b"));
- assertEquals("a", WifiQrCode.removeBackSlash("\\a"));
- assertEquals("\\b", WifiQrCode.removeBackSlash("\\\\b"));
- assertEquals("c\\", WifiQrCode.removeBackSlash("c\\\\"));
+ WifiQrCode wifiQrCode = new WifiQrCode(VALID_WIFI_DPP_QR_CODE);
+
+ assertEquals("\\", wifiQrCode.removeBackSlash("\\\\"));
+ assertEquals("ab", wifiQrCode.removeBackSlash("a\\b"));
+ assertEquals("a", wifiQrCode.removeBackSlash("\\a"));
+ assertEquals("\\b", wifiQrCode.removeBackSlash("\\\\b"));
+ assertEquals("c\\", wifiQrCode.removeBackSlash("c\\\\"));
}
@Test