diff options
| author | 2023-10-04 23:04:17 +0000 | |
|---|---|---|
| committer | 2023-10-04 23:04:17 +0000 | |
| commit | 556b3af48aa79b66cb8972e130a77bc633bfc691 (patch) | |
| tree | 2727a1c537f41f85d3d4d6bba2dd2125b9506ac1 | |
| parent | c8b8fcef930b80a48d1462c44c142f8ece8014f8 (diff) | |
| parent | c8b2a14bbfde2b3366fd0709fac5834a20065139 (diff) | |
Merge "[flexiglass] Foldable UI support for bouncer." into main
5 files changed, 42 insertions, 14 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt index a9944f739975..f2b7b3290f96 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt @@ -144,15 +144,17 @@ private fun SceneScope.BouncerScene( } val childModifier = Modifier.element(Bouncer.Elements.Content).fillMaxSize() + val isFullScreenUserSwitcherEnabled = viewModel.isUserSwitcherVisible - when (windowSizeClass.widthSizeClass) { - WindowWidthSizeClass.Expanded -> + when { + windowSizeClass.widthSizeClass == WindowWidthSizeClass.Expanded -> SideBySide( viewModel = viewModel, dialogFactory = dialogFactory, modifier = childModifier, ) - WindowWidthSizeClass.Medium -> + isFullScreenUserSwitcherEnabled && + windowSizeClass.widthSizeClass == WindowWidthSizeClass.Medium -> Stacked( viewModel = viewModel, dialogFactory = dialogFactory, @@ -442,14 +444,22 @@ private fun SideBySide( label = "offset", ) - UserSwitcher( - viewModel = viewModel, - modifier = - Modifier.fillMaxHeight().weight(1f).graphicsLayer { - translationX = size.width * animatedOffset - alpha = animatedAlpha(animatedOffset) - }, - ) + val userSwitcherModifier = + Modifier.fillMaxHeight().weight(1f).graphicsLayer { + translationX = size.width * animatedOffset + alpha = animatedAlpha(animatedOffset) + } + if (viewModel.isUserSwitcherVisible) { + UserSwitcher( + viewModel = viewModel, + modifier = userSwitcherModifier, + ) + } else { + Box( + modifier = userSwitcherModifier, + ) + } + Box( modifier = Modifier.fillMaxHeight().weight(1f).graphicsLayer { diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/BouncerRepository.kt b/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/BouncerRepository.kt index 943216ebd0d6..b2a7607cb323 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/BouncerRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/BouncerRepository.kt @@ -17,6 +17,8 @@ package com.android.systemui.bouncer.data.repository import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.flags.FeatureFlagsClassic +import com.android.systemui.flags.Flags import javax.inject.Inject import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow @@ -24,11 +26,18 @@ import kotlinx.coroutines.flow.asStateFlow /** Provides access to bouncer-related application state. */ @SysUISingleton -class BouncerRepository @Inject constructor() { +class BouncerRepository +@Inject +constructor( + flags: FeatureFlagsClassic, +) { private val _message = MutableStateFlow<String?>(null) /** The user-facing message to show in the bouncer. */ val message: StateFlow<String?> = _message.asStateFlow() + /** Whether the user switcher should be displayed within the bouncer UI on large screens. */ + val isUserSwitcherVisible: Boolean = flags.isEnabled(Flags.FULL_SCREEN_USER_SWITCHER) + fun setMessage(message: String?) { _message.value = message } diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt b/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt index 0c0236999e39..4ce1422b91e8 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/domain/interactor/BouncerInteractor.kt @@ -96,6 +96,9 @@ constructor( /** Whether the pattern should be visible for the currently-selected user. */ val isPatternVisible: StateFlow<Boolean> = authenticationInteractor.isPatternVisible + /** Whether the user switcher should be displayed within the bouncer UI on large screens. */ + val isUserSwitcherVisible: Boolean = repository.isUserSwitcherVisible + init { if (flags.isEnabled()) { // Clear the message if moved from throttling to no-longer throttling. diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt index 2cb98d879e69..ef0609a99e05 100644 --- a/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/bouncer/ui/viewmodel/BouncerViewModel.kt @@ -99,6 +99,8 @@ class BouncerViewModel( initialValue = emptyList(), ) + val isUserSwitcherVisible: Boolean = bouncerInteractor.isUserSwitcherVisible + private val isInputEnabled: StateFlow<Boolean> = bouncerInteractor.isThrottled .map { !it } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt index 766f748bece8..a4881bc6efec 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneTestUtils.kt @@ -80,7 +80,11 @@ class SceneTestUtils( ) { val testDispatcher = StandardTestDispatcher() val testScope = TestScope(testDispatcher) - val featureFlags = FakeFeatureFlagsClassic().apply { set(Flags.FACE_AUTH_REFACTOR, false) } + val featureFlags = + FakeFeatureFlagsClassic().apply { + set(Flags.FACE_AUTH_REFACTOR, false) + set(Flags.FULL_SCREEN_USER_SWITCHER, false) + } val sceneContainerFlags = FakeSceneContainerFlags().apply { enabled = true } val deviceEntryRepository: FakeDeviceEntryRepository by lazy { FakeDeviceEntryRepository() } val authenticationRepository: FakeAuthenticationRepository by lazy { @@ -205,7 +209,7 @@ class SceneTestUtils( return BouncerInteractor( applicationScope = applicationScope(), applicationContext = context, - repository = BouncerRepository(), + repository = BouncerRepository(featureFlags), deviceEntryInteractor = deviceEntryInteractor, authenticationInteractor = authenticationInteractor, sceneInteractor = sceneInteractor, |