diff options
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/NumPadButton.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/NumPadButton.java | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java index b76499a39ff8..096597afa889 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java @@ -16,37 +16,22 @@ package com.android.keyguard; import android.content.Context; -import android.content.res.ColorStateList; -import android.graphics.drawable.Drawable; -import android.graphics.drawable.LayerDrawable; -import android.graphics.drawable.VectorDrawable; +import android.graphics.drawable.RippleDrawable; import android.util.AttributeSet; -import android.view.ContextThemeWrapper; import android.view.MotionEvent; -import androidx.annotation.Nullable; - -import com.android.settingslib.Utils; -import com.android.systemui.R; - /** * Similar to the {@link NumPadKey}, but displays an image. */ public class NumPadButton extends AlphaOptimizedImageButton { - @Nullable private NumPadAnimator mAnimator; public NumPadButton(Context context, AttributeSet attrs) { super(context, attrs); - Drawable background = getBackground(); - if (background instanceof LayerDrawable) { - mAnimator = new NumPadAnimator(context, (LayerDrawable) background, - attrs.getStyleAttribute()); - } else { - mAnimator = null; - } + mAnimator = new NumPadAnimator(context, (RippleDrawable) getBackground(), + attrs.getStyleAttribute()); } @Override @@ -56,7 +41,7 @@ public class NumPadButton extends AlphaOptimizedImageButton { // Set width/height to the same value to ensure a smooth circle for the bg, but shrink // the height to match the old pin bouncer int width = getMeasuredWidth(); - int height = mAnimator == null ? (int) (width * .75f) : width; + int height = width; setMeasuredDimension(getMeasuredWidth(), height); } @@ -65,13 +50,13 @@ public class NumPadButton extends AlphaOptimizedImageButton { protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); - if (mAnimator != null) mAnimator.onLayout(b - t); + mAnimator.onLayout(b - t); } @Override public boolean onTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { - if (mAnimator != null) mAnimator.start(); + mAnimator.start(); } return super.onTouchEvent(event); } @@ -80,25 +65,6 @@ public class NumPadButton extends AlphaOptimizedImageButton { * Reload colors from resources. **/ public void reloadColors() { - if (mAnimator != null) { - mAnimator.reloadColors(getContext()); - } else { - // Needed for old style pin - int textColor = Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary) - .getDefaultColor(); - ((VectorDrawable) getDrawable()).setTintList(ColorStateList.valueOf(textColor)); - } - } - - /** - * By default, the new layout will be enabled. Invoking will revert to the old style - */ - public void disableNewLayout() { - if (mAnimator != null) { - mAnimator = null; - ContextThemeWrapper ctw = new ContextThemeWrapper(getContext(), R.style.NumPadKey); - setBackground(getContext().getResources().getDrawable( - R.drawable.ripple_drawable_pin, ctw.getTheme())); - } + mAnimator.reloadColors(getContext()); } } |