From 9548384364738f54282293dd54acd223ee047759 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Fri, 16 Apr 2021 12:00:56 -0700 Subject: [PATCH] Make sparkle color and alpha customizable This CL introduces a new attr: effectColor. The attribute can be used on ripple tags to customize the color and alpha of the ripple decoration. It's also possible to change the effect color via code by invoking RippleDrawable#setEffectColor. Fixes: 185602477 Test: atest RippleDrawableTest Change-Id: I9b50f330729a67ef4b529283a92c83c28387fa0b --- core/api/current.txt | 5 +- .../res/drawable/btn_borderless_material.xml | 3 +- .../res/res/drawable/btn_colored_material.xml | 3 +- .../res/res/drawable/btn_default_material.xml | 3 +- core/res/res/drawable/btn_toggle_material.xml | 3 +- core/res/res/values/attrs.xml | 12 ++- core/res/res/values/public.xml | 1 + .../res/res/values/themes_device_defaults.xml | 3 - .../graphics/drawable/RippleDrawable.java | 73 ++++++++++--------- .../graphics/drawable/RippleShader.java | 15 ++-- 10 files changed, 61 insertions(+), 60 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index 4b12d54c5a576..4930969ff39e6 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -592,6 +592,7 @@ package android { field public static final int editTextStyle = 16842862; // 0x101006e field @Deprecated public static final int editable = 16843115; // 0x101016b field public static final int editorExtras = 16843300; // 0x1010224 + field public static final int effectColor; field public static final int elegantTextHeight = 16843869; // 0x101045d field public static final int elevation = 16843840; // 0x1010440 field public static final int ellipsize = 16842923; // 0x10100ab @@ -16817,8 +16818,10 @@ package android.graphics.drawable { public class RippleDrawable extends android.graphics.drawable.LayerDrawable { ctor public RippleDrawable(@NonNull android.content.res.ColorStateList, @Nullable android.graphics.drawable.Drawable, @Nullable android.graphics.drawable.Drawable); + method @NonNull public android.content.res.ColorStateList getEffectColor(); method public int getRadius(); - method public void setColor(android.content.res.ColorStateList); + method public void setColor(@NonNull android.content.res.ColorStateList); + method public void setEffectColor(@NonNull android.content.res.ColorStateList); method public void setRadius(int); field public static final int RADIUS_AUTO = -1; // 0xffffffff } diff --git a/core/res/res/drawable/btn_borderless_material.xml b/core/res/res/drawable/btn_borderless_material.xml index 1a0912ee47dc9..08e1060ebad31 100644 --- a/core/res/res/drawable/btn_borderless_material.xml +++ b/core/res/res/drawable/btn_borderless_material.xml @@ -15,8 +15,7 @@ --> + android:color="?attr/colorControlHighlight"> diff --git a/core/res/res/drawable/btn_colored_material.xml b/core/res/res/drawable/btn_colored_material.xml index 5274ef2f6dce4..7ba21e840a597 100644 --- a/core/res/res/drawable/btn_colored_material.xml +++ b/core/res/res/drawable/btn_colored_material.xml @@ -19,8 +19,7 @@ android:insetTop="@dimen/button_inset_vertical_material" android:insetRight="@dimen/button_inset_horizontal_material" android:insetBottom="@dimen/button_inset_vertical_material"> - + diff --git a/core/res/res/drawable/btn_default_material.xml b/core/res/res/drawable/btn_default_material.xml index 6a9e62110ba40..ed2b5aacb2369 100644 --- a/core/res/res/drawable/btn_default_material.xml +++ b/core/res/res/drawable/btn_default_material.xml @@ -15,7 +15,6 @@ --> + android:color="?attr/colorControlHighlight"> diff --git a/core/res/res/drawable/btn_toggle_material.xml b/core/res/res/drawable/btn_toggle_material.xml index 7cee3820172b7..8b19e4ae3561e 100644 --- a/core/res/res/drawable/btn_toggle_material.xml +++ b/core/res/res/drawable/btn_toggle_material.xml @@ -21,8 +21,7 @@ android:insetBottom="@dimen/button_inset_vertical_material"> - + diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index bd1d84811d4f9..c3112aeb81ca3 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -1176,6 +1176,9 @@ + + + @@ -6540,13 +6543,8 @@ - - - - - - - + + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index f6a67d2ae7105..2a76c57f9e07a 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -3099,6 +3099,7 @@ + diff --git a/core/res/res/values/themes_device_defaults.xml b/core/res/res/values/themes_device_defaults.xml index 1d4beae8cc589..41bedb2ed43c9 100644 --- a/core/res/res/values/themes_device_defaults.xml +++ b/core/res/res/values/themes_device_defaults.xml @@ -234,9 +234,6 @@ easier. @color/text_color_tertiary_device_default_dark @color/foreground_device_default_dark @color/foreground_device_default_light - - - solid