diff options
author | 2025-02-13 21:59:42 +0000 | |
---|---|---|
committer | 2025-02-14 09:16:56 -0800 | |
commit | 25a32bb3373136db9a260dc559b08b4b6ee18af2 (patch) | |
tree | 665beca4940cfadc2f7f67ee8175dd24f7cbf990 | |
parent | e6cbf6ee28d8679125865fe6b3c22e907ae697bc (diff) |
Update pattern bouncer to match spec
Alternative approaches considered:
1. For size dimensions, adding flag check in LockPatternView constructor and reading different dimens constants, however this might break wear resource overlay or we have to add a check to exclude using the new dimens
2. For colors, setting the color attributes using style attributes, however it is not easy to flag check this and would require adding another method to LockPatternView to read and init values based on a new style attribute.
Fixes: 394135697
Test: verified manually
Flag: com.android.systemui.bouncer_ui_revamp_2
Change-Id: I2755eaf87ff4518c982fdad9b7ecc42301c1ed7d
4 files changed, 61 insertions, 3 deletions
diff --git a/core/java/com/android/internal/widget/LockPatternView.java b/core/java/com/android/internal/widget/LockPatternView.java index 0ec55f958f38..1f907602cb9b 100644 --- a/core/java/com/android/internal/widget/LockPatternView.java +++ b/core/java/com/android/internal/widget/LockPatternView.java @@ -87,10 +87,10 @@ public class LockPatternView extends View { private static final int CELL_ACTIVATE = 0; private static final int CELL_DEACTIVATE = 1; - private final int mDotSize; - private final int mDotSizeActivated; + private int mDotSize; + private int mDotSizeActivated; private final float mDotHitFactor; - private final int mPathWidth; + private int mPathWidth; private final int mLineFadeOutAnimationDurationMs; private final int mLineFadeOutAnimationDelayMs; private final int mFadePatternAnimationDurationMs; @@ -1341,6 +1341,38 @@ public class LockPatternView extends View { invalidate(); } + /** + * Change dot colors + */ + public void setDotColors(int dotColor, int dotActivatedColor) { + mDotColor = dotColor; + mDotActivatedColor = dotActivatedColor; + invalidate(); + } + + /** + * Keeps dot activated until the next dot gets activated. + */ + public void setKeepDotActivated(boolean keepDotActivated) { + mKeepDotActivated = keepDotActivated; + } + + /** + * Set dot sizes in dp + */ + public void setDotSizes(int dotSizeDp, int dotSizeActivatedDp) { + mDotSize = dotSizeDp; + mDotSizeActivated = dotSizeActivatedDp; + } + + /** + * Set the stroke width of the pattern line. + */ + public void setPathWidth(int pathWidthDp) { + mPathWidth = pathWidthDp; + mPathPaint.setStrokeWidth(mPathWidth); + } + private float getCenterXForColumn(int column) { return mPaddingLeft + column * mSquareWidth + mSquareWidth / 2f; } diff --git a/packages/SystemUI/res-keyguard/values/dimens.xml b/packages/SystemUI/res-keyguard/values/dimens.xml index bfb37a0d97a7..6d446453d9f7 100644 --- a/packages/SystemUI/res-keyguard/values/dimens.xml +++ b/packages/SystemUI/res-keyguard/values/dimens.xml @@ -31,6 +31,10 @@ <!-- height for the keyguard pin input field --> <dimen name="keyguard_pin_field_height">56dp</dimen> + <dimen name="keyguard_pattern_dot_size">16dp</dimen> + <dimen name="keyguard_pattern_activated_dot_size">24dp</dimen> + <dimen name="keyguard_pattern_stroke_width">32dp</dimen> + <!-- height for the keyguard password input field --> <dimen name="keyguard_password_field_height">56dp</dimen> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java index 5d63c2a92ba8..4a4cb7a232c5 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java @@ -43,6 +43,8 @@ import com.android.internal.widget.LockPatternView; import com.android.settingslib.animation.AppearAnimationCreator; import com.android.settingslib.animation.AppearAnimationUtils; import com.android.settingslib.animation.DisappearAnimationUtils; +import com.android.systemui.Flags; +import com.android.systemui.bouncer.shared.constants.PatternBouncerConstants.ColorId; import com.android.systemui.res.R; import com.android.systemui.statusbar.policy.DevicePostureController.DevicePostureInt; @@ -227,6 +229,18 @@ public class KeyguardPatternView extends KeyguardInputView super.onFinishInflate(); mLockPatternView = findViewById(R.id.lockPatternView); + if (Flags.bouncerUiRevamp2()) { + mLockPatternView.setDotColors(mContext.getColor(ColorId.dotColor), mContext.getColor( + ColorId.activatedDotColor)); + mLockPatternView.setColors(mContext.getColor(ColorId.pathColor), 0, 0); + mLockPatternView.setDotSizes( + getResources().getDimensionPixelSize(R.dimen.keyguard_pattern_dot_size), + getResources().getDimensionPixelSize( + R.dimen.keyguard_pattern_activated_dot_size)); + mLockPatternView.setPathWidth( + getResources().getDimensionPixelSize(R.dimen.keyguard_pattern_stroke_width)); + mLockPatternView.setKeepDotActivated(true); + } mEcaView = findViewById(R.id.keyguard_selector_fade_container); } diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/shared/constants/KeyguardBouncerConstants.kt b/packages/SystemUI/src/com/android/systemui/bouncer/shared/constants/KeyguardBouncerConstants.kt index 149efcdcbb8a..3ef50f68cba4 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/shared/constants/KeyguardBouncerConstants.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/shared/constants/KeyguardBouncerConstants.kt @@ -87,6 +87,14 @@ private fun <T> c(old: T, new: T): T { } } +object PatternBouncerConstants { + object ColorId { + @JvmField val dotColor = colors.materialColorOnSurfaceVariant + @JvmField val activatedDotColor = colors.materialColorOnPrimary + @JvmField val pathColor = colors.materialColorPrimary + } +} + object PinBouncerConstants { @JvmField val pinShapes = c(old = R.array.bouncer_pin_shapes, new = R.array.updated_bouncer_pin_shapes) |