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

Commit 6b94cec9 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Alejandro Nijamkin
Browse files

[flexiglass] Lockscreen scene view-model is SysUiViewModel

Also, no longer injected into anywhere.

Bug: 354270224
Flag: com.android.systemui.scene_container
Test: new unit test, updated existing unit and integration tests
Test: manually verified that lockscreen can navigate to adjacent scenes
and that its elements seem to animate and render correctly

Change-Id: Id677ab4d7d39652c7a10d48c39971572e47766eb
parent 073beda4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -66,11 +66,11 @@ interface LockscreenSceneModule {

        @Provides
        fun providesLockscreenContent(
            viewModel: LockscreenContentViewModel,
            viewModelFactory: LockscreenContentViewModel.Factory,
            blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
            clockInteractor: KeyguardClockInteractor,
        ): LockscreenContent {
            return LockscreenContent(viewModel, blueprints, clockInteractor)
            return LockscreenContent(viewModelFactory, blueprints, clockInteractor)
        }
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.systemui.compose.modifiers.sysuiResTag
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
import com.android.systemui.lifecycle.rememberViewModel

/**
 * Renders the content of the lockscreen.
@@ -37,7 +38,7 @@ import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel
 * outside the scene container framework.
 */
class LockscreenContent(
    private val viewModel: LockscreenContentViewModel,
    private val viewModelFactory: LockscreenContentViewModel.Factory,
    private val blueprints: Set<@JvmSuppressWildcards ComposableLockscreenSceneBlueprint>,
    private val clockInteractor: KeyguardClockInteractor,
) {
@@ -49,6 +50,7 @@ class LockscreenContent(
    fun SceneScope.Content(
        modifier: Modifier = Modifier,
    ) {
        val viewModel = rememberViewModel { viewModelFactory.create() }
        val isContentVisible: Boolean by viewModel.isContentVisible.collectAsStateWithLifecycle()
        if (!isContentVisible) {
            // If the content isn't supposed to be visible, show a large empty box as it's needed
@@ -69,6 +71,6 @@ class LockscreenContent(
        }

        val blueprint = blueprintByBlueprintId[blueprintId] ?: return
        with(blueprint) { Content(modifier.sysuiResTag("keyguard_root_view")) }
        with(blueprint) { Content(viewModel, modifier.sysuiResTag("keyguard_root_view")) }
    }
}
+11 −3
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import com.android.compose.animation.scene.UserAction
import com.android.compose.animation.scene.UserActionResult
import com.android.compose.animation.scene.animateSceneFloatAsState
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneViewModel
import com.android.systemui.keyguard.ui.viewmodel.LockscreenSceneActionsViewModel
import com.android.systemui.qs.ui.composable.QuickSettings
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.composable.ComposableScene
@@ -37,13 +37,21 @@ import kotlinx.coroutines.flow.Flow
class LockscreenScene
@Inject
constructor(
    viewModel: LockscreenSceneViewModel,
    actionsViewModelFactory: LockscreenSceneActionsViewModel.Factory,
    private val lockscreenContent: Lazy<LockscreenContent>,
) : ComposableScene {
    override val key = Scenes.Lockscreen

    private val actionsViewModel: LockscreenSceneActionsViewModel by lazy {
        actionsViewModelFactory.create()
    }

    override val destinationScenes: Flow<Map<UserAction, UserActionResult>> =
        viewModel.destinationScenes
        actionsViewModel.actions

    override suspend fun activate() {
        actionsViewModel.activate()
    }

    @Composable
    override fun SceneScope.Content(
+5 −6
Original line number Diff line number Diff line
@@ -32,16 +32,15 @@ import dagger.multibindings.IntoSet
import javax.inject.Inject

/** Renders the lockscreen scene when showing the communal glanceable hub. */
class CommunalBlueprint
@Inject
constructor(
    private val viewModel: LockscreenContentViewModel,
) : ComposableLockscreenSceneBlueprint {
class CommunalBlueprint @Inject constructor() : ComposableLockscreenSceneBlueprint {

    override val id: String = "communal"

    @Composable
    override fun SceneScope.Content(modifier: Modifier) {
    override fun SceneScope.Content(
        viewModel: LockscreenContentViewModel,
        modifier: Modifier,
    ) {
        LockscreenLongPress(
            viewModel = viewModel.touchHandling,
            modifier = modifier,
+6 −1
Original line number Diff line number Diff line
@@ -20,9 +20,14 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import com.android.compose.animation.scene.SceneScope
import com.android.systemui.keyguard.shared.model.LockscreenSceneBlueprint
import com.android.systemui.keyguard.ui.viewmodel.LockscreenContentViewModel

/** Defines interface for classes that can render the content for a specific blueprint/layout. */
interface ComposableLockscreenSceneBlueprint : LockscreenSceneBlueprint {
    /** Renders the content of this blueprint. */
    @Composable fun SceneScope.Content(modifier: Modifier)
    @Composable
    fun SceneScope.Content(
        viewModel: LockscreenContentViewModel,
        modifier: Modifier,
    )
}
Loading