Merge "Udfps enrollment now focuses on fingerprint region" into sc-dev

This commit is contained in:
Joshua Mccloskey
2021-09-02 19:21:05 +00:00
committed by Android (Google) Code Review
5 changed files with 45 additions and 29 deletions

View File

@@ -20,10 +20,23 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- The layout height/width are placeholders, which will be overwritten by
FingerprintSensorPropertiesInternal. -->
<View
android:id="@+id/udfps_enroll_accessibility_view"
android:layout_gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/accessibility_fingerprint_label"/>
<ImageView
android:id="@+id/udfps_enroll_animation_fp_progress_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!-- Fingerprint -->
<ImageView
android:id="@+id/udfps_enroll_animation_fp_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/accessibility_fingerprint_label"/>
android:layout_height="match_parent"/>
</com.android.systemui.biometrics.UdfpsEnrollView>

View File

@@ -759,6 +759,7 @@ public class UdfpsController implements DozeReceiver {
UdfpsEnrollView enrollView = (UdfpsEnrollView) mInflater.inflate(
R.layout.udfps_enroll_view, null);
mView.addView(enrollView);
enrollView.updateSensorLocation(mSensorProps);
return new UdfpsEnrollViewController(
enrollView,
mServerRequest.mEnrollHelper,

View File

@@ -43,7 +43,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
// 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;
@@ -62,7 +61,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
UdfpsEnrollDrawable(@NonNull Context context) {
super(context);
mProgressDrawable = new UdfpsEnrollProgressBarDrawable(context, this);
mSensorOutlinePaint = new Paint(0 /* flags */);
mSensorOutlinePaint.setAntiAlias(true);
@@ -100,8 +98,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
}
void onEnrollmentProgress(int remaining, int totalSteps) {
mProgressDrawable.setEnrollmentProgress(remaining, totalSteps);
if (mEnrollHelper.isCenterEnrollmentComplete()) {
if (mAnimatorSet != null && mAnimatorSet.isRunning()) {
mAnimatorSet.end();
@@ -139,14 +135,8 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
}
}
void onLastStepAcquired() {
mProgressDrawable.onLastStepAcquired();
}
@Override
public void draw(@NonNull Canvas canvas) {
mProgressDrawable.draw(canvas);
if (isIlluminationShowing()) {
return;
}
@@ -174,11 +164,6 @@ public class UdfpsEnrollDrawable extends UdfpsDrawable {
}
}
@Override
public void onBoundsChange(@NonNull Rect rect) {
mProgressDrawable.setBounds(rect);
}
@Override
public void setAlpha(int alpha) {
super.setAlpha(alpha);

View File

@@ -41,7 +41,6 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
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;
@@ -50,10 +49,8 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
private int mRotation; // After last step, rotate the progress bar once
private boolean mLastStepAcquired;
public UdfpsEnrollProgressBarDrawable(@NonNull Context context,
@NonNull UdfpsEnrollDrawable parent) {
public UdfpsEnrollProgressBarDrawable(@NonNull Context context) {
mContext = context;
mParent = parent;
mBackgroundCirclePaint = new Paint();
mBackgroundCirclePaint.setStrokeWidth(Utils.dpToPixels(context, PROGRESS_BAR_THICKNESS_DP));
@@ -101,7 +98,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
rotationAnimator.addUpdateListener(animation -> {
Log.d(TAG, "Rotation: " + mRotation);
mRotation = (int) animation.getAnimatedValue();
mParent.invalidateSelf();
invalidateSelf();
});
rotationAnimator.start();
}
@@ -114,11 +111,7 @@ public class UdfpsEnrollProgressBarDrawable extends Drawable {
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
// 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();
invalidateSelf();
});
mProgressAnimator.start();
}

View File

@@ -17,9 +17,12 @@
package com.android.systemui.biometrics;
import android.content.Context;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
@@ -32,20 +35,25 @@ import com.android.systemui.R;
*/
public class UdfpsEnrollView extends UdfpsAnimationView {
@NonNull private final UdfpsEnrollDrawable mFingerprintDrawable;
@NonNull private final UdfpsEnrollProgressBarDrawable mFingerprintProgressDrawable;
@NonNull private final Handler mHandler;
@NonNull private ImageView mFingerprintView;
@NonNull private ImageView mFingerprintProgressView;
public UdfpsEnrollView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
mFingerprintDrawable = new UdfpsEnrollDrawable(mContext);
mFingerprintProgressDrawable = new UdfpsEnrollProgressBarDrawable(context);
mHandler = new Handler(Looper.getMainLooper());
}
@Override
protected void onFinishInflate() {
mFingerprintView = findViewById(R.id.udfps_enroll_animation_fp_view);
mFingerprintProgressView = findViewById(R.id.udfps_enroll_animation_fp_progress_view);
mFingerprintView.setImageDrawable(mFingerprintDrawable);
mFingerprintProgressView.setImageDrawable(mFingerprintProgressDrawable);
}
@Override
@@ -53,15 +61,31 @@ public class UdfpsEnrollView extends UdfpsAnimationView {
return mFingerprintDrawable;
}
void updateSensorLocation(@NonNull FingerprintSensorPropertiesInternal sensorProps) {
View fingerprintAccessibilityView = findViewById(R.id.udfps_enroll_accessibility_view);
final int sensorHeight = sensorProps.sensorRadius * 2;
final int sensorWidth = sensorHeight;
ViewGroup.LayoutParams params = fingerprintAccessibilityView.getLayoutParams();
params.width = sensorWidth;
params.height = sensorHeight;
fingerprintAccessibilityView.setLayoutParams(params);
fingerprintAccessibilityView.requestLayout();
}
void setEnrollHelper(UdfpsEnrollHelper enrollHelper) {
mFingerprintDrawable.setEnrollHelper(enrollHelper);
}
void onEnrollmentProgress(int remaining, int totalSteps) {
mHandler.post(() -> mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps));
mHandler.post(() -> {
mFingerprintProgressDrawable.setEnrollmentProgress(remaining, totalSteps);
mFingerprintDrawable.onEnrollmentProgress(remaining, totalSteps);
});
}
void onLastStepAcquired() {
mHandler.post(mFingerprintDrawable::onLastStepAcquired);
mHandler.post(() -> {
mFingerprintProgressDrawable.onLastStepAcquired();
});
}
}