From 0114dc52375695e9a53bfb586e277fbe513013dc Mon Sep 17 00:00:00 2001 From: Andrew Sapperstein Date: Sat, 11 Jun 2016 12:20:50 -0700 Subject: [PATCH] Refactor DeviceDefault themes. Adds colors_device_defaults.xml and defines the primary, primary dark, accent, and secondary colors for the dark, light, and settings themes. Also creates primary and primary dark values for the Material.Settings theme and updates the themes to use those values. Finally, fixes HelpUtils to properly get the value of colorAccent. Previously, if colorAccent were defined to a hex value directly, it would crash. BUG: 28625050 BUG: 29003416 Change-Id: Ia73b7368014c57c1676904d494cbb5169c8a836b --- .../res/res/values/colors_device_defaults.xml | 31 ++ core/res/res/values/colors_material.xml | 4 + .../res/res/values/themes_device_defaults.xml | 268 +++++++++++++++--- core/res/res/values/themes_material.xml | 36 +-- .../com/android/settingslib/HelpUtils.java | 8 +- 5 files changed, 291 insertions(+), 56 deletions(-) create mode 100644 core/res/res/values/colors_device_defaults.xml diff --git a/core/res/res/values/colors_device_defaults.xml b/core/res/res/values/colors_device_defaults.xml new file mode 100644 index 0000000000000..e830b64094f43 --- /dev/null +++ b/core/res/res/values/colors_device_defaults.xml @@ -0,0 +1,31 @@ + + + + + + @color/primary_material_dark + @color/primary_material_light + @color/primary_material_settings + @color/primary_dark_material_dark + @color/primary_dark_material_light + @color/primary_dark_material_settings + + @color/secondary_material_settings + + @color/accent_material_light + @color/accent_material_dark + \ No newline at end of file diff --git a/core/res/res/values/colors_material.xml b/core/res/res/values/colors_material.xml index c8ca11689299b..a18abdf9712ce 100644 --- a/core/res/res/values/colors_material.xml +++ b/core/res/res/values/colors_material.xml @@ -26,9 +26,13 @@ @color/material_grey_900 @color/material_grey_100 + @color/material_blue_grey_900 @color/black @color/material_grey_600 @color/material_grey_300 + @color/material_blue_grey_950 + + @color/material_blue_grey_800 @color/material_deep_teal_500 @color/material_deep_teal_200 diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml index ea1b626a996a0..e5b6c7830adfc 100644 --- a/core/res/res/values/themes_device_defaults.xml +++ b/core/res/res/values/themes_device_defaults.xml @@ -199,25 +199,50 @@ easier. @style/Widget.DeviceDefault.MediaRouteButton + + @color/primary_device_default_dark + @color/primary_dark_device_default_dark + @color/accent_device_default_dark + - - - - + @color/primary_device_default_dark + @color/primary_dark_device_default_dark + @color/accent_device_default_dark - - - - - - - - - - + - + + - - - - - - - - - @@ -510,33 +664,74 @@ easier. @dimen/dialog_fixed_width_minor @dimen/dialog_fixed_height_major @dimen/dialog_fixed_height_minor + + + @color/primary_device_default_light + @color/primary_dark_device_default_light + @color/accent_device_default_light - - - - + + - - diff --git a/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java index 76ba0a7fbd9f7..579116852cf34 100644 --- a/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java +++ b/packages/SettingsLib/src/com/android/settingslib/HelpUtils.java @@ -24,6 +24,7 @@ import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; import android.content.res.Resources.Theme; +import android.content.res.TypedArray; import android.net.Uri; import android.text.TextUtils; import android.util.Log; @@ -162,10 +163,9 @@ public class HelpUtils { intent.putExtra(EXTRA_CONTEXT, backupContext); } intent.putExtra(EXTRA_THEME, 1 /* Light, dark action bar */); - Theme theme = context.getTheme(); - TypedValue typedValue = new TypedValue(); - theme.resolveAttribute(android.R.attr.colorPrimary, typedValue, true); - intent.putExtra(EXTRA_PRIMARY_COLOR, context.getColor(typedValue.resourceId)); + TypedArray array = context.obtainStyledAttributes(new int[]{android.R.attr.colorPrimary}); + intent.putExtra(EXTRA_PRIMARY_COLOR, array.getColor(0, 0)); + array.recycle(); } /**