Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 25a32bb3 authored by Chandru S's avatar Chandru S
Browse files

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
parent e6cbf6ee
Loading
Loading
Loading
Loading
+35 −3
Original line number Diff line number Diff line
@@ -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;
    }
+4 −0
Original line number Diff line number Diff line
@@ -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>

+14 −0
Original line number Diff line number Diff line
@@ -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);
    }
+8 −0
Original line number Diff line number Diff line
@@ -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)