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

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

[flexiglass] SceneContainer in System UI.

If the Jetpack Compose compile-time flag and the scene container runtime
feature flag are both true, when we inflate the root
SceneWindowRootView, we also initialize it with its required
dependencies and add a ComposeView that hosts the SceneContainer
composable function.

This effectively adds the placholder scenes developed through the
Compose gallery app to actual System UI, allowing us to proceed to the
next steps of the project where we being connecting Flexiglass to real
business logic and application state.

Note that the back navigation integration done requires the enablement
of predictive back animation for the shade as described in
go/enable-notification-shade-anim.

Bug: 283836103
Test: manually verified that the Flexiglass placholder scenes correctly
show on top of the shade, correctly hide when the window is gone, can
correctly be navigated between using the placholder up/down buttons, and
the bouncer scene correctly supports the back gesture to go back to
lockscreen.

Change-Id: I82c864e922ce77469ae7fbc5f0cef77e6947ef3f
parent b7de325e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import androidx.lifecycle.LifecycleOwner
import com.android.systemui.multishade.ui.viewmodel.MultiShadeViewModel
import com.android.systemui.people.ui.viewmodel.PeopleViewModel
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModel
import com.android.systemui.scene.shared.model.Scene
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
import com.android.systemui.util.time.SystemClock

/** The Compose facade, when Compose is *not* available. */
@@ -58,6 +61,14 @@ object ComposeFacade : BaseComposeFacade {
        throwComposeUnavailableError()
    }

    override fun createSceneContainerView(
        context: Context,
        viewModel: SceneContainerViewModel,
        sceneByKey: Map<SceneKey, Scene>,
    ): View {
        throwComposeUnavailableError()
    }

    private fun throwComposeUnavailableError(): Nothing {
        error(
            "Compose is not available. Make sure to check isComposeAvailable() before calling any" +
+23 −0
Original line number Diff line number Diff line
@@ -29,6 +29,11 @@ import com.android.systemui.people.ui.compose.PeopleScreen
import com.android.systemui.people.ui.viewmodel.PeopleViewModel
import com.android.systemui.qs.footer.ui.compose.FooterActions
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModel
import com.android.systemui.scene.shared.model.Scene
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.ui.composable.ComposableScene
import com.android.systemui.scene.ui.composable.SceneContainer
import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
import com.android.systemui.util.time.SystemClock

/** The Compose facade, when Compose is available. */
@@ -71,4 +76,22 @@ object ComposeFacade : BaseComposeFacade {
            }
        }
    }

    override fun createSceneContainerView(
        context: Context,
        viewModel: SceneContainerViewModel,
        sceneByKey: Map<SceneKey, Scene>,
    ): View {
        return ComposeView(context).apply {
            setContent {
                PlatformTheme {
                    SceneContainer(
                        viewModel = viewModel,
                        sceneByKey =
                            sceneByKey.mapValues { (_, scene) -> scene as ComposableScene },
                    )
                }
            }
        }
    }
}
+10 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import androidx.lifecycle.LifecycleOwner
import com.android.systemui.multishade.ui.viewmodel.MultiShadeViewModel
import com.android.systemui.people.ui.viewmodel.PeopleViewModel
import com.android.systemui.qs.footer.ui.viewmodel.FooterActionsViewModel
import com.android.systemui.scene.shared.model.Scene
import com.android.systemui.scene.shared.model.SceneKey
import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
import com.android.systemui.util.time.SystemClock

/**
@@ -66,4 +69,11 @@ interface BaseComposeFacade {
        viewModel: MultiShadeViewModel,
        clock: SystemClock,
    ): View

    /** Create a [View] to represent [viewModel] on screen. */
    fun createSceneContainerView(
        context: Context,
        viewModel: SceneContainerViewModel,
        sceneByKey: Map<SceneKey, Scene>,
    ): View
}
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.dagger;

import com.android.systemui.globalactions.ShutdownUiModule;
import com.android.systemui.keyguard.CustomizationProvider;
import com.android.systemui.scene.startable.SceneContainerStartableModule;
import com.android.systemui.statusbar.NotificationInsetsModule;
import com.android.systemui.statusbar.QsFrameTranslateModule;

@@ -33,6 +34,7 @@ import dagger.Subcomponent;
        NotificationInsetsModule.class,
        QsFrameTranslateModule.class,
        ShutdownUiModule.class,
        SceneContainerStartableModule.class,
        SystemUIBinder.class,
        SystemUIModule.class,
        SystemUICoreStartableModule.class,
+0 −2
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import com.android.systemui.qs.tileimpl.QSFactoryImpl;
import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsImplementation;
import com.android.systemui.rotationlock.RotationLockModule;
import com.android.systemui.scene.SceneContainerFrameworkModule;
import com.android.systemui.screenshot.ReferenceScreenshotModule;
import com.android.systemui.settings.dagger.MultiUserUtilsModule;
import com.android.systemui.shade.NotificationShadeWindowControllerImpl;
@@ -104,7 +103,6 @@ import javax.inject.Named;
        QSModule.class,
        ReferenceScreenshotModule.class,
        RotationLockModule.class,
        SceneContainerFrameworkModule.class,
        StatusBarEventsModule.class,
        StartCentralSurfacesModule.class,
        VolumeModule.class,
Loading