Merge "[Flexiglass] Replaces isSplitShade with shadeMode" into main
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
index 0b9f503..51464d0 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/shade/ui/composable/ShadeScene.kt
@@ -73,6 +73,7 @@
import com.android.systemui.res.R
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.scene.ui.composable.ComposableScene
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.shade.ui.viewmodel.ShadeSceneViewModel
import com.android.systemui.statusbar.phone.StatusBarIconController
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager
@@ -152,27 +153,29 @@
mediaHost: MediaHost,
modifier: Modifier = Modifier,
) {
- val isSplitShade by viewModel.isSplitShade.collectAsState()
- if (isSplitShade) {
- SplitShade(
- viewModel = viewModel,
- createTintedIconManager = createTintedIconManager,
- createBatteryMeterViewController = createBatteryMeterViewController,
- statusBarIconController = statusBarIconController,
- mediaCarouselController = mediaCarouselController,
- mediaHost = mediaHost,
- modifier = modifier,
- )
- } else {
- SingleShade(
- viewModel = viewModel,
- createTintedIconManager = createTintedIconManager,
- createBatteryMeterViewController = createBatteryMeterViewController,
- statusBarIconController = statusBarIconController,
- mediaCarouselController = mediaCarouselController,
- mediaHost = mediaHost,
- modifier = modifier,
- )
+ val shadeMode by viewModel.shadeMode.collectAsState()
+ when (shadeMode) {
+ is ShadeMode.Single ->
+ SingleShade(
+ viewModel = viewModel,
+ createTintedIconManager = createTintedIconManager,
+ createBatteryMeterViewController = createBatteryMeterViewController,
+ statusBarIconController = statusBarIconController,
+ mediaCarouselController = mediaCarouselController,
+ mediaHost = mediaHost,
+ modifier = modifier,
+ )
+ is ShadeMode.Split ->
+ SplitShade(
+ viewModel = viewModel,
+ createTintedIconManager = createTintedIconManager,
+ createBatteryMeterViewController = createBatteryMeterViewController,
+ statusBarIconController = statusBarIconController,
+ mediaCarouselController = mediaCarouselController,
+ mediaHost = mediaHost,
+ modifier = modifier,
+ )
+ is ShadeMode.Dual -> error("Dual shade is not yet implemented!")
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt
index 4fe45f6..8c9036a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImplTest.kt
@@ -30,6 +30,7 @@
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.data.repository.shadeRepository
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.testKosmos
import com.android.systemui.user.data.repository.userRepository
import com.google.common.truth.Truth
@@ -562,17 +563,17 @@
}
@Test
- fun isSplitShade() =
+ fun shadeMode() =
testScope.runTest {
- val isSplitShade by collectLastValue(underTest.isSplitShade)
+ val shadeMode by collectLastValue(underTest.shadeMode)
- shadeRepository.setSplitShade(true)
- assertThat(isSplitShade).isTrue()
+ shadeRepository.setShadeMode(ShadeMode.Split)
+ assertThat(shadeMode).isEqualTo(ShadeMode.Split)
- shadeRepository.setSplitShade(false)
- assertThat(isSplitShade).isFalse()
+ shadeRepository.setShadeMode(ShadeMode.Single)
+ assertThat(shadeMode).isEqualTo(ShadeMode.Single)
- shadeRepository.setSplitShade(true)
- assertThat(isSplitShade).isTrue()
+ shadeRepository.setShadeMode(ShadeMode.Split)
+ assertThat(shadeMode).isEqualTo(ShadeMode.Split)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt
index cbb84da..31dacdd 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/startable/ShadeStartableTest.kt
@@ -24,6 +24,7 @@
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.shade.domain.interactor.shadeInteractor
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.test.runTest
@@ -42,20 +43,20 @@
private val underTest = kosmos.shadeStartable
@Test
- fun hydrateSplitShade() =
+ fun hydrateShadeMode() =
testScope.runTest {
overrideResource(R.bool.config_use_split_notification_shade, false)
- val isSplitShade by collectLastValue(shadeInteractor.isSplitShade)
+ val shadeMode by collectLastValue(shadeInteractor.shadeMode)
underTest.start()
- assertThat(isSplitShade).isFalse()
+ assertThat(shadeMode).isEqualTo(ShadeMode.Single)
overrideResource(R.bool.config_use_split_notification_shade, true)
fakeConfigurationRepository.onAnyConfigurationChange()
- assertThat(isSplitShade).isTrue()
+ assertThat(shadeMode).isEqualTo(ShadeMode.Split)
overrideResource(R.bool.config_use_split_notification_shade, false)
fakeConfigurationRepository.onAnyConfigurationChange()
- assertThat(isSplitShade).isFalse()
+ assertThat(shadeMode).isEqualTo(ShadeMode.Single)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
index 2e68d12..1c54961 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModelTest.kt
@@ -37,10 +37,12 @@
import com.android.systemui.res.R
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.privacyChipInteractor
import com.android.systemui.shade.domain.interactor.shadeHeaderClockInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.startable.shadeStartable
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.notificationsPlaceholderViewModel
import com.android.systemui.statusbar.pipeline.airplane.data.repository.FakeAirplaneModeRepository
import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.AirplaneModeInteractor
@@ -72,6 +74,7 @@
private val testScope = kosmos.testScope
private val sceneInteractor by lazy { kosmos.sceneInteractor }
private val deviceEntryInteractor by lazy { kosmos.deviceEntryInteractor }
+ private val shadeRepository by lazy { kosmos.shadeRepository }
private val mobileIconsInteractor = FakeMobileIconsInteractor(FakeMobileMappingsProxy(), mock())
private val flags = FakeFeatureFlagsClassic().also { it.set(Flags.NEW_NETWORK_SLICE_UI, false) }
@@ -274,4 +277,19 @@
assertThat(destinationScenes?.get(Swipe(SwipeDirection.Down))?.toScene)
.isEqualTo(Scenes.QuickSettings)
}
+
+ @Test
+ fun shadeMode() =
+ testScope.runTest {
+ val shadeMode by collectLastValue(underTest.shadeMode)
+
+ shadeRepository.setShadeMode(ShadeMode.Split)
+ assertThat(shadeMode).isEqualTo(ShadeMode.Split)
+
+ shadeRepository.setShadeMode(ShadeMode.Single)
+ assertThat(shadeMode).isEqualTo(ShadeMode.Single)
+
+ shadeRepository.setShadeMode(ShadeMode.Split)
+ assertThat(shadeMode).isEqualTo(ShadeMode.Split)
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
index d89523d..288ef3c 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/LockscreenSceneViewModel.kt
@@ -23,6 +23,7 @@
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -69,8 +70,8 @@
/** The key of the scene we should switch to when swiping down from the top edge. */
val downFromTopEdgeDestinationSceneKey: StateFlow<SceneKey?> =
- shadeInteractor.isSplitShade
- .map { isSplitShade -> Scenes.QuickSettings.takeUnless { isSplitShade } }
+ shadeInteractor.shadeMode
+ .map { shadeMode -> Scenes.QuickSettings.takeIf { shadeMode is ShadeMode.Single } }
.stateIn(
scope = applicationScope,
started = SharingStarted.WhileSubscribed(),
diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModel.kt
index a490fe2..451fd67 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/GoneSceneViewModel.kt
@@ -25,6 +25,7 @@
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.shade.shared.model.ShadeMode
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.SharingStarted
@@ -40,17 +41,17 @@
shadeInteractor: ShadeInteractor,
) {
val destinationScenes: StateFlow<Map<UserAction, UserActionResult>> =
- shadeInteractor.isSplitShade
- .map { isSplitShade -> destinationScenes(isSplitShade = isSplitShade) }
+ shadeInteractor.shadeMode
+ .map { shadeMode -> destinationScenes(shadeMode = shadeMode) }
.stateIn(
scope = applicationScope,
started = SharingStarted.WhileSubscribed(),
- initialValue = destinationScenes(isSplitShade = shadeInteractor.isSplitShade.value)
+ initialValue = destinationScenes(shadeMode = shadeInteractor.shadeMode.value)
)
- private fun destinationScenes(isSplitShade: Boolean): Map<UserAction, UserActionResult> {
+ private fun destinationScenes(shadeMode: ShadeMode): Map<UserAction, UserActionResult> {
return buildMap {
- if (!isSplitShade) {
+ if (shadeMode == ShadeMode.Single) {
this[
Swipe(
pointerCount = 2,
diff --git a/packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt b/packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt
index e050c0b..5c79e1e 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/data/repository/ShadeRepository.kt
@@ -16,6 +16,7 @@
package com.android.systemui.shade.data.repository
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.shade.shared.model.ShadeMode
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
@@ -100,8 +101,7 @@
@Deprecated("Use ShadeInteractor.isQsBypassingShade instead")
val legacyExpandImmediate: StateFlow<Boolean>
- /** Whether the current configuration requires the split shade to be shown. */
- val isSplitShade: StateFlow<Boolean>
+ val shadeMode: StateFlow<ShadeMode>
/** True when QS is taking up the entire screen, i.e. fully expanded on a non-unfolded phone. */
@Deprecated("Use ShadeInteractor instead") val legacyQsFullscreen: StateFlow<Boolean>
@@ -109,7 +109,7 @@
/** NPVC.mClosing as a flow. */
@Deprecated("Use ShadeAnimationInteractor instead") val legacyIsClosing: StateFlow<Boolean>
- fun setSplitShade(isSplitShade: Boolean)
+ fun setShadeMode(mode: ShadeMode)
/** Sets whether a closing animation is happening. */
@Deprecated("Use ShadeAnimationInteractor instead") fun setLegacyIsClosing(isClosing: Boolean)
@@ -219,11 +219,11 @@
@Deprecated("Use ShadeInteractor instead")
override val legacyQsFullscreen: StateFlow<Boolean> = _legacyQsFullscreen.asStateFlow()
- val _isSplitShade = MutableStateFlow(false)
- override val isSplitShade: StateFlow<Boolean> = _isSplitShade.asStateFlow()
+ val _shadeMode = MutableStateFlow<ShadeMode>(ShadeMode.Single)
+ override val shadeMode: StateFlow<ShadeMode> = _shadeMode.asStateFlow()
- override fun setSplitShade(isSplitShade: Boolean) {
- _isSplitShade.value = isSplitShade
+ override fun setShadeMode(shadeMode: ShadeMode) {
+ _shadeMode.value = shadeMode
}
override fun setLegacyQsFullscreen(legacyQsFullscreen: Boolean) {
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt
index ad3fbe5..bc60c83 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt
@@ -16,6 +16,7 @@
package com.android.systemui.shade.domain.interactor
+import com.android.systemui.shade.shared.model.ShadeMode
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
@@ -103,8 +104,7 @@
*/
val isUserInteractingWithQs: Flow<Boolean>
- /** Whether the current configuration requires the split shade to be shown. */
- val isSplitShade: StateFlow<Boolean>
+ val shadeMode: StateFlow<ShadeMode>
}
fun createAnyExpansionFlow(
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorEmptyImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorEmptyImpl.kt
index 57a36b5..e9bb4c6 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorEmptyImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorEmptyImpl.kt
@@ -17,6 +17,7 @@
package com.android.systemui.shade.domain.interactor
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.shade.shared.model.ShadeMode
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
@@ -42,5 +43,5 @@
override val isUserInteracting: StateFlow<Boolean> = inactiveFlowBoolean
override val isShadeTouchable: Flow<Boolean> = inactiveFlowBoolean
override val isExpandToQsEnabled: Flow<Boolean> = inactiveFlowBoolean
- override val isSplitShade: StateFlow<Boolean> = inactiveFlowBoolean
+ override val shadeMode: StateFlow<ShadeMode> = MutableStateFlow(ShadeMode.Single)
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorLegacyImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorLegacyImpl.kt
index 3bccd2b..6414af3 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorLegacyImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorLegacyImpl.kt
@@ -21,6 +21,7 @@
import com.android.systemui.keyguard.data.repository.KeyguardRepository
import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.shade.data.repository.ShadeRepository
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -99,7 +100,7 @@
override val isUserInteractingWithQs: Flow<Boolean> =
userInteractingFlow(repository.legacyQsTracking, repository.qsExpansion)
- override val isSplitShade: StateFlow<Boolean> = repository.isSplitShade
+ override val shadeMode: StateFlow<ShadeMode> = repository.shadeMode
/**
* Return a flow for whether a user is interacting with an expandable shade component using
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt
index ad8c029..7785eda 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorSceneContainerImpl.kt
@@ -23,6 +23,7 @@
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.data.repository.ShadeRepository
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.domain.interactor.SharedNotificationContainerInteractor
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -108,7 +109,7 @@
override val isUserInteractingWithQs: Flow<Boolean> =
sceneBasedInteracting(sceneInteractor, Scenes.QuickSettings)
- override val isSplitShade: StateFlow<Boolean> = shadeRepository.isSplitShade
+ override val shadeMode: StateFlow<ShadeMode> = shadeRepository.shadeMode
/**
* Returns a flow that uses scene transition progress to and from a scene that is pulled down
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt
index 334908e..11ce818 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/startable/ShadeStartable.kt
@@ -22,6 +22,7 @@
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.shade.data.repository.ShadeRepository
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.policy.SplitShadeStateController
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -41,17 +42,25 @@
) : CoreStartable {
override fun start() {
- hydrateSplitShade()
+ hydrateShadeMode()
}
- private fun hydrateSplitShade() {
+ private fun hydrateShadeMode() {
applicationScope.launch {
configurationRepository.onAnyConfigurationChange
// Force initial collection.
.onStart { emit(Unit) }
.map { applicationContext.resources }
.map { resources -> controller.shouldUseSplitNotificationShade(resources) }
- .collect { isSplitShade -> shadeRepository.setSplitShade(isSplitShade) }
+ .collect { isSplitShade ->
+ shadeRepository.setShadeMode(
+ if (isSplitShade) {
+ ShadeMode.Split
+ } else {
+ ShadeMode.Single
+ }
+ )
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/shared/model/ShadeMode.kt b/packages/SystemUI/src/com/android/systemui/shade/shared/model/ShadeMode.kt
new file mode 100644
index 0000000..3451eaf
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/shade/shared/model/ShadeMode.kt
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.systemui.shade.shared.model
+
+/** Enumerates all known modes of operation of the shade. */
+sealed interface ShadeMode {
+
+ /**
+ * The single or "accordion" shade where the QS and notification parts are in two vertically
+ * stacked panels and the user can swipe up and down to expand or collapse between the two
+ * parts.
+ */
+ data object Single : ShadeMode
+
+ /**
+ * The split shade where, on large screens and unfolded foldables, the QS and notification parts
+ * are placed side-by-side and expand/collapse as a single panel.
+ */
+ data object Split : ShadeMode
+
+ /**
+ * The dual shade where the QS and notification parts each have their own independently
+ * expandable/collapsible panel on either side of the large screen / unfolded device or sharing
+ * a space on a small screen or folded device.
+ */
+ data object Dual : ShadeMode
+}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
index 8084a6f..ea549f2 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ui/viewmodel/ShadeSceneViewModel.kt
@@ -33,6 +33,7 @@
import com.android.systemui.qs.ui.adapter.QSSceneAdapter
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.notification.stack.ui.viewmodel.NotificationsPlaceholderViewModel
import java.util.concurrent.atomic.AtomicBoolean
import javax.inject.Inject
@@ -64,12 +65,12 @@
combine(
deviceEntryInteractor.isUnlocked,
deviceEntryInteractor.canSwipeToEnter,
- shadeInteractor.isSplitShade,
- ) { isUnlocked, canSwipeToDismiss, isSplitShade ->
+ shadeInteractor.shadeMode,
+ ) { isUnlocked, canSwipeToDismiss, shadeMode ->
destinationScenes(
isUnlocked = isUnlocked,
canSwipeToDismiss = canSwipeToDismiss,
- isSplitShade = isSplitShade,
+ shadeMode = shadeMode,
)
}
.stateIn(
@@ -79,7 +80,7 @@
destinationScenes(
isUnlocked = deviceEntryInteractor.isUnlocked.value,
canSwipeToDismiss = deviceEntryInteractor.canSwipeToEnter.value,
- isSplitShade = shadeInteractor.isSplitShade.value,
+ shadeMode = shadeInteractor.shadeMode.value,
),
)
@@ -96,8 +97,7 @@
initialValue = false
)
- /** Whether the current configuration requires the split shade to be shown. */
- val isSplitShade: StateFlow<Boolean> = shadeInteractor.isSplitShade
+ val shadeMode: StateFlow<ShadeMode> = shadeInteractor.shadeMode
/** Notifies that some content in the shade was clicked. */
fun onContentClicked() = deviceEntryInteractor.attemptDeviceEntry()
@@ -119,7 +119,7 @@
private fun destinationScenes(
isUnlocked: Boolean,
canSwipeToDismiss: Boolean?,
- isSplitShade: Boolean,
+ shadeMode: ShadeMode,
): Map<UserAction, UserActionResult> {
val up =
when {
@@ -128,7 +128,7 @@
else -> Scenes.Lockscreen
}
- val down = if (isSplitShade) null else Scenes.QuickSettings
+ val down = Scenes.QuickSettings.takeIf { shadeMode is ShadeMode.Single }
return buildMap {
this[Swipe(SwipeDirection.Up)] = UserActionResult(up)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/data/repository/FakeShadeRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/data/repository/FakeShadeRepository.kt
index 6b604e1..728c67a 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/data/repository/FakeShadeRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/data/repository/FakeShadeRepository.kt
@@ -18,6 +18,7 @@
package com.android.systemui.shade.data.repository
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.shade.shared.model.ShadeMode
import dagger.Binds
import dagger.Module
import javax.inject.Inject
@@ -60,8 +61,8 @@
override val legacyLockscreenShadeTracking = MutableStateFlow(false)
- private val _isSplitShade = MutableStateFlow(false)
- override val isSplitShade: StateFlow<Boolean> = _isSplitShade.asStateFlow()
+ private val _shadeMode = MutableStateFlow<ShadeMode>(ShadeMode.Single)
+ override val shadeMode: StateFlow<ShadeMode> = _shadeMode.asStateFlow()
@Deprecated("Use ShadeInteractor instead")
override fun setLegacyIsQsExpanded(legacyIsQsExpanded: Boolean) {
@@ -136,8 +137,8 @@
_legacyShadeExpansion.value = expandedFraction
}
- override fun setSplitShade(isSplitShade: Boolean) {
- _isSplitShade.value = isSplitShade
+ override fun setShadeMode(shadeMode: ShadeMode) {
+ _shadeMode.value = shadeMode
}
}