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

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

Move scene picker definition inside ElementKey (1/2)

This scenes moves the scene picker definition inside ElementKey instead
of inside a transition. The main reason for this is b/317026105: we need
to be able to easily set the default scene of a MovableElement. Without
this change, we would need to set a scene picker on all transitions
between at least one scene that contains that movable element. For
instance, because the movable MediaPlayer in the demo is in the
Lockscreen, Shade and QuickSettings scenes, we would need to add a
picker for all transitions except Bouncer => Launcher.

Test: Existing STL tests
Bug: 317026105
Flag: N/A
Change-Id: I59953fec3be885d2e787a0705f93b621eb2c4f7d
parent 429020dd
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -310,7 +310,6 @@ private fun shouldDrawElement(
        transition,
        scene.key,
        element.key,
        sharedTransformation,
    )
}

@@ -319,9 +318,8 @@ internal fun shouldDrawOrComposeSharedElement(
    transition: TransitionState.Transition,
    scene: SceneKey,
    element: ElementKey,
    sharedTransformation: SharedElementTransformation?
): Boolean {
    val scenePicker = sharedTransformation?.scenePicker ?: DefaultSharedElementScenePicker
    val scenePicker = element.scenePicker ?: DefaultSharedElementScenePicker
    val fromScene = transition.fromScene
    val toScene = transition.toScene

+6 −0
Original line number Diff line number Diff line
@@ -68,6 +68,12 @@ class ElementKey(
     * set to true to make sure that shared backgrounds are drawn below elements of other scenes.
     */
    val isBackground: Boolean = false,

    /**
     * The [SharedElementScenePicker] to use when deciding in which scene we should draw or compose
     * this element when it is shared.
     */
    val scenePicker: SharedElementScenePicker? = null,
) : Key(name, identity), ElementMatcher {
    @VisibleForTesting
    // TODO(b/240432457): Make internal once PlatformComposeSceneTransitionLayoutTestsUtils can
+0 −1
Original line number Diff line number Diff line
@@ -179,7 +179,6 @@ private fun shouldComposeMovableElement(
        transition,
        scene,
        element.key,
        sharedElementTransformation(layoutImpl.state, transition, element.key),
    )
}

+1 −7
Original line number Diff line number Diff line
@@ -119,14 +119,8 @@ interface TransitionBuilder : PropertyTransformationBuilder {
     *
     * @param enabled whether the matched element(s) should actually be shared in this transition.
     *   Defaults to true.
     * @param scenePicker the [SharedElementScenePicker] to use when deciding in which scene we
     *   should draw or compose this shared element.
     */
    fun sharedElement(
        matcher: ElementMatcher,
        enabled: Boolean = true,
        scenePicker: SharedElementScenePicker = DefaultSharedElementScenePicker,
    )
    fun sharedElement(matcher: ElementMatcher, enabled: Boolean = true)

    /**
     * Adds the transformations in [builder] but in reversed order. This allows you to partially
+2 −6
Original line number Diff line number Diff line
@@ -108,12 +108,8 @@ internal class TransitionBuilderImpl : TransitionBuilder {
        range = null
    }

    override fun sharedElement(
        matcher: ElementMatcher,
        enabled: Boolean,
        scenePicker: SharedElementScenePicker,
    ) {
        transformations.add(SharedElementTransformation(matcher, enabled, scenePicker))
    override fun sharedElement(matcher: ElementMatcher, enabled: Boolean) {
        transformations.add(SharedElementTransformation(matcher, enabled))
    }

    override fun timestampRange(
Loading