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

Commit 3022e6c2 authored by Darrell Shi's avatar Darrell Shi
Browse files

Add background to Glanceable Hub in scene container

Reuse existing composable in CommunalContainer for CommunalScene, which
gives it a background and all the good stuff added later on. Also
declared basic transitions. Note that they do not match UX specs
perfectly.

Test: verified manually that background and keyguard elements like lock
      icon and charging status show up in Glanceable Hub
Fix: 339448760
Flag: com.android.systemui.scene_container
Change-Id: Iec37367ea22b22fcec8d7bf76f35cf2218d9dbdd
parent 30186ac1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ fun CommunalContainer(

/** Scene containing the glanceable hub UI. */
@Composable
private fun SceneScope.CommunalScene(
fun SceneScope.CommunalScene(
    backgroundType: CommunalBackgroundType,
    colors: CommunalColors,
    content: CommunalContent,
+16 −11
Original line number Diff line number Diff line
@@ -17,20 +17,21 @@
package com.android.systemui.communal.ui.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.scene.SceneScope
import com.android.compose.animation.scene.Swipe
import com.android.compose.animation.scene.SwipeDirection
import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
import com.android.systemui.communal.ui.view.layout.sections.CommunalAppWidgetSection
import com.android.systemui.communal.shared.model.CommunalBackgroundType
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.communal.widgets.WidgetInteractionHandler
import com.android.systemui.communal.util.CommunalColors
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.composable.Scene
import com.android.systemui.statusbar.phone.SystemUIDialogFactory
import javax.inject.Inject
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.flow.Flow
@@ -43,9 +44,8 @@ class CommunalScene
@Inject
constructor(
    private val viewModel: CommunalViewModel,
    private val dialogFactory: SystemUIDialogFactory,
    private val interactionHandler: WidgetInteractionHandler,
    private val widgetSection: CommunalAppWidgetSection,
    private val communalColors: CommunalColors,
    private val communalContent: CommunalContent,
) : ExclusiveActivatable(), Scene {
    override val key = Scenes.Communal

@@ -63,12 +63,17 @@ constructor(

    @Composable
    override fun SceneScope.Content(modifier: Modifier) {
        CommunalHub(
            modifier = modifier,
        val backgroundType by
            viewModel.communalBackground.collectAsStateWithLifecycle(
                initialValue = CommunalBackgroundType.ANIMATED
            )

        CommunalScene(
            backgroundType = backgroundType,
            colors = communalColors,
            content = communalContent,
            viewModel = viewModel,
            interactionHandler = interactionHandler,
            widgetSection = widgetSection,
            dialogFactory = dialogFactory,
            modifier = modifier.horizontalNestedScrollToScene(),
        )
    }
}
+9 −4
Original line number Diff line number Diff line
@@ -19,14 +19,19 @@ package com.android.systemui.scene.ui.composable.transitions
import androidx.compose.animation.core.tween
import com.android.compose.animation.scene.Edge
import com.android.compose.animation.scene.TransitionBuilder
import com.android.systemui.communal.ui.compose.AllElements
import com.android.systemui.communal.ui.compose.Communal
import com.android.systemui.scene.shared.model.Scenes

fun TransitionBuilder.lockscreenToCommunalTransition() {
    spec = tween(durationMillis = 500)
    spec = tween(durationMillis = 1000)

    // Translate lockscreen to the left.
    // Translate lockscreen to the start direction.
    translate(Scenes.Lockscreen.rootElementKey, Edge.Start)

    // Translate communal from the right.
    translate(Scenes.Communal.rootElementKey, Edge.End)
    // Translate communal hub grid from the end direction.
    translate(Communal.Elements.Grid, Edge.End)

    // Fade all communal hub elements.
    timestampRange(startMillis = 167, endMillis = 334) { fade(AllElements) }
}