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

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

Fix letterboxed activity cropped in cross activity back anim

Bug: 328446606
Flag: ACONFIG com.android.systemui.predictive_back_system_anims NEXTFOOD
Test: Manual, i.e. testing back animation in letterboxed app (and verifying no regressions in landscape, split screen, large screen etc.)
Change-Id: I7f69ef4edc8f6740e2174f7411fb2a585445c8f6
parent 2fe6f173
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@ class CrossActivityBackAnimation @Inject constructor(
    private var scrimLayer: SurfaceControl? = null
    private var maxScrimAlpha: Float = 0f

    private var isLetterboxed = false

    override fun onConfigurationChanged(newConfiguration: Configuration) {
        cornerRadius = ScreenDecorationsUtils.getWindowCornerRadius(context)
    }
@@ -112,9 +114,15 @@ class CrossActivityBackAnimation @Inject constructor(
        initialTouchPos.set(backMotionEvent.touchX, backMotionEvent.touchY)

        transaction.setAnimationTransaction()

        // Offset start rectangle to align task bounds.
        isLetterboxed = closingTarget!!.taskInfo.appCompatTaskInfo.topActivityBoundsLetterboxed
        if (isLetterboxed) {
            // Include letterbox in back animation
            backAnimRect.set(closingTarget!!.windowConfiguration.bounds)
        } else {
            // otherwise play animation on localBounds only
            backAnimRect.set(closingTarget!!.localBounds)
        }
        // Offset start rectangle to align task bounds.
        backAnimRect.offsetTo(0, 0)

        startClosingRect.set(backAnimRect)
@@ -241,6 +249,7 @@ class CrossActivityBackAnimation @Inject constructor(
        }
        finishCallback = null
        removeScrimLayer()
        isLetterboxed = false
    }

    private fun applyTransform(leash: SurfaceControl?, rect: RectF, alpha: Float) {
@@ -274,10 +283,11 @@ class CrossActivityBackAnimation @Inject constructor(
        scrimLayer = scrimBuilder.build()
        val colorComponents = floatArrayOf(0f, 0f, 0f)
        maxScrimAlpha = if (isDarkTheme) MAX_SCRIM_ALPHA_DARK else MAX_SCRIM_ALPHA_LIGHT
        val scrimCrop = if (isLetterboxed) backAnimRect else closingTarget!!.localBounds
        transaction
            .setColor(scrimLayer, colorComponents)
            .setAlpha(scrimLayer!!, maxScrimAlpha)
            .setCrop(scrimLayer!!, closingTarget!!.localBounds)
            .setCrop(scrimLayer!!, scrimCrop)
            .setRelativeLayer(scrimLayer!!, closingTarget!!.leash, -1)
            .show(scrimLayer)
    }