summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDil3mm4 <dil3mm4.dev@gmail.com>2021-01-26 23:28:26 +0000
committeralk3pInjection <webmaster@raspii.tech>2021-09-27 21:17:05 +0800
commitf55e2c7961f41f3e2e661c2ca882ab2882285002 (patch)
treee0503dab08eed9f8000fa4bc6b6414c1d946da52
parent08fec2448afdb3fae981cb692d4643e53da085ed (diff)
[ArrowOS][11.0] SystemUI: Face Unlock animation
Change-Id: I3b6addb91923ca703f9e73bfce9bcf0bf8f1fc85
-rw-r--r--packages/SystemUI/res/drawable/ic_lock_face.xml10
-rw-r--r--packages/SystemUI/src/com/android/systemui/FaceLockUIAnimations.java68
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java19
3 files changed, 93 insertions, 4 deletions
diff --git a/packages/SystemUI/res/drawable/ic_lock_face.xml b/packages/SystemUI/res/drawable/ic_lock_face.xml
new file mode 100644
index 000000000000..78e4896bfefa
--- /dev/null
+++ b/packages/SystemUI/res/drawable/ic_lock_face.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="32dp"
+ android:width="32dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+
+ <path android:fillColor="#ffffffff"
+ android:pathData="M12,17.5C14.33,17.5 16.3,16.04 17.11,14H6.89C7.69,16.04 9.67,17.5 12,17.5M8.5,11A1.5,1.5 0 0,0 10,9.5A1.5,1.5 0 0,0 8.5,8A1.5,1.5 0 0,0 7,9.5A1.5,1.5 0 0,0 8.5,11M15.5,11A1.5,1.5 0 0,0 17,9.5A1.5,1.5 0 0,0 15.5,8A1.5,1.5 0 0,0 14,9.5A1.5,1.5 0 0,0 15.5,11M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
+
+</vector>
diff --git a/packages/SystemUI/src/com/android/systemui/FaceLockUIAnimations.java b/packages/SystemUI/src/com/android/systemui/FaceLockUIAnimations.java
new file mode 100644
index 000000000000..5786c6dd9aba
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/FaceLockUIAnimations.java
@@ -0,0 +1,68 @@
+package com.android.systemui;
+
+import android.animation.Animator;
+import android.animation.ObjectAnimator;
+import android.view.animation.Animation;
+import android.view.animation.BounceInterpolator;
+import android.view.animation.LinearInterpolator;
+import android.view.View;
+
+import java.util.Random;
+
+public class FaceLockUIAnimations {
+
+ private static boolean mAnimationStarted = false;
+
+ public static void faceLockShake(View targetView, boolean isCancelling) {
+ if (!isCancelling) {
+ ObjectAnimator animator = ObjectAnimator.ofFloat(targetView, "translationY", -100, 0, 0);
+ ObjectAnimator animator2 = ObjectAnimator.ofFloat(targetView, "translationX", 0, 17, 0);
+ animator.setInterpolator(new BounceInterpolator());
+ animator2.setInterpolator(new BounceInterpolator());
+ animator.setDuration(500);
+ animator2.setStartDelay(500);
+ animator2.setDuration(500);
+ animator2.setRepeatCount(-1);
+ animator.setAutoCancel(true);
+ animator2.setAutoCancel(true);
+ animator.start();
+ animator2.start();
+ } else {
+ setNullAnim(targetView);
+ }
+ }
+
+ public static void aodBackgroundRotation(View targetView, boolean isCancelling, boolean isPinwheel) {
+ if (!mAnimationStarted) {
+ if (!isCancelling) {
+ ObjectAnimator animator = ObjectAnimator.ofFloat(targetView, "rotation", 0f, 360f);
+ if (isPinwheel) {
+ animator.setDuration(getRandomNumberInRange(1000,3000));
+ } else {
+ animator.setDuration(30000);
+ }
+ animator.setInterpolator(new LinearInterpolator());
+ animator.setRepeatCount(ObjectAnimator.INFINITE);
+ animator.setRepeatMode(ObjectAnimator.INFINITE);
+ animator.start();
+ } else {
+ setNullAnim(targetView);
+ }
+ }
+ }
+
+ private static void setNullAnim(View targetView) {
+ ObjectAnimator animator = ObjectAnimator.ofFloat(targetView, "translationY", 0, 0, 0);
+ ObjectAnimator animator2 = ObjectAnimator.ofFloat(targetView, "translationX", 0, 0, 0);
+ mAnimationStarted = false;
+ animator.setDuration(0);
+ animator2.setDuration(0);
+ animator.start();
+ animator2.start();
+ }
+
+ private static int getRandomNumberInRange(int min, int max) {
+ Random r = new Random();
+ return r.nextInt((max - min) + 1) + min;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
index 40b329d39032..1bbc5e4caeb8 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
@@ -32,6 +32,7 @@ import android.util.SparseArray;
import android.view.ViewTreeObserver.OnPreDrawListener;
import com.android.internal.graphics.ColorUtils;
+import com.android.systemui.FaceLockUIAnimations;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.statusbar.KeyguardAffordanceView;
@@ -55,6 +56,7 @@ public class LockIcon extends KeyguardAffordanceView {
private boolean mPulsing;
private boolean mDozing;
private boolean mKeyguardJustShown;
+ private boolean mIsFaceUnlock;
private boolean mPredrawRegistered;
private Drawable mFaceScanningAnim;
private final SparseArray<Drawable> mDrawableCache = new SparseArray<>();
@@ -67,13 +69,17 @@ public class LockIcon extends KeyguardAffordanceView {
int newState = mState;
Drawable icon = getIcon(newState);
- setImageDrawable(icon, false);
+ mIsFaceUnlock = newState == STATE_SCANNING_FACE;
- if (newState == STATE_SCANNING_FACE) {
+ if (mIsFaceUnlock) {
+ icon = mContext.getDrawable(getIconForState(newState));
announceForAccessibility(getResources().getString(
R.string.accessibility_scanning_face));
}
+ setImageDrawable(icon, false);
+ shakeFace();
+
if (icon instanceof AnimatedVectorDrawable) {
final AnimatedVectorDrawable animation = (AnimatedVectorDrawable) icon;
animation.forceAnimationOnUI();
@@ -186,11 +192,12 @@ public class LockIcon extends KeyguardAffordanceView {
private static int getIconForState(int state) {
int iconRes;
switch (state) {
+ case STATE_SCANNING_FACE:
+ iconRes = com.android.systemui.R.drawable.ic_lock_face;
+ break;
case STATE_LOCKED:
// Scanning animation is a pulsing padlock. This means that the resting state is
// just a padlock.
- case STATE_SCANNING_FACE:
- // Error animation also starts and ands on the padlock.
case STATE_BIOMETRICS_ERROR:
iconRes = com.android.internal.R.drawable.ic_lock;
break;
@@ -268,4 +275,8 @@ public class LockIcon extends KeyguardAffordanceView {
}
return LOCK_ANIM_RES_IDS[0][lockAnimIndex];
}
+
+ public void shakeFace() {
+ FaceLockUIAnimations.faceLockShake(this, mIsFaceUnlock ? false :true);
+ }
}