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

Commit 556c3159 authored by Matt Pietal's avatar Matt Pietal Committed by Automerger Merge Worker
Browse files

Merge "Lock Pattern View - Visual update" into sc-dev am: 04487293

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13459659

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1bbe8d7ac20740e6c1b5b548b5fb6d83d42c857b
parents 2580827f 04487293
Loading
Loading
Loading
Loading
+38 −25
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ public class LockPatternView extends View {
    private int mRegularColor;
    private int mErrorColor;
    private int mSuccessColor;
    private int mDotColor;

    private final Interpolator mFastOutSlowInInterpolator;
    private final Interpolator mLinearOutSlowInInterpolator;
@@ -318,6 +319,7 @@ public class LockPatternView extends View {
        mRegularColor = a.getColor(R.styleable.LockPatternView_regularColor, 0);
        mErrorColor = a.getColor(R.styleable.LockPatternView_errorColor, 0);
        mSuccessColor = a.getColor(R.styleable.LockPatternView_successColor, 0);
        mDotColor = a.getColor(R.styleable.LockPatternView_dotColor, mRegularColor);

        int pathColor = a.getColor(R.styleable.LockPatternView_pathColor, mRegularColor);
        mPathPaint.setColor(pathColor);
@@ -522,7 +524,7 @@ public class LockPatternView extends View {
                getCenterYForRow(cellState.row) + startTranslationY);
        cellState.hwCenterX = CanvasProperty.createFloat(getCenterXForColumn(cellState.col));
        cellState.hwRadius = CanvasProperty.createFloat(mDotSize/2 * startScale);
        mPaint.setColor(getCurrentColor(false));
        mPaint.setColor(getDotColor());
        mPaint.setAlpha((int) (startAlpha * 255));
        cellState.hwPaint = CanvasProperty.createPaint(new Paint(mPaint));

@@ -1163,29 +1165,6 @@ public class LockPatternView extends View {
        final Path currentPath = mCurrentPath;
        currentPath.rewind();

        // draw the circles
        for (int i = 0; i < 3; i++) {
            float centerY = getCenterYForRow(i);
            for (int j = 0; j < 3; j++) {
                CellState cellState = mCellStates[i][j];
                float centerX = getCenterXForColumn(j);
                float translationY = cellState.translationY;

                if (mUseLockPatternDrawable) {
                    drawCellDrawable(canvas, i, j, cellState.radius, drawLookup[i][j]);
                } else {
                    if (isHardwareAccelerated() && cellState.hwAnimating) {
                        RecordingCanvas recordingCanvas = (RecordingCanvas) canvas;
                        recordingCanvas.drawCircle(cellState.hwCenterX, cellState.hwCenterY,
                                cellState.hwRadius, cellState.hwPaint);
                    } else {
                        drawCircle(canvas, (int) centerX, (int) centerY + translationY,
                                cellState.radius, drawLookup[i][j], cellState.alpha);
                    }
                }
            }
        }

        // TODO: the path should be created and cached every time we hit-detect a cell
        // only the last segment of the path should be computed here
        // draw the path of the pattern (unless we are in stealth mode)
@@ -1256,6 +1235,29 @@ public class LockPatternView extends View {
                canvas.drawPath(currentPath, mPathPaint);
            }
        }

        // draw the circles
        for (int i = 0; i < 3; i++) {
            float centerY = getCenterYForRow(i);
            for (int j = 0; j < 3; j++) {
                CellState cellState = mCellStates[i][j];
                float centerX = getCenterXForColumn(j);
                float translationY = cellState.translationY;

                if (mUseLockPatternDrawable) {
                    drawCellDrawable(canvas, i, j, cellState.radius, drawLookup[i][j]);
                } else {
                    if (isHardwareAccelerated() && cellState.hwAnimating) {
                        RecordingCanvas recordingCanvas = (RecordingCanvas) canvas;
                        recordingCanvas.drawCircle(cellState.hwCenterX, cellState.hwCenterY,
                                cellState.hwRadius, cellState.hwPaint);
                    } else {
                        drawCircle(canvas, (int) centerX, (int) centerY + translationY,
                                cellState.radius, drawLookup[i][j], cellState.alpha);
                    }
                }
            }
        }
    }

    private float calculateLastSegmentAlpha(float x, float y, float lastX, float lastY) {
@@ -1266,6 +1268,17 @@ public class LockPatternView extends View {
        return Math.min(1f, Math.max(0f, (frac - 0.3f) * 4f));
    }

    private int getDotColor() {
        if (mInStealthMode) {
            // Always use the default color in this case
            return mDotColor;
        } else if (mPatternDisplayMode == DisplayMode.Wrong) {
            // the pattern is wrong
            return mErrorColor;
        }
        return mDotColor;
    }

    private int getCurrentColor(boolean partOfPattern) {
        if (!partOfPattern || mInStealthMode || mPatternInProgress) {
            // unselected circle
@@ -1286,7 +1299,7 @@ public class LockPatternView extends View {
     */
    private void drawCircle(Canvas canvas, float centerX, float centerY, float radius,
            boolean partOfPattern, float alpha) {
        mPaint.setColor(getCurrentColor(partOfPattern));
        mPaint.setColor(getDotColor());
        mPaint.setAlpha((int) (alpha * 255));
        canvas.drawCircle(centerX, centerY, radius, mPaint);
    }
+3 −0
Original line number Diff line number Diff line
@@ -8437,6 +8437,9 @@
        <attr name="errorColor" format="color|reference" />
        <!-- The success color -->
        <attr name="successColor" format="color|reference"/>
        <!-- The dot color -->
        <attr name="dotColor" format="color|reference"/>
    </declare-styleable>
    <!-- =============================== -->
+3 −3
Original line number Diff line number Diff line
@@ -622,9 +622,9 @@
         aliasing effects). This is only used on circular displays. -->
    <dimen name="circular_display_mask_thickness">1px</dimen>

    <dimen name="lock_pattern_dot_line_width">3dp</dimen>
    <dimen name="lock_pattern_dot_size">12dp</dimen>
    <dimen name="lock_pattern_dot_size_activated">28dp</dimen>
    <dimen name="lock_pattern_dot_line_width">22dp</dimen>
    <dimen name="lock_pattern_dot_size">14dp</dimen>
    <dimen name="lock_pattern_dot_size_activated">30dp</dimen>

    <dimen name="text_handle_min_size">40dp</dimen>

+3 −1
Original line number Diff line number Diff line
@@ -354,15 +354,17 @@
    </style>

    <style name="LockPatternStyle">
        <item name="*android:regularColor">?android:attr/textColorPrimary</item>
        <item name="*android:regularColor">?android:attr/colorAccent</item>
        <item name="*android:successColor">?android:attr/textColorPrimary</item>
        <item name="*android:errorColor">?android:attr/colorError</item>
        <item name="*android:dotColor">?android:attr/textColorSecondary</item>
    </style>

    <style name="LockPatternStyleBiometricPrompt">
        <item name="*android:regularColor">?android:attr/colorForeground</item>
        <item name="*android:successColor">?android:attr/colorForeground</item>
        <item name="*android:errorColor">?android:attr/colorError</item>
        <item name="*android:dotColor">?android:attr/textColorSecondary</item>
    </style>

    <style name="qs_theme" parent="@*android:style/Theme.DeviceDefault.QuickSettings">