From 195baa1c93f6e20bfe0030caf6dad88b70a85176 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Thu, 28 Apr 2022 09:22:01 -0400 Subject: [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 --- .../SystemUI/res-keyguard/values-night/styles.xml | 26 ++++++ .../res/color/bouncer_user_switcher_item_text.xml | 21 +++++ .../keyguard/KeyguardSecurityContainer.java | 19 +++++ .../KeyguardSecurityContainerController.java | 9 +- .../src/com/android/keyguard/NumPadAnimator.java | 98 ++++++++++++---------- 5 files changed, 125 insertions(+), 48 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 000000000000..b5e0b655254f --- /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 000000000000..b1e4b3467037 --- /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 fd7a6e624e2d..f8c0590a8d75 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 28a3dbbf6c83..90f53a1815e3 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 { - if (digitTextView != null) { - digitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); + if (mDigitTextView != null) { + mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); } }); @@ -115,8 +158,8 @@ class NumPadAnimator { contractTextColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS); contractTextColorAnimator.setDuration(CONTRACT_ANIMATION_MS); contractTextColorAnimator.addUpdateListener(valueAnimator -> { - if (digitTextView != null) { - digitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); + if (mDigitTextView != null) { + mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue()); } }); @@ -124,42 +167,5 @@ class NumPadAnimator { mContractAnimatorSet.playTogether(mContractAnimator, contractBackgroundColorAnimator, contractTextColorAnimator); } - - public void expand() { - mExpandAnimatorSet.cancel(); - mContractAnimatorSet.cancel(); - mExpandAnimatorSet.start(); - } - - public void contract() { - mExpandAnimatorSet.cancel(); - mContractAnimatorSet.cancel(); - mContractAnimatorSet.start(); - } - - void onLayout(int height) { - float startRadius = height / 2f; - float endRadius = height / 4f; - mBackground.setCornerRadius(startRadius); - mExpandAnimator.setFloatValues(startRadius, endRadius); - mContractAnimator.setFloatValues(endRadius, startRadius); - } - - /** - * Reload colors from resources. - **/ - void reloadColors(Context context) { - int[] customAttrs = {android.R.attr.colorControlNormal, - android.R.attr.colorControlHighlight}; - - ContextThemeWrapper ctw = new ContextThemeWrapper(context, mStyle); - TypedArray a = ctw.obtainStyledAttributes(customAttrs); - mNormalColor = getPrivateAttrColorIfUnset(ctw, a, 0, 0, - com.android.internal.R.attr.colorSurface); - mHighlightColor = a.getColor(1, 0); - a.recycle(); - - mBackground.setColor(mNormalColor); - } } -- cgit v1.2.3-59-g8ed1b