Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1038e87 authored by Beverly's avatar Beverly
Browse files

Cancel & restart auth ripple if already running

Instead of completely ignoring the request to
startUnlockedRipple if the auth ripple is still running.

This prevents quick subsequent authentications from not
showing a new ripple animation.

Fixes: 263565188
Test: Authenticate with UDFPS multiple times in a row, observe
auth ripple always shows

Change-Id: I74095fcb493352f68c9c9715aab4db8d1a2925ae
parent 633bd1e8
Loading
Loading
Loading
Loading
+6 −9
Original line number Original line Diff line number Diff line
@@ -55,11 +55,11 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at
    private val fadeDuration = 83L
    private val fadeDuration = 83L
    private val retractDuration = 400L
    private val retractDuration = 400L
    private var alphaInDuration: Long = 0
    private var alphaInDuration: Long = 0
    private var unlockedRippleInProgress: Boolean = false
    private val dwellShader = DwellRippleShader()
    private val dwellShader = DwellRippleShader()
    private val dwellPaint = Paint()
    private val dwellPaint = Paint()
    private val rippleShader = RippleShader()
    private val rippleShader = RippleShader()
    private val ripplePaint = Paint()
    private val ripplePaint = Paint()
    private var unlockedRippleAnimator: AnimatorSet? = null
    private var fadeDwellAnimator: Animator? = null
    private var fadeDwellAnimator: Animator? = null
    private var retractDwellAnimator: Animator? = null
    private var retractDwellAnimator: Animator? = null
    private var dwellPulseOutAnimator: Animator? = null
    private var dwellPulseOutAnimator: Animator? = null
@@ -205,7 +205,7 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at
     * Plays a ripple animation that grows to the dwellRadius with distortion.
     * Plays a ripple animation that grows to the dwellRadius with distortion.
     */
     */
    fun startDwellRipple(isDozing: Boolean) {
    fun startDwellRipple(isDozing: Boolean) {
        if (unlockedRippleInProgress || dwellPulseOutAnimator?.isRunning == true) {
        if (unlockedRippleAnimator?.isRunning == true || dwellPulseOutAnimator?.isRunning == true) {
            return
            return
        }
        }


@@ -262,9 +262,7 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at
     * Ripple that bursts outwards from the position of the sensor to the edges of the screen
     * Ripple that bursts outwards from the position of the sensor to the edges of the screen
     */
     */
    fun startUnlockedRipple(onAnimationEnd: Runnable?) {
    fun startUnlockedRipple(onAnimationEnd: Runnable?) {
        if (unlockedRippleInProgress) {
        unlockedRippleAnimator?.cancel()
            return // Ignore if ripple effect is already playing
        }


        val rippleAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
        val rippleAnimator = ValueAnimator.ofFloat(0f, 1f).apply {
            interpolator = Interpolators.LINEAR_OUT_SLOW_IN
            interpolator = Interpolators.LINEAR_OUT_SLOW_IN
@@ -289,14 +287,13 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at
            }
            }
        }
        }


        val animatorSet = AnimatorSet().apply {
        unlockedRippleAnimator = AnimatorSet().apply {
            playTogether(
            playTogether(
                rippleAnimator,
                rippleAnimator,
                alphaInAnimator
                alphaInAnimator
            )
            )
            addListener(object : AnimatorListenerAdapter() {
            addListener(object : AnimatorListenerAdapter() {
                override fun onAnimationStart(animation: Animator?) {
                override fun onAnimationStart(animation: Animator?) {
                    unlockedRippleInProgress = true
                    rippleShader.rippleFill = false
                    rippleShader.rippleFill = false
                    drawRipple = true
                    drawRipple = true
                    visibility = VISIBLE
                    visibility = VISIBLE
@@ -304,13 +301,13 @@ class AuthRippleView(context: Context?, attrs: AttributeSet?) : View(context, at


                override fun onAnimationEnd(animation: Animator?) {
                override fun onAnimationEnd(animation: Animator?) {
                    onAnimationEnd?.run()
                    onAnimationEnd?.run()
                    unlockedRippleInProgress = false
                    drawRipple = false
                    drawRipple = false
                    visibility = GONE
                    visibility = GONE
                    unlockedRippleAnimator = null
                }
                }
            })
            })
        }
        }
        animatorSet.start()
        unlockedRippleAnimator?.start()
    }
    }


    fun resetRippleAlpha() {
    fun resetRippleAlpha() {