diff options
| author | 2023-10-26 13:35:46 -0700 | |
|---|---|---|
| committer | 2023-10-27 10:49:22 -0700 | |
| commit | 1fd8cccc8f52c09b4c6fb715e3d9ae5d99ac12a5 (patch) | |
| tree | f2fc7a1666dd7b6c0b1e23a0ef14c6bbdec663ee | |
| parent | fe2b9e790d7446f8c92aac9d0eb33ec867a59b6a (diff) | |
Add a staggered delete animation.
For when we long press the delete button for the pin screen, we want to
stagger the deletion of each pin dot. The maximum time for deleting all
of dots does not exceed 200ms.
Fixes: 285828860
Test: long press delete with a bunch of dots
Flag: NONE
Change-Id: Ib7764b77c3adec6508612fe7e2367eee123ca8a2
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java b/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java index 265d9e0c5ee6..ee70de3e86a0 100644 --- a/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java +++ b/packages/SystemUI/src/com/android/keyguard/PinShapeNonHintingView.java @@ -47,9 +47,11 @@ import com.android.systemui.res.R; * non six digit pin on their device */ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInput { - + private static final int RESET_STAGGER_DELAY = 40; + private static final int RESET_MAX_DELAY = 200; private int mColor = Utils.getColorAttr(getContext(), PIN_SHAPES).getDefaultColor(); private int mPosition = 0; + private boolean mIsAnimatingReset = false; private final PinShapeAdapter mPinShapeAdapter; private ValueAnimator mValueAnimator = ValueAnimator.ofFloat(1f, 0f); private Rect mFirstChildVisibleRect = new Rect(); @@ -78,6 +80,9 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu @Override public void append() { + if (mIsAnimatingReset) { + return; + } int size = getResources().getDimensionPixelSize(R.dimen.password_shape_size); ImageView pinDot = new ImageView(getContext()); pinDot.setLayoutParams(new LayoutParams(size, size)); @@ -131,9 +136,20 @@ public class PinShapeNonHintingView extends LinearLayout implements PinShapeInpu @Override public void reset() { + if (mPosition == 0) { + return; + } final int position = mPosition; + float baseDelay = Math.min(RESET_MAX_DELAY / position, RESET_STAGGER_DELAY); + mIsAnimatingReset = true; for (int i = 0; i < position; i++) { - delete(); + int delayMillis = (int) (baseDelay * i); + postDelayed(this::delete, delayMillis); + // When we reach the last index, we want to send a signal that the animation is + // complete. + if (i == position - 1) { + postDelayed(() -> mIsAnimatingReset = false, delayMillis); + } } } |