Merge "Bouncer: Add error animation for buttons" into tm-dev am: 5720539c73

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

Change-Id: Ic48ecc3c0baba4565f1de0bc032091090e5a92f7
This commit is contained in:
Aaron Liu
2022-03-08 20:20:30 +00:00
committed by Automerger Merge Worker
3 changed files with 60 additions and 0 deletions

View File

@@ -194,9 +194,12 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
mMessageAreaController.setMessage(mView.getWrongPasswordStringId()); mMessageAreaController.setMessage(mView.getWrongPasswordStringId());
} }
mView.resetPasswordText(true /* animate */, false /* announce deletion if no match */); mView.resetPasswordText(true /* animate */, false /* announce deletion if no match */);
startErrorAnimation();
} }
} }
protected void startErrorAnimation() { /* no-op */ }
protected void verifyPasswordAndUnlock() { protected void verifyPasswordAndUnlock() {
if (mDismissing) return; // already verified but haven't been dismissed; don't do it again. if (mDismissing) return; // already verified but haven't been dismissed; don't do it again.

View File

@@ -24,6 +24,9 @@ import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART;
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT; import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST; import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.content.Context; import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
@@ -32,6 +35,10 @@ import android.view.View;
import com.android.internal.widget.LockscreenCredential; import com.android.internal.widget.LockscreenCredential;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import java.util.ArrayList;
import java.util.List;
/** /**
* A Pin based Keyguard input view * A Pin based Keyguard input view
@@ -188,4 +195,48 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
return getContext().getString( return getContext().getString(
com.android.internal.R.string.keyguard_accessibility_pin_unlock); com.android.internal.R.string.keyguard_accessibility_pin_unlock);
} }
/**
* Begins an error animation for this view.
**/
public void startErrorAnimation() {
AnimatorSet animatorSet = new AnimatorSet();
List<Animator> animators = new ArrayList();
List<View> 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();
}
} }

View File

@@ -134,4 +134,10 @@ public abstract class KeyguardPinBasedInputViewController<T extends KeyguardPinB
mView.setPasswordEntryEnabled(true); mView.setPasswordEntryEnabled(true);
mMessageAreaController.setMessage(R.string.keyguard_enter_your_pin); mMessageAreaController.setMessage(R.string.keyguard_enter_your_pin);
} }
@Override
protected void startErrorAnimation() {
super.startErrorAnimation();
mView.startErrorAnimation();
}
} }