Merge "Keep the shade footer visible during clear-all, if there is a button to display" into udc-qpr-dev
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
index b2d26d9..90e10a7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java
@@ -497,14 +497,14 @@
return stackHeight / stackEndHeight;
}
- private boolean hasNonDismissableNotifs(StackScrollAlgorithmState algorithmState) {
+ private boolean hasNonClearableNotifs(StackScrollAlgorithmState algorithmState) {
for (int i = 0; i < algorithmState.visibleChildren.size(); i++) {
View child = algorithmState.visibleChildren.get(i);
if (!(child instanceof ExpandableNotificationRow)) {
continue;
}
final ExpandableNotificationRow row = (ExpandableNotificationRow) child;
- if (!row.canViewBeDismissed()) {
+ if (!row.canViewBeCleared()) {
return true;
}
}
@@ -579,7 +579,7 @@
((FooterView.FooterViewState) viewState).hideContent =
isShelfShowing || noSpaceForFooter
|| (ambientState.isClearAllInProgress()
- && !hasNonDismissableNotifs(algorithmState));
+ && !hasNonClearableNotifs(algorithmState));
}
} else {
if (view instanceof EmptyShadeView) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
index 987861d..42f7b52 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithmTest.kt
@@ -14,6 +14,8 @@
import com.android.systemui.statusbar.StatusBarState
import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow
import com.android.systemui.statusbar.notification.row.ExpandableView
+import com.android.systemui.statusbar.notification.row.FooterView
+import com.android.systemui.statusbar.notification.row.FooterView.FooterViewState
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.util.mockito.mock
import com.google.common.truth.Expect
@@ -47,6 +49,7 @@
private val emptyShadeView = EmptyShadeView(context, /* attrs= */ null).apply {
layout(/* l= */ 0, /* t= */ 0, /* r= */ 100, /* b= */ 100)
}
+ private val footerView = FooterView(context, /*attrs=*/null)
private val ambientState = AmbientState(
context,
dumpManager,
@@ -325,6 +328,57 @@
}
@Test
+ fun resetViewStates_noSpaceForFooter_footerHidden() {
+ ambientState.isShadeExpanded = true
+ ambientState.stackEndHeight = 0f // no space for the footer in the stack
+ hostView.addView(footerView)
+
+ stackScrollAlgorithm.resetViewStates(ambientState, 0)
+
+ assertThat((footerView.viewState as FooterViewState).hideContent).isTrue()
+ }
+
+ @Test
+ fun resetViewStates_clearAllInProgress_hasNonClearableRow_footerVisible() {
+ whenever(notificationRow.canViewBeCleared()).thenReturn(false)
+ ambientState.isClearAllInProgress = true
+ ambientState.isShadeExpanded = true
+ ambientState.stackEndHeight = 1000f // plenty space for the footer in the stack
+ hostView.addView(footerView)
+
+ stackScrollAlgorithm.resetViewStates(ambientState, 0)
+
+ assertThat(footerView.viewState.hidden).isFalse()
+ assertThat((footerView.viewState as FooterViewState).hideContent).isFalse()
+ }
+
+ @Test
+ fun resetViewStates_clearAllInProgress_allRowsClearable_footerHidden() {
+ whenever(notificationRow.canViewBeCleared()).thenReturn(true)
+ ambientState.isClearAllInProgress = true
+ ambientState.isShadeExpanded = true
+ ambientState.stackEndHeight = 1000f // plenty space for the footer in the stack
+ hostView.addView(footerView)
+
+ stackScrollAlgorithm.resetViewStates(ambientState, 0)
+
+ assertThat((footerView.viewState as FooterViewState).hideContent).isTrue()
+ }
+
+ @Test
+ fun resetViewStates_clearAllInProgress_allRowsRemoved_emptyShade_footerHidden() {
+ ambientState.isClearAllInProgress = true
+ ambientState.isShadeExpanded = true
+ ambientState.stackEndHeight = 1000f // plenty space for the footer in the stack
+ hostView.removeAllViews() // remove all rows
+ hostView.addView(footerView)
+
+ stackScrollAlgorithm.resetViewStates(ambientState, 0)
+
+ assertThat((footerView.viewState as FooterViewState).hideContent).isTrue()
+ }
+
+ @Test
fun getGapForLocation_onLockscreen_returnsSmallGap() {
val gap = stackScrollAlgorithm.getGapForLocation(
/* fractionToShade= */ 0f, /* onKeyguard= */ true)