Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e71598ed authored by Johannes Gallmann's avatar Johannes Gallmann
Browse files

Move closing activity to left for rhs (with custom animation)

Bug: 339440390
Flag: ACONFIG com.android.window.flags.predictive_back_system_anims NEXTFOOD
Test: Manual, i.e. verifying closing window is moved towards the left (instead of middle) when performing custom predictive back animation
Change-Id: I755921dfad4f768f972cb963b511e68aad1b3370
parent c14c0eac
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ abstract class CrossActivityBackAnimation(
    private var triggerBack = false
    private var finishCallback: IRemoteAnimationFinishedCallback? = null
    private val progressAnimator = BackProgressAnimator()
    private val displayBoundsMargin =
    protected val displayBoundsMargin =
        context.resources.getDimension(R.dimen.cross_task_back_vertical_margin)

    private val gestureInterpolator = Interpolators.BACK_GESTURE
@@ -116,6 +116,12 @@ abstract class CrossActivityBackAnimation(
     */
    abstract val allowEnteringYShift: Boolean

    /**
     * Subclasses must set the [startClosingRect] and [targetClosingRect] to define the movement
     * of the closingTarget during pre-commit phase.
     */
    abstract fun preparePreCommitClosingRectMovement(@BackEvent.SwipeEdge swipeEdge: Int)

    /**
     * Subclasses must set the [startEnteringRect] and [targetEnteringRect] to define the movement
     * of the enteringTarget during pre-commit phase.
@@ -170,18 +176,7 @@ abstract class CrossActivityBackAnimation(
        // Offset start rectangle to align task bounds.
        backAnimRect.offsetTo(0, 0)

        startClosingRect.set(backAnimRect)

        // scale closing target into the middle for rhs and to the right for lhs
        targetClosingRect.set(startClosingRect)
        targetClosingRect.scaleCentered(MAX_SCALE)
        if (backMotionEvent.swipeEdge != BackEvent.EDGE_RIGHT) {
            targetClosingRect.offset(
                startClosingRect.right - targetClosingRect.right - displayBoundsMargin,
                0f
            )
        }

        preparePreCommitClosingRectMovement(backMotionEvent.swipeEdge)
        preparePreCommitEnteringRectMovement()

        background.ensureBackground(
+16 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.view.Choreographer
import android.view.SurfaceControl
import android.view.animation.Animation
import android.view.animation.Transformation
import android.window.BackEvent
import android.window.BackMotionEvent
import android.window.BackNavigationInfo
import com.android.internal.R
@@ -74,6 +75,21 @@ class CustomCrossActivityBackAnimation(
        )
    )

    override fun preparePreCommitClosingRectMovement(swipeEdge: Int) {
        startClosingRect.set(backAnimRect)

        // scale closing target to the left for right-hand-swipe and to the right for
        // left-hand-swipe
        targetClosingRect.set(startClosingRect)
        targetClosingRect.scaleCentered(MAX_SCALE)
        val offset = if (swipeEdge != BackEvent.EDGE_RIGHT) {
            startClosingRect.right - targetClosingRect.right - displayBoundsMargin
        } else {
            -targetClosingRect.left + displayBoundsMargin
        }
        targetClosingRect.offset(offset, 0f)
    }

    override fun preparePreCommitEnteringRectMovement() {
        // No movement for the entering rect
        startEnteringRect.set(startClosingRect)
+15 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.wm.shell.back
import android.content.Context
import android.view.Choreographer
import android.view.SurfaceControl
import android.window.BackEvent
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.animation.Interpolators
@@ -47,6 +48,20 @@ constructor(
        context.resources.getDimension(R.dimen.cross_activity_back_entering_start_offset)
    override val allowEnteringYShift = true

    override fun preparePreCommitClosingRectMovement(swipeEdge: Int) {
        startClosingRect.set(backAnimRect)

        // scale closing target into the middle for rhs and to the right for lhs
        targetClosingRect.set(startClosingRect)
        targetClosingRect.scaleCentered(MAX_SCALE)
        if (swipeEdge != BackEvent.EDGE_RIGHT) {
            targetClosingRect.offset(
                    startClosingRect.right - targetClosingRect.right - displayBoundsMargin,
                    0f
            )
        }
    }

    override fun preparePreCommitEnteringRectMovement() {
        // the entering target starts 96dp to the left of the screen edge...
        startEnteringRect.set(startClosingRect)