Merge changes I95f2f13d,Ie6aed9d7 into sc-dev

* changes:
  Remove stroke from UDFPS enroll icon
  Animate last section of progress when ACQUIRED_GOOD
This commit is contained in:
Kevin Chyn
2021-06-08 00:14:58 +00:00
committed by Android (Google) Code Review
7 changed files with 74 additions and 16 deletions

View File

@@ -187,7 +187,6 @@
<!-- UDFPS colors -->
<color name="udfps_enroll_icon">#000000</color> <!-- 100% black -->
<color name="udfps_moving_target_fill">#cc4285f4</color> <!-- 80% blue -->
<color name="udfps_moving_target_stroke">#ff669DF6</color> <!-- 100% blue -->
<color name="udfps_enroll_progress">#ff669DF6</color> <!-- 100% blue -->
<!-- Logout button -->

View File

@@ -211,6 +211,12 @@ public class UdfpsController implements DozeReceiver {
}
}
void onAcquiredGood() {
if (mEnrollHelper != null) {
mEnrollHelper.animateIfLastStep();
}
}
void onEnrollmentHelp() {
if (mEnrollHelper != null) {
mEnrollHelper.onEnrollmentHelp();
@@ -260,6 +266,11 @@ public class UdfpsController implements DozeReceiver {
}
mGoodCaptureReceived = true;
mView.stopIllumination();
if (mServerRequest != null) {
mServerRequest.onAcquiredGood();
} else {
Log.e(TAG, "Null serverRequest when onAcquiredGood");
}
});
}

View File

@@ -47,7 +47,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
@NonNull private final Drawable mMovingTargetFpIcon;
@NonNull private final Paint mSensorOutlinePaint;
@NonNull private final Paint mBlueFill;
@NonNull private final Paint mBlueStroke;
@Nullable private RectF mSensorRect;
@Nullable private UdfpsEnrollHelper mEnrollHelper;
@@ -76,12 +75,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
mBlueFill.setColor(context.getColor(R.color.udfps_moving_target_fill));
mBlueFill.setStyle(Paint.Style.FILL);
mBlueStroke = new Paint(0 /* flags */);
mBlueStroke.setAntiAlias(true);
mBlueStroke.setColor(context.getColor(R.color.udfps_moving_target_stroke));
mBlueStroke.setStyle(Paint.Style.STROKE);
mBlueStroke.setStrokeWidth(12);
mMovingTargetFpIcon = context.getResources().getDrawable(R.drawable.ic_fingerprint, null);
mMovingTargetFpIcon.setTint(Color.WHITE);
mMovingTargetFpIcon.mutate();
@@ -146,6 +139,10 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
}
}
void onLastStepAcquired() {
mProgressDrawable.onLastStepAcquired();
}
@Override
public void draw(@NonNull Canvas canvas) {
mProgressDrawable.draw(canvas);
@@ -163,7 +160,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
canvas.scale(mCurrentScale, mCurrentScale,
mSensorRect.centerX(), mSensorRect.centerY());
canvas.drawOval(mSensorRect, mBlueFill);
canvas.drawOval(mSensorRect, mBlueStroke);
}
mMovingTargetFpIcon.draw(canvas);
@@ -188,7 +184,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
super.setAlpha(alpha);
mSensorOutlinePaint.setAlpha(alpha);
mBlueFill.setAlpha(alpha);
mBlueStroke.setAlpha(alpha);
mMovingTargetFpIcon.setAlpha(alpha);
invalidateSelf();
}

View File

@@ -49,6 +49,7 @@ public class UdfpsEnrollHelper {
interface Listener {
void onEnrollmentProgress(int remaining, int totalSteps);
void onLastStepAcquired();
}
@NonNull private final Context mContext;
@@ -178,4 +179,15 @@ public class UdfpsEnrollHelper {
.get(index % mGuidedEnrollmentPoints.size());
return new PointF(originalPoint.x * scale, originalPoint.y * scale);
}
void animateIfLastStep() {
if (mListener == null) {
Log.e(TAG, "animateIfLastStep, null listener");
return;
}
if (mRemainingSteps <= 2 && mRemainingSteps >= 0) {
mListener.onLastStepAcquired();
}
}
}

View File

@@ -23,6 +23,7 @@ import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.TypedValue;
import androidx.annotation.NonNull;
@@ -46,6 +47,8 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
@Nullable private ValueAnimator mProgressAnimator;
private float mProgress;
private int mRotation; // After last step, rotate the progress bar once
private boolean mLastStepAcquired;
public UdfpsEnrollProgressBarDrawable(@NonNull Context context,
@NonNull UdfpsEnrollDrawable parent) {
@@ -81,13 +84,34 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
// 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);
setEnrollmentProgress(progress);
}
private void setEnrollmentProgress(float progress) {
if (mLastStepAcquired) {
return;
}
long animationDuration = 150;
if (progress == 1.f) {
animationDuration = 400;
final ValueAnimator rotationAnimator = ValueAnimator.ofInt(0, 400);
rotationAnimator.setDuration(animationDuration);
rotationAnimator.addUpdateListener(animation -> {
Log.d(TAG, "Rotation: " + mRotation);
mRotation = (int) animation.getAnimatedValue();
mParent.invalidateSelf();
});
rotationAnimator.start();
}
if (mProgressAnimator != null && mProgressAnimator.isRunning()) {
mProgressAnimator.cancel();
}
mProgressAnimator = ValueAnimator.ofFloat(mProgress, progress);
mProgressAnimator.setDuration(150);
mProgressAnimator.setDuration(animationDuration);
mProgressAnimator.addUpdateListener(animation -> {
mProgress = (float) animation.getAnimatedValue();
// Use the parent to invalidate, since it's the one that's attached as the view's
@@ -99,12 +123,17 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
mProgressAnimator.start();
}
void onLastStepAcquired() {
setEnrollmentProgress(1.f);
mLastStepAcquired = true;
}
@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());
canvas.rotate(-90 + mRotation, getBounds().centerX(), getBounds().centerY());
// Progress bar "background track"
final float halfPaddingPx = Utils.dpToPixels(mContext, PROGRESS_BAR_THICKNESS_DP) / 2;

View File

@@ -63,8 +63,10 @@ public class UdfpsEnrollView extends UdfpsAnimationView {
}
void onEnrollmentProgress(int remaining, int totalSteps) {
mHandler.post(() -> {
mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps);
});
mHandler.post(() -> mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps));
}
void onLastStepAcquired() {
mHandler.post(mFingerprintDrawable::onLastStepAcquired);
}
}

View File

@@ -32,7 +32,17 @@ public class UdfpsEnrollViewController extends UdfpsAnimationViewController<Udfp
private final int mEnrollProgressBarRadius;
@NonNull private final UdfpsEnrollHelper mEnrollHelper;
@NonNull private final UdfpsEnrollHelper.Listener mEnrollHelperListener =
mView::onEnrollmentProgress;
new UdfpsEnrollHelper.Listener() {
@Override
public void onEnrollmentProgress(int remaining, int totalSteps) {
mView.onEnrollmentProgress(remaining, totalSteps);
}
@Override
public void onLastStepAcquired() {
mView.onLastStepAcquired();
}
};
protected UdfpsEnrollViewController(
@NonNull UdfpsEnrollView view,