Merge "Decreased fling duration and fixed width interpolation for large screens" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
aa8c33a112
@@ -58,12 +58,14 @@ private const val MIN_DURATION_ACTIVE_AFTER_INACTIVE_ANIMATION = 130L
|
|||||||
private const val MIN_DURATION_CANCELLED_ANIMATION = 200L
|
private const val MIN_DURATION_CANCELLED_ANIMATION = 200L
|
||||||
private const val MIN_DURATION_COMMITTED_ANIMATION = 120L
|
private const val MIN_DURATION_COMMITTED_ANIMATION = 120L
|
||||||
private const val MIN_DURATION_INACTIVE_BEFORE_FLUNG_ANIMATION = 50L
|
private const val MIN_DURATION_INACTIVE_BEFORE_FLUNG_ANIMATION = 50L
|
||||||
|
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_ENTRY_TO_ACTIVE_CONSIDERED_AS_FLING = 100L
|
||||||
private const val MIN_DURATION_INACTIVE_TO_ACTIVE_CONSIDERED_AS_FLING = 400L
|
private const val MIN_DURATION_INACTIVE_TO_ACTIVE_CONSIDERED_AS_FLING = 400L
|
||||||
|
|
||||||
private const val FAILSAFE_DELAY_MS = 350L
|
private const val FAILSAFE_DELAY_MS = 350L
|
||||||
private const val POP_ON_FLING_DELAY = 140L
|
private const val POP_ON_FLING_DELAY = 50L
|
||||||
|
private const val POP_ON_FLING_SCALE = 3f
|
||||||
|
|
||||||
internal val VIBRATE_ACTIVATED_EFFECT =
|
internal val VIBRATE_ACTIVATED_EFFECT =
|
||||||
VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK)
|
VibrationEffect.createPredefined(VibrationEffect.EFFECT_CLICK)
|
||||||
@@ -230,7 +232,12 @@ class BackPanelController internal constructor(
|
|||||||
updateArrowState(GestureState.GONE)
|
updateArrowState(GestureState.GONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val playAnimationThenSetGoneOnAlphaEnd = Runnable { playAnimationThenSetGoneEnd() }
|
private val onAlphaEndSetGoneStateListener = DelayedOnAnimationEndListener(mainHandler, 0L) {
|
||||||
|
updateRestingArrowDimens()
|
||||||
|
if (!mView.addAnimationEndListener(mView.backgroundAlpha, onEndSetGoneStateListener)) {
|
||||||
|
scheduleFailsafe()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Minimum of the screen's width or the predefined threshold
|
// Minimum of the screen's width or the predefined threshold
|
||||||
private var fullyStretchedThreshold = 0f
|
private var fullyStretchedThreshold = 0f
|
||||||
@@ -357,7 +364,7 @@ class BackPanelController internal constructor(
|
|||||||
mView.cancelAnimations()
|
mView.cancelAnimations()
|
||||||
mainHandler.removeCallbacks(onEndSetCommittedStateListener.runnable)
|
mainHandler.removeCallbacks(onEndSetCommittedStateListener.runnable)
|
||||||
mainHandler.removeCallbacks(onEndSetGoneStateListener.runnable)
|
mainHandler.removeCallbacks(onEndSetGoneStateListener.runnable)
|
||||||
mainHandler.removeCallbacks(playAnimationThenSetGoneOnAlphaEnd)
|
mainHandler.removeCallbacks(onAlphaEndSetGoneStateListener.runnable)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -509,7 +516,7 @@ class BackPanelController internal constructor(
|
|||||||
val maxYOffset = (mView.height - params.entryIndicator.backgroundDimens.height) / 2f
|
val maxYOffset = (mView.height - params.entryIndicator.backgroundDimens.height) / 2f
|
||||||
val rubberbandAmount = 15f
|
val rubberbandAmount = 15f
|
||||||
val yProgress = MathUtils.saturate(yTranslation / (maxYOffset * rubberbandAmount))
|
val yProgress = MathUtils.saturate(yTranslation / (maxYOffset * rubberbandAmount))
|
||||||
val yPosition = params.translationInterpolator.getInterpolation(yProgress) *
|
val yPosition = params.verticalTranslationInterpolator.getInterpolation(yProgress) *
|
||||||
maxYOffset *
|
maxYOffset *
|
||||||
sign(yOffset)
|
sign(yOffset)
|
||||||
mView.animateVertically(yPosition)
|
mView.animateVertically(yPosition)
|
||||||
@@ -520,10 +527,9 @@ class BackPanelController internal constructor(
|
|||||||
* the arrow is fully stretched (between 0.0 - 1.0f)
|
* the arrow is fully stretched (between 0.0 - 1.0f)
|
||||||
*/
|
*/
|
||||||
private fun fullScreenProgress(xTranslation: Float): Float {
|
private fun fullScreenProgress(xTranslation: Float): Float {
|
||||||
return MathUtils.saturate(
|
val progress = abs((xTranslation - previousXTranslationOnActiveOffset) /
|
||||||
(xTranslation - previousXTranslationOnActiveOffset) /
|
(fullyStretchedThreshold - previousXTranslationOnActiveOffset))
|
||||||
(fullyStretchedThreshold - previousXTranslationOnActiveOffset)
|
return MathUtils.saturate(progress)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -540,7 +546,7 @@ class BackPanelController internal constructor(
|
|||||||
|
|
||||||
private fun stretchActiveBackIndicator(progress: Float) {
|
private fun stretchActiveBackIndicator(progress: Float) {
|
||||||
mView.setStretch(
|
mView.setStretch(
|
||||||
horizontalTranslationStretchAmount = params.translationInterpolator
|
horizontalTranslationStretchAmount = params.horizontalTranslationInterpolator
|
||||||
.getInterpolation(progress),
|
.getInterpolation(progress),
|
||||||
arrowStretchAmount = params.arrowAngleInterpolator.getInterpolation(progress),
|
arrowStretchAmount = params.arrowAngleInterpolator.getInterpolation(progress),
|
||||||
backgroundWidthStretchAmount = params.activeWidthInterpolator
|
backgroundWidthStretchAmount = params.activeWidthInterpolator
|
||||||
@@ -639,20 +645,6 @@ class BackPanelController internal constructor(
|
|||||||
return flingDistance > minFlingDistance && isPastFlingVelocityThreshold
|
return flingDistance > minFlingDistance && isPastFlingVelocityThreshold
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun playHorizontalAnimationThen(onEnd: DelayedOnAnimationEndListener) {
|
|
||||||
updateRestingArrowDimens()
|
|
||||||
if (!mView.addAnimationEndListener(mView.horizontalTranslation, onEnd)) {
|
|
||||||
scheduleFailsafe()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun playAnimationThenSetGoneEnd() {
|
|
||||||
updateRestingArrowDimens()
|
|
||||||
if (!mView.addAnimationEndListener(mView.backgroundAlpha, onEndSetGoneStateListener)) {
|
|
||||||
scheduleFailsafe()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun playWithBackgroundWidthAnimation(
|
private fun playWithBackgroundWidthAnimation(
|
||||||
onEnd: DelayedOnAnimationEndListener,
|
onEnd: DelayedOnAnimationEndListener,
|
||||||
delay: Long = 0L
|
delay: Long = 0L
|
||||||
@@ -912,18 +904,25 @@ class BackPanelController internal constructor(
|
|||||||
updateRestingArrowDimens()
|
updateRestingArrowDimens()
|
||||||
}
|
}
|
||||||
GestureState.FLUNG -> {
|
GestureState.FLUNG -> {
|
||||||
mainHandler.postDelayed(POP_ON_FLING_DELAY) { mView.popScale(1.9f) }
|
mainHandler.postDelayed(POP_ON_FLING_DELAY) { mView.popScale(POP_ON_FLING_SCALE) }
|
||||||
playHorizontalAnimationThen(onEndSetCommittedStateListener)
|
updateRestingArrowDimens()
|
||||||
|
mainHandler.postDelayed(onEndSetCommittedStateListener.runnable,
|
||||||
|
MIN_DURATION_FLING_ANIMATION)
|
||||||
}
|
}
|
||||||
GestureState.COMMITTED -> {
|
GestureState.COMMITTED -> {
|
||||||
|
// In most cases, animating between states is handled via `updateRestingArrowDimens`
|
||||||
|
// which plays an animation immediately upon state change. Some animations however
|
||||||
|
// occur after a delay upon state change and these animations may be independent
|
||||||
|
// or non-sequential from the state change animation. `postDelayed` is used to
|
||||||
|
// manually play these kinds of animations in parallel.
|
||||||
if (previousState == GestureState.FLUNG) {
|
if (previousState == GestureState.FLUNG) {
|
||||||
playAnimationThenSetGoneEnd()
|
updateRestingArrowDimens()
|
||||||
|
mainHandler.postDelayed(onEndSetGoneStateListener.runnable,
|
||||||
|
MIN_DURATION_COMMITTED_ANIMATION)
|
||||||
} else {
|
} else {
|
||||||
mView.popScale(3f)
|
mView.popScale(POP_ON_FLING_SCALE)
|
||||||
mainHandler.postDelayed(
|
mainHandler.postDelayed(onAlphaEndSetGoneStateListener.runnable,
|
||||||
playAnimationThenSetGoneOnAlphaEnd,
|
MIN_DURATION_COMMITTED_ANIMATION)
|
||||||
MIN_DURATION_COMMITTED_ANIMATION
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GestureState.CANCELLED -> {
|
GestureState.CANCELLED -> {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.android.systemui.navigationbar.gestural
|
|||||||
|
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
|
import androidx.core.animation.Interpolator
|
||||||
import androidx.core.animation.PathInterpolator
|
import androidx.core.animation.PathInterpolator
|
||||||
import androidx.dynamicanimation.animation.SpringForce
|
import androidx.dynamicanimation.animation.SpringForce
|
||||||
import com.android.systemui.R
|
import com.android.systemui.R
|
||||||
@@ -77,21 +78,23 @@ data class EdgePanelParams(private var resources: Resources) {
|
|||||||
var swipeProgressThreshold: Float = 0f
|
var swipeProgressThreshold: Float = 0f
|
||||||
private set
|
private set
|
||||||
|
|
||||||
lateinit var entryWidthInterpolator: PathInterpolator
|
lateinit var entryWidthInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
lateinit var entryWidthTowardsEdgeInterpolator: PathInterpolator
|
lateinit var entryWidthTowardsEdgeInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
lateinit var activeWidthInterpolator: PathInterpolator
|
lateinit var activeWidthInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
lateinit var arrowAngleInterpolator: PathInterpolator
|
lateinit var arrowAngleInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
lateinit var translationInterpolator: PathInterpolator
|
lateinit var horizontalTranslationInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
lateinit var farCornerInterpolator: PathInterpolator
|
lateinit var verticalTranslationInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
lateinit var edgeCornerInterpolator: PathInterpolator
|
lateinit var farCornerInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
lateinit var heightInterpolator: PathInterpolator
|
lateinit var edgeCornerInterpolator: Interpolator
|
||||||
|
private set
|
||||||
|
lateinit var heightInterpolator: Interpolator
|
||||||
private set
|
private set
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -125,9 +128,10 @@ data class EdgePanelParams(private var resources: Resources) {
|
|||||||
|
|
||||||
entryWidthInterpolator = PathInterpolator(.19f, 1.27f, .71f, .86f)
|
entryWidthInterpolator = PathInterpolator(.19f, 1.27f, .71f, .86f)
|
||||||
entryWidthTowardsEdgeInterpolator = PathInterpolator(1f, -3f, 1f, 1.2f)
|
entryWidthTowardsEdgeInterpolator = PathInterpolator(1f, -3f, 1f, 1.2f)
|
||||||
activeWidthInterpolator = PathInterpolator(.7f, .06f, .34f, .97f)
|
activeWidthInterpolator = PathInterpolator(.56f, -0.39f, .18f, 1.46f)
|
||||||
arrowAngleInterpolator = entryWidthInterpolator
|
arrowAngleInterpolator = entryWidthInterpolator
|
||||||
translationInterpolator = PathInterpolator(0.2f, 1.0f, 1.0f, 1.0f)
|
horizontalTranslationInterpolator = PathInterpolator(0.2f, 1.0f, 1.0f, 1.0f)
|
||||||
|
verticalTranslationInterpolator = PathInterpolator(.5f, 1.15f, .41f, .94f)
|
||||||
farCornerInterpolator = PathInterpolator(.03f, .19f, .14f, 1.09f)
|
farCornerInterpolator = PathInterpolator(.03f, .19f, .14f, 1.09f)
|
||||||
edgeCornerInterpolator = PathInterpolator(0f, 1.11f, .85f, .84f)
|
edgeCornerInterpolator = PathInterpolator(0f, 1.11f, .85f, .84f)
|
||||||
heightInterpolator = PathInterpolator(1f, .05f, .9f, -0.29f)
|
heightInterpolator = PathInterpolator(1f, .05f, .9f, -0.29f)
|
||||||
@@ -147,7 +151,7 @@ data class EdgePanelParams(private var resources: Resources) {
|
|||||||
scale = getDimenFloat(R.dimen.navigation_edge_entry_scale),
|
scale = getDimenFloat(R.dimen.navigation_edge_entry_scale),
|
||||||
scalePivotX = getDimen(R.dimen.navigation_edge_pre_threshold_background_width),
|
scalePivotX = getDimen(R.dimen.navigation_edge_pre_threshold_background_width),
|
||||||
horizontalTranslationSpring = entryActiveHorizontalTranslationSpring,
|
horizontalTranslationSpring = entryActiveHorizontalTranslationSpring,
|
||||||
verticalTranslationSpring = createSpring(10000f, 0.9f),
|
verticalTranslationSpring = createSpring(30000f, 1f),
|
||||||
scaleSpring = createSpring(120f, 0.8f),
|
scaleSpring = createSpring(120f, 0.8f),
|
||||||
arrowDimens = ArrowDimens(
|
arrowDimens = ArrowDimens(
|
||||||
length = getDimen(R.dimen.navigation_edge_entry_arrow_length),
|
length = getDimen(R.dimen.navigation_edge_entry_arrow_length),
|
||||||
@@ -174,7 +178,6 @@ data class EdgePanelParams(private var resources: Resources) {
|
|||||||
height = getDimen(R.dimen.navigation_edge_entry_background_height),
|
height = getDimen(R.dimen.navigation_edge_entry_background_height),
|
||||||
edgeCornerRadius = getDimen(R.dimen.navigation_edge_entry_edge_corners),
|
edgeCornerRadius = getDimen(R.dimen.navigation_edge_entry_edge_corners),
|
||||||
farCornerRadius = getDimen(R.dimen.navigation_edge_entry_far_corners),
|
farCornerRadius = getDimen(R.dimen.navigation_edge_entry_far_corners),
|
||||||
alphaSpring = createSpring(1100f, 1f),
|
|
||||||
widthSpring = createSpring(450f, 0.65f),
|
widthSpring = createSpring(450f, 0.65f),
|
||||||
heightSpring = createSpring(1500f, 0.45f),
|
heightSpring = createSpring(1500f, 0.45f),
|
||||||
farCornerRadiusSpring = createSpring(300f, 0.5f),
|
farCornerRadiusSpring = createSpring(300f, 0.5f),
|
||||||
@@ -269,10 +272,10 @@ data class EdgePanelParams(private var resources: Resources) {
|
|||||||
heightSpring = flungCommittedHeightSpring,
|
heightSpring = flungCommittedHeightSpring,
|
||||||
edgeCornerRadiusSpring = flungCommittedEdgeCornerSpring,
|
edgeCornerRadiusSpring = flungCommittedEdgeCornerSpring,
|
||||||
farCornerRadiusSpring = flungCommittedFarCornerSpring,
|
farCornerRadiusSpring = flungCommittedFarCornerSpring,
|
||||||
alphaSpring = createSpring(1100f, 1f),
|
alphaSpring = createSpring(1400f, 1f),
|
||||||
),
|
),
|
||||||
scale = 0.85f,
|
scale = 0.85f,
|
||||||
scaleSpring = createSpring(1150f, 1f),
|
scaleSpring = createSpring(6000f, 1f),
|
||||||
)
|
)
|
||||||
|
|
||||||
flungIndicator = committedIndicator.copy(
|
flungIndicator = committedIndicator.copy(
|
||||||
|
|||||||
Reference in New Issue
Block a user