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

Commit a659003b authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Rename STLState.snapToScene() to snapTo()

Bug: 373799480
Test: N/A
Flag: EXEMPT simple renaming
Change-Id: I2247708bbc695297b736952e21ab35f76fc67e92
parent e018f198
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ class SceneTransitionLayoutDataSource(
    }

    override fun snapToScene(toScene: SceneKey) {
        state.snapToScene(scene = toScene)
        state.snapTo(scene = toScene)
    }

    override fun showOverlay(overlay: OverlayKey, transitionKey: TransitionKey?) {
@@ -97,16 +97,10 @@ class SceneTransitionLayoutDataSource(
    }

    override fun instantlyShowOverlay(overlay: OverlayKey) {
        state.snapToScene(
            scene = state.transitionState.currentScene,
            currentOverlays = state.currentOverlays + overlay,
        )
        state.snapTo(overlays = state.currentOverlays + overlay)
    }

    override fun instantlyHideOverlay(overlay: OverlayKey) {
        state.snapToScene(
            scene = state.transitionState.currentScene,
            currentOverlays = state.currentOverlays - overlay,
        )
        state.snapTo(overlays = state.currentOverlays - overlay)
    }
}
+9 −6
Original line number Diff line number Diff line
@@ -138,10 +138,13 @@ sealed interface MutableSceneTransitionLayoutState : SceneTransitionLayoutState
        transitionKey: TransitionKey? = null,
    ): Pair<TransitionState.Transition, Job>?

    /** Immediately snap to the given [scene]. */
    fun snapToScene(
        scene: SceneKey,
        currentOverlays: Set<OverlayKey> = transitionState.currentOverlays,
    /**
     * Immediately snap to the given [scene] and/or [overlays], instantly interrupting all ongoing
     * transitions and settling to a [TransitionState.Idle] state.
     */
    fun snapTo(
        scene: SceneKey = transitionState.currentScene,
        overlays: Set<OverlayKey> = transitionState.currentOverlays,
    )

    /**
@@ -554,7 +557,7 @@ internal class MutableSceneTransitionLayoutStateImpl(
        this.transitionStates = listOf(idle)
    }

    override fun snapToScene(scene: SceneKey, currentOverlays: Set<OverlayKey>) {
    override fun snapTo(scene: SceneKey, overlays: Set<OverlayKey>) {
        checkThread()

        // Force finish all transitions.
@@ -562,7 +565,7 @@ internal class MutableSceneTransitionLayoutStateImpl(

        check(transitionStates.size == 1)
        check(currentTransitions.isEmpty())
        transitionStates = listOf(TransitionState.Idle(scene, currentOverlays))
        transitionStates = listOf(TransitionState.Idle(scene, overlays))
    }

    override fun showOverlay(
+1 −1
Original line number Diff line number Diff line
@@ -247,7 +247,7 @@ class ElementTest {
                rule.runOnUiThread {
                    // We snap to scene B so that the transition A => B is removed from the list of
                    // transitions.
                    state.snapToScene(SceneB)
                    state.snapTo(SceneB)
                    state.setTargetScene(SceneC, coroutineScope)
                }
            }
+4 −4
Original line number Diff line number Diff line
@@ -255,7 +255,7 @@ class SceneTransitionLayoutStateTest {
        assertThat(transition).hasCurrentScene(SceneB)

        // Snap to C.
        state.snapToScene(SceneC)
        state.snapTo(SceneC)
        assertThat(state.transitionState).isIdle()
        assertThat(state.transitionState).hasCurrentScene(SceneC)
    }
@@ -272,7 +272,7 @@ class SceneTransitionLayoutStateTest {
        assertThat(transition).hasToScene(SceneB)

        // Snap to C.
        state.snapToScene(SceneC)
        state.snapTo(SceneC)
        assertThat(state.transitionState).isIdle()
        assertThat(state.transitionState).hasCurrentScene(SceneC)
    }
@@ -375,7 +375,7 @@ class SceneTransitionLayoutStateTest {
        val job = transition.coroutineScope.launch { awaitCancellation() }

        // Force snap state to SceneB to force finish all current transitions.
        state.snapToScene(SceneB)
        state.snapTo(SceneB)
        assertThat(state.transitionState).isIdle()
        assertThat(job.isCancelled).isTrue()
    }
@@ -411,7 +411,7 @@ class SceneTransitionLayoutStateTest {
        val state = MutableSceneTransitionLayoutStateForTests(SceneA)
        state.startTransitionImmediately(this, transition(SceneA, SceneB))
        state.startTransitionImmediately(this, transition(SceneB, SceneC))
        state.snapToScene(SceneC)
        state.snapTo(SceneC)

        assertThat(state.transitionState).isIdle()
        assertThat(state.transitionState).hasCurrentScene(SceneC)
+2 −2
Original line number Diff line number Diff line
@@ -457,9 +457,9 @@ class SceneTransitionLayoutTest {
        }

        // Snap to B then C to compose these scenes at least once.
        rule.runOnUiThread { state.snapToScene(SceneB) }
        rule.runOnUiThread { state.snapTo(SceneB) }
        rule.waitForIdle()
        rule.runOnUiThread { state.snapToScene(SceneC) }
        rule.runOnUiThread { state.snapTo(SceneC) }
        rule.waitForIdle()

        assertThat(keyInA).isEqualTo(SceneA)
Loading