Remove UDFPS ProgressBar from Settings

Moving it to SystemUI, which handles rotation and position calculation
much easier.

Bug: 177965281
Test: manual
Change-Id: I9b7aadce95aae26330192074295d91283e49a24d
This commit is contained in:
Kevin Chyn
2021-02-04 16:04:44 -08:00
parent 92c1b3d5d3
commit 2eca234af7
3 changed files with 30 additions and 80 deletions

View File

@@ -40,12 +40,6 @@
android:layout_marginEnd="0dp" android:layout_marginEnd="0dp"
android:layout_marginStart="0dp" /> android:layout_marginStart="0dp" />
<Space
android:id="@+id/space_below_title"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<FrameLayout <FrameLayout
android:id="@+id/description_area" android:id="@+id/description_area"
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -80,19 +74,4 @@
android:paddingEnd="5dp" android:paddingEnd="5dp"
android:paddingStart="5dp" android:paddingStart="5dp"
android:visibility="invisible" /> android:visibility="invisible" />
<Space
android:id="@+id/space_above_animation"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<com.android.settings.widget.RingProgressBar
android:id="@+id/fingerprint_progress_bar"
android:layout_width="match_parent"
android:layout_height="match_parent"
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>

View File

@@ -93,7 +93,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
.build(); .build();
private boolean mCanAssumeUdfps; private boolean mCanAssumeUdfps;
private ProgressBar mProgressBar; @Nullable private ProgressBar mProgressBar;
private ObjectAnimator mProgressAnim; private ObjectAnimator mProgressAnim;
private TextView mStartMessage; private TextView mStartMessage;
private TextView mRepeatMessage; private TextView mRepeatMessage;
@@ -162,10 +162,6 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
mProgressBar = findViewById(R.id.fingerprint_progress_bar); mProgressBar = findViewById(R.id.fingerprint_progress_bar);
mVibrator = getSystemService(Vibrator.class); mVibrator = getSystemService(Vibrator.class);
if (mCanAssumeUdfps) {
mProgressBar.setVisibility(View.INVISIBLE);
}
if (getLayout().shouldApplyPartnerHeavyThemeResource()) { if (getLayout().shouldApplyPartnerHeavyThemeResource()) {
DescriptionStyler.applyPartnerCustomizationHeavyStyle(mRepeatMessage); DescriptionStyler.applyPartnerCustomizationHeavyStyle(mRepeatMessage);
} else if (getLayout().shouldApplyPartnerResource()) { } else if (getLayout().shouldApplyPartnerResource()) {
@@ -181,7 +177,8 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
.build() .build()
); );
final LayerDrawable fingerprintDrawable = (LayerDrawable) mProgressBar.getBackground(); final LayerDrawable fingerprintDrawable = mProgressBar != null
? (LayerDrawable) mProgressBar.getBackground() : null;
if (fingerprintDrawable != null) { if (fingerprintDrawable != null) {
mIconAnimationDrawable = (AnimatedVectorDrawable) mIconAnimationDrawable = (AnimatedVectorDrawable)
fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_animation); fingerprintDrawable.findDrawableByLayerId(R.id.fingerprint_animation);
@@ -196,6 +193,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
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);
if (mProgressBar != null) {
mProgressBar.setOnTouchListener((v, event) -> { mProgressBar.setOnTouchListener((v, event) -> {
if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
mIconTouchCount++; mIconTouchCount++;
@@ -211,6 +209,7 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
} }
return true; return true;
}); });
}
mRestoring = savedInstanceState != null; mRestoring = savedInstanceState != null;
} }
@@ -236,9 +235,6 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
updateDescription(); updateDescription();
if (mRestoring) { if (mRestoring) {
startIconAnimation(); startIconAnimation();
if (mCanAssumeUdfps) {
mProgressBar.setVisibility(View.VISIBLE);
}
} }
} }
@@ -248,8 +244,6 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
if (mCanAssumeUdfps) { if (mCanAssumeUdfps) {
startEnrollment(); startEnrollment();
updateProgress(false /* animate */);
mProgressBar.setVisibility(View.VISIBLE);
} }
mAnimationCancelled = false; mAnimationCancelled = false;
@@ -276,6 +270,14 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
} }
private void animateProgress(int progress) { private void animateProgress(int progress) {
if (mCanAssumeUdfps) {
// UDFPS animations are owned by SystemUI
if (progress >= PROGRESS_BAR_MAX) {
// Wait for any animations in SysUI to finish, then proceed to next page
getMainThreadHandler().postDelayed(mDelayedFinishRunnable, FINISH_DELAY);
}
return;
}
if (mProgressAnim != null) { if (mProgressAnim != null) {
mProgressAnim.cancel(); mProgressAnim.cancel();
} }
@@ -356,7 +358,9 @@ public class FingerprintEnrollEnrolling extends BiometricsEnrollEnrolling {
if (animate) { if (animate) {
animateProgress(progress); animateProgress(progress);
} else { } else {
if (mProgressBar != null) {
mProgressBar.setProgress(progress); mProgressBar.setProgress(progress);
}
if (progress >= PROGRESS_BAR_MAX) { if (progress >= PROGRESS_BAR_MAX) {
mDelayedFinishRunnable.run(); mDelayedFinishRunnable.run();
} }

View File

@@ -31,45 +31,12 @@ public class UdfpsEnrollLayout extends LinearLayout {
private static final String TAG = "UdfpsEnrollLayout"; private static final String TAG = "UdfpsEnrollLayout";
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)
.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
public void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
final View animation = findViewById(R.id.fingerprint_progress_bar);
final WindowManager wm = getContext().getSystemService(WindowManager.class);
final int statusbarHeight = Math.abs(wm.getCurrentWindowMetrics().getWindowInsets()
.getInsets(WindowInsets.Type.statusBars()).toRect().height());
// Calculate the amount of translation required. This is just re-arranged from
// animation.setY(mSensorProps.sensorLocationY-statusbarHeight-mSensorProps.sensorRadius)
// The translationY is the amount of extra height that should be added to the spacer
// above the animation
final int spaceHeight = mSensorProps.sensorLocationY - statusbarHeight
- (mAnimationDiameter / 2) - animation.getTop();
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);
animation.measure(MeasureSpec.makeMeasureSpec(mAnimationDiameter, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mAnimationDiameter, MeasureSpec.EXACTLY));
} }
} }