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
This commit is contained in:
@@ -45,8 +45,6 @@ public class BubblePreference extends Preference implements View.OnClickListener
|
|||||||
private int mSelectedPreference;
|
private int mSelectedPreference;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Drawable mSelectedBackground;
|
|
||||||
private Drawable mUnselectedBackground;
|
|
||||||
|
|
||||||
private ButtonViewHolder mBubbleAllButton;
|
private ButtonViewHolder mBubbleAllButton;
|
||||||
private ButtonViewHolder mBubbleSelectedButton;
|
private ButtonViewHolder mBubbleSelectedButton;
|
||||||
@@ -72,8 +70,6 @@ public class BubblePreference extends Preference implements View.OnClickListener
|
|||||||
mHelper = new RestrictedPreferenceHelper(context, this, attrs);
|
mHelper = new RestrictedPreferenceHelper(context, this, attrs);
|
||||||
mHelper.useAdminDisabledSummary(true);
|
mHelper.useAdminDisabledSummary(true);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mSelectedBackground = mContext.getDrawable(R.drawable.button_border_selected);
|
|
||||||
mUnselectedBackground = mContext.getDrawable(R.drawable.button_border_unselected);
|
|
||||||
setLayoutResource(R.layout.bubble_preference);
|
setLayoutResource(R.layout.bubble_preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +163,9 @@ public class BubblePreference extends Preference implements View.OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setSelected(Context context, boolean selected) {
|
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);
|
mView.setSelected(selected);
|
||||||
|
|
||||||
ColorStateList stateList = selected
|
ColorStateList stateList = selected
|
||||||
|
Reference in New Issue
Block a user