Merge "Update FingerprintEnrollEnrolling for UDFPS"

This commit is contained in:
TreeHugger Robot
2021-01-14 03:30:56 +00:00
committed by Android (Google) Code Review
3 changed files with 54 additions and 39 deletions

View File

@@ -87,10 +87,12 @@
android:layout_height="0dp"
android:layout_weight="1" />
<include
layout="@layout/fingerprint_enroll_enrolling_content"
<com.android.settings.widget.RingProgressBar
android:id="@+id/fingerprint_progress_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
android:minHeight="@dimen/fingerprint_progress_bar_min_size"
android:progress="0"
android:layout_gravity="center"/>
</com.android.settings.biometrics.fingerprint.UdfpsEnrollLayout>

View File

@@ -18,6 +18,7 @@ package com.android.settings.biometrics.fingerprint;
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.annotation.Nullable;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.DialogInterface;
@@ -102,8 +103,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
private Interpolator mFastOutLinearInInterpolator;
private int mIconTouchCount;
private boolean mAnimationCancelled;
private AnimatedVectorDrawable mIconAnimationDrawable;
private AnimatedVectorDrawable mIconBackgroundBlinksDrawable;
@Nullable private AnimatedVectorDrawable mIconAnimationDrawable;
@Nullable private AnimatedVectorDrawable mIconBackgroundBlinksDrawable;
private boolean mRestoring;
private Vibrator mVibrator;
@@ -181,34 +182,34 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
);
final LayerDrawable fingerprintDrawable = (LayerDrawable) mProgressBar.getBackground();
mIconAnimationDrawable = (AnimatedVectorDrawable)
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_animation);
mIconBackgroundBlinksDrawable = (AnimatedVectorDrawable)
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_background);
mIconAnimationDrawable.registerAnimationCallback(mIconAnimationCallback);
if (fingerprintDrawable != null) {
mIconAnimationDrawable = (AnimatedVectorDrawable)
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_animation);
mIconBackgroundBlinksDrawable = (AnimatedVectorDrawable)
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_background);
mIconAnimationDrawable.registerAnimationCallback(mIconAnimationCallback);
}
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(
this, android.R.interpolator.fast_out_slow_in);
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(
this, android.R.interpolator.linear_out_slow_in);
mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(
this, android.R.interpolator.fast_out_linear_in);
mProgressBar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mIconTouchCount++;
if (mIconTouchCount == ICON_TOUCH_COUNT_SHOW_UNTIL_DIALOG_SHOWN) {
showIconTouchDialog();
} else {
mProgressBar.postDelayed(mShowDialogRunnable,
ICON_TOUCH_DURATION_UNTIL_DIALOG_SHOWN);
}
} else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL
|| event.getActionMasked() == MotionEvent.ACTION_UP) {
mProgressBar.removeCallbacks(mShowDialogRunnable);
mProgressBar.setOnTouchListener((v, event) -> {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mIconTouchCount++;
if (mIconTouchCount == ICON_TOUCH_COUNT_SHOW_UNTIL_DIALOG_SHOWN) {
showIconTouchDialog();
} else {
mProgressBar.postDelayed(mShowDialogRunnable,
ICON_TOUCH_DURATION_UNTIL_DIALOG_SHOWN);
}
return true;
} else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL
|| event.getActionMasked() == MotionEvent.ACTION_UP) {
mProgressBar.removeCallbacks(mShowDialogRunnable);
}
return true;
});
mRestoring = savedInstanceState != null;
}
@@ -220,7 +221,12 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
@Override
protected boolean shouldStartAutomatically() {
return !mCanAssumeUdfps;
if (mCanAssumeUdfps) {
// Continue enrollment if restoring (e.g. configuration changed). Otherwise, wait
// for the entry animation to complete before starting.
return mRestoring;
}
return true;
}
@Override
@@ -230,6 +236,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
updateDescription();
if (mRestoring) {
startIconAnimation();
if (mCanAssumeUdfps) {
mProgressBar.setVisibility(View.VISIBLE);
}
}
}
@@ -239,6 +248,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
if (mCanAssumeUdfps) {
startEnrollment();
updateProgress(false /* animate */);
mProgressBar.setVisibility(View.VISIBLE);
}
@@ -247,7 +257,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
}
private void startIconAnimation() {
mIconAnimationDrawable.start();
if (mIconAnimationDrawable != null) {
mIconAnimationDrawable.start();
}
}
private void stopIconAnimation() {
@@ -277,7 +289,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
}
private void animateFlash() {
mIconBackgroundBlinksDrawable.start();
if (mIconBackgroundBlinksDrawable != null) {
mIconBackgroundBlinksDrawable.start();
}
}
protected Intent getFinishIntent() {

View File

@@ -17,11 +17,9 @@
package com.android.settings.biometrics.fingerprint;
import android.content.Context;
import android.graphics.Rect;
import android.hardware.fingerprint.FingerprintManager;
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.WindowInsets;
import android.view.WindowManager;
@@ -34,11 +32,17 @@ public class UdfpsEnrollLayout extends LinearLayout {
private static final String TAG = "UdfpsEnrollLayout";
private final FingerprintSensorPropertiesInternal mSensorProps;
private final int mSensorDiameter;
private final int mAnimationDiameter;
public UdfpsEnrollLayout(Context context, AttributeSet attrs) {
super(context, attrs);
mSensorProps = context.getSystemService(FingerprintManager.class)
.getSensorPropertiesInternal().get(0);
mSensorDiameter = mSensorProps.sensorRadius * 2;
// Multiply the progress bar size slightly so that the progress bar is outside the UDFPS
// affordance, which is shown by SystemUI
mAnimationDiameter = (int) (mSensorDiameter * 2);
}
@Override
@@ -55,22 +59,17 @@ public class UdfpsEnrollLayout extends LinearLayout {
// The translationY is the amount of extra height that should be added to the spacer
// above the animation
final int spaceHeight = mSensorProps.sensorLocationY - statusbarHeight
- mSensorProps.sensorRadius - animation.getTop();
- (mAnimationDiameter / 2) - animation.getTop();
animation.setTranslationY(spaceHeight);
}
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
final View animation = findViewById(R.id.fingerprint_progress_bar);
final int sensorDiameter = mSensorProps.sensorRadius * 2;
// Multiply it slightly so that the progress bar is outside the UDFPS affordance, and that
// the animation is within the UDFPS affordance.
final int animationDiameter = (int) (sensorDiameter * 1);
animation.measure(MeasureSpec.makeMeasureSpec(animationDiameter, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(animationDiameter, MeasureSpec.EXACTLY));
animation.measure(MeasureSpec.makeMeasureSpec(mAnimationDiameter, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mAnimationDiameter, MeasureSpec.EXACTLY));
}
}