summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Aaron Liu <aaronjli@google.com> 2024-03-27 09:45:39 -0700
committer Aaron Liu <aaronjli@google.com> 2024-03-27 13:54:43 -0700
commit31c702d0df141a967047ff4295c81fe7f2d4dc64 (patch)
tree4a8b92c673d7adeab712efcdfc34c343a15e17fb
parent38a8c65a1c6332a05d21e5c4b76e277f5f18da86 (diff)
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
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt31
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt29
3 files changed, 30 insertions, 36 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt
index 1178cc843d60..4bef9efe79d1 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenContent.kt
@@ -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) }
}
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
index 7acb4d5498db..c241f9ca7253 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/keyguard/ui/composable/LockscreenScene.kt
@@ -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()) }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
index fa845c7cf784..3da3e2f9cbcc 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
@@ -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 {
- LockscreenContent(
- viewModel = viewModel,
- blueprints = sceneBlueprints,
- clockInteractor = clockInteractor
- )
- .Content(modifier = Modifier.fillMaxSize())
+ // 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())
+ }
+ }
+ }
}
}
}