Check class type before creating animator
ag/17048689 removed the check for the drawable type before creating the NumPadAnimator. A check for a GradientDrawable should be re-introduced for when it is not that type (such as on AAOS). Bug: 223386100 Test: manual Change-Id: I247a6731e6e633f1a13e3acd9fe7ac81d474e126
This commit is contained in:
@@ -19,6 +19,8 @@ import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.graphics.drawable.VectorDrawable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
@@ -37,8 +39,14 @@ public class NumPadButton extends AlphaOptimizedImageButton {
|
||||
public NumPadButton(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
mAnimator = new NumPadAnimator(context, getBackground().mutate(),
|
||||
attrs.getStyleAttribute());
|
||||
Drawable background = getBackground();
|
||||
if (background instanceof GradientDrawable) {
|
||||
mAnimator = new NumPadAnimator(context, background.mutate(),
|
||||
attrs.getStyleAttribute());
|
||||
} else {
|
||||
mAnimator = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,6 +18,8 @@ package com.android.keyguard;
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
@@ -129,8 +131,13 @@ public class NumPadKey extends ViewGroup {
|
||||
|
||||
setContentDescription(mDigitText.getText().toString());
|
||||
|
||||
mAnimator = new NumPadAnimator(context, getBackground().mutate(),
|
||||
R.style.NumPadKey, mDigitText);
|
||||
Drawable background = getBackground();
|
||||
if (background instanceof GradientDrawable) {
|
||||
mAnimator = new NumPadAnimator(context, background.mutate(),
|
||||
R.style.NumPadKey, mDigitText);
|
||||
} else {
|
||||
mAnimator = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user