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

Commit bac051a5 authored by Eric Rahm's avatar Eric Rahm Committed by Android (Google) Code Review
Browse files

Merge changes from topic "vertax_enlarge_upstream"

* changes:
  Feature flag enlargeVertexEntryArea
  Enlarge LockPatternView's vertax hit area
parents c4be82a3 ccbd67a2
Loading
Loading
Loading
Loading
+23 −2
Original line number Diff line number Diff line
@@ -160,6 +160,7 @@ public class LockPatternView extends View {
    @UnsupportedAppUsage
    private float mSquareHeight;
    private float mDotHitRadius;
    private float mDotHitMaxRadius;
    private final LinearGradient mFadeOutGradientShader;

    private final Path mCurrentPath = new Path();
@@ -173,6 +174,7 @@ public class LockPatternView extends View {
    private int mDotColor;
    private int mDotActivatedColor;
    private boolean mKeepDotActivated;
    private boolean mEnlargeVertex;

    private final Interpolator mFastOutSlowInInterpolator;
    private final Interpolator mLinearOutSlowInInterpolator;
@@ -348,6 +350,7 @@ public class LockPatternView extends View {
        mDotColor = a.getColor(R.styleable.LockPatternView_dotColor, mRegularColor);
        mDotActivatedColor = a.getColor(R.styleable.LockPatternView_dotActivatedColor, mDotColor);
        mKeepDotActivated = a.getBoolean(R.styleable.LockPatternView_keepDotActivated, false);
        mEnlargeVertex = a.getBoolean(R.styleable.LockPatternView_enlargeVertexEntryArea, false);

        int pathColor = a.getColor(R.styleable.LockPatternView_pathColor, mRegularColor);
        mPathPaint.setColor(pathColor);
@@ -729,7 +732,8 @@ public class LockPatternView extends View {
        final int height = h - mPaddingTop - mPaddingBottom;
        mSquareHeight = height / 3.0f;
        mExploreByTouchHelper.invalidateRoot();
        mDotHitRadius = Math.min(mSquareHeight / 2, mSquareWidth / 2) * mDotHitFactor;
        mDotHitMaxRadius = Math.min(mSquareHeight / 2, mSquareWidth / 2);
        mDotHitRadius = mDotHitMaxRadius * mDotHitFactor;

        if (mUseLockPatternDrawable) {
            mNotSelectedDrawable.setBounds(mPaddingLeft, mPaddingTop, width, height);
@@ -1003,11 +1007,24 @@ public class LockPatternView extends View {
    /** Helper method to find which cell a point maps to. */
    @Nullable
    private Cell detectCellHit(float x, float y) {
        final float hitRadiusSquared = mDotHitRadius * mDotHitRadius;
        for (int row = 0; row < 3; row++) {
            for (int column = 0; column < 3; column++) {
                float centerY = getCenterYForRow(row);
                float centerX = getCenterXForColumn(column);
                float hitRadiusSquared;

                if (mEnlargeVertex) {
                    // Maximize vertex dots' hit radius for the small screen.
                    // This eases users to draw more patterns with diagnal lines, while keeps
                    // drawing patterns with vertex dots easy.
                    hitRadiusSquared =
                            isVertex(row, column)
                                    ? (mDotHitMaxRadius * mDotHitMaxRadius)
                                    : (mDotHitRadius * mDotHitRadius);
                } else {
                    hitRadiusSquared = mDotHitRadius * mDotHitRadius;
                }

                if ((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY)
                        < hitRadiusSquared) {
                    return Cell.of(row, column);
@@ -1017,6 +1034,10 @@ public class LockPatternView extends View {
        return null;
    }

    private boolean isVertex(int row, int column) {
        return !(row == 1 || column == 1);
    }

    @Override
    public boolean onHoverEvent(MotionEvent event) {
        if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) {
+2 −0
Original line number Diff line number Diff line
@@ -9096,6 +9096,8 @@
        <attr name="dotActivatedColor" format="color|reference"/>
        <!-- Keep dot in activated state until segment completion -->
        <attr name="keepDotActivated" format="boolean"/>
        <!-- Enlarge vertex entry area for some form factors -->
        <attr name="enlargeVertexEntryArea" format="boolean"/>
    </declare-styleable>
    <!-- =============================== -->