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
diff --git a/color-check-baseline.xml b/color-check-baseline.xml
index 6fa2042..506770c 100644
--- a/color-check-baseline.xml
+++ b/color-check-baseline.xml
@@ -2,18 +2,6 @@
<issues format="4">
<issue
- id="LintError"
- severity="Error"
- message="No `.class` files were found in project ".", so none of the classfile based checks could be run. Does the project need to be built first?"
- category="Lint"
- priority="10"
- summary="Lint Failure"
- explanation="This issue type represents a problem running lint itself. Examples include failure to find bytecode for source files (which means certain detectors could not be run), parsing errors in lint configuration files, etc.
These errors are not errors in your own code, but they are shown to make it clear that some checks were not completed.">
- <location
- file="."/>
- </issue>
-
- <issue
id="HardCodedColor"
severity="Error"
message="Avoid using hardcoded color"
@@ -757,11 +745,27 @@
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="switch_bar_background">#ff80868B</color>"
+ errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
+ <location
+ file="res/values/colors.xml"
+ line="84"
+ 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="message_text_incoming">#ffffffff</color>"
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="85"
+ line="87"
column="5"/>
</issue>
@@ -777,7 +781,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="86"
+ line="88"
column="5"/>
</issue>
@@ -793,7 +797,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="87"
+ line="89"
column="5"/>
</issue>
@@ -809,7 +813,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="88"
+ line="90"
column="5"/>
</issue>
@@ -825,7 +829,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="89"
+ line="91"
column="5"/>
</issue>
@@ -841,7 +845,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="90"
+ line="92"
column="5"/>
</issue>
@@ -857,7 +861,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="91"
+ line="93"
column="5"/>
</issue>
@@ -873,7 +877,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="92"
+ line="94"
column="5"/>
</issue>
@@ -889,7 +893,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="93"
+ line="95"
column="5"/>
</issue>
@@ -905,7 +909,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="94"
+ line="96"
column="5"/>
</issue>
@@ -921,7 +925,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="95"
+ line="97"
column="5"/>
</issue>
@@ -937,7 +941,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="98"
+ line="100"
column="5"/>
</issue>
@@ -953,7 +957,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="100"
+ line="102"
column="5"/>
</issue>
@@ -969,7 +973,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="103"
+ line="105"
column="5"/>
</issue>
@@ -985,7 +989,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="105"
+ line="107"
column="5"/>
</issue>
@@ -1001,7 +1005,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="108"
+ line="110"
column="5"/>
</issue>
@@ -1017,7 +1021,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="111"
+ line="113"
column="5"/>
</issue>
@@ -1033,7 +1037,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="114"
+ line="116"
column="5"/>
</issue>
@@ -1049,7 +1053,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="117"
+ line="119"
column="5"/>
</issue>
@@ -1065,7 +1069,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/colors.xml"
- line="118"
+ line="120"
column="5"/>
</issue>
@@ -1305,7 +1309,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
- line="17"
+ line="32"
column="23"/>
</issue>
@@ -1321,7 +1325,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
- line="18"
+ line="33"
column="23"/>
</issue>
@@ -1337,7 +1341,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
- line="32"
+ line="47"
column="23"/>
</issue>
@@ -1353,7 +1357,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_color_inversion.xml"
- line="33"
+ line="48"
column="23"/>
</issue>
@@ -1369,7 +1373,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
- line="16"
+ line="31"
column="27"/>
</issue>
@@ -1385,7 +1389,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
- line="17"
+ line="32"
column="27"/>
</issue>
@@ -1401,7 +1405,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
- line="36"
+ line="51"
column="23"/>
</issue>
@@ -1417,7 +1421,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
<location
file="res/drawable/ic_daltonizer.xml"
- line="37"
+ line="52"
column="23"/>
</issue>
@@ -2073,7 +2077,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rXC/strings.xml"
- line="2333"
+ line="2353"
column="168"/>
</issue>
@@ -2089,7 +2093,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rAU/strings.xml"
- line="2334"
+ line="2354"
column="64"/>
</issue>
@@ -2105,7 +2109,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rCA/strings.xml"
- line="2334"
+ line="2354"
column="64"/>
</issue>
@@ -2121,7 +2125,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rGB/strings.xml"
- line="2334"
+ line="2354"
column="64"/>
</issue>
@@ -2137,7 +2141,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values-en-rIN/strings.xml"
- line="2334"
+ line="2354"
column="64"/>
</issue>
@@ -2153,7 +2157,7 @@
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
<location
file="res/values/strings.xml"
- line="5512"
+ line="5539"
column="36"/>
</issue>
@@ -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=" ^">
- <location
- file="res/values/styles.xml"
- line="366"
- column="42"/>
- </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="*android:regularColor">@color/lock_pattern_view_regular_color</item>"
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="443"
+ line="442"
column="44"/>
</issue>
@@ -2217,7 +2205,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="449"
+ line="448"
column="44"/>
</issue>
@@ -2233,7 +2221,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="450"
+ line="449"
column="44"/>
</issue>
@@ -2249,7 +2237,7 @@
errorLine2=" ^">
<location
file="res/values/styles.xml"
- line="473"
+ line="472"
column="41"/>
</issue>
@@ -2393,7 +2381,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="139"
+ line="154"
column="43"/>
</issue>
@@ -2409,7 +2397,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="140"
+ line="155"
column="42"/>
</issue>
@@ -2425,7 +2413,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="141"
+ line="156"
column="45"/>
</issue>
@@ -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=" ^">
<location
file="res/values/themes.xml"
- line="147"
+ line="233"
column="47"/>
</issue>
@@ -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=" ^">
- <location
- file="res/values/themes.xml"
- line="148"
- column="52"/>
- </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="android:statusBarColor">#00000000</item>"
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="298"
+ line="316"
column="45"/>
</issue>
@@ -2489,7 +2461,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="299"
+ line="317"
column="49"/>
</issue>
@@ -2505,7 +2477,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="307"
+ line="325"
column="45"/>
</issue>
@@ -2521,7 +2493,7 @@
errorLine2=" ^">
<location
file="res/values/themes.xml"
- line="308"
+ line="326"
column="49"/>
</issue>
diff --git a/res/color/switchbar_switch_thumb_tint.xml b/res/color/switchbar_switch_thumb_tint.xml
new file mode 100644
index 0000000..4c75a7e
--- /dev/null
+++ b/res/color/switchbar_switch_thumb_tint.xml
@@ -0,0 +1,20 @@
+<?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.
+ -->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="#FFFFFF" />
+</selector>
\ 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 0000000..141f977
--- /dev/null
+++ b/res/color/switchbar_switch_track_tint.xml
@@ -0,0 +1,21 @@
+<?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.
+ -->
+
+<selector
+ xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="#BFFFFFFF" />
+</selector>
\ No newline at end of file
diff --git a/res/layout/settings_main_prefs.xml b/res/layout/settings_main_prefs.xml
index 4f08679..c4c0af5 100644
--- a/res/layout/settings_main_prefs.xml
+++ b/res/layout/settings_main_prefs.xml
@@ -31,15 +31,12 @@
<com.android.settings.widget.SwitchBar android:id="@+id/switch_bar"
android:layout_height="?android:attr/actionBarSize"
android:layout_width="match_parent"
- android:background="@drawable/switchbar_background"
- android:theme="?attr/switchBarTheme"
- />
+ android:theme="?attr/switchBarTheme" />
<FrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
- android:layout_height="match_parent"
- />
+ android:layout_height="match_parent" />
</LinearLayout>
@@ -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" />
<LinearLayout
android:orientation="horizontal"
@@ -68,15 +64,13 @@
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:text="@*android:string/skip_button_label"
- android:visibility="gone"
- />
+ android:visibility="gone" />
<Button android:id="@+id/next_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
- android:text="@*android:string/next_button_label"
- />
+ android:text="@*android:string/next_button_label" />
</LinearLayout>
diff --git a/res/layout/styled_switch_bar.xml b/res/layout/styled_switch_bar.xml
index dd61907..1777c0f 100644
--- a/res/layout/styled_switch_bar.xml
+++ b/res/layout/styled_switch_bar.xml
@@ -25,7 +25,5 @@
android:layout_height="?android:attr/actionBarSize"
android:layout_width="match_parent"
android:paddingStart="0dp"
- android:background="@drawable/switchbar_background"
- android:theme="?attr/switchBarTheme"
- />
+ android:theme="?attr/switchBarTheme" />
</LinearLayout>
\ No newline at end of file
diff --git a/res/layout/switch_bar.xml b/res/layout/switch_bar.xml
index 11d7306..29e125b 100644
--- a/res/layout/switch_bar.xml
+++ b/res/layout/switch_bar.xml
@@ -17,33 +17,37 @@
*/
-->
-<merge xmlns:android="http://schemas.android.com/apk/res/android" >
+<merge xmlns:android="http://schemas.android.com/apk/res/android">
- <TextView android:id="@+id/switch_text"
- android:layout_height="wrap_content"
- android:layout_width="0dp"
- android:layout_weight="1"
- android:layout_gravity="center_vertical"
- android:maxLines="2"
- android:ellipsize="end"
- android:textAppearance="@style/TextAppearance.Switch"
- android:textColor="?android:attr/textColorPrimary"
- android:textAlignment="viewStart" />
+ <TextView
+ android:id="@+id/switch_text"
+ android:layout_height="wrap_content"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_gravity="center_vertical"
+ android:maxLines="2"
+ android:ellipsize="end"
+ android:textAppearance="@style/TextAppearance.Switch"
+ android:textColor="?android:attr/textColorPrimary"
+ android:textSize="18sp"
+ android:textAlignment="viewStart" />
- <ImageView android:id="@+id/restricted_icon"
- android:layout_width="@dimen/restricted_icon_size"
- android:layout_height="@dimen/restricted_icon_size"
- android:src="@drawable/ic_info"
- android:theme="@android:style/Theme.Material"
- android:layout_gravity="center_vertical"
- android:layout_marginEnd="@dimen/restricted_icon_margin_end"
- android:visibility="gone" />
+ <ImageView
+ android:id="@+id/restricted_icon"
+ android:layout_width="@dimen/restricted_icon_size"
+ android:layout_height="@dimen/restricted_icon_size"
+ android:src="@drawable/ic_info"
+ android:theme="@android:style/Theme.Material"
+ android:layout_gravity="center_vertical"
+ android:layout_marginEnd="@dimen/restricted_icon_margin_end"
+ android:visibility="gone" />
- <com.android.settings.widget.ToggleSwitch android:id="@+id/switch_widget"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:theme="@style/ThemeOverlay.SwitchBar.Settings" />
+ <com.android.settings.widget.ToggleSwitch
+ android:id="@+id/switch_widget"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:theme="@style/Widget.SwitchBar.Switch" />
</merge>
diff --git a/res/layout/wifi_calling_settings_preferences.xml b/res/layout/wifi_calling_settings_preferences.xml
index 4e64f40..7e411e1 100644
--- a/res/layout/wifi_calling_settings_preferences.xml
+++ b/res/layout/wifi_calling_settings_preferences.xml
@@ -14,8 +14,8 @@
limitations under the License.
-->
-
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tabs_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -25,7 +25,6 @@
android:id="@+id/switch_bar"
android:layout_height="?android:attr/actionBarSize"
android:layout_width="match_parent"
- android:background="@drawable/switchbar_background"
android:theme="?attr/switchBarTheme" />
<FrameLayout
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 1f78abd..8e47a62 100755
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -57,7 +57,6 @@
<!-- SwitchBar sub settings margin start / end -->
<dimen name="switchbar_subsettings_margin_start">80dp</dimen>
- <dimen name="switchbar_subsettings_margin_end">24dp</dimen>
<dimen name="search_bar_height">64dp</dimen>
<dimen name="search_bar_half_height">32dp</dimen>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index e3fa070..2d48e42 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -123,6 +123,7 @@
<attr name="switchBarMarginStart" format="dimension" />
<attr name="switchBarMarginEnd" format="dimension" />
<attr name="switchBarBackgroundColor" format="color" />
+ <attr name="switchBarBackgroundActivatedColor" format="color" />
<attr name="preferenceBackgroundColor" format="color" />
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 3e80ab4..72f2d91 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -81,6 +81,8 @@
<color name="material_blue_700">#3367D6</color>
<color name="material_grey_100">#f5f5f5</color>
<color name="material_grey_200">#ffffff</color>
+ <color name="switch_bar_background">#ff80868B</color>
+
<color name="message_text_incoming">#ffffffff</color>
<color name="message_text_outgoing">#ff323232</color>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ef4d269..8e61a70 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -112,7 +112,7 @@
<!-- SwitchBar sub settings margin start / end -->
<dimen name="switchbar_subsettings_margin_start">72dp</dimen>
- <dimen name="switchbar_subsettings_margin_end">16dp</dimen>
+ <dimen name="switchbar_subsettings_margin_end">24dp</dimen>
<!-- The following two margins need to match, with the caveat that
the second should be negative. The second one ensures that the icons and text
diff --git a/res/values/themes.xml b/res/values/themes.xml
index e3010a6..4d7780c 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -155,13 +155,7 @@
<item name="android:colorAccent">@color/material_blue_700</item>
<item name="android:titleTextColor">@color/material_blue_700</item>
<item name="preferenceTheme">@style/PreferenceTheme</item>
- <item name="switchBarTheme">@style/SetupWizardAccessibilitySwitchBarTheme</item>
- </style>
-
- <style name="SetupWizardAccessibilitySwitchBarTheme" parent="ThemeOverlay.SwitchBar.Settings">
- <item name="switchBarBackgroundColor">@color/material_grey_200</item>
- <item name="android:colorControlActivated">@color/material_blue_500</item>
- <item name="android:textColorPrimary">@android:color/black</item>
+ <item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.Settings</item>
</style>
<!-- Theme with no local references, used by AccountPreferenceBase where we have to inflate
@@ -205,7 +199,7 @@
<!-- Redefine the ActionBar style for contentInsetStart -->
<item name="android:actionBarStyle">@style/Theme.ActionBar.SubSettings</item>
- <item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.SubSettings</item>
+ <item name="switchBarTheme">@style/ThemeOverlay.SwitchBar.Settings</item>
</style>
<!-- Variant of the settings theme with no action bar. -->
@@ -233,15 +227,16 @@
</style>
<style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.ActionBar">
+ <item name="android:textColorPrimary">@android:color/white</item>
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
- <item name="switchBarBackgroundColor">?android:attr/colorSecondary</item>
+ <item name="switchBarBackgroundColor">@color/switch_bar_background</item>
+ <item name="switchBarBackgroundActivatedColor">?android:attr/colorAccent</item>
</style>
- <style name="ThemeOverlay.SwitchBar.SubSettings" parent="@android:style/ThemeOverlay.Material.ActionBar">
- <item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
- <item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
- <item name="switchBarBackgroundColor">?android:attr/colorSecondary</item>
+ <style name="Widget.SwitchBar.Switch" parent="@android:style/Widget.Material.CompoundButton.Switch">
+ <item name="android:trackTint">@color/switchbar_switch_track_tint</item>
+ <item name="android:thumbTint">@color/switchbar_switch_thumb_tint</item>
</style>
<style name="Theme.CryptKeeper" parent="@android:style/Theme.Material.NoActionBar">
diff --git a/src/com/android/settings/widget/SwitchBar.java b/src/com/android/settings/widget/SwitchBar.java
index 3c1e7c1..749ec0a 100644
--- a/src/com/android/settings/widget/SwitchBar.java
+++ b/src/com/android/settings/widget/SwitchBar.java
@@ -22,6 +22,8 @@
import android.content.res.TypedArray;
import android.os.Parcel;
import android.os.Parcelable;
+import android.support.annotation.ColorInt;
+import android.support.annotation.StringRes;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.TextAppearanceSpan;
@@ -42,6 +44,7 @@
import com.android.settingslib.RestrictedLockUtils;
import java.util.ArrayList;
+import java.util.List;
public class SwitchBar extends LinearLayout implements CompoundButton.OnCheckedChangeListener,
View.OnClickListener {
@@ -56,7 +59,14 @@
void onSwitchChanged(Switch switchView, boolean isChecked);
}
- private MetricsFeatureProvider mMetricsFeatureProvider;
+ private static final int[] XML_ATTRIBUTES = {
+ R.attr.switchBarMarginStart,
+ R.attr.switchBarMarginEnd,
+ R.attr.switchBarBackgroundColor,
+ R.attr.switchBarBackgroundActivatedColor};
+
+ private final List<OnSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
+ private final MetricsFeatureProvider mMetricsFeatureProvider;
private final TextAppearanceSpan mSummarySpan;
private ToggleSwitch mSwitch;
@@ -64,20 +74,20 @@
private TextView mTextView;
private String mLabel;
private String mSummary;
+ @ColorInt
+ private int mBackgroundColor;
+ @ColorInt
+ private int mBackgroundActivatedColor;
+ @StringRes
private int mOnTextId;
+ @StringRes
private int mOffTextId;
private boolean mLoggingIntialized;
private boolean mDisabledByAdmin;
private EnforcedAdmin mEnforcedAdmin = null;
-
private String mMetricsTag;
- private final ArrayList<OnSwitchChangeListener> mSwitchChangeListeners = new ArrayList<>();
-
- private static int[] XML_ATTRIBUTES = {
- R.attr.switchBarMarginStart, R.attr.switchBarMarginEnd,
- R.attr.switchBarBackgroundColor};
public SwitchBar(Context context) {
this(context, null);
@@ -99,32 +109,30 @@
final TypedArray a = context.obtainStyledAttributes(attrs, XML_ATTRIBUTES);
int switchBarMarginStart = (int) a.getDimension(0, 0);
int switchBarMarginEnd = (int) a.getDimension(1, 0);
- int switchBarBackgroundColor = (int) a.getColor(2, 0);
+ mBackgroundColor = a.getColor(2, 0);
+ mBackgroundActivatedColor = a.getColor(3, 0);
a.recycle();
- mTextView = (TextView) findViewById(R.id.switch_text);
+ mTextView = findViewById(R.id.switch_text);
mTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
mSummarySpan = new TextAppearanceSpan(mContext, R.style.TextAppearance_Small_SwitchBar);
ViewGroup.MarginLayoutParams lp = (MarginLayoutParams) mTextView.getLayoutParams();
lp.setMarginStart(switchBarMarginStart);
- mSwitch = (ToggleSwitch) findViewById(R.id.switch_widget);
+ mSwitch = findViewById(R.id.switch_widget);
// Prevent onSaveInstanceState() to be called as we are managing the state of the Switch
// on our own
mSwitch.setSaveEnabled(false);
mSwitch.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
+
lp = (MarginLayoutParams) mSwitch.getLayoutParams();
lp.setMarginEnd(switchBarMarginEnd);
- setBackgroundColor(switchBarBackgroundColor);
+ setBackgroundColor(mBackgroundColor);
setSwitchBarText(R.string.switch_on_text, R.string.switch_off_text);
- addOnSwitchChangeListener(new OnSwitchChangeListener() {
- @Override
- public void onSwitchChanged(Switch switchView, boolean isChecked) {
- setTextViewLabel(isChecked);
- }
- });
+ addOnSwitchChangeListener(
+ (switchView, isChecked) -> setTextViewLabelAndBackground(isChecked));
mRestrictedIcon = findViewById(R.id.restricted_icon);
@@ -140,15 +148,16 @@
mMetricsTag = tag;
}
- public void setTextViewLabel(boolean isChecked) {
+ public void setTextViewLabelAndBackground(boolean isChecked) {
mLabel = getResources().getString(isChecked ? mOnTextId : mOffTextId);
+ setBackgroundColor(isChecked ? mBackgroundActivatedColor : mBackgroundColor);
updateText();
}
public void setSwitchBarText(int onText, int offText) {
mOnTextId = onText;
mOffTextId = offText;
- setTextViewLabel(isChecked());
+ setTextViewLabelAndBackground(isChecked());
}
public void setSummary(String summary) {
@@ -169,12 +178,12 @@
}
public void setChecked(boolean checked) {
- setTextViewLabel(checked);
+ setTextViewLabelAndBackground(checked);
mSwitch.setChecked(checked);
}
public void setCheckedInternal(boolean checked) {
- setTextViewLabel(checked);
+ setTextViewLabelAndBackground(checked);
mSwitch.setCheckedInternal(checked);
}
@@ -290,8 +299,8 @@
*/
private SavedState(Parcel in) {
super(in);
- checked = (Boolean)in.readValue(null);
- visible = (Boolean)in.readValue(null);
+ checked = (Boolean) in.readValue(null);
+ visible = (Boolean) in.readValue(null);
}
@Override
@@ -338,7 +347,7 @@
super.onRestoreInstanceState(ss.getSuperState());
mSwitch.setCheckedInternal(ss.checked);
- setTextViewLabel(ss.checked);
+ setTextViewLabelAndBackground(ss.checked);
setVisibility(ss.visible ? View.VISIBLE : View.GONE);
mSwitch.setOnCheckedChangeListener(ss.visible ? this : null);
diff --git a/src/com/android/settings/widget/SwitchBarController.java b/src/com/android/settings/widget/SwitchBarController.java
index cc4c8dc..ede02af 100644
--- a/src/com/android/settings/widget/SwitchBarController.java
+++ b/src/com/android/settings/widget/SwitchBarController.java
@@ -43,7 +43,7 @@
@Override
public void updateTitle(boolean isChecked) {
- mSwitchBar.setTextViewLabel(isChecked);
+ mSwitchBar.setTextViewLabelAndBackground(isChecked);
}
@Override
diff --git a/src/com/android/settings/widget/ToggleSwitch.java b/src/com/android/settings/widget/ToggleSwitch.java
index 8232ff1..b392c8e 100644
--- a/src/com/android/settings/widget/ToggleSwitch.java
+++ b/src/com/android/settings/widget/ToggleSwitch.java
@@ -24,8 +24,8 @@
private ToggleSwitch.OnBeforeCheckedChangeListener mOnBeforeListener;
- public static interface OnBeforeCheckedChangeListener {
- public boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked);
+ public interface OnBeforeCheckedChangeListener {
+ boolean onBeforeCheckedChanged(ToggleSwitch toggleSwitch, boolean checked);
}
public ToggleSwitch(Context context) {
diff --git a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
index c805761..8eb19cd 100644
--- a/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
+++ b/tests/robotests/src/com/android/settings/widget/SwitchBarTest.java
@@ -17,10 +17,10 @@
package com.android.settings.widget;
import static com.google.common.truth.Truth.assertThat;
-
import static org.robolectric.RuntimeEnvironment.application;
import android.content.Context;
+import android.graphics.drawable.ColorDrawable;
import android.widget.TextView;
import com.android.settings.R;
@@ -38,36 +38,50 @@
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class SwitchBarTest {
+ private static final int COLOR_BACKGROUND = 1;
+ private static final int COLOR_BACKGROUND_ACTIVATED = 2;
+
private Context mContext;
private SwitchBar mBar;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
- mBar = new SwitchBar(application, Robolectric.buildAttributeSet().build());
+ mBar = new SwitchBar(application, Robolectric.buildAttributeSet()
+ .addAttribute(R.attr.switchBarBackgroundColor, String.valueOf(COLOR_BACKGROUND))
+ .addAttribute(R.attr.switchBarBackgroundActivatedColor,
+ String.valueOf(COLOR_BACKGROUND_ACTIVATED))
+ .build());
}
@Test
- public void testDefaultLabels() {
- int defaultOnText = R.string.switch_on_text;
- int defaultOffText = R.string.switch_off_text;
+ public void cycleChecked_defaultLabel_shouldUpdateTextAndBackground() {
+ final int defaultOnText = R.string.switch_on_text;
+ final int defaultOffText = R.string.switch_off_text;
+
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(defaultOffText));
+ assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND));
mBar.setChecked(true);
+
+ assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND_ACTIVATED));
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(defaultOnText));
}
@Test
- public void testCustomLabels() {
- int onText = R.string.master_clear_progress_text;
- int offText = R.string.manage_space_text;
+ public void cycleChecked_customLabel_shouldUpdateTextAndBackground() {
+ final int onText = R.string.master_clear_progress_text;
+ final int offText = R.string.manage_space_text;
+
mBar.setSwitchBarText(onText, offText);
+ assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND));
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(offText));
mBar.setChecked(true);
+ assertThat(mBar.getBackground()).isEqualTo(new ColorDrawable(COLOR_BACKGROUND_ACTIVATED));
assertThat(((TextView) mBar.findViewById(R.id.switch_text)).getText())
.isEqualTo(mContext.getString(onText));
}