diff options
| author | 2022-05-04 20:32:58 +0000 | |
|---|---|---|
| committer | 2022-05-04 20:32:58 +0000 | |
| commit | 3079ea52c716cd78dba3635bb56a696f23587c86 (patch) | |
| tree | b746aeda2b68726d7ce09103eec78ac11f7ac14e | |
| parent | 806a5efea16eb9cb7caa82206fac7d65e3439c56 (diff) | |
| parent | 47cba6dd846af9f46df75dcc2ba80ad7b2921fdb (diff) | |
Merge "[Bouncer] Update colors for pin pad" into tm-dev
3 files changed, 39 insertions, 27 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java index caf7ee4db2c3..c91c8992780c 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java @@ -30,7 +30,6 @@ import android.widget.TextView; import androidx.annotation.StyleRes; -import com.android.settingslib.Utils; import com.android.systemui.animation.Interpolators; /** @@ -42,24 +41,29 @@ class NumPadAnimator { private ValueAnimator mContractAnimator; private AnimatorSet mContractAnimatorSet; private GradientDrawable mBackground; - private int mNormalColor; - private int mHighlightColor; - private int mStyle; + private Drawable mImageButton; private TextView mDigitTextView; + private int mNormalBackgroundColor; + private int mPressedBackgroundColor; + private int mTextColorPrimary; + private int mTextColorPressed; + private int mStyle; private static final int EXPAND_ANIMATION_MS = 100; private static final int EXPAND_COLOR_ANIMATION_MS = 50; private static final int CONTRACT_ANIMATION_DELAY_MS = 33; private static final int CONTRACT_ANIMATION_MS = 417; - NumPadAnimator(Context context, final Drawable drawable, @StyleRes int style) { - this(context, drawable, style, null); + NumPadAnimator(Context context, final Drawable drawable, + @StyleRes int style, Drawable buttonImage) { + this(context, drawable, style, null, buttonImage); } NumPadAnimator(Context context, final Drawable drawable, @StyleRes int style, - @Nullable TextView digitTextView) { + @Nullable TextView digitTextView, @Nullable Drawable buttonImage) { mStyle = style; mBackground = (GradientDrawable) drawable; mDigitTextView = digitTextView; + mImageButton = buttonImage; reloadColors(context); } @@ -88,26 +92,28 @@ class NumPadAnimator { * Reload colors from resources. **/ void reloadColors(Context context) { - int[] customAttrs = {android.R.attr.colorControlNormal, - android.R.attr.colorControlHighlight}; + boolean isNumPadKey = mImageButton == null; + int[] customAttrs = {android.R.attr.colorControlNormal}; ContextThemeWrapper ctw = new ContextThemeWrapper(context, mStyle); TypedArray a = ctw.obtainStyledAttributes(customAttrs); - mNormalColor = getPrivateAttrColorIfUnset(ctw, a, 0, 0, + mNormalBackgroundColor = getPrivateAttrColorIfUnset(ctw, a, 0, 0, com.android.internal.R.attr.colorSurface); - mHighlightColor = a.getColor(1, 0); a.recycle(); - - mBackground.setColor(mNormalColor); - createAnimators(context); + mBackground.setColor(mNormalBackgroundColor); + + mPressedBackgroundColor = context.getColor(android.R.color.system_accent1_200); + mTextColorPrimary = isNumPadKey + ? com.android.settingslib.Utils + .getColorAttrDefaultColor(context, android.R.attr.textColorPrimary) + : com.android.settingslib.Utils + .getColorAttrDefaultColor(context, android.R.attr.textColorPrimaryInverse); + mTextColorPressed = com.android.settingslib.Utils + .getColorAttrDefaultColor(context, com.android.internal.R.attr.textColorOnAccent); + createAnimators(); } - private void createAnimators(Context context) { - int textColorPrimary = Utils.getColorAttrDefaultColor(context, - android.R.attr.textColorPrimary); - int textColorPrimaryInverse = Utils.getColorAttrDefaultColor(context, - android.R.attr.textColorPrimaryInverse); - + private void createAnimators() { // Actual values will be updated later, usually during an onLayout() call mExpandAnimator = ValueAnimator.ofFloat(0f, 1f); mExpandAnimator.setDuration(EXPAND_ANIMATION_MS); @@ -116,7 +122,7 @@ class NumPadAnimator { anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue())); ValueAnimator expandBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), - mNormalColor, mHighlightColor); + mNormalBackgroundColor, mPressedBackgroundColor); expandBackgroundColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS); expandBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR); expandBackgroundColorAnimator.addUpdateListener( @@ -124,13 +130,16 @@ class NumPadAnimator { ValueAnimator expandTextColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), - textColorPrimary, textColorPrimaryInverse); + mTextColorPrimary, mTextColorPressed); expandTextColorAnimator.setInterpolator(Interpolators.LINEAR); expandTextColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS); expandTextColorAnimator.addUpdateListener(valueAnimator -> { if (mDigitTextView != null) { mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); } + if (mImageButton != null) { + mImageButton.setTint((int) valueAnimator.getAnimatedValue()); + } }); mExpandAnimatorSet = new AnimatorSet(); @@ -144,7 +153,7 @@ class NumPadAnimator { mContractAnimator.addUpdateListener( anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue())); ValueAnimator contractBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), - mHighlightColor, mNormalColor); + mPressedBackgroundColor, mNormalBackgroundColor); contractBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR); contractBackgroundColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); contractBackgroundColorAnimator.setDuration(CONTRACT_ANIMATION_MS); @@ -152,8 +161,8 @@ class NumPadAnimator { animator -> mBackground.setColor((int) animator.getAnimatedValue())); ValueAnimator contractTextColorAnimator = - ValueAnimator.ofObject(new ArgbEvaluator(), textColorPrimaryInverse, - textColorPrimary); + ValueAnimator.ofObject(new ArgbEvaluator(), mTextColorPressed, + mTextColorPrimary); contractTextColorAnimator.setInterpolator(Interpolators.LINEAR); contractTextColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); contractTextColorAnimator.setDuration(CONTRACT_ANIMATION_MS); @@ -161,6 +170,9 @@ class NumPadAnimator { if (mDigitTextView != null) { mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); } + if (mImageButton != null) { + mImageButton.setTint((int) valueAnimator.getAnimatedValue()); + } }); mContractAnimatorSet = new AnimatorSet(); diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java index 7b98f2759d80..8099f75ed7d4 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java @@ -42,7 +42,7 @@ public class NumPadButton extends AlphaOptimizedImageButton { Drawable background = getBackground(); if (background instanceof GradientDrawable) { mAnimator = new NumPadAnimator(context, background.mutate(), - attrs.getStyleAttribute()); + attrs.getStyleAttribute(), getDrawable()); } else { mAnimator = null; } diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java index f771c974fe60..4aed2513d4f2 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java @@ -134,7 +134,7 @@ public class NumPadKey extends ViewGroup { Drawable background = getBackground(); if (background instanceof GradientDrawable) { mAnimator = new NumPadAnimator(context, background.mutate(), - R.style.NumPadKey, mDigitText); + R.style.NumPadKey, mDigitText, null); } else { mAnimator = null; } |