From 778aa79fc79e70071e7b71582a82c4665b773e04 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Mon, 7 Mar 2022 18:33:49 +0000 Subject: [PATCH] Bouncer: Add error animation for buttons Adds an animation for buttons when there is an incorrect entry. Bug: 222541046 Test: Test on device Change-Id: I4ac82e0b623d567f697b5bc62c082ae0d9561871 --- .../KeyguardAbsKeyInputViewController.java | 3 ++ .../keyguard/KeyguardPinBasedInputView.java | 51 +++++++++++++++++++ .../KeyguardPinBasedInputViewController.java | 6 +++ 3 files changed, 60 insertions(+) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index 7f456dba60530..eb418ff3b142a 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -194,9 +194,12 @@ public abstract class KeyguardAbsKeyInputViewController animators = new ArrayList(); + List buttons = new ArrayList<>(); + for (int i = 1; i <= 9; i++) { + buttons.add(mButtons[i]); + } + buttons.add(mDeleteButton); + buttons.add(mButtons[0]); + buttons.add(mOkButton); + + int delay = 0; + for (int i = 0; i < buttons.size(); i++) { + final View button = buttons.get(i); + AnimatorSet animateWrapper = new AnimatorSet(); + animateWrapper.setStartDelay(delay); + + ValueAnimator scaleDownAnimator = ValueAnimator.ofFloat(1f, 0.8f); + scaleDownAnimator.setInterpolator(Interpolators.STANDARD); + scaleDownAnimator.addUpdateListener(valueAnimator -> { + button.setScaleX((float) valueAnimator.getAnimatedValue()); + button.setScaleY((float) valueAnimator.getAnimatedValue()); + }); + scaleDownAnimator.setDuration(50); + + ValueAnimator scaleUpAnimator = ValueAnimator.ofFloat(0.8f, 1f); + scaleUpAnimator.setInterpolator(Interpolators.STANDARD); + scaleUpAnimator.addUpdateListener(valueAnimator -> { + button.setScaleX((float) valueAnimator.getAnimatedValue()); + button.setScaleY((float) valueAnimator.getAnimatedValue()); + }); + scaleUpAnimator.setDuration(617); + + animateWrapper.playSequentially(scaleDownAnimator, scaleUpAnimator); + animators.add(animateWrapper); + delay += 33; + } + animatorSet.playTogether(animators); + animatorSet.start(); + } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java index a9c03d1ac08ea..cc7e4f7a0d9a8 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPinBasedInputViewController.java @@ -134,4 +134,10 @@ public abstract class KeyguardPinBasedInputViewController