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
This commit is contained in:
Andrew Sapperstein
2016-05-16 17:27:12 -07:00
parent 3b15d6234d
commit 8dd11327b6
5 changed files with 22 additions and 18 deletions

View File

@@ -16,6 +16,6 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android" <ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?android:attr/colorControlHighlight"> android:color="?android:attr/colorControlHighlight">
<item android:drawable="@color/switchbar_background_color" /> <item android:drawable="?attr/colorSecondary" />
</ripple> </ripple>

View File

@@ -44,7 +44,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:background="@null" android:background="@null"
android:theme="@style/ThemeOverlay.SwitchBar" /> android:theme="@style/ThemeOverlay.SwitchBar.Settings" />
</merge> </merge>

View File

@@ -121,6 +121,8 @@
<attr name="switchBarMarginEnd" format="dimension" /> <attr name="switchBarMarginEnd" format="dimension" />
<attr name="switchBarBackgroundColor" format="color" /> <attr name="switchBarBackgroundColor" format="color" />
<attr name="colorSecondary" format="color" />
<attr name="preferenceBackgroundColor" format="color" /> <attr name="preferenceBackgroundColor" format="color" />
<!-- Confirm device credentials screen --> <!-- Confirm device credentials screen -->

View File

@@ -74,9 +74,6 @@
<color name="card_background">#ffffffff</color> <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="wifi_divider">#ffe0e0e0</color>
<color name="sim_noitification">@*android:color/material_deep_teal_500</color> <color name="sim_noitification">@*android:color/material_deep_teal_500</color>
@@ -108,6 +105,7 @@
<color name="importance_disabled_tint">#4d000000</color> <color name="importance_disabled_tint">#4d000000</color>
<!-- Accessibility SUW colors --> <!-- Accessibility SUW colors -->
<color name="material_blue_400">#5e97f6</color>
<color name="material_blue_500">#4285F4</color> <color name="material_blue_500">#4285F4</color>
<color name="material_blue_700">#3367D6</color> <color name="material_blue_700">#3367D6</color>
@@ -133,4 +131,10 @@
<color name="card_background_grey">#eeeeee</color> <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> </resources>

View File

@@ -96,7 +96,7 @@
<item name="android:windowAnimationStyle">@null</item> <item name="android:windowAnimationStyle">@null</item>
</style> </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:preferenceStyle">@style/Preference</item>
<item name="@android:editTextPreferenceStyle">@style/EditTextPreference</item> <item name="@android:editTextPreferenceStyle">@style/EditTextPreference</item>
<item name="@dropdownPreferenceStyle">@style/Preference.DropDown.Material</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 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 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. --> 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"> <style name="Theme.Settings" parent="Theme.SettingsBase">
<item name="preferenceTheme">@style/PreferenceTheme</item> <item name="preferenceTheme">@style/PreferenceTheme</item>
@@ -196,15 +200,16 @@
</style> </style>
<style name="ThemeOverlay.SwitchBar.Settings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar"> <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="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</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>
<style name="ThemeOverlay.SwitchBar.SubSettings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar"> <style name="ThemeOverlay.SwitchBar.SubSettings" parent="@android:style/ThemeOverlay.Material.Dark.ActionBar">
<item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item> <item name="switchBarMarginStart">@dimen/switchbar_subsettings_margin_start</item>
<item name="switchBarMarginEnd">@dimen/switchbar_subsettings_margin_end</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>
<style name="Theme.DialogWhenLarge" parent="@*android:style/Theme.Material.Settings.DialogWhenLarge"> <style name="Theme.DialogWhenLarge" parent="@*android:style/Theme.Material.Settings.DialogWhenLarge">
@@ -253,21 +258,14 @@
<item name="preferenceBackgroundColor">@android:color/transparent</item> <item name="preferenceBackgroundColor">@android:color/transparent</item>
</style> </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"> <style name="Theme.ConfirmDeviceCredentials" parent="Theme.SubSettings">
<item name="confirmDeviceCredentialsSideMargin">16dp</item> <item name="confirmDeviceCredentialsSideMargin">16dp</item>
<item name="confirmDeviceCredentialsTopMargin">16dp</item> <item name="confirmDeviceCredentialsTopMargin">16dp</item>
</style> </style>
<style name="Theme.ConfirmDeviceCredentialsDark" parent="@android:style/Theme.Material"> <style name="Theme.ConfirmDeviceCredentialsDark" parent="@android:style/Theme.Material">
<item name="android:colorPrimary">@*android:color/material_blue_grey_900</item> <item name="android:colorPrimary">@color/primary_color</item>
<item name="android:colorPrimaryDark">@*android:color/material_blue_grey_950</item> <item name="android:colorPrimaryDark">@color/primary_dark_color</item>
<item name="android:windowActionBar">false</item> <item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item> <item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@color/confirm_device_credential_dark_background</item> <item name="android:windowBackground">@color/confirm_device_credential_dark_background</item>