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

Commit 8af56443 authored by Ioana Alexandru's avatar Ioana Alexandru
Browse files

Notif redesign: Hide footer buttons when message is visible

When we show the text "Unlock to see older notifications", neither of
the settings/history buttons should be visible/tappable.

Test: FooterViewModelTest
Test: turn on feature to see only unseen notifs, lock device, check that
message looks good and no buttons are showing
Flag: com.android.systemui.notifications_redesign_footer_view
Bug: 375010573

Change-Id: I087ba490a42a42b18c7db9d72652ca1d6f3491d5
parent 9d8a7016
Loading
Loading
Loading
Loading
+36 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@

package com.android.systemui.statusbar.notification.footer.ui.viewmodel

import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import android.provider.Settings
@@ -40,6 +41,7 @@ import com.android.systemui.statusbar.notification.collection.render.NotifStats
import com.android.systemui.statusbar.notification.data.repository.activeNotificationListRepository
import com.android.systemui.statusbar.notification.emptyshade.shared.ModesEmptyShadeFix
import com.android.systemui.statusbar.notification.footer.shared.FooterViewRefactor
import com.android.systemui.statusbar.notification.footer.shared.NotifRedesignFooter
import com.android.systemui.testKosmos
import com.android.systemui.util.ui.isAnimating
import com.android.systemui.util.ui.value
@@ -230,6 +232,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
        }

    @Test
    @DisableFlags(NotifRedesignFooter.FLAG_NAME)
    fun manageButton_whenHistoryDisabled() =
        testScope.runTest {
            val buttonLabel by collectLastValue(underTest.manageOrHistoryButton.labelId)
@@ -243,6 +246,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
        }

    @Test
    @DisableFlags(NotifRedesignFooter.FLAG_NAME)
    fun historyButton_whenHistoryEnabled() =
        testScope.runTest {
            val buttonLabel by collectLastValue(underTest.manageOrHistoryButton.labelId)
@@ -255,8 +259,9 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
            assertThat(buttonLabel).isEqualTo(R.string.manage_notifications_history_text)
        }

    @EnableFlags(ModesEmptyShadeFix.FLAG_NAME)
    @Test
    @EnableFlags(ModesEmptyShadeFix.FLAG_NAME)
    @DisableFlags(NotifRedesignFooter.FLAG_NAME)
    fun manageButtonOnClick_whenHistoryDisabled() =
        testScope.runTest {
            val onClick by collectLastValue(underTest.manageOrHistoryButtonClick)
@@ -271,8 +276,9 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
            assertThat(onClick?.backStack).isEmpty()
        }

    @EnableFlags(ModesEmptyShadeFix.FLAG_NAME)
    @Test
    @EnableFlags(ModesEmptyShadeFix.FLAG_NAME)
    @DisableFlags(NotifRedesignFooter.FLAG_NAME)
    fun historyButtonOnClick_whenHistoryEnabled() =
        testScope.runTest {
            val onClick by collectLastValue(underTest.manageOrHistoryButtonClick)
@@ -289,6 +295,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
        }

    @Test
    @DisableFlags(NotifRedesignFooter.FLAG_NAME)
    fun manageButtonVisible_whenMessageVisible() =
        testScope.runTest {
            val visible by collectLastValue(underTest.manageOrHistoryButton.isVisible)
@@ -299,6 +306,7 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
        }

    @Test
    @DisableFlags(NotifRedesignFooter.FLAG_NAME)
    fun manageButtonVisible_whenMessageNotVisible() =
        testScope.runTest {
            val visible by collectLastValue(underTest.manageOrHistoryButton.isVisible)
@@ -307,4 +315,30 @@ class FooterViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {

            assertThat(visible?.value).isTrue()
        }

    @Test
    @EnableFlags(NotifRedesignFooter.FLAG_NAME)
    fun settingsAndHistoryButtonsNotVisible_whenMessageVisible() =
        testScope.runTest {
            val settingsVisible by collectLastValue(underTest.settingsButtonVisible)
            val historyVisible by collectLastValue(underTest.historyButtonVisible)

            activeNotificationListRepository.hasFilteredOutSeenNotifications.value = true

            assertThat(settingsVisible).isFalse()
            assertThat(historyVisible).isFalse()
        }

    @Test
    @EnableFlags(NotifRedesignFooter.FLAG_NAME)
    fun settingsAndHistoryButtonsNotVisible_whenMessageNotVisible() =
        testScope.runTest {
            val settingsVisible by collectLastValue(underTest.settingsButtonVisible)
            val historyVisible by collectLastValue(underTest.historyButtonVisible)

            activeNotificationListRepository.hasFilteredOutSeenNotifications.value = false

            assertThat(settingsVisible).isTrue()
            assertThat(historyVisible).isTrue()
        }
}
+20 −1
Original line number Diff line number Diff line
@@ -107,12 +107,31 @@ public class FooterView extends StackScrollerDecorView {
        setClearAllButtonVisible(visible, animate, /* onAnimationEnded = */ null);
    }

    /** Set the visibility of the "Manage"/"History" button to {@code visible}. */
    /**
     * Set the visibility of the "Manage"/"History" button to {@code visible}. This is replaced by
     * two separate buttons in the redesign.
     */
    public void setManageOrHistoryButtonVisible(boolean visible) {
        NotifRedesignFooter.assertInLegacyMode();
        mManageOrHistoryButton.setVisibility(visible ? View.VISIBLE : View.GONE);
    }

    /** Set the visibility of the Settings button to {@code visible}. */
    public void setSettingsButtonVisible(boolean visible) {
        if (NotifRedesignFooter.isUnexpectedlyInLegacyMode()) {
            return;
        }
        mSettingsButton.setVisibility(visible ? View.VISIBLE : View.GONE);
    }

    /** Set the visibility of the History button to {@code visible}. */
    public void setHistoryButtonVisible(boolean visible) {
        if (NotifRedesignFooter.isUnexpectedlyInLegacyMode()) {
            return;
        }
        mHistoryButton.setVisibility(visible ? View.VISIBLE : View.GONE);
    }

    /**
     * Set the visibility of the "Clear all" button to {@code visible}. Animate the change if
     * {@code animate} is true.
+22 −6
Original line number Diff line number Diff line
@@ -77,8 +77,8 @@ object FooterViewBinder {
                )
            }
        } else {
            bindSettingsButtonListener(footer, notificationActivityStarter)
            bindHistoryButtonListener(footer, notificationActivityStarter)
            launch { bindSettingsButton(footer, viewModel, notificationActivityStarter) }
            launch { bindHistoryButton(footer, viewModel, notificationActivityStarter) }
        }
        launch { bindMessage(footer, viewModel) }
    }
@@ -122,10 +122,11 @@ object FooterViewBinder {
        }
    }

    private fun bindSettingsButtonListener(
    private suspend fun bindSettingsButton(
        footer: FooterView,
        viewModel: FooterViewModel,
        notificationActivityStarter: NotificationActivityStarter,
    ) {
    ) = coroutineScope {
        val settingsIntent =
            SettingsIntent.forNotificationSettings(
                cujType = InteractionJankMonitor.CUJ_SHADE_APP_LAUNCH_FROM_HISTORY_BUTTON
@@ -134,12 +135,20 @@ object FooterViewBinder {
            notificationActivityStarter.startSettingsIntent(view, settingsIntent)
        }
        footer.setSettingsButtonClickListener(onClickListener)

        launch {
            // NOTE: This visibility change is never animated. We also don't need to do anything
            // special about the onClickListener here, since we're changing the visibility to
            // GONE so it won't be clickable anyway.
            viewModel.settingsButtonVisible.collect { footer.setSettingsButtonVisible(it) }
        }
    }

    private fun bindHistoryButtonListener(
    private suspend fun bindHistoryButton(
        footer: FooterView,
        viewModel: FooterViewModel,
        notificationActivityStarter: NotificationActivityStarter,
    ) {
    ) = coroutineScope {
        val settingsIntent =
            SettingsIntent.forNotificationHistory(
                cujType = InteractionJankMonitor.CUJ_SHADE_APP_LAUNCH_FROM_HISTORY_BUTTON
@@ -148,6 +157,13 @@ object FooterViewBinder {
            notificationActivityStarter.startSettingsIntent(view, settingsIntent)
        }
        footer.setHistoryButtonClickListener(onClickListener)

        launch {
            // NOTE: This visibility change is never animated. We also don't need to do anything
            // special about the onClickListener here, since we're changing the visibility to
            // GONE so it won't be clickable anyway.
            viewModel.historyButtonVisible.collect { footer.setHistoryButtonVisible(it) }
        }
    }

    private suspend fun bindManageOrHistoryButton(
+4 −0
Original line number Diff line number Diff line
@@ -95,6 +95,10 @@ class FooterViewModel(
                    .toAnimatedValueFlow(),
        )

    // Settings buttons are not visible when the message is.
    val settingsButtonVisible: Flow<Boolean> = message.isVisible.map { !it }
    val historyButtonVisible: Flow<Boolean> = message.isVisible.map { !it }

    val manageButtonShouldLaunchHistory =
        notificationSettingsInteractor.isNotificationHistoryEnabled