From b1e1dbfb36b658bd2710fedf8c0381a5d89fa302 Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Thu, 7 Aug 2014 17:17:43 -0700 Subject: [PATCH] Update disabled states to be less opaque Also adds Resources method for retrieving floating-point values. BUG: 16374059 Change-Id: I68c6a40cbe5badfad624548b9abf2d657dbc2019 --- .../android/content/res/ColorStateList.java | 2 +- core/java/android/content/res/Resources.java | 28 +++++++++++++++++++ .../res/color/btn_default_material_dark.xml | 4 ++- .../res/color/btn_default_material_light.xml | 4 ++- ...rimary_text_disable_only_material_dark.xml | 6 ++-- ...imary_text_disable_only_material_light.xml | 6 ++-- .../res/color/primary_text_material_dark.xml | 4 ++- .../res/color/primary_text_material_light.xml | 4 ++- .../drawable/switch_thumb_material_anim.xml | 3 +- .../res/drawable/switch_track_material.xml | 7 +---- core/res/res/values/dimens_material.xml | 3 ++ core/res/res/values/themes_material.xml | 4 +-- 12 files changed, 56 insertions(+), 19 deletions(-) diff --git a/core/java/android/content/res/ColorStateList.java b/core/java/android/content/res/ColorStateList.java index 900b41d6095f5..3c290f72a5374 100644 --- a/core/java/android/content/res/ColorStateList.java +++ b/core/java/android/content/res/ColorStateList.java @@ -233,7 +233,7 @@ public class ColorStateList implements Parcelable { } if (alphaRes != 0) { - alpha = r.getFraction(alphaRes, 1, 1); + alpha = r.getFloat(alphaRes); } // Apply alpha modulation. diff --git a/core/java/android/content/res/Resources.java b/core/java/android/content/res/Resources.java index 5face6977e635..52d1c7910b331 100644 --- a/core/java/android/content/res/Resources.java +++ b/core/java/android/content/res/Resources.java @@ -985,6 +985,34 @@ public class Resources { } } + /** + * Retrieve a floating-point value for a particular resource ID. + * + * @param id The desired resource identifier, as generated by the aapt + * tool. This integer encodes the package, type, and resource + * entry. The value 0 is an invalid identifier. + * + * @return Returns the floating-point value contained in the resource. + * + * @throws NotFoundException Throws NotFoundException if the given ID does + * not exist or is not a floating-point value. + * @hide Pending API council approval. + */ + public float getFloat(int id) { + synchronized (mAccessLock) { + TypedValue value = mTmpValue; + if (value == null) { + mTmpValue = value = new TypedValue(); + } + getValue(id, value, true); + if (value.type == TypedValue.TYPE_FLOAT) { + return value.getFloat(); + } + throw new NotFoundException("Resource ID #0x" + Integer.toHexString(id) + " type #0x" + + Integer.toHexString(value.type) + " is not valid"); + } + } + /** * Return an XmlResourceParser through which you can read a view layout * description for the given resource ID. This parser has limited diff --git a/core/res/res/color/btn_default_material_dark.xml b/core/res/res/color/btn_default_material_dark.xml index 59555ae27b93e..7c904cdfc6bd5 100644 --- a/core/res/res/color/btn_default_material_dark.xml +++ b/core/res/res/color/btn_default_material_dark.xml @@ -15,6 +15,8 @@ --> - + diff --git a/core/res/res/color/btn_default_material_light.xml b/core/res/res/color/btn_default_material_light.xml index 6511a22ed92fc..738f9ad00e9e1 100644 --- a/core/res/res/color/btn_default_material_light.xml +++ b/core/res/res/color/btn_default_material_light.xml @@ -15,6 +15,8 @@ --> - + diff --git a/core/res/res/color/primary_text_disable_only_material_dark.xml b/core/res/res/color/primary_text_disable_only_material_dark.xml index cf7acaafa0b19..cdae79012ba8c 100644 --- a/core/res/res/color/primary_text_disable_only_material_dark.xml +++ b/core/res/res/color/primary_text_disable_only_material_dark.xml @@ -15,6 +15,8 @@ --> - - + + diff --git a/core/res/res/color/primary_text_disable_only_material_light.xml b/core/res/res/color/primary_text_disable_only_material_light.xml index bf5d2c0d5c5d2..0bf14d03aee72 100644 --- a/core/res/res/color/primary_text_disable_only_material_light.xml +++ b/core/res/res/color/primary_text_disable_only_material_light.xml @@ -15,6 +15,8 @@ --> - - + + diff --git a/core/res/res/color/primary_text_material_dark.xml b/core/res/res/color/primary_text_material_dark.xml index caef9d04b6488..6ad837ba4a254 100644 --- a/core/res/res/color/primary_text_material_dark.xml +++ b/core/res/res/color/primary_text_material_dark.xml @@ -15,6 +15,8 @@ --> - + diff --git a/core/res/res/color/primary_text_material_light.xml b/core/res/res/color/primary_text_material_light.xml index 81a593bd812e5..4c19e1256ffcf 100644 --- a/core/res/res/color/primary_text_material_light.xml +++ b/core/res/res/color/primary_text_material_light.xml @@ -15,6 +15,8 @@ --> - + diff --git a/core/res/res/drawable/switch_thumb_material_anim.xml b/core/res/res/drawable/switch_thumb_material_anim.xml index 71f6cfdc89425..30bc88823409d 100644 --- a/core/res/res/drawable/switch_thumb_material_anim.xml +++ b/core/res/res/drawable/switch_thumb_material_anim.xml @@ -31,8 +31,7 @@ android:src="@drawable/btn_switch_to_on_mtrl_00001" android:gravity="center" android:tintMode="multiply" - android:tint="?attr/colorButtonNormal" - android:alpha="?attr/disabledAlpha" /> + android:tint="?attr/colorButtonNormal" /> - - - + android:alpha="0.2" /> 4dp 2dp + + + 0.26 diff --git a/core/res/res/values/themes_material.xml b/core/res/res/values/themes_material.xml index 6ee9a03f5fc58..1376dfa3dae1f 100644 --- a/core/res/res/values/themes_material.xml +++ b/core/res/res/values/themes_material.xml @@ -46,7 +46,7 @@ please see themes_device_defaults.xml. @color/bright_foreground_material_light @color/background_material_dark @color/background_cache_hint_selector_material_dark - 0.5 + @dimen/disabled_alpha_material 0.6 @@ -387,7 +387,7 @@ please see themes_device_defaults.xml. @color/bright_foreground_material_dark @color/background_material_light @color/background_cache_hint_selector_material_light - 0.5 + @dimen/disabled_alpha_material 0.6