From 4d49d726186315f4121edc8a8673b0f89b6031ce Mon Sep 17 00:00:00 2001 From: Thales Lima Date: Tue, 1 Jun 2021 16:45:11 +0000 Subject: [PATCH] sysui: show empty view in split mode When showing the notification shade in split mode, the empty view was not showing. This should fix it. If it is in split mode, it doesn't matter if Quick Settings is expanded or not, it should always show the empty view (depending on the other requisites). Also changing the name of the test file and class so it is correctly indexable in IntelliJ. Bug: 188894961 Test: added test NotificationStackScrollLayoutControllerTest#testUpdateEmptyShadeView_splitShadeMode_alwaysShowEmptyView Change-Id: I0d1228bff778cd9699afeda1431b69f77e3d3028 --- .../stack/NotificationStackScrollLayout.java | 4 ++ ...tificationStackScrollLayoutController.java | 7 ++- ...ationStackScrollLayoutControllerTest.java} | 46 +++++++++++++++---- 3 files changed, 46 insertions(+), 11 deletions(-) rename packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/{NotificationStackScrollerControllerTest.java => NotificationStackScrollLayoutControllerTest.java} (91%) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java index 94edbd092a4d4..2b48e87681045 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java @@ -5232,6 +5232,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable mSwipeHelper.resetExposedMenuView(animate, force); } + boolean isUsingSplitNotificationShade() { + return mShouldUseSplitNotificationShade; + } + static boolean matchesSelection( ExpandableNotificationRow row, @SelectedRows int selection) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java index 4432f5463802e..5d87df8444923 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutController.java @@ -1103,11 +1103,16 @@ public class NotificationStackScrollLayoutController { /** * Update whether we should show the empty shade view (no notifications in the shade). * If so, send the update to our view. + * + * When in split mode, notifications are always visible regardless of the state of the + * QuickSettings panel. That being the case, empty view is always shown if the other conditions + * are true. */ public void updateShowEmptyShadeView() { mShowEmptyShadeView = mBarState != KEYGUARD - && !mView.isQsExpanded() + && (!mView.isQsExpanded() || mView.isUsingSplitNotificationShade()) && mView.getVisibleNotificationCount() == 0; + mView.updateEmptyShadeView( mShowEmptyShadeView, mZenModeController.areNotificationsHiddenInShade()); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java similarity index 91% rename from packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java rename to packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java index f376e88b2cb12..6ee2f2026deb1 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollerControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayoutControllerTest.java @@ -92,7 +92,7 @@ import org.mockito.MockitoAnnotations; */ @SmallTest @RunWith(AndroidTestingRunner.class) -public class NotificationStackScrollerControllerTest extends SysuiTestCase { +public class NotificationStackScrollLayoutControllerTest extends SysuiTestCase { @Mock private NotificationGutsManager mNotificationGutsManager; @Mock private HeadsUpManagerPhone mHeadsUpManager; @@ -232,16 +232,15 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( - true /* visible */, - - true /* notifVisibleInShade */); + /* visible= */ true, + /* notifVisibleInShade= */ true); setupShowEmptyShadeViewState(stateListener, false); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( - false /* visible */, - true /* notifVisibleInShade */); + /* visible= */ false, + /* notifVisibleInShade= */ true); } @Test @@ -257,15 +256,42 @@ public class NotificationStackScrollerControllerTest extends SysuiTestCase { reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( - true /* visible */, - false /* notifVisibleInShade */); + /* visible= */ true, + /* notifVisibleInShade= */ false); setupShowEmptyShadeViewState(stateListener, false); reset(mNotificationStackScrollLayout); mController.updateShowEmptyShadeView(); verify(mNotificationStackScrollLayout).updateEmptyShadeView( - false /* visible */, - false /* notifVisibleInShade */); + /* visible= */ false, + /* notifVisibleInShade= */ false); + } + + @Test + public void testUpdateEmptyShadeView_splitShadeMode_alwaysShowEmptyView() { + when(mZenModeController.areNotificationsHiddenInShade()).thenReturn(false); + mController.attach(mNotificationStackScrollLayout); + verify(mSysuiStatusBarStateController).addCallback( + mStateListenerArgumentCaptor.capture(), anyInt()); + StatusBarStateController.StateListener stateListener = + mStateListenerArgumentCaptor.getValue(); + when(mNotificationStackScrollLayout.isUsingSplitNotificationShade()).thenReturn(true); + stateListener.onStateChanged(SHADE); + mController.getView().removeAllViews(); + + mController.setQsExpanded(false); + reset(mNotificationStackScrollLayout); + mController.updateShowEmptyShadeView(); + verify(mNotificationStackScrollLayout).updateEmptyShadeView( + /* visible= */ true, + /* notifVisibleInShade= */ false); + + mController.setQsExpanded(true); + reset(mNotificationStackScrollLayout); + mController.updateShowEmptyShadeView(); + verify(mNotificationStackScrollLayout).updateEmptyShadeView( + /* visible= */ true, + /* notifVisibleInShade= */ false); } @Test