Merge "Fix emphasized button drawable to avoid ripple shape glitch." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fee0ac2158
@@ -40,6 +40,7 @@ import com.android.internal.R;
|
|||||||
@RemoteViews.RemoteView
|
@RemoteViews.RemoteView
|
||||||
public class EmphasizedNotificationButton extends Button {
|
public class EmphasizedNotificationButton extends Button {
|
||||||
private final RippleDrawable mRipple;
|
private final RippleDrawable mRipple;
|
||||||
|
private final GradientDrawable mBackground;
|
||||||
private boolean mPriority;
|
private boolean mPriority;
|
||||||
|
|
||||||
public EmphasizedNotificationButton(Context context) {
|
public EmphasizedNotificationButton(Context context) {
|
||||||
@@ -57,9 +58,10 @@ public class EmphasizedNotificationButton extends Button {
|
|||||||
public EmphasizedNotificationButton(Context context, AttributeSet attrs, int defStyleAttr,
|
public EmphasizedNotificationButton(Context context, AttributeSet attrs, int defStyleAttr,
|
||||||
int defStyleRes) {
|
int defStyleRes) {
|
||||||
super(context, attrs, defStyleAttr, defStyleRes);
|
super(context, attrs, defStyleAttr, defStyleRes);
|
||||||
DrawableWrapper background = (DrawableWrapper) getBackground().mutate();
|
mRipple = (RippleDrawable) getBackground();
|
||||||
mRipple = (RippleDrawable) background.getDrawable();
|
|
||||||
mRipple.mutate();
|
mRipple.mutate();
|
||||||
|
DrawableWrapper inset = (DrawableWrapper) mRipple.getDrawable(0);
|
||||||
|
mBackground = (GradientDrawable) inset.getDrawable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@RemotableViewMethod
|
@RemotableViewMethod
|
||||||
@@ -70,8 +72,7 @@ public class EmphasizedNotificationButton extends Button {
|
|||||||
|
|
||||||
@RemotableViewMethod
|
@RemotableViewMethod
|
||||||
public void setButtonBackground(ColorStateList color) {
|
public void setButtonBackground(ColorStateList color) {
|
||||||
GradientDrawable inner = (GradientDrawable) mRipple.getDrawable(0);
|
mBackground.setColor(color);
|
||||||
inner.setColor(color);
|
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
~ limitations under the License
|
~ limitations under the License
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<inset xmlns:android="http://schemas.android.com/apk/res/android"
|
<ripple xmlns:android="http://schemas.android.com/apk/res/android" android:color="?attr/colorControlHighlight">
|
||||||
|
<item>
|
||||||
|
<inset
|
||||||
android:insetLeft="@dimen/button_inset_horizontal_material"
|
android:insetLeft="@dimen/button_inset_horizontal_material"
|
||||||
android:insetTop="@dimen/button_inset_vertical_material"
|
android:insetTop="@dimen/button_inset_vertical_material"
|
||||||
android:insetRight="@dimen/button_inset_horizontal_material"
|
android:insetRight="@dimen/button_inset_horizontal_material"
|
||||||
android:insetBottom="@dimen/button_inset_vertical_material">
|
android:insetBottom="@dimen/button_inset_vertical_material">
|
||||||
<ripple android:color="?attr/colorControlHighlight">
|
|
||||||
<item>
|
|
||||||
<shape android:shape="rectangle">
|
<shape android:shape="rectangle">
|
||||||
<corners android:radius="@dimen/notification_action_button_radius" />
|
<corners android:radius="@dimen/notification_action_button_radius" />
|
||||||
<padding android:left="12dp"
|
<padding android:left="12dp"
|
||||||
@@ -30,6 +30,6 @@
|
|||||||
android:bottom="@dimen/button_padding_vertical_material" />
|
android:bottom="@dimen/button_padding_vertical_material" />
|
||||||
<solid android:color="@color/white" />
|
<solid android:color="@color/white" />
|
||||||
</shape>
|
</shape>
|
||||||
|
</inset>
|
||||||
</item>
|
</item>
|
||||||
</ripple>
|
</ripple>
|
||||||
</inset>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user