Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModelTest.kt +31 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.provider.Settings import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic Loading @@ -39,6 +41,7 @@ import com.android.systemui.shade.shadeTestUtil import com.android.systemui.shared.settings.data.repository.fakeSecureSettingsRepository import com.android.systemui.statusbar.notification.data.model.NotifStats import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs import com.android.systemui.statusbar.notification.footer.shared.NotifRedesignFooter import com.android.systemui.testKosmos import com.android.systemui.util.ui.isAnimating Loading Loading @@ -80,6 +83,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test @DisableSceneContainer fun messageVisible_whenFilteredNotifications() = kosmos.runTest { val visible by collectLastValue(underTest.message.isVisible) Loading @@ -87,6 +91,30 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(visible).isTrue() } @Test @EnableSceneContainer fun messageVisible_whenFilteredNotificationsAndEmptyShade() = kosmos.runTest { val visible by collectLastValue(underTest.message.isVisible) activeNotificationListRepository.setActiveNotifs(count = 0) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(visible).isFalse() } @Test @EnableSceneContainer fun messageVisible_whenFilteredNotificationsAndShadeNotEmpty() = kosmos.runTest { val visible by collectLastValue(underTest.message.isVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(visible).isTrue() } @Test fun messageVisible_whenNoFilteredNotifications() = kosmos.runTest { Loading Loading @@ -132,6 +160,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { kosmos.runTest { val visible by collectLastValue(underTest.clearAllButton.isVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.notifStats.value = NotifStats( hasNonClearableAlertingNotifs = false, Loading Loading @@ -264,6 +293,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { fun manageButtonVisible_whenMessageVisible() = kosmos.runTest { val visible by collectLastValue(underTest.manageOrHistoryButton.isVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(visible?.value).isFalse() } Loading @@ -284,6 +314,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { val settingsVisible by collectLastValue(underTest.settingsButtonVisible) val historyVisible by collectLastValue(underTest.historyButtonVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(settingsVisible).isFalse() Loading packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterMessageViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -18,11 +18,11 @@ package com.android.systemui.statusbar.notification.footer.ui.viewmodel import android.annotation.DrawableRes import android.annotation.StringRes import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.Flow /** A ViewModel for the string message that can be shown in the footer. */ data class FooterMessageViewModel( @StringRes val messageId: Int, @DrawableRes val iconId: Int, val isVisible: StateFlow<Boolean>, val isVisible: Flow<Boolean>, ) packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModel.kt +15 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.footer.ui.viewmodel import android.annotation.SuppressLint import com.android.internal.jank.InteractionJankMonitor import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor import com.android.systemui.statusbar.notification.NotificationActivityStarter.SettingsIntent Loading Loading @@ -55,7 +56,20 @@ constructor( FooterMessageViewModel( messageId = R.string.unlock_to_see_notif_text, iconId = R.drawable.ic_friction_lock_closed, isVisible = seenNotificationsInteractor.hasFilteredOutSeenNotifications, isVisible = if (SceneContainerFlag.isEnabled) { // Only show the footer message if there are notifications present. // Otherwise the empty shade will show it instead, so the footer only needs // to show the buttons. combine( seenNotificationsInteractor.hasFilteredOutSeenNotifications, activeNotificationsInteractor.areAnyNotificationsPresent, ) { hasFilteredOutSeenNotifications, areAnyNotificationsPresent -> hasFilteredOutSeenNotifications && areAnyNotificationsPresent } } else { seenNotificationsInteractor.hasFilteredOutSeenNotifications }, ) private val clearAllButtonVisible = Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModelTest.kt +31 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,8 @@ import android.provider.Settings import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.flags.DisableSceneContainer import com.android.systemui.flags.EnableSceneContainer import com.android.systemui.flags.Flags import com.android.systemui.flags.andSceneContainer import com.android.systemui.flags.fakeFeatureFlagsClassic Loading @@ -39,6 +41,7 @@ import com.android.systemui.shade.shadeTestUtil import com.android.systemui.shared.settings.data.repository.fakeSecureSettingsRepository import com.android.systemui.statusbar.notification.data.model.NotifStats import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository import com.android.systemui.statusbar.notification.data.repository.setActiveNotifs import com.android.systemui.statusbar.notification.footer.shared.NotifRedesignFooter import com.android.systemui.testKosmos import com.android.systemui.util.ui.isAnimating Loading Loading @@ -80,6 +83,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test @DisableSceneContainer fun messageVisible_whenFilteredNotifications() = kosmos.runTest { val visible by collectLastValue(underTest.message.isVisible) Loading @@ -87,6 +91,30 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { assertThat(visible).isTrue() } @Test @EnableSceneContainer fun messageVisible_whenFilteredNotificationsAndEmptyShade() = kosmos.runTest { val visible by collectLastValue(underTest.message.isVisible) activeNotificationListRepository.setActiveNotifs(count = 0) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(visible).isFalse() } @Test @EnableSceneContainer fun messageVisible_whenFilteredNotificationsAndShadeNotEmpty() = kosmos.runTest { val visible by collectLastValue(underTest.message.isVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(visible).isTrue() } @Test fun messageVisible_whenNoFilteredNotifications() = kosmos.runTest { Loading Loading @@ -132,6 +160,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { kosmos.runTest { val visible by collectLastValue(underTest.clearAllButton.isVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.notifStats.value = NotifStats( hasNonClearableAlertingNotifs = false, Loading Loading @@ -264,6 +293,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { fun manageButtonVisible_whenMessageVisible() = kosmos.runTest { val visible by collectLastValue(underTest.manageOrHistoryButton.isVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(visible?.value).isFalse() } Loading @@ -284,6 +314,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { val settingsVisible by collectLastValue(underTest.settingsButtonVisible) val historyVisible by collectLastValue(underTest.historyButtonVisible) activeNotificationListRepository.setActiveNotifs(count = 1) activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true assertThat(settingsVisible).isFalse() Loading
packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterMessageViewModel.kt +2 −2 Original line number Diff line number Diff line Loading @@ -18,11 +18,11 @@ package com.android.systemui.statusbar.notification.footer.ui.viewmodel import android.annotation.DrawableRes import android.annotation.StringRes import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.Flow /** A ViewModel for the string message that can be shown in the footer. */ data class FooterMessageViewModel( @StringRes val messageId: Int, @DrawableRes val iconId: Int, val isVisible: StateFlow<Boolean>, val isVisible: Flow<Boolean>, )
packages/SystemUI/src/com/android/systemui/statusbar/notification/footer/ui/viewmodel/FooterViewModel.kt +15 −1 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.footer.ui.viewmodel import android.annotation.SuppressLint import com.android.internal.jank.InteractionJankMonitor import com.android.systemui.res.R import com.android.systemui.scene.shared.flag.SceneContainerFlag import com.android.systemui.shade.domain.interactor.ShadeInteractor import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor import com.android.systemui.statusbar.notification.NotificationActivityStarter.SettingsIntent Loading Loading @@ -55,7 +56,20 @@ constructor( FooterMessageViewModel( messageId = R.string.unlock_to_see_notif_text, iconId = R.drawable.ic_friction_lock_closed, isVisible = seenNotificationsInteractor.hasFilteredOutSeenNotifications, isVisible = if (SceneContainerFlag.isEnabled) { // Only show the footer message if there are notifications present. // Otherwise the empty shade will show it instead, so the footer only needs // to show the buttons. combine( seenNotificationsInteractor.hasFilteredOutSeenNotifications, activeNotificationsInteractor.areAnyNotificationsPresent, ) { hasFilteredOutSeenNotifications, areAnyNotificationsPresent -> hasFilteredOutSeenNotifications && areAnyNotificationsPresent } } else { seenNotificationsInteractor.hasFilteredOutSeenNotifications }, ) private val clearAllButtonVisible = Loading