Refactor Settings theme colors.
Introduces stock colors (primary_color, primary_dark_color, etc) to allow
overriding the colors via resource overlays.
Creates new colorSecondary attribute and updates switches to use theme
attributes for foreground/background colors rather than hardcoded values.
Some other mild color cleanup to make things more straightforward.
BUG: 28760785
Change-Id: I4deba962357217bdb2e08c08e8f83b9b57a683d4
diff --git a/res/drawable/switchbar_background.xml b/res/drawable/switchbar_background.xml
index ac340be..3d729fd 100644
--- a/res/drawable/switchbar_background.xml
+++ b/res/drawable/switchbar_background.xml
@@ -16,6 +16,6 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight">
- <item android:drawable="@color/switchbar_background_color" />
+ <item android:drawable="?attr/colorSecondary" />
</ripple>
diff --git a/res/layout/switch_bar.xml b/res/layout/switch_bar.xml
index a31bd3e..8b69a1d 100644
--- a/res/layout/switch_bar.xml
+++ b/res/layout/switch_bar.xml
@@ -44,7 +44,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="@null"
- android:theme="@style/ThemeOverlay.SwitchBar" />
+ android:theme="@style/ThemeOverlay.SwitchBar.Settings" />
</merge>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 0a072ae..ca3d247 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -121,6 +121,8 @@
<attr name="switchBarMarginEnd" format="dimension" />
<attr name="switchBarBackgroundColor" format="color" />
+ <attr name="colorSecondary" format="color" />
+
<attr name="preferenceBackgroundColor" format="color" />
<!-- Confirm device credentials screen -->
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 81f3d32..003eda9 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -74,9 +74,6 @@
<color name="card_background">#ffffffff</color>
- <color name="switchbar_background_color">#ff37474f</color>
- <color name="switch_accent_color">#ff7fcac3</color>
-
<color name="wifi_divider">#ffe0e0e0</color>
<color name="sim_noitification">@*android:color/material_deep_teal_500</color>
@@ -108,6 +105,7 @@
<color name="importance_disabled_tint">#4d000000</color>
<!-- Accessibility SUW colors -->
+ <color name="material_blue_400">#5e97f6</color>
<color name="material_blue_500">#4285F4</color>
<color name="material_blue_700">#3367D6</color>
@@ -133,4 +131,10 @@
<color name="card_background_grey">#eeeeee</color>
+ <color name="primary_color">@color/material_blue_grey_900</color>
+ <color name="primary_dark_color">@color/material_blue_grey_950</color>
+ <color name="secondary_color">#ff37474f</color>
+ <color name="accent_color">@color/accent_material_light</color>
+ <color name="accent_color_lighter">#ff7fcac3</color>
+
</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
index ec59e4f..011957b 100644
--- a/res/values/themes.xml
+++ b/res/values/themes.xml
@@ -96,7 +96,7 @@
<item name="android:windowAnimationStyle">@null</item>
</style>
- <style name="PreferenceTheme" parent="@android:style/Theme.DeviceDefault.Settings">
+ <style name="PreferenceTheme" parent="Theme.SettingsBase">
<item name="@android:preferenceStyle">@style/Preference</item>
<item name="@android:editTextPreferenceStyle">@style/EditTextPreference</item>
<item name="@dropdownPreferenceStyle">@style/Preference.DropDown.Material</item>
@@ -132,7 +132,11 @@
layouts against a remote context using our local theme colors. Due to the implementation
details of Theme, we can't reference any local resources and MUST instead use the values
directly. So use #ff263238 instead of @color/theme_primary and so on. -->
- <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings" />
+ <style name="Theme.SettingsBase" parent="@android:style/Theme.Material.Settings">
+ <item name="android:colorPrimary">@color/primary_color</item>
+ <item name="android:colorAccent">@color/accent_color</item>
+ <item name="colorSecondary">@color/secondary_color</item>
+ </style>
<style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item>
@@ -196,15 +200,16 @@
</style>
<style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar">
+ <item name="android:colorAccent">@color/accent_color_lighter</item>
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
- <item name="switchBarBackgroundColor">@color/switchbar_background_color</item>
+ <item name="switchBarBackgroundColor">?attr/colorSecondary</item>
</style>
<style name="ThemeOverlay.SwitchBar.SubSettings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar">
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</item>
- <item name="switchBarBackgroundColor">@color/switchbar_background_color</item>
+ <item name="switchBarBackgroundColor">?attr/colorSecondary</item>
</style>
<style name="Theme.DialogWhenLarge" parent="@*android:style/Theme.Material.Settings.DialogWhenLarge">
@@ -253,21 +258,14 @@
<item name="preferenceBackgroundColor">@android:color/transparent</item>
</style>
- <!-- Used to color the switch bar controls -->
- <style name="ThemeOverlay.SwitchBar" parent="@android:style/ThemeOverlay">
- <!-- Used by controls, e.g. CheckBox, ProgressBar, etc. -->
- <item name="android:colorAccent">@color/switch_accent_color</item>
- <item name="switchBarBackgroundColor">@color/switchbar_background_color</item>
- </style>
-
<style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
<item name="confirmDeviceCredentialsSideMargin">16dp</item>
<item name="confirmDeviceCredentialsTopMargin">16dp</item>
</style>
<style name="Theme.ConfirmDeviceCredentialsDark" parent="@android:style/Theme.Material">
- <item name="android:colorPrimary">@*android:color/material_blue_grey_900</item>
- <item name="android:colorPrimaryDark">@*android:color/material_blue_grey_950</item>
+ <item name="android:colorPrimary">@color/primary_color</item>
+ <item name="android:colorPrimaryDark">@color/primary_dark_color</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/confirm_device_credential_dark_background</item>