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

Commit 31c702d0 authored by Aaron Liu's avatar Aaron Liu
Browse files

Remove STL from the blueprint level

Removes the STL defined in the LockscreenContent and use the scene scope
that is provided on the top level. In KeyguardViewConfigurator, we need
to make an STL at the root level so that we can invoke the composable
with a SceneScope.

Bug: 301968149
Test: Do transitions in flexiglass
Flag: ACONFIG com.android.systemui.compose_lockscreen DEVELOPMENT
Change-Id: I476b34e7d10f5a4ecab80967f3c9d78d8551f8bc
parent 38a8c65a
Loading
Loading
Loading
Loading
+6 −25
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.keyguard.ui.composable

import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.collectAsState
@@ -24,9 +23,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalView
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.animation.scene.transitions
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.keyguard.domain.interactor.KeyguardClockInteractor
import com.android.systemui.keyguard.ui.composable.blueprint.ComposableLockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
@@ -45,16 +42,12 @@ constructor(
    private val blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
    private val clockInteractor: KeyguardClockInteractor,
) {

    private val sceneKeyByBlueprint: Map<ComposableLockscreenSceneBlueprint, SceneKey> by lazy {
        blueprints.associateWith { blueprint -> SceneKey(blueprint.id) }
    }
    private val sceneKeyByBlueprintId: Map<String, SceneKey> by lazy {
        sceneKeyByBlueprint.entries.associate { (blueprint, sceneKey) -> blueprint.id to sceneKey }
    private val blueprintByBlueprintId: Map<String, ComposableLockscreenSceneBlueprint> by lazy {
        blueprints.associateBy { it.id }
    }

    @Composable
    fun Content(
    fun SceneScope.Content(
        modifier: Modifier = Modifier,
    ) {
        val coroutineScope = rememberCoroutineScope()
@@ -66,19 +59,7 @@ constructor(
            onDispose { clockInteractor.clockEventController.unregisterListeners() }
        }

        // Switch smoothly between blueprints, any composable tagged with element() will be
        // transition-animated between any two blueprints, if they both display the same element.
        SceneTransitionLayout(
            currentScene = checkNotNull(sceneKeyByBlueprintId[blueprintId]),
            onChangeScene = {},
            transitions =
                transitions { sceneKeyByBlueprintId.values.forEach { sceneKey -> to(sceneKey) } },
            modifier = modifier,
            enableInterruptions = false,
        ) {
            sceneKeyByBlueprint.entries.forEach { (blueprint, sceneKey) ->
                scene(sceneKey) { with(blueprint) { Content(Modifier.fillMaxSize()) } }
            }
        }
        val blueprint = blueprintByBlueprintId[blueprintId] ?: return
        with(blueprint) { Content(modifier) }
    }
}
+1 −5
Original line number Diff line number Diff line
@@ -66,9 +66,5 @@ private fun SceneScope.LockscreenScene(
        key = QuickSettings.SharedValues.TilesSquishiness,
    )

    lockscreenContent
        .get()
        .Content(
            modifier = modifier.fillMaxSize(),
        )
    with(lockscreenContent.get()) { Content(modifier = modifier.fillMaxSize()) }
}
+23 −6
Original line number Diff line number Diff line
@@ -29,6 +29,9 @@ import androidx.constraintlayout.widget.ConstraintSet.END
import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
import androidx.constraintlayout.widget.ConstraintSet.START
import androidx.constraintlayout.widget.ConstraintSet.TOP
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.SceneTransitionLayout
import com.android.compose.animation.scene.transitions
import com.android.internal.jank.InteractionJankMonitor
import com.android.keyguard.KeyguardStatusView
import com.android.keyguard.KeyguardStatusViewController
@@ -109,6 +112,7 @@ constructor(

    private var rootViewHandle: DisposableHandle? = null
    private var indicationAreaHandle: DisposableHandle? = null
    private val sceneKey = SceneKey("root-view-scene-key")

    var keyguardStatusViewController: KeyguardStatusViewController? = null
        get() {
@@ -219,12 +223,25 @@ constructor(
            blueprints.mapNotNull { it as? ComposableLockscreenSceneBlueprint }.toSet()
        return ComposeView(context).apply {
            setContent {
                // STL is used solely to provide a SceneScope to enable us to invoke SceneScope
                // composables.
                SceneTransitionLayout(
                    currentScene = sceneKey,
                    onChangeScene = {},
                    transitions = transitions {},
                ) {
                    scene(sceneKey) {
                        with(
                            LockscreenContent(
                                viewModel = viewModel,
                                blueprints = sceneBlueprints,
                                clockInteractor = clockInteractor
                            )
                    .Content(modifier = Modifier.fillMaxSize())
                        ) {
                            Content(modifier = Modifier.fillMaxSize())
                        }
                    }
                }
            }
        }
    }