From 46b5474be42204086df3b89966ad991c7ce9044d Mon Sep 17 00:00:00 2001 From: Fan Zhang Date: Wed, 10 Jan 2018 12:22:36 -0800 Subject: [PATCH] Update master switch style - When off, background grey - When on, background accent - Switch toggle always white, only change the slider color during on/off Change-Id: I0ca49439f4e20e75517d503f28cc3068930591e8 Bug: 69462439 Test: robotests --- color-check-baseline.xml | 154 +++++++++------------ res/color/switchbar_switch_thumb_tint.xml | 20 +++ res/color/switchbar_switch_track_tint.xml | 21 +++ res/layout/settings_main_prefs.xml | 16 +-- res/layout/styled_switch_bar.xml | 4 +- res/layout/switch_bar.xml | 52 +++---- res/layout/wifi_calling_settings_preferences.xml | 5 +- res/values-sw600dp/dimens.xml | 1 - res/values/attrs.xml | 1 + res/values/colors.xml | 2 + res/values/dimens.xml | 2 +- res/values/themes.xml | 21 ++- src/com/android/settings/widget/SwitchBar.java | 57 ++++---- .../settings/widget/SwitchBarController.java | 2 +- src/com/android/settings/widget/ToggleSwitch.java | 4 +- .../com/android/settings/widget/SwitchBarTest.java | 30 ++-- 16 files changed, 210 insertions(+), 182 deletions(-) create mode 100644 res/color/switchbar_switch_thumb_tint.xml create mode 100644 res/color/switchbar_switch_track_tint.xml diff --git a/color-check-baseline.xml b/color-check-baseline.xml index 6fa20421e3..506770cc83 100644 --- a/color-check-baseline.xml +++ b/color-check-baseline.xml @@ -2,18 +2,6 @@ - - - - + + + + @@ -777,7 +781,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -793,7 +797,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -809,7 +813,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -825,7 +829,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -841,7 +845,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -857,7 +861,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -873,7 +877,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -889,7 +893,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -905,7 +909,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -921,7 +925,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -937,7 +941,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -953,7 +957,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -969,7 +973,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -985,7 +989,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1001,7 +1005,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1017,7 +1021,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1033,7 +1037,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1049,7 +1053,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1065,7 +1069,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1305,7 +1309,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1321,7 +1325,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1337,7 +1341,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1353,7 +1357,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1369,7 +1373,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1385,7 +1389,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1401,7 +1405,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -1417,7 +1421,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~"> @@ -2073,7 +2077,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2089,7 +2093,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2105,7 +2109,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2121,7 +2125,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2137,7 +2141,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2153,7 +2157,7 @@ errorLine2=" ~~~~~~~~~~~~~~~~~~~"> @@ -2181,27 +2185,11 @@ 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="android:colorAccent">#ff009688</item>" - errorLine2=" ^"> - - - - @@ -2217,7 +2205,7 @@ errorLine2=" ^"> @@ -2233,7 +2221,7 @@ errorLine2=" ^"> @@ -2249,7 +2237,7 @@ errorLine2=" ^"> @@ -2393,7 +2381,7 @@ errorLine2=" ^"> @@ -2409,7 +2397,7 @@ errorLine2=" ^"> @@ -2425,7 +2413,7 @@ errorLine2=" ^"> @@ -2437,11 +2425,11 @@ 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="switchBarBackgroundColor">@color/material_grey_200</item>" + errorLine1=" <item name="switchBarBackgroundColor">@color/switch_bar_background</item>" errorLine2=" ^"> @@ -2453,27 +2441,11 @@ 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="android:colorControlActivated">@color/material_blue_500</item>" - errorLine2=" ^"> - - - - @@ -2489,7 +2461,7 @@ errorLine2=" ^"> @@ -2505,7 +2477,7 @@ errorLine2=" ^"> @@ -2521,7 +2493,7 @@ errorLine2=" ^"> diff --git a/res/color/switchbar_switch_thumb_tint.xml b/res/color/switchbar_switch_thumb_tint.xml new file mode 100644 index 0000000000..4c75a7e4cc --- /dev/null +++ b/res/color/switchbar_switch_thumb_tint.xml @@ -0,0 +1,20 @@ + + + + + + \ No newline at end of file diff --git a/res/color/switchbar_switch_track_tint.xml b/res/color/switchbar_switch_track_tint.xml new file mode 100644 index 0000000000..141f9775bb --- /dev/null +++ b/res/color/switchbar_switch_track_tint.xml @@ -0,0 +1,21 @@ + + + + + + \ No newline at end of file diff --git a/res/layout/settings_main_prefs.xml b/res/layout/settings_main_prefs.xml index 4f08679c22..c4c0af570b 100644 --- a/res/layout/settings_main_prefs.xml +++ b/res/layout/settings_main_prefs.xml @@ -31,15 +31,12 @@ + android:theme="?attr/switchBarTheme" /> + android:layout_height="match_parent" /> @@ -54,8 +51,7 @@ android:layout_height="wrap_content" android:layout_margin="5dip" android:layout_alignParentStart="true" - android:text="@*android:string/back_button_label" - /> + android:text="@*android:string/back_button_label" /> + android:visibility="gone" />