From d8478aeb3b643a18fa4adf998a242224d06c175a Mon Sep 17 00:00:00 2001 From: Steve Elliott Date: Fri, 9 Dec 2022 15:37:10 -0500 Subject: [PATCH] Add unlock to see more messaging to notif footer If the device is locked, and there are no notifications on the keyguard, and then one or more new notifications are received, and the user expands the shade, if there would be additional notifications present if the device is unlocked, then display a message in the footer. Bug: 254647461 Test: manual 1: Enable "Only Show Unseen Notifs On Keyguard" flag 2: Have some notifications 3: Lock device 4: On keyguard, observe no notifications 5. Receive a notification. 6: Expand shade (without unlocking) Observe: New UI treatment is visible Change-Id: Ibe4c3f955229ab78845a6f51adffc30ab355f52f --- .../layout/status_bar_notification_footer.xml | 11 ++++ .../notification/row/FooterView.java | 50 +++++++++++++++++++ .../stack/NotificationStackScrollLayout.java | 19 +++++-- ...tificationStackScrollLayoutController.java | 9 ++-- .../notification/row/FooterViewTest.java | 13 +++++ ...cationStackScrollLayoutControllerTest.java | 36 ++++++++----- .../NotificationStackScrollLayoutTest.java | 33 ++++++++++-- 7 files changed, 145 insertions(+), 26 deletions(-) diff --git a/packages/SystemUI/res/layout/status_bar_notification_footer.xml b/packages/SystemUI/res/layout/status_bar_notification_footer.xml index bbb8df1c5a4aa..db94c92738f27 100644 --- a/packages/SystemUI/res/layout/status_bar_notification_footer.xml +++ b/packages/SystemUI/res/layout/status_bar_notification_footer.xml @@ -26,6 +26,17 @@ android:id="@+id/content" android:layout_width="match_parent" android:layout_height="wrap_content"> + mStateListenerArgumentCaptor; + private final SeenNotificationsProviderImpl mSeenNotificationsProvider = + new SeenNotificationsProviderImpl(); + private NotificationStackScrollLayoutController mController; @Before @@ -180,7 +185,7 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mUiEventLogger, mRemoteInputManager, mVisibilityLocationProviderDelegator, - new SeenNotificationsProviderImpl(), + mSeenNotificationsProvider, mShadeController, mJankMonitor, mStackLogger, @@ -233,16 +238,14 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ true, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ true); setupShowEmptyShadeViewState(false); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ false, - /* notifVisibleInShade= */ true, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ true); } @Test @@ -255,16 +258,14 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); setupShowEmptyShadeViewState(false); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ false, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); } @Test @@ -283,16 +284,14 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); mController.setQsFullScreen(true); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( /* visible= */ true, - /* notifVisibleInShade= */ false, - /* areSeenNotifsFiltered= */false); + /* notifVisibleInShade= */ false); } @Test @@ -400,6 +399,17 @@ public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { verify(mNotificationStackScrollLayout).setIsRemoteInputActive(true); } + @Test + public void testSetNotifStats_updatesHasFilteredOutSeenNotifications() { + when(mNotifPipelineFlags.getShouldFilterUnseenNotifsOnKeyguard()).thenReturn(true); + mSeenNotificationsProvider.setHasFilteredOutSeenNotifications(true); + mController.attach(mNotificationStackScrollLayout); + mController.getNotifStackController().setNotifStats(NotifStats.getEmpty()); + verify(mNotificationStackScrollLayout).setHasFilteredOutSeenNotifications(true); + verify(mNotificationStackScrollLayout).updateFooter(); + verify(mNotificationStackScrollLayout).updateEmptyShadeView(anyBoolean(), anyBoolean()); + } + private LogMaker logMatcher(int category, int type) { return argThat(new LogMatcher(category, type)); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java index 7622549d29dee..dd7143ae7e169 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutTest.java @@ -30,6 +30,7 @@ import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertTrue; import static org.junit.Assert.assertFalse; +import static org.mockito.AdditionalMatchers.not; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; @@ -53,6 +54,7 @@ import android.util.MathUtils; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; +import android.widget.TextView; import androidx.test.annotation.UiThreadTest; import androidx.test.filters.SmallTest; @@ -328,7 +330,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { public void updateEmptyView_dndSuppressing() { when(mEmptyShadeView.willBeGone()).thenReturn(true); - mStackScroller.updateEmptyShadeView(true, true, false); + mStackScroller.updateEmptyShadeView(true, true); verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text); } @@ -338,7 +340,7 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { mStackScroller.setEmptyShadeView(mEmptyShadeView); when(mEmptyShadeView.willBeGone()).thenReturn(true); - mStackScroller.updateEmptyShadeView(true, false, false); + mStackScroller.updateEmptyShadeView(true, false); verify(mEmptyShadeView).setText(R.string.empty_shade_text); } @@ -347,10 +349,10 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { public void updateEmptyView_noNotificationsToDndSuppressing() { mStackScroller.setEmptyShadeView(mEmptyShadeView); when(mEmptyShadeView.willBeGone()).thenReturn(true); - mStackScroller.updateEmptyShadeView(true, false, false); + mStackScroller.updateEmptyShadeView(true, false); verify(mEmptyShadeView).setText(R.string.empty_shade_text); - mStackScroller.updateEmptyShadeView(true, true, false); + mStackScroller.updateEmptyShadeView(true, true); verify(mEmptyShadeView).setText(R.string.dnd_suppressing_shade_text); } @@ -818,6 +820,29 @@ public class NotificationStackScrollLayoutTest extends SysuiTestCase { assertEquals(0f, mAmbientState.getStackY()); } + @Test + public void hasFilteredOutSeenNotifs_updateFooter() { + mStackScroller.setCurrentUserSetup(true); + + // add footer + mStackScroller.inflateFooterView(); + TextView footerLabel = + mStackScroller.mFooterView.requireViewById(R.id.unlock_prompt_footer); + + mStackScroller.setHasFilteredOutSeenNotifications(true); + mStackScroller.updateFooter(); + + assertThat(footerLabel.getVisibility()).isEqualTo(View.VISIBLE); + } + + @Test + public void hasFilteredOutSeenNotifs_updateEmptyShadeView() { + mStackScroller.setHasFilteredOutSeenNotifications(true); + mStackScroller.updateEmptyShadeView(true, false); + + verify(mEmptyShadeView).setFooterText(not(0)); + } + private void setBarStateForTest(int state) { // Can't inject this through the listener or we end up on the actual implementation // rather than the mock because the spy just coppied the anonymous inner /shruggie.