Update FingerprintEnrollEnrolling for UDFPS
SysUI is now responsible for showing the fingerprint icon and circle (when finger is not down). This changes makes slight tweak so the progress indicator is not covered by SysUI. Fixes a few corner cases when onConfigurationChange occurs Bug: 177026664 Bug: 177275693 Test: No effect on existing devices Change-Id: Id06eab00861878a867804a27f4778f1e3fbd174e
This commit is contained in:
@@ -87,10 +87,12 @@
|
|||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<include
|
<com.android.settings.widget.RingProgressBar
|
||||||
layout="@layout/fingerprint_enroll_enrolling_content"
|
android:id="@+id/fingerprint_progress_bar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="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>
|
</com.android.settings.biometrics.fingerprint.UdfpsEnrollLayout>
|
||||||
|
@@ -18,6 +18,7 @@ package com.android.settings.biometrics.fingerprint;
|
|||||||
|
|
||||||
import android.animation.Animator;
|
import android.animation.Animator;
|
||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
|
import android.annotation.Nullable;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
@@ -102,8 +103,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
private Interpolator mFastOutLinearInInterpolator;
|
private Interpolator mFastOutLinearInInterpolator;
|
||||||
private int mIconTouchCount;
|
private int mIconTouchCount;
|
||||||
private boolean mAnimationCancelled;
|
private boolean mAnimationCancelled;
|
||||||
private AnimatedVectorDrawable mIconAnimationDrawable;
|
@Nullable private AnimatedVectorDrawable mIconAnimationDrawable;
|
||||||
private AnimatedVectorDrawable mIconBackgroundBlinksDrawable;
|
@Nullable private AnimatedVectorDrawable mIconBackgroundBlinksDrawable;
|
||||||
private boolean mRestoring;
|
private boolean mRestoring;
|
||||||
private Vibrator mVibrator;
|
private Vibrator mVibrator;
|
||||||
|
|
||||||
@@ -181,20 +182,21 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final LayerDrawable fingerprintDrawable = (LayerDrawable) mProgressBar.getBackground();
|
final LayerDrawable fingerprintDrawable = (LayerDrawable) mProgressBar.getBackground();
|
||||||
|
if (fingerprintDrawable != null) {
|
||||||
mIconAnimationDrawable = (AnimatedVectorDrawable)
|
mIconAnimationDrawable = (AnimatedVectorDrawable)
|
||||||
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_animation);
|
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_animation);
|
||||||
mIconBackgroundBlinksDrawable = (AnimatedVectorDrawable)
|
mIconBackgroundBlinksDrawable = (AnimatedVectorDrawable)
|
||||||
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_background);
|
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_background);
|
||||||
mIconAnimationDrawable.registerAnimationCallback(mIconAnimationCallback);
|
mIconAnimationDrawable.registerAnimationCallback(mIconAnimationCallback);
|
||||||
|
}
|
||||||
|
|
||||||
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(
|
mFastOutSlowInInterpolator = AnimationUtils.loadInterpolator(
|
||||||
this, android.R.interpolator.fast_out_slow_in);
|
this, android.R.interpolator.fast_out_slow_in);
|
||||||
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(
|
mLinearOutSlowInInterpolator = AnimationUtils.loadInterpolator(
|
||||||
this, android.R.interpolator.linear_out_slow_in);
|
this, android.R.interpolator.linear_out_slow_in);
|
||||||
mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(
|
mFastOutLinearInInterpolator = AnimationUtils.loadInterpolator(
|
||||||
this, android.R.interpolator.fast_out_linear_in);
|
this, android.R.interpolator.fast_out_linear_in);
|
||||||
mProgressBar.setOnTouchListener(new View.OnTouchListener() {
|
mProgressBar.setOnTouchListener((v, event) -> {
|
||||||
@Override
|
|
||||||
public boolean onTouch(View v, MotionEvent event) {
|
|
||||||
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
|
||||||
mIconTouchCount++;
|
mIconTouchCount++;
|
||||||
if (mIconTouchCount == ICON_TOUCH_COUNT_SHOW_UNTIL_DIALOG_SHOWN) {
|
if (mIconTouchCount == ICON_TOUCH_COUNT_SHOW_UNTIL_DIALOG_SHOWN) {
|
||||||
@@ -208,7 +210,6 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
mProgressBar.removeCallbacks(mShowDialogRunnable);
|
mProgressBar.removeCallbacks(mShowDialogRunnable);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
});
|
});
|
||||||
mRestoring = savedInstanceState != null;
|
mRestoring = savedInstanceState != null;
|
||||||
}
|
}
|
||||||
@@ -220,7 +221,12 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean shouldStartAutomatically() {
|
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
|
@Override
|
||||||
@@ -230,6 +236,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
updateDescription();
|
updateDescription();
|
||||||
if (mRestoring) {
|
if (mRestoring) {
|
||||||
startIconAnimation();
|
startIconAnimation();
|
||||||
|
if (mCanAssumeUdfps) {
|
||||||
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,6 +248,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
|
|
||||||
if (mCanAssumeUdfps) {
|
if (mCanAssumeUdfps) {
|
||||||
startEnrollment();
|
startEnrollment();
|
||||||
|
updateProgress(false /* animate */);
|
||||||
mProgressBar.setVisibility(View.VISIBLE);
|
mProgressBar.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,8 +257,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void startIconAnimation() {
|
private void startIconAnimation() {
|
||||||
|
if (mIconAnimationDrawable != null) {
|
||||||
mIconAnimationDrawable.start();
|
mIconAnimationDrawable.start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void stopIconAnimation() {
|
private void stopIconAnimation() {
|
||||||
mAnimationCancelled = true;
|
mAnimationCancelled = true;
|
||||||
@@ -277,8 +289,10 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void animateFlash() {
|
private void animateFlash() {
|
||||||
|
if (mIconBackgroundBlinksDrawable != null) {
|
||||||
mIconBackgroundBlinksDrawable.start();
|
mIconBackgroundBlinksDrawable.start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected Intent getFinishIntent() {
|
protected Intent getFinishIntent() {
|
||||||
return new Intent(this, FingerprintEnrollFinish.class);
|
return new Intent(this, FingerprintEnrollFinish.class);
|
||||||
|
@@ -17,11 +17,9 @@
|
|||||||
package com.android.settings.biometrics.fingerprint;
|
package com.android.settings.biometrics.fingerprint;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.hardware.fingerprint.FingerprintManager;
|
import android.hardware.fingerprint.FingerprintManager;
|
||||||
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
@@ -34,11 +32,17 @@ public class UdfpsEnrollLayout extends LinearLayout {
|
|||||||
private static final String TAG = "UdfpsEnrollLayout";
|
private static final String TAG = "UdfpsEnrollLayout";
|
||||||
|
|
||||||
private final FingerprintSensorPropertiesInternal mSensorProps;
|
private final FingerprintSensorPropertiesInternal mSensorProps;
|
||||||
|
private final int mSensorDiameter;
|
||||||
|
private final int mAnimationDiameter;
|
||||||
|
|
||||||
public UdfpsEnrollLayout(Context context, AttributeSet attrs) {
|
public UdfpsEnrollLayout(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mSensorProps = context.getSystemService(FingerprintManager.class)
|
mSensorProps = context.getSystemService(FingerprintManager.class)
|
||||||
.getSensorPropertiesInternal().get(0);
|
.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
|
@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
|
// The translationY is the amount of extra height that should be added to the spacer
|
||||||
// above the animation
|
// above the animation
|
||||||
final int spaceHeight = mSensorProps.sensorLocationY - statusbarHeight
|
final int spaceHeight = mSensorProps.sensorLocationY - statusbarHeight
|
||||||
- mSensorProps.sensorRadius - animation.getTop();
|
- (mAnimationDiameter / 2) - animation.getTop();
|
||||||
animation.setTranslationY(spaceHeight);
|
animation.setTranslationY(spaceHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
|
|
||||||
final View animation = findViewById(R.id.fingerprint_progress_bar);
|
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
|
animation.measure(MeasureSpec.makeMeasureSpec(mAnimationDiameter, MeasureSpec.EXACTLY),
|
||||||
// the animation is within the UDFPS affordance.
|
MeasureSpec.makeMeasureSpec(mAnimationDiameter, MeasureSpec.EXACTLY));
|
||||||
final int animationDiameter = (int) (sensorDiameter * 1);
|
|
||||||
animation.measure(MeasureSpec.makeMeasureSpec(animationDiameter, MeasureSpec.EXACTLY),
|
|
||||||
MeasureSpec.makeMeasureSpec(animationDiameter, MeasureSpec.EXACTLY));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user