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

Commit 94309556 authored by Lucas Silva's avatar Lucas Silva
Browse files

Avoid removing glanceable hub view when in edit mode

This keeps the view in the shade when in edit mode, so that we can
quickly change the scene back to Communal when exiting edit mode.

Bug: 333774684
Test: atest GlanceableHubContainerControllerTest
Flag: ACONFIG com.android.systemui.communal_hub TEAMFOOD
Change-Id: Ieb3df4ca20c6f1bc141046ea7f8aff84c799cb2a
parent 1bbbc897
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.ComponentName
import android.os.UserHandle
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.compose.animation.scene.SceneKey
import com.android.compose.animation.scene.TransitionKey
import com.android.systemui.communal.domain.interactor.CommunalInteractor
import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.widgets.WidgetConfigurator
@@ -52,8 +53,8 @@ abstract class BaseCommunalViewModel(
        communalInteractor.signalUserInteraction()
    }

    fun changeScene(scene: SceneKey) {
        communalInteractor.changeScene(scene)
    fun changeScene(scene: SceneKey, transitionKey: TransitionKey? = null) {
        communalInteractor.changeScene(scene, transitionKey)
    }

    /**
+5 −1
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ import com.android.compose.theme.PlatformTheme
import com.android.internal.logging.UiEventLogger
import com.android.systemui.communal.shared.log.CommunalUiEvent
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.shared.model.CommunalTransitionKeys
import com.android.systemui.communal.ui.compose.CommunalHub
import com.android.systemui.communal.ui.viewmodel.CommunalEditModeViewModel
import com.android.systemui.communal.util.WidgetPickerIntentUtils.getWidgetExtraFromIntent
@@ -149,7 +150,10 @@ constructor(

    private fun onEditDone() {
        try {
            communalViewModel.changeScene(CommunalScenes.Communal)
            communalViewModel.changeScene(
                CommunalScenes.Communal,
                CommunalTransitionKeys.SimpleFade
            )
            checkNotNull(windowManagerService).lockNow(/* options */ null)
            finish()
        } catch (e: RemoteException) {
+3 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.SceneDataSourceDelegator
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.phone.SystemUIDialogFactory
import com.android.systemui.util.kotlin.BooleanFlowOperators.or
import com.android.systemui.util.kotlin.collectFlow
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
@@ -137,7 +138,8 @@ constructor(
    private var isDreaming = false

    /** Returns a flow that tracks whether communal hub is available. */
    fun communalAvailable(): Flow<Boolean> = communalInteractor.isCommunalAvailable
    fun communalAvailable(): Flow<Boolean> =
        or(communalInteractor.isCommunalAvailable, communalInteractor.editModeOpen)

    /**
     * Creates the container view containing the glanceable hub UI.
+14 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.systemui.communal.domain.interactor.setCommunalAvailable
import com.android.systemui.communal.shared.model.CommunalScenes
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.communal.util.CommunalColors
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.data.repository.fakeKeyguardTransitionRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
@@ -325,6 +326,19 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() {
            }
        }

    @Test
    fun editMode_communalAvailable() =
        with(kosmos) {
            testScope.runTest {
                val available by collectLastValue(underTest.communalAvailable())
                setCommunalAvailable(false)

                assertThat(available).isFalse()
                communalInteractor.setEditModeOpen(true)
                assertThat(available).isTrue()
            }
        }

    private fun initAndAttachContainerView() {
        containerView = View(context)