Merge "QSLongPressEffect Animator initialized when called to START" into main
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
index db2ec8f..ea8d7d7 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
@@ -189,7 +189,6 @@
durations?.get(1) ?: LongPressHapticBuilder.INVALID_DURATION,
effectDuration
)
- _postedActionType.value = ActionType.INITIALIZE_ANIMATOR
setState(State.IDLE)
return true
}
@@ -209,6 +208,5 @@
START_ANIMATOR,
REVERSE_ANIMATOR,
CANCEL_ANIMATOR,
- INITIALIZE_ANIMATOR,
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
index 338c53b..c464ed1 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffectViewBinder.kt
@@ -67,8 +67,32 @@
qsLongPressEffect.clearActionType()
}
QSLongPressEffect.ActionType.START_ANIMATOR -> {
- if (effectAnimator?.isRunning == false) {
- effectAnimator?.start()
+ if (effectAnimator?.isRunning != true) {
+ effectAnimator =
+ ValueAnimator.ofFloat(0f, 1f).apply {
+ this.duration =
+ qsLongPressEffect.effectDuration.toLong()
+ interpolator = AccelerateDecelerateInterpolator()
+
+ doOnStart {
+ qsLongPressEffect.handleAnimationStart()
+ }
+ addUpdateListener {
+ val value = animatedValue as Float
+ if (value == 0f) {
+ tile.bringToFront()
+ } else {
+ tile.updateLongPressEffectProperties(value)
+ }
+ }
+ doOnEnd {
+ qsLongPressEffect.handleAnimationComplete()
+ }
+ doOnCancel {
+ qsLongPressEffect.handleAnimationCancel()
+ }
+ start()
+ }
}
}
QSLongPressEffect.ActionType.REVERSE_ANIMATOR -> {
@@ -82,26 +106,6 @@
tile.resetLongPressEffectProperties()
effectAnimator?.cancel()
}
- QSLongPressEffect.ActionType.INITIALIZE_ANIMATOR -> {
- effectAnimator =
- ValueAnimator.ofFloat(0f, 1f).apply {
- this.duration =
- qsLongPressEffect.effectDuration.toLong()
- interpolator = AccelerateDecelerateInterpolator()
-
- doOnStart { qsLongPressEffect.handleAnimationStart() }
- addUpdateListener {
- val value = animatedValue as Float
- if (value == 0f) {
- tile.bringToFront()
- } else {
- tile.updateLongPressEffectProperties(value)
- }
- }
- doOnEnd { qsLongPressEffect.handleAnimationComplete() }
- doOnCancel { qsLongPressEffect.handleAnimationCancel() }
- }
- }
}
}
}