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

Commit 7f7ba0f1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Start minimize animation for the minimize button" into main

parents fa245522 8e69aa77
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM
import android.os.Handler
import android.os.IBinder
import android.view.SurfaceControl.Transaction
import android.view.WindowManager.TRANSIT_TO_BACK
import android.window.TransitionInfo
import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
@@ -61,7 +62,9 @@ class DesktopMinimizationTransitionHandler(
        finishTransaction: Transaction,
        finishCallback: Transitions.TransitionFinishCallback,
    ): Boolean {
        if (!TransitionUtil.isClosingType(info.type)) return false
        val shouldAnimate =
            TransitionUtil.isClosingType(info.type) || info.type == Transitions.TRANSIT_MINIMIZE
        if (!shouldAnimate) return false

        val animations = mutableListOf<Animator>()
        val onAnimFinish: (Animator) -> Unit = { animator ->
@@ -75,10 +78,14 @@ class DesktopMinimizationTransitionHandler(
            }
        }

        val checkChangeMode = { change: TransitionInfo.Change ->
            change.mode == info.type ||
                (info.type == Transitions.TRANSIT_MINIMIZE && change.mode == TRANSIT_TO_BACK)
        }
        animations +=
            info.changes
                .filter {
                    it.mode == info.type && it.taskInfo?.windowingMode == WINDOWING_MODE_FREEFORM
                    checkChangeMode(it) && it.taskInfo?.windowingMode == WINDOWING_MODE_FREEFORM
                }
                .mapNotNull { createMinimizeAnimation(it, finishTransaction, onAnimFinish) }
        if (animations.isEmpty()) return false
+19 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.TestRunningTaskInfoBuilder
import com.android.wm.shell.common.DisplayController
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.transition.Transitions
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
@@ -154,6 +155,24 @@ class DesktopMinimizationTransitionHandlerTest : ShellTestCase() {
        assertTrue("Should animate going to back freeform task close transition", animates)
    }

    @Test
    fun startAnimation_minimizeTransitionToBackFreeformTask_returnsTrue() {
        val animates =
            handler.startAnimation(
                transition = mock(),
                info =
                    createTransitionInfo(
                        type = Transitions.TRANSIT_MINIMIZE,
                        task = createTask(WINDOWING_MODE_FREEFORM),
                    ),
                startTransaction = mock(),
                finishTransaction = mock(),
                finishCallback = {},
            )

        assertTrue("Should animate going to back freeform task minimize transition", animates)
    }

    private fun createTransitionInfo(
        type: Int = WindowManager.TRANSIT_TO_BACK,
        changeMode: Int = WindowManager.TRANSIT_TO_BACK,