CrossActivityBackMotion

Android's default cross-activity back animation, driven by a back gesture and drawn on two pages instead of two windows.

This is a port of AOSP's DefaultCrossActivityBackAnimation and its base class CrossActivityBackAnimation (frameworks/base/libs/WindowManager/Shell/src/com/android/wm/ shell/back/, Apache License 2.0). Like them it works in rectangles: every frame places the closing and the entering page in a rectangle of the display, and the phases only differ in where those rectangles come from.

  • Pre-commit, while the finger is down: both rectangles move from their start to their target by the gesture's progress, eased with BACK_GESTURE. The closing page shrinks to MaxScale and rests against the far edge (or stays centred for a swipe from the right edge); the entering page, ActivityMotion.EnteringStartOffset further out, shrinks with it. Both shift vertically with the finger, by as much as the closing page's current size leaves room for.

  • Post-commit, once back is invoked: both rectangles start from exactly where the gesture left them. The entering page grows to fill the display and the closing page carries on, fading within the first fifth, over PostCommitMillis with the emphasized curve. A spring started with the gesture's velocity shrinks both a little further and lets them bounce back.

  • Cancel: the system animates the progress back to zero, and the rectangles follow it.

The progress this receives has already been smoothed by the platform's BackProgressAnimator, as the system's own animation receives it; it is not smoothed again here.

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

The scene key of the page going away, while phase is not Phase.Idle.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Whether a swipe from the right edge mirrors a swipe from the left, so the page follows the finger to the left edge and the page underneath waits on the right; the default. False plays Android's own animation, which shrinks the page in place for a swipe from the right.

Link copied to clipboard

Where the animation is. Phase.Idle draws both pages untouched.

Functions

Link copied to clipboard
fun cancel()

The gesture was cancelled and the system has brought its progress back to zero.

Link copied to clipboard

The closing page fades out within the first fifth of the post-commit phase.

Link copied to clipboard

The closing page's rectangle, in pixels of the display. Read while drawing.

Link copied to clipboard
fun commit(onFinished: () -> Unit)

Back was invoked: plays the post-commit phase from where the gesture left the pages, and calls onFinished once both have arrived.

Link copied to clipboard

The entering page's rectangle, in pixels of the display. Read while drawing.

Link copied to clipboard

The gesture moved, or the system moved its progress, while cancelling included.

Link copied to clipboard

The black scrim between the closing page and everything under it: at its full strength from the start of the gesture, fading out over the post-commit phase.

Link copied to clipboard
fun start(event: NavigationEvent, closingKey: Any, displaySize: Size)

A gesture began on the scene closingKey, over a display of displaySize.