Animate Back arrow pop off edge consistently

Previously velocity was taken into account but a predetermined pop animation based on transition is used for simplification

Bug: 280119431
Test: Manual
Change-Id: I4412722d20ce8401d1a9a892bde82beee17bd2a7
This commit is contained in:
Marvin Bernal
2023-04-29 02:00:09 +00:00
parent 0bdf223f49
commit f2e2e77dec

View File

@@ -71,10 +71,9 @@ private const val MIN_DURATION_INACTIVE_TO_ACTIVE_CONSIDERED_AS_FLING = 400L
private const val POP_ON_FLING_DELAY = 60L
private const val POP_ON_FLING_VELOCITY = 2f
private const val POP_ON_COMMITTED_VELOCITY = 3f
private const val POP_ON_ACTIVE_MAX_VELOCITY = 2.5f
private const val POP_ON_ACTIVE_MIN_VELOCITY = 4.5f
private const val POP_ON_INACTIVE_MAX_VELOCITY = -1.05f
private const val POP_ON_INACTIVE_MIN_VELOCITY = -1.5f
private const val POP_ON_ENTRY_TO_ACTIVE_VELOCITY = 4.5f
private const val POP_ON_INACTIVE_TO_ACTIVE_VELOCITY = 4.7f
private const val POP_ON_INACTIVE_VELOCITY = -1.5f
internal val VIBRATE_ACTIVATED_EFFECT =
VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK)
@@ -916,11 +915,12 @@ class BackPanelController internal constructor(
mainHandler.postDelayed(10L) {
vibratorHelper.vibrate(VIBRATE_ACTIVATED_EFFECT)
}
val startingVelocity = convertVelocityToAnimationFactor(
valueOnFastVelocity = POP_ON_ACTIVE_MAX_VELOCITY,
valueOnSlowVelocity = POP_ON_ACTIVE_MIN_VELOCITY,
)
mView.popOffEdge(startingVelocity)
val popVelocity = if (previousState == GestureState.INACTIVE) {
POP_ON_INACTIVE_TO_ACTIVE_VELOCITY
} else {
POP_ON_ENTRY_TO_ACTIVE_VELOCITY
}
mView.popOffEdge(popVelocity)
}
GestureState.INACTIVE -> {
@@ -933,11 +933,7 @@ class BackPanelController internal constructor(
// so that gesture progress in this state is consistent regardless of entry
totalTouchDeltaInactive = params.deactivationTriggerThreshold
val startingVelocity = convertVelocityToAnimationFactor(
valueOnFastVelocity = POP_ON_INACTIVE_MAX_VELOCITY,
valueOnSlowVelocity = POP_ON_INACTIVE_MIN_VELOCITY
)
mView.popOffEdge(startingVelocity)
mView.popOffEdge(POP_ON_INACTIVE_VELOCITY)
vibratorHelper.vibrate(VIBRATE_DEACTIVATED_EFFECT)
updateRestingArrowDimens()