Back Arrow tweak slow swipe and fling animation

Also fixes incorrect backgroundDimens to scalePivotX mapping.

Bug: 275084917
Test: Manual
Change-Id: If2cd6b7daaab592b3a574a66ba90d0cf7577e58f
This commit is contained in:
Marvin Bernal
2023-04-02 01:23:09 +00:00
parent a8e179cb60
commit ac7c12040d
3 changed files with 15 additions and 14 deletions

View File

@@ -363,12 +363,8 @@ class BackPanel(
}
fun popOffEdge(startingVelocity: Float) {
val heightStretchAmount = startingVelocity * 50
val widthStretchAmount = startingVelocity * 150
val scaleStretchAmount = startingVelocity * 0.8f
backgroundHeight.stretchTo(stretchAmount = 0f, startingVelocity = -heightStretchAmount)
backgroundWidth.stretchTo(stretchAmount = 0f, startingVelocity = widthStretchAmount)
scale.stretchTo(stretchAmount = 0f, startingVelocity = -scaleStretchAmount)
scale.stretchTo(stretchAmount = 0f, startingVelocity = startingVelocity * -.8f)
horizontalTranslation.stretchTo(stretchAmount = 0f, startingVelocity * 200f)
}
fun popScale(startingVelocity: Float) {
@@ -410,7 +406,7 @@ class BackPanel(
arrowAlpha.updateRestingPosition(restingParams.arrowDimens.alpha, animate)
arrowLength.updateRestingPosition(restingParams.arrowDimens.length, animate)
arrowHeight.updateRestingPosition(restingParams.arrowDimens.height, animate)
scalePivotX.updateRestingPosition(restingParams.backgroundDimens.width, animate)
scalePivotX.updateRestingPosition(restingParams.scalePivotX, animate)
backgroundWidth.updateRestingPosition(restingParams.backgroundDimens.width, animate)
backgroundHeight.updateRestingPosition(restingParams.backgroundDimens.height, animate)
backgroundEdgeCornerRadius.updateRestingPosition(

View File

@@ -49,6 +49,7 @@ import kotlin.math.sign
private const val TAG = "BackPanelController"
private const val ENABLE_FAILSAFE = true
private const val FAILSAFE_DELAY_MS = 350L
private const val PX_PER_SEC = 1000
private const val PX_PER_MS = 1
@@ -63,9 +64,9 @@ private const val MIN_DURATION_FLING_ANIMATION = 160L
private const val MIN_DURATION_ENTRY_TO_ACTIVE_CONSIDERED_AS_FLING = 100L
private const val MIN_DURATION_INACTIVE_TO_ACTIVE_CONSIDERED_AS_FLING = 400L
private const val FAILSAFE_DELAY_MS = 350L
private const val POP_ON_FLING_DELAY = 50L
private const val POP_ON_FLING_SCALE = 3f
private const val POP_ON_FLING_DELAY = 60L
private const val POP_ON_FLING_SCALE = 2f
private const val POP_ON_COMMITTED_SCALE = 3f
internal val VIBRATE_ACTIVATED_EFFECT =
VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK)
@@ -773,7 +774,9 @@ class BackPanelController internal constructor(
GestureState.ENTRY,
GestureState.INACTIVE,
GestureState.CANCELLED -> params.preThresholdIndicator.scalePivotX
else -> params.committedIndicator.scalePivotX
GestureState.ACTIVE -> params.activeIndicator.scalePivotX
GestureState.FLUNG,
GestureState.COMMITTED -> params.committedIndicator.scalePivotX
},
horizontalTranslation = when (currentState) {
GestureState.GONE -> {
@@ -920,7 +923,7 @@ class BackPanelController internal constructor(
mainHandler.postDelayed(onEndSetGoneStateListener.runnable,
MIN_DURATION_COMMITTED_ANIMATION)
} else {
mView.popScale(POP_ON_FLING_SCALE)
mView.popScale(POP_ON_COMMITTED_SCALE)
mainHandler.postDelayed(onAlphaEndSetGoneStateListener.runnable,
MIN_DURATION_COMMITTED_ANIMATION)
}

View File

@@ -35,7 +35,7 @@ data class EdgePanelParams(private var resources: Resources) {
data class BackIndicatorDimens(
val horizontalTranslation: Float? = 0f,
val scale: Float = 0f,
val scalePivotX: Float = 0f,
val scalePivotX: Float? = null,
val arrowDimens: ArrowDimens,
val backgroundDimens: BackgroundDimens,
val verticalTranslationSpring: SpringForce? = null,
@@ -203,7 +203,8 @@ data class EdgePanelParams(private var resources: Resources) {
horizontalTranslation = getDimen(R.dimen.navigation_edge_active_margin),
scale = getDimenFloat(R.dimen.navigation_edge_active_scale),
horizontalTranslationSpring = entryActiveHorizontalTranslationSpring,
scaleSpring = createSpring(450f, 0.415f),
scaleSpring = createSpring(450f, 0.39f),
scalePivotX = getDimen(R.dimen.navigation_edge_active_background_width),
arrowDimens = ArrowDimens(
length = getDimen(R.dimen.navigation_edge_active_arrow_length),
height = getDimen(R.dimen.navigation_edge_active_arrow_height),
@@ -258,6 +259,7 @@ data class EdgePanelParams(private var resources: Resources) {
committedIndicator = activeIndicator.copy(
horizontalTranslation = null,
scalePivotX = null,
arrowDimens = activeIndicator.arrowDimens.copy(
lengthSpring = activeCommittedArrowLengthSpring,
heightSpring = activeCommittedArrowHeightSpring,