diff --git a/packages/SystemUI/res/drawable/udfps_progress_bar.xml b/packages/SystemUI/res/drawable/udfps_progress_bar.xml
deleted file mode 100644
index e5389f3b99ef5..0000000000000
--- a/packages/SystemUI/res/drawable/udfps_progress_bar.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-
-
-
-
- -
-
-
-
-
- -
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/packages/SystemUI/res/layout/udfps_enroll_view.xml b/packages/SystemUI/res/layout/udfps_enroll_view.xml
index 40353052ca857..a55653e5485fb 100644
--- a/packages/SystemUI/res/layout/udfps_enroll_view.xml
+++ b/packages/SystemUI/res/layout/udfps_enroll_view.xml
@@ -20,17 +20,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
-
#000000
#cc4285f4
#ff669DF6
+ #ff669DF6
#ccffffff
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 119507b67e9ad..34a1452295802 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -630,6 +630,11 @@
58.0001 29.2229,56.9551 26.8945,55.195
+
+
+ 360
+
+
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index c0ebff6d638c1..abdd21e5a3cb3 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -1188,9 +1188,6 @@
60dp
-
- 12dp
-
0dp
4dp
diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml
index aadcaba09402e..83b8e2b147427 100644
--- a/packages/SystemUI/res/values/styles.xml
+++ b/packages/SystemUI/res/values/styles.xml
@@ -871,14 +871,6 @@
- ?android:attr/textColorPrimary
-
-
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java
index 83ae865d7427d..6b6e0f19d7fb3 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollDrawable.java
@@ -26,8 +26,6 @@ import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import android.os.Looper;
import android.view.animation.AccelerateDecelerateInterpolator;
import androidx.annotation.NonNull;
@@ -41,17 +39,15 @@ import com.android.systemui.R;
public class UdfpsEnrollDrawable extends UdfpsDrawable {
private static final String TAG = "UdfpsAnimationEnroll";
- static final float PROGRESS_BAR_RADIUS = 360.f;
-
private static final long ANIM_DURATION = 800;
// 1 + SCALE_MAX is the maximum that the moving target will animate to
private static final float SCALE_MAX = 0.25f;
+ @NonNull private final UdfpsEnrollProgressBarDrawable mProgressDrawable;
@NonNull private final Drawable mMovingTargetFpIcon;
@NonNull private final Paint mSensorOutlinePaint;
@NonNull private final Paint mBlueFill;
@NonNull private final Paint mBlueStroke;
- @NonNull private final Handler mHandler;
@Nullable private RectF mSensorRect;
@Nullable private UdfpsEnrollHelper mEnrollHelper;
@@ -64,11 +60,10 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
// Moving target size
float mCurrentScale = 1.f;
-
UdfpsEnrollDrawable(@NonNull Context context) {
super(context);
- mHandler = new Handler(Looper.getMainLooper());
+ mProgressDrawable = new UdfpsEnrollProgressBarDrawable(context, this);
mSensorOutlinePaint = new Paint(0 /* flags */);
mSensorOutlinePaint.setAntiAlias(true);
@@ -112,47 +107,49 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
}
void onEnrollmentProgress(int remaining, int totalSteps) {
+ mProgressDrawable.setEnrollmentProgress(remaining, totalSteps);
+
if (mEnrollHelper.isCenterEnrollmentComplete()) {
- mHandler.post(() -> {
- if (mAnimatorSet != null && mAnimatorSet.isRunning()) {
- mAnimatorSet.end();
- }
+ if (mAnimatorSet != null && mAnimatorSet.isRunning()) {
+ mAnimatorSet.end();
+ }
- final PointF point = mEnrollHelper.getNextGuidedEnrollmentPoint();
+ final PointF point = mEnrollHelper.getNextGuidedEnrollmentPoint();
- final ValueAnimator x = ValueAnimator.ofFloat(mCurrentX, point.x);
- x.addUpdateListener(animation -> {
- mCurrentX = (float) animation.getAnimatedValue();
- invalidateSelf();
- });
-
- final ValueAnimator y = ValueAnimator.ofFloat(mCurrentY, point.y);
- y.addUpdateListener(animation -> {
- mCurrentY = (float) animation.getAnimatedValue();
- invalidateSelf();
- });
-
- final ValueAnimator scale = ValueAnimator.ofFloat(0, (float) Math.PI);
- scale.setDuration(ANIM_DURATION);
- scale.addUpdateListener(animation -> {
- // Grow then shrink
- mCurrentScale = 1 +
- SCALE_MAX * (float) Math.sin((float) animation.getAnimatedValue());
- invalidateSelf();
- });
-
- mAnimatorSet = new AnimatorSet();
-
- mAnimatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
- mAnimatorSet.setDuration(ANIM_DURATION);
- mAnimatorSet.playTogether(x, y, scale);
- mAnimatorSet.start();
+ final ValueAnimator x = ValueAnimator.ofFloat(mCurrentX, point.x);
+ x.addUpdateListener(animation -> {
+ mCurrentX = (float) animation.getAnimatedValue();
+ invalidateSelf();
});
+
+ final ValueAnimator y = ValueAnimator.ofFloat(mCurrentY, point.y);
+ y.addUpdateListener(animation -> {
+ mCurrentY = (float) animation.getAnimatedValue();
+ invalidateSelf();
+ });
+
+ final ValueAnimator scale = ValueAnimator.ofFloat(0, (float) Math.PI);
+ scale.setDuration(ANIM_DURATION);
+ scale.addUpdateListener(animation -> {
+ // Grow then shrink
+ mCurrentScale = 1 +
+ SCALE_MAX * (float) Math.sin((float) animation.getAnimatedValue());
+ invalidateSelf();
+ });
+
+ mAnimatorSet = new AnimatorSet();
+
+ mAnimatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
+ mAnimatorSet.setDuration(ANIM_DURATION);
+ mAnimatorSet.playTogether(x, y, scale);
+ mAnimatorSet.start();
}
}
@Override
public void draw(@NonNull Canvas canvas) {
+ mProgressDrawable.draw(canvas);
+
if (isIlluminationShowing()) {
return;
}
@@ -181,6 +178,11 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
}
}
+ @Override
+ public void onBoundsChange(@NonNull Rect rect) {
+ mProgressDrawable.setBounds(rect);
+ }
+
@Override
public void setAlpha(int alpha) {
super.setAlpha(alpha);
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java
new file mode 100644
index 0000000000000..5c9e52f864712
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollProgressBarDrawable.java
@@ -0,0 +1,150 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.biometrics;
+
+import android.animation.ValueAnimator;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+import android.util.TypedValue;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import com.android.systemui.R;
+
+/**
+ * UDFPS enrollment progress bar.
+ */
+public class UdfpsEnrollProgressBarDrawable extends Drawable {
+
+ private static final String TAG = "UdfpsEnrollProgressBarDrawable";
+
+ private static final float PROGRESS_BAR_THICKNESS_DP = 12;
+
+ @NonNull private final Context mContext;
+ @NonNull private final UdfpsEnrollDrawable mParent;
+ @NonNull private final Paint mBackgroundCirclePaint;
+ @NonNull private final Paint mProgressPaint;
+
+ @Nullable private ValueAnimator mProgressAnimator;
+ private float mProgress;
+
+ public UdfpsEnrollProgressBarDrawable(@NonNull Context context,
+ @NonNull UdfpsEnrollDrawable parent) {
+ mContext = context;
+ mParent = parent;
+
+ mBackgroundCirclePaint = new Paint();
+ mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
+ mBackgroundCirclePaint.setColor(context.getColor(R.color.white_disabled));
+ mBackgroundCirclePaint.setAntiAlias(true);
+ mBackgroundCirclePaint.setStyle(Paint.Style.STROKE);
+
+ // Background circle color + alpha
+ TypedArray tc = context.obtainStyledAttributes(
+ new int[] {android.R.attr.colorControlNormal});
+ int tintColor = tc.getColor(0, mBackgroundCirclePaint.getColor());
+ mBackgroundCirclePaint.setColor(tintColor);
+ tc.recycle();
+ TypedValue alpha = new TypedValue();
+ context.getTheme().resolveAttribute(android.R.attr.disabledAlpha, alpha, true);
+ mBackgroundCirclePaint.setAlpha((int) (alpha.getFloat() * 255));
+
+ // Progress should not be color extracted
+ mProgressPaint = new Paint();
+ mProgressPaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
+ mProgressPaint.setColor(context.getColor(R.color.udfps_enroll_progress));
+ mProgressPaint.setAntiAlias(true);
+ mProgressPaint.setStyle(Paint.Style.STROKE);
+ mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
+ }
+
+ void setEnrollmentProgress(int remaining, int totalSteps) {
+ // Add one so that the first steps actually changes progress, but also so that the last
+ // step ends at 1.0
+ final float progress = (totalSteps - remaining + 1) / (float) (totalSteps + 1);
+
+ if (mProgressAnimator != null && mProgressAnimator.isRunning()) {
+ mProgressAnimator.cancel();
+ }
+
+ mProgressAnimator = ValueAnimator.ofFloat(mProgress, progress);
+ mProgressAnimator.setDuration(150);
+ mProgressAnimator.addUpdateListener(animation -> {
+ mProgress = (float) animation.getAnimatedValue();
+ // Use the parent to invalidate, since it's the one that's attached as the view's
+ // drawable and has its callback set automatically. Invalidating via
+ // `this.invalidateSelf` actually does not invoke draw(), since this drawable's callback
+ // is not really set.
+ mParent.invalidateSelf();
+ });
+ mProgressAnimator.start();
+ }
+
+ @Override
+ public void draw(@NonNull Canvas canvas) {
+ canvas.save();
+
+ // Progress starts from the top, instead of the right
+ canvas.rotate(-90, getBounds().centerX(), getBounds().centerY());
+
+ // Progress bar "background track"
+ final float halfPaddingPx = Utils.dpToPixels(mContext, PROGRESS_BAR_THICKNESS_DP) / 2;
+ canvas.drawArc(halfPaddingPx,
+ halfPaddingPx,
+ getBounds().right - halfPaddingPx,
+ getBounds().bottom - halfPaddingPx,
+ 0,
+ 360,
+ false,
+ mBackgroundCirclePaint
+ );
+
+ final float progress = 360.f * mProgress;
+ // Progress
+ canvas.drawArc(halfPaddingPx,
+ halfPaddingPx,
+ getBounds().right - halfPaddingPx,
+ getBounds().bottom - halfPaddingPx,
+ 0,
+ progress,
+ false,
+ mProgressPaint
+ );
+
+ canvas.restore();
+ }
+
+ @Override
+ public void setAlpha(int alpha) {
+
+ }
+
+ @Override
+ public void setColorFilter(@Nullable ColorFilter colorFilter) {
+
+ }
+
+ @Override
+ public int getOpacity() {
+ return 0;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java
index 3bf1864aca4c9..3b30220458490 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollView.java
@@ -17,6 +17,8 @@
package com.android.systemui.biometrics;
import android.content.Context;
+import android.os.Handler;
+import android.os.Looper;
import android.util.AttributeSet;
import android.widget.ImageView;
@@ -30,26 +32,25 @@ import com.android.systemui.R;
*/
public class UdfpsEnrollView extends UdfpsAnimationView {
@NonNull private final UdfpsEnrollDrawable mFingerprintDrawable;
+ @NonNull private final Handler mHandler;
+
@NonNull private ImageView mFingerprintView;
- @NonNull private UdfpsProgressBar mProgressBar;
public UdfpsEnrollView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
mFingerprintDrawable = new UdfpsEnrollDrawable(mContext);
+ mHandler = new Handler(Looper.getMainLooper());
}
@Override
protected void updateAlpha() {
super.updateAlpha();
- mProgressBar.setAlpha(calculateAlpha());
- mProgressBar.getProgressDrawable().setAlpha(calculateAlpha());
}
@Override
protected void onFinishInflate() {
mFingerprintView = findViewById(R.id.udfps_enroll_animation_fp_view);
mFingerprintView.setImageDrawable(mFingerprintDrawable);
- mProgressBar = findViewById(R.id.progress_bar);
}
@Override
@@ -62,6 +63,8 @@ public class UdfpsEnrollView extends UdfpsAnimationView {
}
void onEnrollmentProgress(int remaining, int totalSteps) {
- mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps);
+ mHandler.post(() -> {
+ mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps);
+ });
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java
index c1f3fe0ffbfdb..953448d93d6a4 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsEnrollViewController.java
@@ -18,7 +18,6 @@ package com.android.systemui.biometrics;
import android.annotation.NonNull;
import android.graphics.PointF;
-import android.view.View;
import com.android.systemui.R;
import com.android.systemui.dump.DumpManager;
@@ -29,8 +28,11 @@ import com.android.systemui.statusbar.phone.StatusBar;
* Class that coordinates non-HBM animations during enrollment.
*/
public class UdfpsEnrollViewController extends UdfpsAnimationViewController {
- @NonNull private final UdfpsProgressBar mProgressBar;
+
+ private final int mEnrollProgressBarRadius;
@NonNull private final UdfpsEnrollHelper mEnrollHelper;
+ @NonNull private final UdfpsEnrollHelper.Listener mEnrollHelperListener =
+ mView::onEnrollmentProgress;
protected UdfpsEnrollViewController(
@NonNull UdfpsEnrollView view,
@@ -39,8 +41,9 @@ public class UdfpsEnrollViewController extends UdfpsAnimationViewController