From 5de9b1e4f1f6fe923c7faaae1d23eb4517a60687 Mon Sep 17 00:00:00 2001 From: Lyn Han Date: Tue, 30 Jun 2020 14:12:55 -0700 Subject: [PATCH] Fix sketchy bubble preference button We were re-using the same "unselected" drawable for buttons with different heights, which causes one height to override the other, leading to unexpected drawable overlap and height/text-line mismatch. Instead, use separate drawable per button. Fixes: 154087375 Test: toggle between pref buttons in every font size Change-Id: I5db6e1eb5150a72a0d8038b0840538a0982a5f67 --- .../settings/notification/app/BubblePreference.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/com/android/settings/notification/app/BubblePreference.java b/src/com/android/settings/notification/app/BubblePreference.java index 7e071ff938a..f0046d793d0 100644 --- a/src/com/android/settings/notification/app/BubblePreference.java +++ b/src/com/android/settings/notification/app/BubblePreference.java @@ -45,8 +45,6 @@ public class BubblePreference extends Preference implements View.OnClickListener private int mSelectedPreference; private Context mContext; - private Drawable mSelectedBackground; - private Drawable mUnselectedBackground; private ButtonViewHolder mBubbleAllButton; private ButtonViewHolder mBubbleSelectedButton; @@ -72,8 +70,6 @@ public class BubblePreference extends Preference implements View.OnClickListener mHelper = new RestrictedPreferenceHelper(context, this, attrs); mHelper.useAdminDisabledSummary(true); mContext = context; - mSelectedBackground = mContext.getDrawable(R.drawable.button_border_selected); - mUnselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected); setLayoutResource(R.layout.bubble_preference); } @@ -167,7 +163,9 @@ public class BubblePreference extends Preference implements View.OnClickListener } void setSelected(Context context, boolean selected) { - mView.setBackground(selected ? mSelectedBackground : mUnselectedBackground); + mView.setBackground(mContext.getDrawable(selected + ? R.drawable.button_border_selected + : R.drawable.button_border_unselected)); mView.setSelected(selected); ColorStateList stateList = selected