Merge "Fix FingerprintDialogView when show is called before animation is complete" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
74ebf9a87c
@@ -134,8 +134,11 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
|
||||
}
|
||||
|
||||
private void handleShowDialog(SomeArgs args) {
|
||||
if (DEBUG) Log.d(TAG, "handleShowDialog");
|
||||
if (mDialogShowing) {
|
||||
if (DEBUG) Log.d(TAG, "handleShowDialog, isAnimatingAway: "
|
||||
+ mDialogView.isAnimatingAway());
|
||||
if (mDialogView.isAnimatingAway()) {
|
||||
mDialogView.forceRemove();
|
||||
} else if (mDialogShowing) {
|
||||
Log.w(TAG, "Dialog already showing");
|
||||
return;
|
||||
}
|
||||
@@ -168,7 +171,7 @@ public class FingerprintDialogImpl extends SystemUI implements CommandQueue.Call
|
||||
}
|
||||
|
||||
private void handleHideDialog(boolean userCanceled) {
|
||||
if (DEBUG) Log.d(TAG, "handleHideDialog");
|
||||
if (DEBUG) Log.d(TAG, "handleHideDialog, userCanceled: " + userCanceled);
|
||||
if (!mDialogShowing) {
|
||||
// This can happen if there's a race and we get called from both
|
||||
// onAuthenticated and onError, etc.
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.systemui.fingerprint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.AnimatedVectorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.biometrics.BiometricPrompt;
|
||||
@@ -76,9 +75,29 @@ public class FingerprintDialogView extends LinearLayout {
|
||||
private Bundle mBundle;
|
||||
private final LinearLayout mDialog;
|
||||
private int mLastState;
|
||||
private boolean mAnimatingAway;
|
||||
private boolean mWasForceRemoved;
|
||||
|
||||
private final float mDisplayWidth;
|
||||
|
||||
private final Runnable mShowAnimationRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mLayout.animate()
|
||||
.alpha(1f)
|
||||
.setDuration(ANIMATION_DURATION_SHOW)
|
||||
.setInterpolator(mLinearOutSlowIn)
|
||||
.withLayer()
|
||||
.start();
|
||||
mDialog.animate()
|
||||
.translationY(0)
|
||||
.setDuration(ANIMATION_DURATION_SHOW)
|
||||
.setInterpolator(mLinearOutSlowIn)
|
||||
.withLayer()
|
||||
.start();
|
||||
}
|
||||
};
|
||||
|
||||
public FingerprintDialogView(Context context, Handler handler) {
|
||||
super(context);
|
||||
mHandler = handler;
|
||||
@@ -192,26 +211,20 @@ public class FingerprintDialogView extends LinearLayout {
|
||||
positive.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// Dim the background and slide the dialog up
|
||||
mDialog.setTranslationY(mAnimationTranslationOffset);
|
||||
mLayout.setAlpha(0f);
|
||||
postOnAnimation(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mLayout.animate()
|
||||
.alpha(1f)
|
||||
.setDuration(ANIMATION_DURATION_SHOW)
|
||||
.setInterpolator(mLinearOutSlowIn)
|
||||
.withLayer()
|
||||
.start();
|
||||
mDialog.animate()
|
||||
.translationY(0)
|
||||
.setDuration(ANIMATION_DURATION_SHOW)
|
||||
.setInterpolator(mLinearOutSlowIn)
|
||||
.withLayer()
|
||||
.start();
|
||||
}
|
||||
});
|
||||
if (!mWasForceRemoved) {
|
||||
// Dim the background and slide the dialog up
|
||||
mDialog.setTranslationY(mAnimationTranslationOffset);
|
||||
mLayout.setAlpha(0f);
|
||||
postOnAnimation(mShowAnimationRunnable);
|
||||
} else {
|
||||
// Show the dialog immediately
|
||||
mLayout.animate().cancel();
|
||||
mDialog.animate().cancel();
|
||||
mDialog.setAlpha(1.0f);
|
||||
mDialog.setTranslationY(0);
|
||||
mLayout.setAlpha(1.0f);
|
||||
}
|
||||
mWasForceRemoved = false;
|
||||
}
|
||||
|
||||
private void setDismissesDialog(View v) {
|
||||
@@ -224,10 +237,13 @@ public class FingerprintDialogView extends LinearLayout {
|
||||
}
|
||||
|
||||
public void startDismiss() {
|
||||
mAnimatingAway = true;
|
||||
|
||||
final Runnable endActionRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWindowManager.removeView(FingerprintDialogView.this);
|
||||
mAnimatingAway = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -251,6 +267,23 @@ public class FingerprintDialogView extends LinearLayout {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Force remove the window, cancelling any animation that's happening. This should only be
|
||||
* called if we want to quickly show the dialog again (e.g. on rotation). Calling this method
|
||||
* will cause the dialog to show without an animation the next time it's attached.
|
||||
*/
|
||||
public void forceRemove() {
|
||||
mLayout.animate().cancel();
|
||||
mDialog.animate().cancel();
|
||||
mWindowManager.removeView(FingerprintDialogView.this);
|
||||
mAnimatingAway = false;
|
||||
mWasForceRemoved = true;
|
||||
}
|
||||
|
||||
public boolean isAnimatingAway() {
|
||||
return mAnimatingAway;
|
||||
}
|
||||
|
||||
public void setBundle(Bundle bundle) {
|
||||
mBundle = bundle;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user