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

Commit da8659da authored by William Xiao's avatar William Xiao Committed by Android (Google) Code Review
Browse files

Merge "Only allow hub mode to show when keyguard is visible" into main

parents 73ff9c2f 4dd9f772
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -65,10 +65,13 @@ fun CommunalContainer(
        viewModel.currentScene
            .transform<CommunalSceneKey, SceneKey> { value -> value.toTransitionSceneKey() }
            .collectAsState(TransitionSceneKey.Blank)
    // Don't show hub mode UI if keyguard is present. This is important since we're in the shade,
    // which can be opened from many locations.
    val isKeyguardShowing by viewModel.isKeyguardVisible.collectAsState(initial = false)

    // Failsafe to hide the whole SceneTransitionLayout in case of bugginess.
    var showSceneTransitionLayout by remember { mutableStateOf(true) }
    if (!showSceneTransitionLayout) {
    if (!showSceneTransitionLayout || !isKeyguardShowing) {
        return
    }

+4 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.systemui.communal.shared.model.CommunalContentSize
import com.android.systemui.communal.shared.model.CommunalSceneKey
import com.android.systemui.communal.widgets.EditWidgetsActivityStarter
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.smartspace.data.repository.SmartspaceRepository
import javax.inject.Inject
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -46,6 +47,7 @@ constructor(
    private val widgetRepository: CommunalWidgetRepository,
    mediaRepository: CommunalMediaRepository,
    smartspaceRepository: SmartspaceRepository,
    keyguardInteractor: KeyguardInteractor,
    private val appWidgetHost: AppWidgetHost,
    private val editWidgetsActivityStarter: EditWidgetsActivityStarter
) {
@@ -67,6 +69,8 @@ constructor(
    val isCommunalShowing: Flow<Boolean> =
        communalRepository.desiredScene.map { it == CommunalSceneKey.Communal }

    val isKeyguardVisible: Flow<Boolean> = keyguardInteractor.isKeyguardVisible

    /** Callback received whenever the [SceneTransitionLayout] finishes a scene transition. */
    fun onSceneChanged(newScene: CommunalSceneKey) {
        communalRepository.setDesiredScene(newScene)
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ abstract class BaseCommunalViewModel(
    private val communalInteractor: CommunalInteractor,
    val mediaHost: MediaHost,
) {
    val isKeyguardVisible: Flow<Boolean> = communalInteractor.isKeyguardVisible

    val currentScene: StateFlow<CommunalSceneKey> = communalInteractor.desiredScene

    fun onSceneChanged(scene: CommunalSceneKey) {
+0 −1
Original line number Diff line number Diff line
@@ -39,7 +39,6 @@ constructor(
    tutorialInteractor: CommunalTutorialInteractor,
    @Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
) : BaseCommunalViewModel(communalInteractor, mediaHost) {

    @OptIn(ExperimentalCoroutinesApi::class)
    override val communalContent: Flow<List<CommunalContentModel>> =
        tutorialInteractor.isTutorialAvailable.flatMapLatest { isTutorialMode ->
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ object CommunalInteractorFactory {
                widgetRepository,
                mediaRepository,
                smartspaceRepository,
                withDeps.keyguardInteractor,
                appWidgetHost,
                editWidgetsActivityStarter,
            ),