From 195baa1c93f6e20bfe0030caf6dad88b70a85176 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Thu, 28 Apr 2022 09:22:01 -0400 Subject: [PATCH] [DO NOT MERGE] Bouncer - Update selected item text color Constrast was too low, didn't match specs. Also noticed that if the user updated the dark mode while on lockscreen, the colors for both the user switcher and the num pad keys were not properly updating. Fixes: 221368641 Test: manual Change-Id: I5b9b2dca8f8246d403bcf919b8f2a2ba4ea2d9ec --- .../res-keyguard/values-night/styles.xml | 26 ++++ .../color/bouncer_user_switcher_item_text.xml | 21 +++ .../keyguard/KeyguardSecurityContainer.java | 19 +++ .../KeyguardSecurityContainerController.java | 9 +- .../com/android/keyguard/NumPadAnimator.java | 134 +++++++++--------- 5 files changed, 143 insertions(+), 66 deletions(-) create mode 100644 packages/SystemUI/res-keyguard/values-night/styles.xml create mode 100644 packages/SystemUI/res/color/bouncer_user_switcher_item_text.xml diff --git a/packages/SystemUI/res-keyguard/values-night/styles.xml b/packages/SystemUI/res-keyguard/values-night/styles.xml new file mode 100644 index 0000000000000..b5e0b655254fd --- /dev/null +++ b/packages/SystemUI/res-keyguard/values-night/styles.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/packages/SystemUI/res/color/bouncer_user_switcher_item_text.xml b/packages/SystemUI/res/color/bouncer_user_switcher_item_text.xml new file mode 100644 index 0000000000000..b1e4b34670378 --- /dev/null +++ b/packages/SystemUI/res/color/bouncer_user_switcher_item_text.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index fd7a6e624e2db..f8c0590a8d75e 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -707,6 +707,10 @@ public class KeyguardSecurityContainer extends FrameLayout { mDisappearAnimRunning = false; } + void reloadColors() { + mViewMode.reloadColors(); + } + /** * Enscapsulates the differences between bouncer modes for the container. */ @@ -728,6 +732,9 @@ public class KeyguardSecurityContainer extends FrameLayout { /** Called when the view needs to reset or hides */ default void reset() {}; + /** Refresh colors */ + default void reloadColors() {}; + /** On a successful auth, optionally handle how the view disappears */ default void startDisappearAnimation(SecurityMode securityMode) {}; @@ -821,6 +828,17 @@ public class KeyguardSecurityContainer extends FrameLayout { } } + @Override + public void reloadColors() { + TextView header = (TextView) mView.findViewById(R.id.user_switcher_header); + if (header != null) { + header.setTextColor(Utils.getColorAttrDefaultColor(mView.getContext(), + android.R.attr.textColorPrimary)); + header.setBackground(mView.getContext().getDrawable( + R.drawable.bouncer_user_switcher_header_bg)); + } + } + @Override public void onDestroy() { mUserSwitcherController.removeUserSwitchCallback(mUserSwitchCallback); @@ -911,6 +929,7 @@ public class KeyguardSecurityContainer extends FrameLayout { } else { textView.setBackground(null); } + textView.setSelected(item == currentUser); view.setEnabled(item.isSwitchToEnabled); view.setAlpha(view.isEnabled() ? USER_SWITCH_ENABLED_ALPHA : USER_SWITCH_DISABLED_ALPHA); diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index 28a3dbbf6c834..90f53a1815e35 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -232,12 +232,12 @@ public class KeyguardSecurityContainerController extends ViewController mBackground.setCornerRadius((float) anim.getAnimatedValue())); - - ValueAnimator expandBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), - mNormalColor, mHighlightColor); - expandBackgroundColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS); - expandBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR); - expandBackgroundColorAnimator.addUpdateListener( - animator -> mBackground.setColor((int) animator.getAnimatedValue())); - - ValueAnimator expandTextColorAnimator = - ValueAnimator.ofObject(new ArgbEvaluator(), - textColorPrimary, textColorPrimaryInverse); - expandTextColorAnimator.setInterpolator(Interpolators.LINEAR); - expandTextColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS); - expandTextColorAnimator.addUpdateListener(valueAnimator -> { - if (digitTextView != null) { - digitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); - } - }); - - mExpandAnimatorSet = new AnimatorSet(); - mExpandAnimatorSet.playTogether(mExpandAnimator, - expandBackgroundColorAnimator, expandTextColorAnimator); - - mContractAnimator = ValueAnimator.ofFloat(1f, 0f); - mContractAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); - mContractAnimator.setDuration(CONTRACT_ANIMATION_MS); - mContractAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); - mContractAnimator.addUpdateListener( - anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue())); - ValueAnimator contractBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), - mHighlightColor, mNormalColor); - contractBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR); - contractBackgroundColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); - contractBackgroundColorAnimator.setDuration(CONTRACT_ANIMATION_MS); - contractBackgroundColorAnimator.addUpdateListener( - animator -> mBackground.setColor((int) animator.getAnimatedValue())); - - ValueAnimator contractTextColorAnimator = - ValueAnimator.ofObject(new ArgbEvaluator(), textColorPrimaryInverse, - textColorPrimary); - contractTextColorAnimator.setInterpolator(Interpolators.LINEAR); - contractTextColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); - contractTextColorAnimator.setDuration(CONTRACT_ANIMATION_MS); - contractTextColorAnimator.addUpdateListener(valueAnimator -> { - if (digitTextView != null) { - digitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); - } - }); - - mContractAnimatorSet = new AnimatorSet(); - mContractAnimatorSet.playTogether(mContractAnimator, - contractBackgroundColorAnimator, contractTextColorAnimator); } public void expand() { @@ -160,6 +99,73 @@ class NumPadAnimator { a.recycle(); mBackground.setColor(mNormalColor); + createAnimators(context); + } + + private void createAnimators(Context context) { + int textColorPrimary = Utils.getColorAttrDefaultColor(context, + android.R.attr.textColorPrimary); + int textColorPrimaryInverse = Utils.getColorAttrDefaultColor(context, + android.R.attr.textColorPrimaryInverse); + + // Actual values will be updated later, usually during an onLayout() call + mExpandAnimator = ValueAnimator.ofFloat(0f, 1f); + mExpandAnimator.setDuration(EXPAND_ANIMATION_MS); + mExpandAnimator.setInterpolator(Interpolators.LINEAR); + mExpandAnimator.addUpdateListener( + anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue())); + + ValueAnimator expandBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), + mNormalColor, mHighlightColor); + expandBackgroundColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS); + expandBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR); + expandBackgroundColorAnimator.addUpdateListener( + animator -> mBackground.setColor((int) animator.getAnimatedValue())); + + ValueAnimator expandTextColorAnimator = + ValueAnimator.ofObject(new ArgbEvaluator(), + textColorPrimary, textColorPrimaryInverse); + expandTextColorAnimator.setInterpolator(Interpolators.LINEAR); + expandTextColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS); + expandTextColorAnimator.addUpdateListener(valueAnimator -> { + if (mDigitTextView != null) { + mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); + } + }); + + mExpandAnimatorSet = new AnimatorSet(); + mExpandAnimatorSet.playTogether(mExpandAnimator, + expandBackgroundColorAnimator, expandTextColorAnimator); + + mContractAnimator = ValueAnimator.ofFloat(1f, 0f); + mContractAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); + mContractAnimator.setDuration(CONTRACT_ANIMATION_MS); + mContractAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); + mContractAnimator.addUpdateListener( + anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue())); + ValueAnimator contractBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), + mHighlightColor, mNormalColor); + contractBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR); + contractBackgroundColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); + contractBackgroundColorAnimator.setDuration(CONTRACT_ANIMATION_MS); + contractBackgroundColorAnimator.addUpdateListener( + animator -> mBackground.setColor((int) animator.getAnimatedValue())); + + ValueAnimator contractTextColorAnimator = + ValueAnimator.ofObject(new ArgbEvaluator(), textColorPrimaryInverse, + textColorPrimary); + contractTextColorAnimator.setInterpolator(Interpolators.LINEAR); + contractTextColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); + contractTextColorAnimator.setDuration(CONTRACT_ANIMATION_MS); + contractTextColorAnimator.addUpdateListener(valueAnimator -> { + if (mDigitTextView != null) { + mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); + } + }); + + mContractAnimatorSet = new AnimatorSet(); + mContractAnimatorSet.playTogether(mContractAnimator, + contractBackgroundColorAnimator, contractTextColorAnimator); } }