Loading packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java +37 −25 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import android.widget.TextView; import androidx.annotation.StyleRes; import com.android.settingslib.Utils; import com.android.systemui.animation.Interpolators; /** Loading @@ -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); } Loading Loading @@ -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); Loading @@ -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( Loading @@ -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(); Loading @@ -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); Loading @@ -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); Loading @@ -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(); Loading packages/SystemUI/src/com/android/keyguard/NumPadButton.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading packages/SystemUI/src/com/android/keyguard/NumPadKey.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading Loading
packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java +37 −25 Original line number Diff line number Diff line Loading @@ -30,7 +30,6 @@ import android.widget.TextView; import androidx.annotation.StyleRes; import com.android.settingslib.Utils; import com.android.systemui.animation.Interpolators; /** Loading @@ -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); } Loading Loading @@ -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); Loading @@ -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( Loading @@ -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(); Loading @@ -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); Loading @@ -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); Loading @@ -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(); Loading
packages/SystemUI/src/com/android/keyguard/NumPadButton.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading
packages/SystemUI/src/com/android/keyguard/NumPadKey.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; } Loading