Merge "Add visual feedback on UDFPS enrollment help." into sc-qpr1-dev

This commit is contained in:
Joe Bolinger
2021-09-01 22:46:45 +00:00
committed by Android (Google) Code Review
6 changed files with 76 additions and 4 deletions

View File

@@ -187,7 +187,8 @@
<!-- UDFPS colors -->
<color name="udfps_enroll_icon">#000000</color> <!-- 100% black -->
<color name="udfps_moving_target_fill">#cc4285f4</color> <!-- 80% blue -->
<color name="udfps_enroll_progress">#ff669DF6</color> <!-- 100% blue -->
<color name="udfps_enroll_progress">#ff669DF6</color> <!-- blue 400 -->
<color name="udfps_enroll_progress_help">#ffEE675C</color> <!-- red 400 -->
<!-- Logout button -->
<color name="logout_button_bg_color">#ccffffff</color>

View File

@@ -143,6 +143,10 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
mProgressDrawable.onLastStepAcquired();
}
void onEnrollmentHelp() {
mProgressDrawable.onEnrollmentHelp();
}
@Override
public void draw(@NonNull Canvas canvas) {
mProgressDrawable.draw(canvas);

View File

@@ -50,6 +50,7 @@ public class UdfpsEnrollHelper {
interface Listener {
void onEnrollmentProgress(int remaining, int totalSteps);
void onLastStepAcquired();
void onEnrollmentHelp();
}
@NonNull private final Context mContext;
@@ -138,7 +139,9 @@ public class UdfpsEnrollHelper {
}
void onEnrollmentHelp() {
if (mListener != null) {
mListener.onEnrollmentHelp();
}
}
void setListener(Listener listener) {

View File

@@ -16,7 +16,9 @@
package com.android.systemui.biometrics;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.annotation.ColorInt;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
@@ -46,6 +48,11 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
@NonNull private final Paint mProgressPaint;
@Nullable private ValueAnimator mProgressAnimator;
@Nullable private ValueAnimator mProgressShowingHelpAnimator;
@Nullable private ValueAnimator mProgressHidingHelpAnimator;
@ColorInt private final int mProgressColor;
@ColorInt private final int mProgressHelpColor;
private final int mShortAnimationDuration;
private float mProgress;
private int mRotation; // After last step, rotate the progress bar once
private boolean mLastStepAcquired;
@@ -55,6 +62,11 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
mContext = context;
mParent = parent;
mShortAnimationDuration = context.getResources()
.getInteger(com.android.internal.R.integer.config_shortAnimTime);
mProgressColor = context.getColor(R.color.udfps_enroll_progress);
mProgressHelpColor = context.getColor(R.color.udfps_enroll_progress_help);
mBackgroundCirclePaint = new Paint();
mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
mBackgroundCirclePaint.setColor(context.getColor(R.color.white_disabled));
@@ -74,7 +86,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
// 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.setColor(mProgressColor);
mProgressPaint.setAntiAlias(true);
mProgressPaint.setStyle(Paint.Style.STROKE);
mProgressPaint.setStrokeCap(Paint.Cap.ROUND);
@@ -92,7 +104,9 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
return;
}
long animationDuration = 150;
long animationDuration = mShortAnimationDuration;
hideEnrollmentHelp();
if (progress == 1.f) {
animationDuration = 400;
@@ -128,6 +142,47 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
mLastStepAcquired = true;
}
void onEnrollmentHelp() {
if (mProgressShowingHelpAnimator != null || mProgressAnimator == null) {
return; // already showing or at 0% (no progress bar visible)
}
if (mProgressHidingHelpAnimator != null && mProgressHidingHelpAnimator.isRunning()) {
mProgressHidingHelpAnimator.cancel();
}
mProgressHidingHelpAnimator = null;
mProgressShowingHelpAnimator = getProgressColorAnimator(
mProgressPaint.getColor(), mProgressHelpColor);
mProgressShowingHelpAnimator.start();
}
private void hideEnrollmentHelp() {
if (mProgressHidingHelpAnimator != null || mProgressShowingHelpAnimator == null) {
return; // already hidden or help never shown
}
if (mProgressShowingHelpAnimator != null && mProgressShowingHelpAnimator.isRunning()) {
mProgressShowingHelpAnimator.cancel();
}
mProgressShowingHelpAnimator = null;
mProgressHidingHelpAnimator = getProgressColorAnimator(
mProgressPaint.getColor(), mProgressColor);
mProgressHidingHelpAnimator.start();
}
private ValueAnimator getProgressColorAnimator(@ColorInt int from, @ColorInt int to) {
final ValueAnimator animator = ValueAnimator.ofObject(
ArgbEvaluator.getInstance(), from, to);
animator.setDuration(mShortAnimationDuration);
animator.addUpdateListener(animation -> {
mProgressPaint.setColor((int) animation.getAnimatedValue());
mParent.invalidateSelf();
});
return animator;
}
@Override
public void draw(@NonNull Canvas canvas) {
canvas.save();

View File

@@ -64,4 +64,8 @@ public class UdfpsEnrollView extends UdfpsAnimationView {
void onLastStepAcquired() {
mHandler.post(mFingerprintDrawable::onLastStepAcquired);
}
void onEnrollmentHelp() {
mHandler.post(mFingerprintDrawable::onEnrollmentHelp);
}
}

View File

@@ -42,6 +42,11 @@ public class UdfpsEnrollViewController extends UdfpsAnimationViewController<Udfp
public void onLastStepAcquired() {
mView.onLastStepAcquired();
}
@Override
public void onEnrollmentHelp() {
mView.onEnrollmentHelp();
}
};
protected UdfpsEnrollViewController(