diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java index 7fdb5eab8701a..9281eb8acb56f 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java @@ -34,8 +34,10 @@ import android.widget.FrameLayout; * - optionally can override dozeTimeTick to adjust views for burn-in mitigation */ public abstract class UdfpsAnimationView extends FrameLayout { - // mAlpha takes into consideration the status bar expansion amount to fade out icon when - // the status bar is expanded + private float mDialogSuggestedAlpha = 1f; + private float mNotificationShadeExpansion = 0f; + + // mAlpha takes into consideration the status bar expansion amount and dialog suggested alpha private int mAlpha; boolean mPauseAuth; @@ -92,6 +94,10 @@ public abstract class UdfpsAnimationView extends FrameLayout { } int calculateAlpha() { + int alpha = expansionToAlpha(mNotificationShadeExpansion); + alpha *= mDialogSuggestedAlpha; + mAlpha = alpha; + return mPauseAuth ? mAlpha : 255; } @@ -111,8 +117,26 @@ public abstract class UdfpsAnimationView extends FrameLayout { return (int) ((1 - percent) * 255); } + /** + * Set the suggested alpha based on whether a dialog was recently shown or hidden. + * @param dialogSuggestedAlpha value from 0f to 1f. + */ + public void setDialogSuggestedAlpha(float dialogSuggestedAlpha) { + mDialogSuggestedAlpha = dialogSuggestedAlpha; + updateAlpha(); + } + + public float getDialogSuggestedAlpha() { + return mDialogSuggestedAlpha; + } + + /** + * Sets the amount the notification shade is expanded. This will influence the opacity of the + * this visual affordance. + * @param expansion amount the shade has expanded from 0f to 1f. + */ public void onExpansionChanged(float expansion) { - mAlpha = expansionToAlpha(expansion); + mNotificationShadeExpansion = expansion; updateAlpha(); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewController.kt index c33cd8d537dce..27b0592af2d79 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewController.kt @@ -15,10 +15,12 @@ */ package com.android.systemui.biometrics +import android.animation.ValueAnimator import android.graphics.PointF import android.graphics.RectF import com.android.systemui.Dumpable import com.android.systemui.dump.DumpManager +import com.android.systemui.animation.Interpolators import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.SystemUIDialogManager import com.android.systemui.statusbar.phone.panelstate.PanelExpansionListener @@ -50,7 +52,8 @@ abstract class UdfpsAnimationViewController( private val view: T get() = mView!! - private val dialogListener = SystemUIDialogManager.Listener { updatePauseAuth() } + private var dialogAlphaAnimator: ValueAnimator? = null + private val dialogListener = SystemUIDialogManager.Listener { runDialogAlphaAnimator() } private val panelExpansionListener = PanelExpansionListener { fraction, expanded, tracking -> @@ -83,6 +86,29 @@ abstract class UdfpsAnimationViewController( */ open val paddingY: Int = 0 + open fun updateAlpha() { + view.updateAlpha() + } + + fun runDialogAlphaAnimator() { + val hideAffordance = dialogManager.shouldHideAffordance() + dialogAlphaAnimator?.cancel() + dialogAlphaAnimator = ValueAnimator.ofFloat( + view.calculateAlpha() / 255f, + if (hideAffordance) 0f else 1f) + .apply { + duration = if (hideAffordance) 83L else 200L + interpolator = if (hideAffordance) Interpolators.LINEAR else Interpolators.ALPHA_IN + + addUpdateListener { animatedValue -> + view.setDialogSuggestedAlpha(animatedValue.animatedValue as Float) + updateAlpha() + updatePauseAuth() + } + start() + } + } + override fun onViewAttached() { panelExpansionStateManager.addExpansionListener(panelExpansionListener) dialogManager.registerListener(dialogListener) @@ -106,6 +132,7 @@ abstract class UdfpsAnimationViewController( pw.println("mNotificationShadeVisible=$notificationShadeVisible") pw.println("shouldPauseAuth()=" + shouldPauseAuth()) pw.println("isPauseAuth=" + view.isPauseAuth) + pw.println("dialogSuggestedAlpha=" + view.dialogSuggestedAlpha) } /** diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java index 5ac21ff42f4fa..b8334a02e5f29 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java @@ -28,6 +28,7 @@ import android.view.MotionEvent; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.R; import com.android.systemui.animation.ActivityLaunchAnimator; +import com.android.systemui.animation.Interpolators; import com.android.systemui.dump.DumpManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.LockscreenShadeTransitionController; @@ -112,6 +113,7 @@ public class UdfpsKeyguardViewController extends UdfpsAnimationViewController