summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ned Burns <pixel@google.com> 2019-02-11 20:42:58 -0500
committer Ned Burns <pixel@google.com> 2019-02-12 15:16:21 -0500
commita13b6f18b0104fabb313d45d8546b598e7057279 (patch)
tree00741971319b63e462273b0399328f58ad3005c4
parentebfc162db31137ecbdf746aec389184b4975ce38 (diff)
Centralize reorder-on-priority-change logic
The visual stability manager has a special exception that allows notifs to be reordered if their priority changes. Previously, this was tracked by various members and method spread across a lot of classes: it was set in one place, read in another, and cleared out in a third. This CL attemps to centralize this logic as much as possible to be just contained in the VisualStabilityManager. Test: atest, manual Change-Id: I19e047711ef1f8bcb083bdd62f45f2fe68109cc4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryListener.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java27
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java10
6 files changed, 23 insertions, 39 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryListener.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryListener.java
index 839b06cec496..1ed671fdb6fb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryListener.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryListener.java
@@ -47,7 +47,11 @@ public interface NotificationEntryListener {
}
/**
- * Called when a notification is updated, before any filtering of notifications have occurred.
+ * Called when a notification is about to be updated. Notification- and ranking-derived fields
+ * on the entry have already been updated but the following have not yet occurred:
+ * (a) View binding (i.e. the associated view has not yet been updated / inflation has not yet
+ * been kicked off.
+ * (b) Notification filtering
*/
default void onPreEntryUpdated(NotificationEntry entry) {
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
index 81d0e25782db..f24ce6a91011 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryManager.java
@@ -230,7 +230,6 @@ public class NotificationEntryManager implements
}
}
}
- entry.setLowPriorityStateUpdated(false);
}
@Override
@@ -384,13 +383,12 @@ public class NotificationEntryManager implements
mNotificationData.update(entry, ranking, notification);
- getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification),
- mNotificationData.get(entry.key) != null);
-
for (NotificationEntryListener listener : mNotificationEntryListeners) {
listener.onPreEntryUpdated(entry);
}
+ getRowBinder().inflateViews(entry, () -> performRemoveNotification(notification),
+ mNotificationData.get(entry.key) != null);
updateNotifications();
if (DEBUG) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java
index 0b8596f9cba7..80a719796eed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationRowBinder.java
@@ -226,10 +226,7 @@ public class NotificationRowBinder {
StatusBarNotification sbn,
ExpandableNotificationRow row,
boolean isUpdate) {
- boolean isLowPriority = entry.ambient;
- boolean wasLowPriority = row.isLowPriority();
- row.setIsLowPriority(isLowPriority);
- row.setLowPriorityStateUpdated(isUpdate && (wasLowPriority != isLowPriority));
+ row.setIsLowPriority(entry.ambient);
// bind the click event to the content area
checkNotNull(mNotificationClicker).register(row, sbn);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
index c886685424f7..396a3a7834fb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/VisualStabilityManager.java
@@ -45,7 +45,7 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
private boolean mReorderingAllowed;
private VisibilityLocationProvider mVisibilityLocationProvider;
private ArraySet<View> mAllowedReorderViews = new ArraySet<>();
- private ArraySet<View> mLowPriorityReorderingViews = new ArraySet<>();
+ private ArraySet<NotificationEntry> mLowPriorityReorderingViews = new ArraySet<>();
private ArraySet<View> mAddedChildren = new ArraySet<>();
private boolean mPulsing;
@@ -53,14 +53,21 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
public VisualStabilityManager(NotificationEntryManager notificationEntryManager) {
notificationEntryManager.addNotificationEntryListener(new NotificationEntryListener() {
@Override
- public void onEntryReinflated(NotificationEntry entry) {
- if (entry.hasLowPriorityStateUpdated()) {
- onLowPriorityUpdated(entry);
- if (mPresenter != null) {
- mPresenter.updateNotificationViews();
- }
+ public void onPreEntryUpdated(NotificationEntry entry) {
+ final boolean mAmbientStateHasChanged =
+ entry.ambient != entry.getRow().isLowPriority();
+ if (mAmbientStateHasChanged) {
+ mLowPriorityReorderingViews.add(entry);
}
}
+
+ @Override
+ public void onPostEntryUpdated(NotificationEntry entry) {
+ // This line is technically not required as we'll get called as the hierarchy
+ // manager will call onReorderingFinished() immediately before this.
+ // TODO: Find a way to make this relationship more explicit
+ mLowPriorityReorderingViews.remove(entry);
+ }
});
}
@@ -142,7 +149,7 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
if (mAddedChildren.contains(row)) {
return true;
}
- if (mLowPriorityReorderingViews.contains(row)) {
+ if (mLowPriorityReorderingViews.contains(row.getEntry())) {
return true;
}
if (mAllowedReorderViews.contains(row)
@@ -172,10 +179,6 @@ public class VisualStabilityManager implements OnHeadsUpChangedListener {
}
}
- private void onLowPriorityUpdated(NotificationEntry entry) {
- mLowPriorityReorderingViews.add(entry.getRow());
- }
-
/**
* Notify the visual stability manager that a new view was added and should be allowed to
* reorder next time.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
index f74de5beb585..f6d4ce22e905 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotificationEntry.java
@@ -622,10 +622,6 @@ public final class NotificationEntry {
return null;
}
- public boolean hasLowPriorityStateUpdated() {
- return row != null && row.hasLowPriorityStateUpdated();
- }
-
public void removeRow() {
if (row != null) row.setRemoved();
}
@@ -650,10 +646,6 @@ public final class NotificationEntry {
return parent == null;
}
- public void setLowPriorityStateUpdated(boolean updated) {
- if (row != null) row.setLowPriorityStateUpdated(updated);
- }
-
/**
* @return Can the underlying notification be cleared? This can be different from whether the
* notification can be dismissed in case notifications are sensitive on the lockscreen.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
index b8e33a8e0d2d..1bf288597abe 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ExpandableNotificationRow.java
@@ -133,7 +133,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
private LayoutListener mLayoutListener;
- private boolean mLowPriorityStateUpdated;
private final NotificationInflater mNotificationInflater;
private int mIconTransformContentShift;
private int mIconTransformContentShiftNoIcon;
@@ -1577,15 +1576,6 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
}
-
- public void setLowPriorityStateUpdated(boolean lowPriorityStateUpdated) {
- mLowPriorityStateUpdated = lowPriorityStateUpdated;
- }
-
- public boolean hasLowPriorityStateUpdated() {
- return mLowPriorityStateUpdated;
- }
-
public boolean isLowPriority() {
return mIsLowPriority;
}