summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt45
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java10
2 files changed, 36 insertions, 19 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt
index ba7675f27cf4..0bdac39f35e9 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManager.kt
@@ -287,21 +287,17 @@ class NotificationSectionsManager @Inject internal constructor(
// Is there a section discontinuity? This usually occurs due to HUNs
if (prev?.entry?.bucket?.let { it > child.entry.bucket } == true) {
// Remove existing headers, and move the Incoming header if necessary
- if (alertingHeaderTarget != -1) {
- if (showHeaders && incomingHeaderTarget != -1) {
- incomingHeaderTarget = alertingHeaderTarget
- }
- alertingHeaderTarget = -1
- }
- if (peopleHeaderTarget != -1) {
- if (showHeaders && incomingHeaderTarget != -1) {
- incomingHeaderTarget = peopleHeaderTarget
- }
- peopleHeaderTarget = -1
- }
- if (showHeaders && incomingHeaderTarget == -1) {
- incomingHeaderTarget = 0
+ incomingHeaderTarget = when {
+ !showHeaders -> -1
+ incomingHeaderTarget != -1 -> incomingHeaderTarget
+ peopleHeaderTarget != -1 -> peopleHeaderTarget
+ alertingHeaderTarget != -1 -> alertingHeaderTarget
+ gentleHeaderTarget != -1 -> gentleHeaderTarget
+ else -> 0
}
+ peopleHeaderTarget = -1
+ alertingHeaderTarget = -1
+ gentleHeaderTarget = -1
// Walk backwards changing all previous notifications to the Incoming
// section
for (j in i - 1 downTo lastIncomingIndex + 1) {
@@ -323,6 +319,9 @@ class NotificationSectionsManager @Inject internal constructor(
peopleHeaderTarget = i
// Offset the target if there are other headers before this that
// will be moved.
+ if (currentIncomingHeaderIdx != -1 && incomingHeaderTarget == -1) {
+ peopleHeaderTarget--
+ }
if (currentPeopleHeaderIdx != -1) {
peopleHeaderTarget--
}
@@ -340,6 +339,13 @@ class NotificationSectionsManager @Inject internal constructor(
alertingHeaderTarget = i
// Offset the target if there are other headers before this that
// will be moved.
+ if (currentIncomingHeaderIdx != -1 && incomingHeaderTarget == -1) {
+ alertingHeaderTarget--
+ }
+ if (currentPeopleHeaderIdx != -1 && peopleHeaderTarget == -1) {
+ // People header will be removed
+ alertingHeaderTarget--
+ }
if (currentAlertingHeaderIdx != -1) {
alertingHeaderTarget--
}
@@ -354,6 +360,17 @@ class NotificationSectionsManager @Inject internal constructor(
gentleHeaderTarget = i
// Offset the target if there are other headers before this that
// will be moved.
+ if (currentIncomingHeaderIdx != -1 && incomingHeaderTarget == -1) {
+ gentleHeaderTarget--
+ }
+ if (currentPeopleHeaderIdx != -1 && peopleHeaderTarget == -1) {
+ // People header will be removed
+ gentleHeaderTarget--
+ }
+ if (currentAlertingHeaderIdx != -1 && alertingHeaderTarget == -1) {
+ // Alerting header will be removed
+ gentleHeaderTarget--
+ }
if (currentGentleHeaderIdx != -1) {
gentleHeaderTarget--
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java
index 3dc941a0bd20..c55391a387d8 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/stack/NotificationSectionsManagerTest.java
@@ -403,11 +403,11 @@ public class NotificationSectionsManagerTest extends SysuiTestCase {
enablePeopleFiltering();
setupMockStack(
- PERSON.headsUp(),
- INCOMING_HEADER,
- ALERTING.headsUp(),
- PEOPLE_HEADER,
- PERSON
+ PERSON.headsUp(), // personHeaderTarget = 0
+ INCOMING_HEADER, // currentIncomingHeaderIdx = 1
+ ALERTING.headsUp(), // alertingHeaderTarget = 1
+ PEOPLE_HEADER, // currentPeopleHeaderIdx = 3
+ PERSON //
);
mSectionsManager.updateSectionBoundaries();