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

Commit 10c18e46 authored by Matt Pietal's avatar Matt Pietal
Browse files

Add PIN digits if quickly typed during reset

The reset animation introduces some delay when processing
PIN touches that can lead to a visual inconsistency: The touch
was recorded but not shown to the user. This could be confusing
to the user when they have correctly typed their PIN but it was
rejected. Make sure to visually show all taps after the reset
has completed.

Fixes: 441008042
Test: Manual - rapidly enter PIN digits with auto-entry on
Flag: EXEMPT bugfix
Change-Id: I4c0cfe4059121a3a854443076d7643963ecbf788
parent 81dbf32b
Loading
Loading
Loading
Loading
+13 −1
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu
    private int mColor = getContext().getColor(PIN_SHAPES);
    private int mColor = getContext().getColor(PIN_SHAPES);
    private int mPosition = 0;
    private int mPosition = 0;
    private boolean mIsAnimatingReset = false;
    private boolean mIsAnimatingReset = false;
    private int mDelayedAppend = 0;
    private final PinShapeAdapter mPinShapeAdapter;
    private final PinShapeAdapter mPinShapeAdapter;
    private ValueAnimator mValueAnimator = ValueAnimator.ofFloat(1f, 0f);
    private ValueAnimator mValueAnimator = ValueAnimator.ofFloat(1f, 0f);
    private Rect mFirstChildVisibleRect = new Rect();
    private Rect mFirstChildVisibleRect = new Rect();
@@ -83,6 +84,9 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu
    @Override
    @Override
    public void append() {
    public void append() {
        if (mIsAnimatingReset) {
        if (mIsAnimatingReset) {
            // If the user is quickly typing in their PIN while the reset animation is playing,
            // make sure to visibly show the added symbols after reset is complete
            mDelayedAppend++;
            return;
            return;
        }
        }
        int size = getResources().getDimensionPixelSize(R.dimen.password_shape_size);
        int size = getResources().getDimensionPixelSize(R.dimen.password_shape_size);
@@ -101,6 +105,14 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu
        mPosition++;
        mPosition++;
    }
    }


    private void appendAnyNewDigits() {
        mIsAnimatingReset = false;
        for (int i = 0; i < mDelayedAppend; i++) {
            append();
        }
        mDelayedAppend = 0;
    }

    @Override
    @Override
    public void delete() {
    public void delete() {
        if (mPosition == 0) {
        if (mPosition == 0) {
@@ -150,7 +162,7 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu
            // When we reach the last index, we want to send a signal that the animation is
            // When we reach the last index, we want to send a signal that the animation is
            // complete.
            // complete.
            if (i == position - 1) {
            if (i == position - 1) {
                postDelayed(() -> mIsAnimatingReset = false, delayMillis);
                postDelayed(() -> appendAnyNewDigits(), delayMillis);
            }
            }
        }
        }
    }
    }