Loading libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt +7 −2 Original line number Diff line number Diff line Loading @@ -130,6 +130,11 @@ abstract class CrossActivityBackAnimation( */ abstract fun preparePreCommitEnteringRectMovement() /** * Subclasses must provide a duration (in ms) for the post-commit part of the animation */ abstract fun getPostCommitAnimationDuration(): Long /** * Returns a base transformation to apply to the entering target during pre-commit. The system * will apply the default animation on top of it. Loading Loading @@ -259,7 +264,8 @@ abstract class CrossActivityBackAnimation( .setSpring(postCommitFlingSpring) flingAnimation.start() val valueAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(POST_COMMIT_DURATION) val valueAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(getPostCommitAnimationDuration()) valueAnimator.addUpdateListener { animation: ValueAnimator -> val progress = animation.animatedFraction onPostCommitProgress(progress) Loading Loading @@ -522,7 +528,6 @@ abstract class CrossActivityBackAnimation( internal const val MAX_SCALE = 0.9f private const val MAX_SCRIM_ALPHA_DARK = 0.8f private const val MAX_SCRIM_ALPHA_LIGHT = 0.2f private const val POST_COMMIT_DURATION = 300L private const val SPRING_SCALE = 100f private const val MAX_FLING_SCALE = 0.6f } Loading libs/WindowManager/Shell/src/com/android/wm/shell/back/CustomCrossActivityBackAnimation.kt +33 −8 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import com.android.wm.shell.RootTaskDisplayAreaOrganizer import com.android.wm.shell.protolog.ShellProtoLogGroup import com.android.wm.shell.shared.annotations.ShellMainThread import javax.inject.Inject import kotlin.math.max import kotlin.math.min /** Class that handles customized predictive cross activity back animations. */ @ShellMainThread Loading Loading @@ -96,6 +98,12 @@ class CustomCrossActivityBackAnimation( targetEnteringRect.set(startClosingRect) } override fun getPostCommitAnimationDuration(): Long { return min( MAX_POST_COMMIT_ANIM_DURATION, max(closeAnimation!!.duration, enterAnimation!!.duration) ) } override fun getPreCommitEnteringBaseTransformation(progress: Float): Transformation { gestureProgress = progress transformation.clear() Loading Loading @@ -125,10 +133,13 @@ class CustomCrossActivityBackAnimation( super.onPostCommitProgress(linearProgress) if (closingTarget == null || enteringTarget == null) return // TODO: Should we use the duration from the custom xml spec for the post-commit animation? applyTransform(closingTarget!!.leash, currentClosingRect, linearProgress, closeAnimation!!) val enteringProgress = MathUtils.lerp(gestureProgress * PRE_COMMIT_MAX_PROGRESS, 1f, linearProgress) val closingProgress = closeAnimation!!.getPostCommitProgress(linearProgress) applyTransform(closingTarget!!.leash, currentClosingRect, closingProgress, closeAnimation!!) val enteringProgress = MathUtils.lerp( gestureProgress * PRE_COMMIT_MAX_PROGRESS, 1f, enterAnimation!!.getPostCommitProgress(linearProgress) ) applyTransform( enteringTarget!!.leash, currentEnteringRect, Loading Loading @@ -175,6 +186,19 @@ class CustomCrossActivityBackAnimation( return false } private fun Animation.getPostCommitProgress(linearProgress: Float): Float { return when (duration) { 0L -> 1f else -> min( 1f, getPostCommitAnimationDuration() / min( MAX_POST_COMMIT_ANIM_DURATION, duration ).toFloat() * linearProgress ) } } class AnimationLoadResult { var closeAnimation: Animation? = null var enterAnimation: Animation? = null Loading @@ -183,6 +207,7 @@ class CustomCrossActivityBackAnimation( companion object { private const val PRE_COMMIT_MAX_PROGRESS = 0.2f private const val MAX_POST_COMMIT_ANIM_DURATION = 2000L } } Loading libs/WindowManager/Shell/src/com/android/wm/shell/back/DefaultCrossActivityBackAnimation.kt +7 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ constructor( targetEnteringRect.scaleCentered(MAX_SCALE) } override fun getPostCommitAnimationDuration() = POST_COMMIT_DURATION override fun onGestureCommitted(velocity: Float) { // We enter phase 2 of the animation, the starting coordinates for phase 2 are the current // coordinate of the gesture driven phase. Let's update the start and target rects and kick Loading @@ -93,4 +95,9 @@ constructor( applyTransform(enteringTarget?.leash, currentEnteringRect, 1f) applyTransaction() } companion object { private const val POST_COMMIT_DURATION = 300L } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/back/CrossActivityBackAnimation.kt +7 −2 Original line number Diff line number Diff line Loading @@ -130,6 +130,11 @@ abstract class CrossActivityBackAnimation( */ abstract fun preparePreCommitEnteringRectMovement() /** * Subclasses must provide a duration (in ms) for the post-commit part of the animation */ abstract fun getPostCommitAnimationDuration(): Long /** * Returns a base transformation to apply to the entering target during pre-commit. The system * will apply the default animation on top of it. Loading Loading @@ -259,7 +264,8 @@ abstract class CrossActivityBackAnimation( .setSpring(postCommitFlingSpring) flingAnimation.start() val valueAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(POST_COMMIT_DURATION) val valueAnimator = ValueAnimator.ofFloat(1f, 0f).setDuration(getPostCommitAnimationDuration()) valueAnimator.addUpdateListener { animation: ValueAnimator -> val progress = animation.animatedFraction onPostCommitProgress(progress) Loading Loading @@ -522,7 +528,6 @@ abstract class CrossActivityBackAnimation( internal const val MAX_SCALE = 0.9f private const val MAX_SCRIM_ALPHA_DARK = 0.8f private const val MAX_SCRIM_ALPHA_LIGHT = 0.2f private const val POST_COMMIT_DURATION = 300L private const val SPRING_SCALE = 100f private const val MAX_FLING_SCALE = 0.6f } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/back/CustomCrossActivityBackAnimation.kt +33 −8 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ import com.android.wm.shell.RootTaskDisplayAreaOrganizer import com.android.wm.shell.protolog.ShellProtoLogGroup import com.android.wm.shell.shared.annotations.ShellMainThread import javax.inject.Inject import kotlin.math.max import kotlin.math.min /** Class that handles customized predictive cross activity back animations. */ @ShellMainThread Loading Loading @@ -96,6 +98,12 @@ class CustomCrossActivityBackAnimation( targetEnteringRect.set(startClosingRect) } override fun getPostCommitAnimationDuration(): Long { return min( MAX_POST_COMMIT_ANIM_DURATION, max(closeAnimation!!.duration, enterAnimation!!.duration) ) } override fun getPreCommitEnteringBaseTransformation(progress: Float): Transformation { gestureProgress = progress transformation.clear() Loading Loading @@ -125,10 +133,13 @@ class CustomCrossActivityBackAnimation( super.onPostCommitProgress(linearProgress) if (closingTarget == null || enteringTarget == null) return // TODO: Should we use the duration from the custom xml spec for the post-commit animation? applyTransform(closingTarget!!.leash, currentClosingRect, linearProgress, closeAnimation!!) val enteringProgress = MathUtils.lerp(gestureProgress * PRE_COMMIT_MAX_PROGRESS, 1f, linearProgress) val closingProgress = closeAnimation!!.getPostCommitProgress(linearProgress) applyTransform(closingTarget!!.leash, currentClosingRect, closingProgress, closeAnimation!!) val enteringProgress = MathUtils.lerp( gestureProgress * PRE_COMMIT_MAX_PROGRESS, 1f, enterAnimation!!.getPostCommitProgress(linearProgress) ) applyTransform( enteringTarget!!.leash, currentEnteringRect, Loading Loading @@ -175,6 +186,19 @@ class CustomCrossActivityBackAnimation( return false } private fun Animation.getPostCommitProgress(linearProgress: Float): Float { return when (duration) { 0L -> 1f else -> min( 1f, getPostCommitAnimationDuration() / min( MAX_POST_COMMIT_ANIM_DURATION, duration ).toFloat() * linearProgress ) } } class AnimationLoadResult { var closeAnimation: Animation? = null var enterAnimation: Animation? = null Loading @@ -183,6 +207,7 @@ class CustomCrossActivityBackAnimation( companion object { private const val PRE_COMMIT_MAX_PROGRESS = 0.2f private const val MAX_POST_COMMIT_ANIM_DURATION = 2000L } } Loading
libs/WindowManager/Shell/src/com/android/wm/shell/back/DefaultCrossActivityBackAnimation.kt +7 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ constructor( targetEnteringRect.scaleCentered(MAX_SCALE) } override fun getPostCommitAnimationDuration() = POST_COMMIT_DURATION override fun onGestureCommitted(velocity: Float) { // We enter phase 2 of the animation, the starting coordinates for phase 2 are the current // coordinate of the gesture driven phase. Let's update the start and target rects and kick Loading @@ -93,4 +95,9 @@ constructor( applyTransform(enteringTarget?.leash, currentEnteringRect, 1f) applyTransaction() } companion object { private const val POST_COMMIT_DURATION = 300L } }