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

Commit 318638dc authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Move ContentState.Transition back into TransitionState.Transition (1/2)

This CL is a revert of ag/28505631: in my first iteration of overlays,
there was a strong split between scene transitions and overlay
transitions, they were contained in separate collections in STLState.
However for swipe gestures I realized that we still need to support the
concept of "isActive", i.e. whether the current transition (scene or
overlay) is the current, last one. This means that we still need some
kind of ordering between scene and overlay transitions, which is why the
second iteration of overlays (that will be introduced in ag/28338922)
keeps the current list of transitions in STLState.currentTransitions for
both scenes and overlays. For this reason, we still need a base class
for transitions, which is TransitionState.Transition.

This now means that TransitionState.Transition is the generic transition
base class (between contents) and not the specialized scene transition
(between scenes). For this reason, this CL also introduces the
TransitionState.Transition.ChangeCurrentScene for the more specific
scene transitions.

Bug: 353679003
Test: atest PlatformComposeSceneTransitionLayoutTests
Flag: com.android.systemui.scene_container
Change-Id: I6c464cdc6211cb7092f7438c2bf24f9a9e5ad603
parent eda5a4f2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ constructor(
                    1f
                }

            val dir = if (transition.toScene == splitShadeLargeClockScene) -1f else 1f
            val dir = if (transition.toContent == splitShadeLargeClockScene) -1f else 1f
            val distance = dir * getClockCenteringDistance()
            val largeClock = checkNotNull(currentClock).largeClock
            largeClock.animations.onPositionUpdated(
+3 −3
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import com.android.compose.animation.scene.ElementContentPicker
import com.android.compose.animation.scene.ElementKey
import com.android.compose.animation.scene.SceneTransitionLayoutState
import com.android.compose.animation.scene.StaticElementContentPicker
import com.android.compose.animation.scene.content.state.ContentState
import com.android.compose.animation.scene.content.state.TransitionState
import com.android.systemui.scene.shared.model.Scenes

/** [ElementContentPicker] implementation for the media carousel object. */
@@ -38,7 +38,7 @@ object MediaContentPicker : StaticElementContentPicker {

    override fun contentDuringTransition(
        element: ElementKey,
        transition: ContentState.Transition<*>,
        transition: TransitionState.Transition,
        fromContentZIndex: Float,
        toContentZIndex: Float
    ): ContentKey {
@@ -64,7 +64,7 @@ object MediaContentPicker : StaticElementContentPicker {
    }

    /** Returns true when the media should be laid on top of the rest for the given [transition]. */
    fun shouldElevateMedia(transition: ContentState.Transition<*>): Boolean {
    fun shouldElevateMedia(transition: TransitionState.Transition): Boolean {
        return transition.isTransitioningBetween(Scenes.Lockscreen, Scenes.Shade)
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ private fun SceneScope.stateForQuickSettingsContent(
                else -> QSSceneAdapter.State.CLOSED
            }
        }
        is TransitionState.Transition ->
        is TransitionState.Transition.ChangeCurrentScene ->
            with(transitionState) {
                when {
                    isSplitShade -> UnsquishingQS(squishiness)
@@ -108,16 +108,16 @@ private fun SceneScope.stateForQuickSettingsContent(
                    fromScene == Scenes.QuickSettings && toScene == Scenes.Shade -> {
                        Collapsing { progress }
                    }
                    fromScene == Scenes.Shade || toScene == Scenes.Shade -> {
                    fromContent == Scenes.Shade || toContent == Scenes.Shade -> {
                        UnsquishingQQS(squishiness)
                    }
                    fromScene == Scenes.QuickSettings || toScene == Scenes.QuickSettings -> {
                    fromContent == Scenes.QuickSettings || toContent == Scenes.QuickSettings -> {
                        QSSceneAdapter.State.QS
                    }
                    else ->
                        error(
                            "Bad transition for QuickSettings: fromScene=$fromScene," +
                                " toScene=$toScene"
                            "Bad transition for QuickSettings: fromContent=$fromContent," +
                                " toScene=$toContent"
                        )
                }
            }
+1 −1
Original line number Diff line number Diff line
@@ -253,7 +253,7 @@ private fun SceneScope.QuickSettingsScene(
        val isScrollable =
            when (val state = layoutState.transitionState) {
                is TransitionState.Idle -> true
                is TransitionState.Transition -> state.fromScene == Scenes.QuickSettings
                is TransitionState.Transition -> state.fromContent == Scenes.QuickSettings
            }

        LaunchedEffect(isCustomizing, scrollState) {
+2 −2
Original line number Diff line number Diff line
@@ -19,14 +19,14 @@ package com.android.compose.animation.scene
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.AnimationVector1D
import androidx.compose.animation.core.SpringSpec
import com.android.compose.animation.scene.content.state.ContentState
import com.android.compose.animation.scene.content.state.TransitionState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch

internal fun CoroutineScope.animateContent(
    transition: ContentState.Transition<*>,
    transition: TransitionState.Transition,
    oneOffAnimation: OneOffAnimation,
    targetProgress: Float,
    startTransition: () -> Unit,
Loading