diff options
author | 2025-02-10 12:54:22 -0800 | |
---|---|---|
committer | 2025-02-10 12:54:22 -0800 | |
commit | d2656a9c8e32f7117519c10764689bc280d5336e (patch) | |
tree | 51448134640584162f963200e7d268e50d23431a | |
parent | 6747443b19da0ecec46808679a4235b60b5f0723 (diff) | |
parent | 37d245648e2a50977a511fd5a87074c8afac07ef (diff) |
Merge "Allow swiping to Glanceable Hub by config." into main
7 files changed, 24 insertions, 5 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt index 2ca70558f18b..0b17a3f71bda 100644 --- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt +++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalContainer.kt @@ -200,8 +200,9 @@ fun CommunalContainer( scene( CommunalScenes.Blank, userActions = - if (viewModel.v2FlagEnabled()) emptyMap() - else mapOf(Swipe.Start(fromSource = Edge.End) to CommunalScenes.Communal), + if (viewModel.swipeToHubEnabled()) + mapOf(Swipe.Start(fromSource = Edge.End) to CommunalScenes.Communal) + else emptyMap(), ) { // This scene shows nothing only allowing for transitions to the communal scene. Box(modifier = Modifier.fillMaxSize()) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt index 433894b58350..799054a92bee 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/view/viewmodel/CommunalViewModelTest.kt @@ -191,6 +191,7 @@ class CommunalViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { metricsLogger, kosmos.mediaCarouselController, kosmos.blurConfig, + false, ) } diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml index 9b8926e921c9..09aa2241e42b 100644 --- a/packages/SystemUI/res/values/config.xml +++ b/packages/SystemUI/res/values/config.xml @@ -1110,4 +1110,7 @@ <!-- Configuration for wallpaper focal area --> <bool name="center_align_focal_area_shape">false</bool> <string name="focal_area_target" translatable="false" /> + + <!-- Configuration to swipe to open glanceable hub --> + <bool name="config_swipeToOpenGlanceableHub">false</bool> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt index f01a6dbf568f..ff741625a3cc 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/dagger/CommunalModule.kt @@ -104,6 +104,7 @@ interface CommunalModule { companion object { const val LOGGABLE_PREFIXES = "loggable_prefixes" const val LAUNCHER_PACKAGE = "launcher_package" + const val SWIPE_TO_HUB = "swipe_to_hub" @Provides @Communal @@ -143,5 +144,11 @@ interface CommunalModule { fun provideLauncherPackage(@Main resources: Resources): String { return resources.getString(R.string.launcher_overlayable_package) } + + @Provides + @Named(SWIPE_TO_HUB) + fun provideSwipeToHub(@Main resources: Resources): Boolean { + return resources.getBoolean(R.bool.config_swipeToOpenGlanceableHub) + } } } diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt index dd4018a9d7b9..2169881d11c5 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalViewModel.kt @@ -19,6 +19,7 @@ package com.android.systemui.communal.ui.viewmodel import android.content.ComponentName import com.android.app.tracing.coroutines.launchTraced as launch import com.android.systemui.Flags +import com.android.systemui.communal.dagger.CommunalModule.Companion.SWIPE_TO_HUB import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor @@ -92,6 +93,7 @@ constructor( private val metricsLogger: CommunalMetricsLogger, mediaCarouselController: MediaCarouselController, blurConfig: BlurConfig, + @Named(SWIPE_TO_HUB) private val swipeToHub: Boolean, ) : BaseCommunalViewModel( communalSceneInteractor, @@ -357,6 +359,8 @@ constructor( /** See [CommunalSettingsInteractor.isV2FlagEnabled] */ fun v2FlagEnabled(): Boolean = communalSettingsInteractor.isV2FlagEnabled() + fun swipeToHubEnabled(): Boolean = swipeToHub + companion object { const val POPUP_AUTO_HIDE_TIMEOUT_MS = 12000L } diff --git a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt index a379ef7b0b96..305e71e48702 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt +++ b/packages/SystemUI/src/com/android/systemui/shade/GlanceableHubContainerController.kt @@ -520,7 +520,10 @@ constructor( val glanceableHubV2 = communalSettingsInteractor.isV2FlagEnabled() if ( !hubShowing && - (touchOnNotifications || touchOnUmo || touchOnSmartspace || glanceableHubV2) + (touchOnNotifications || + touchOnUmo || + touchOnSmartspace || + !communalViewModel.swipeToHubEnabled()) ) { logger.d({ "Lockscreen touch ignored: touchOnNotifications: $bool1, touchOnUmo: $bool2, " + diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt index 732561e0979b..944604f94ce4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/GlanceableHubContainerControllerTest.kt @@ -640,11 +640,11 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { } } - @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun onTouchEvent_shadeInteracting_movesNotDispatched() = with(kosmos) { testScope.runTest { + `whenever`(communalViewModel.swipeToHubEnabled()).thenReturn(true) // On lockscreen. goToScene(CommunalScenes.Blank) whenever( @@ -721,11 +721,11 @@ class GlanceableHubContainerControllerTest : SysuiTestCase() { } } - @DisableFlags(FLAG_GLANCEABLE_HUB_V2) @Test fun onTouchEvent_bouncerInteracting_movesNotDispatched() = with(kosmos) { testScope.runTest { + `whenever`(communalViewModel.swipeToHubEnabled()).thenReturn(true) // On lockscreen. goToScene(CommunalScenes.Blank) whenever( |