From 5eeb0d554bf0ec708ab1c28b915a2e5c6e0dc669 Mon Sep 17 00:00:00 2001 From: Jeff DeCew Date: Thu, 17 Jun 2021 15:55:37 -0400 Subject: [PATCH] Fix emphasized button drawable to avoid ripple shape glitch. Fixes: 191001646 Test: tap a button in the alarm notification Change-Id: I3d8f77f96dc799bc36a44104874514c9320d11ce --- .../widget/EmphasizedNotificationButton.java | 9 +++++---- .../drawable/btn_notification_emphasized.xml | 20 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/core/java/com/android/internal/widget/EmphasizedNotificationButton.java b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java index 4460e4a0ea781..ce6af49eef0be 100644 --- a/core/java/com/android/internal/widget/EmphasizedNotificationButton.java +++ b/core/java/com/android/internal/widget/EmphasizedNotificationButton.java @@ -40,6 +40,7 @@ import com.android.internal.R; @RemoteViews.RemoteView public class EmphasizedNotificationButton extends Button { private final RippleDrawable mRipple; + private final GradientDrawable mBackground; private boolean mPriority; public EmphasizedNotificationButton(Context context) { @@ -57,9 +58,10 @@ public class EmphasizedNotificationButton extends Button { public EmphasizedNotificationButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - DrawableWrapper background = (DrawableWrapper) getBackground().mutate(); - mRipple = (RippleDrawable) background.getDrawable(); + mRipple = (RippleDrawable) getBackground(); mRipple.mutate(); + DrawableWrapper inset = (DrawableWrapper) mRipple.getDrawable(0); + mBackground = (GradientDrawable) inset.getDrawable(); } @RemotableViewMethod @@ -70,8 +72,7 @@ public class EmphasizedNotificationButton extends Button { @RemotableViewMethod public void setButtonBackground(ColorStateList color) { - GradientDrawable inner = (GradientDrawable) mRipple.getDrawable(0); - inner.setColor(color); + mBackground.setColor(color); invalidate(); } diff --git a/core/res/res/drawable/btn_notification_emphasized.xml b/core/res/res/drawable/btn_notification_emphasized.xml index 63707ab7f5d69..29c51f2a33c94 100644 --- a/core/res/res/drawable/btn_notification_emphasized.xml +++ b/core/res/res/drawable/btn_notification_emphasized.xml @@ -15,13 +15,13 @@ ~ limitations under the License --> - - - + + + - - - + + +