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

Commit 35a43704 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

No footer message when showing empty shade

In dual shade, we show the footer even if the empty shade is visible.
Since the empty shade shows the "Unlock to see older notifications"
already, we don't need to show it in the footer in this case.

We don't need to check for dual shade especially, since the footer just
won't be visible at all when there are no notifications and dual shade
is off, so it doesn't matter.

Fix: 439537988
Test: FooterViewModelTest
Test: tested manually with multiple states (dual shade on/off), new
empty shade design on/off, with and without notifications
Flag: com.android.systemui.scene_container

Change-Id: Ib55b33e2b84291c28b1ae2e6201c48eb2b34d6aa
parent 1125f7d1
Loading
Loading
Loading
Loading
+31 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,8 @@ import android.provider.Settings
import androidx.test.filters.SmallTest
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.SysuiTestCase
import com.android.systemui.coroutines.collectLastValue
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.Flags
import com.android.systemui.flags.andSceneContainer
import com.android.systemui.flags.andSceneContainer
import com.android.systemui.flags.fakeFeatureFlagsClassic
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -39,6 +41,7 @@ import com.android.systemui.shade.shadeTestUtil
import com.android.systemui.shared.settings.data.repository.fakeSecureSettingsRepository
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.model.NotifStats
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
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.statusbar.notification.footer.shared.NotifRedesignFooter
import com.android.systemui.testKosmos
import com.android.systemui.testKosmos
import com.android.systemui.util.ui.isAnimating
import com.android.systemui.util.ui.isAnimating
@@ -80,6 +83,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
    }
    }


    @Test
    @Test
    @DisableSceneContainer
    fun messageVisible_whenFilteredNotifications() =
    fun messageVisible_whenFilteredNotifications() =
        kosmos.runTest {
        kosmos.runTest {
            val visible by collectLastValue(underTest.message.isVisible)
            val visible by collectLastValue(underTest.message.isVisible)
@@ -87,6 +91,30 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
            assertThat(visible).isTrue()
            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
    @Test
    fun messageVisible_whenNoFilteredNotifications() =
    fun messageVisible_whenNoFilteredNotifications() =
        kosmos.runTest {
        kosmos.runTest {
@@ -132,6 +160,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
        kosmos.runTest {
        kosmos.runTest {
            val visible by collectLastValue(underTest.clearAllButton.isVisible)
            val visible by collectLastValue(underTest.clearAllButton.isVisible)


            activeNotificationListRepository.setActiveNotifs(count = 1)
            activeNotificationListRepository.notifStats.value =
            activeNotificationListRepository.notifStats.value =
                NotifStats(
                NotifStats(
                    hasNonClearableAlertingNotifs = false,
                    hasNonClearableAlertingNotifs = false,
@@ -264,6 +293,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
    fun manageButtonVisible_whenMessageVisible() =
    fun manageButtonVisible_whenMessageVisible() =
        kosmos.runTest {
        kosmos.runTest {
            val visible by collectLastValue(underTest.manageOrHistoryButton.isVisible)
            val visible by collectLastValue(underTest.manageOrHistoryButton.isVisible)
            activeNotificationListRepository.setActiveNotifs(count = 1)
            activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true
            activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true
            assertThat(visible?.value).isFalse()
            assertThat(visible?.value).isFalse()
        }
        }
@@ -284,6 +314,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
            val settingsVisible by collectLastValue(underTest.settingsButtonVisible)
            val settingsVisible by collectLastValue(underTest.settingsButtonVisible)
            val historyVisible by collectLastValue(underTest.historyButtonVisible)
            val historyVisible by collectLastValue(underTest.historyButtonVisible)


            activeNotificationListRepository.setActiveNotifs(count = 1)
            activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true
            activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true


            assertThat(settingsVisible).isFalse()
            assertThat(settingsVisible).isFalse()
+2 −2
Original line number Original line Diff line number Diff line
@@ -18,11 +18,11 @@ package com.android.systemui.statusbar.notification.footer.ui.viewmodel


import android.annotation.DrawableRes
import android.annotation.DrawableRes
import android.annotation.StringRes
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. */
/** A ViewModel for the string message that can be shown in the footer. */
data class FooterMessageViewModel(
data class FooterMessageViewModel(
    @StringRes val messageId: Int,
    @StringRes val messageId: Int,
    @DrawableRes val iconId: Int,
    @DrawableRes val iconId: Int,
    val isVisible: StateFlow<Boolean>,
    val isVisible: Flow<Boolean>,
)
)
+15 −1
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.notification.footer.ui.viewmodel
import android.annotation.SuppressLint
import android.annotation.SuppressLint
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor
import com.android.systemui.res.R
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.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor
import com.android.systemui.shared.notifications.domain.interactor.NotificationSettingsInteractor
import com.android.systemui.statusbar.notification.NotificationActivityStarter.SettingsIntent
import com.android.systemui.statusbar.notification.NotificationActivityStarter.SettingsIntent
@@ -55,7 +56,20 @@ constructor(
        FooterMessageViewModel(
        FooterMessageViewModel(
            messageId = R.string.unlock_to_see_notif_text,
            messageId = R.string.unlock_to_see_notif_text,
            iconId = R.drawable.ic_friction_lock_closed,
            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 =
    private val clearAllButtonVisible =