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

Commit e2e25006 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez Committed by Android (Google) Code Review
Browse files

Merge "QSLongPressEffect Animator initialized when called to START" into main

parents f73c9a59 fd43a6ca
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -189,7 +189,6 @@ constructor(
                durations?.get(1) ?: LongPressHapticBuilder.INVALID_DURATION,
                effectDuration
            )
        _postedActionType.value = ActionType.INITIALIZE_ANIMATOR
        setState(State.IDLE)
        return true
    }
@@ -209,6 +208,5 @@ constructor(
        START_ANIMATOR,
        REVERSE_ANIMATOR,
        CANCEL_ANIMATOR,
        INITIALIZE_ANIMATOR,
    }
}
+26 −22
Original line number Diff line number Diff line
@@ -67,29 +67,16 @@ object QSLongPressEffectViewBinder {
                                    qsLongPressEffect.clearActionType()
                                }
                                QSLongPressEffect.ActionType.START_ANIMATOR -> {
                                    if (effectAnimator?.isRunning == false) {
                                        effectAnimator?.start()
                                    }
                                }
                                QSLongPressEffect.ActionType.REVERSE_ANIMATOR -> {
                                    effectAnimator?.let {
                                        val pausedProgress = it.animatedFraction
                                        qsLongPressEffect.playReverseHaptics(pausedProgress)
                                        it.reverse()
                                    }
                                }
                                QSLongPressEffect.ActionType.CANCEL_ANIMATOR -> {
                                    tile.resetLongPressEffectProperties()
                                    effectAnimator?.cancel()
                                }
                                QSLongPressEffect.ActionType.INITIALIZE_ANIMATOR -> {
                                    if (effectAnimator?.isRunning != true) {
                                        effectAnimator =
                                            ValueAnimator.ofFloat(0f, 1f).apply {
                                                this.duration =
                                                    qsLongPressEffect.effectDuration.toLong()
                                                interpolator = AccelerateDecelerateInterpolator()

                                            doOnStart { qsLongPressEffect.handleAnimationStart() }
                                                doOnStart {
                                                    qsLongPressEffect.handleAnimationStart()
                                                }
                                                addUpdateListener {
                                                    val value = animatedValue as Float
                                                    if (value == 0f) {
@@ -98,9 +85,26 @@ object QSLongPressEffectViewBinder {
                                                        tile.updateLongPressEffectProperties(value)
                                                    }
                                                }
                                            doOnEnd { qsLongPressEffect.handleAnimationComplete() }
                                            doOnCancel { qsLongPressEffect.handleAnimationCancel() }
                                                doOnEnd {
                                                    qsLongPressEffect.handleAnimationComplete()
                                                }
                                                doOnCancel {
                                                    qsLongPressEffect.handleAnimationCancel()
                                                }
                                                start()
                                            }
                                    }
                                }
                                QSLongPressEffect.ActionType.REVERSE_ANIMATOR -> {
                                    effectAnimator?.let {
                                        val pausedProgress = it.animatedFraction
                                        qsLongPressEffect.playReverseHaptics(pausedProgress)
                                        it.reverse()
                                    }
                                }
                                QSLongPressEffect.ActionType.CANCEL_ANIMATOR -> {
                                    tile.resetLongPressEffectProperties()
                                    effectAnimator?.cancel()
                                }
                            }
                        }