Merge "Hiding the summary of notification groups with a single child now" into nyc-dev
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index bb4a771..7119559c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -2056,24 +2056,24 @@
}
for (int i = 0; i < N; i++) {
NotificationData.Entry entry = activeNotifications.get(i);
+ boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification);
if (onKeyguard) {
entry.row.setOnKeyguard(true);
} else {
entry.row.setOnKeyguard(false);
- boolean top = (i == 0);
- entry.row.setSystemExpanded(top);
+ entry.row.setSystemExpanded(visibleNotifications == 0 && !childNotification);
}
- boolean childNotification = mGroupManager.isChildInGroupWithSummary(entry.notification);
+ boolean suppressedSummary = mGroupManager.isSummaryOfSuppressedGroup(entry.notification);
boolean childWithVisibleSummary = childNotification
&& mGroupManager.getGroupSummary(entry.notification).getVisibility()
== View.VISIBLE;
boolean showOnKeyguard = shouldShowOnKeyguard(entry.notification);
- if ((isLockscreenPublicMode() && !mShowLockscreenNotifications) ||
+ if (suppressedSummary || (isLockscreenPublicMode() && !mShowLockscreenNotifications) ||
(onKeyguard && (visibleNotifications >= maxNotifications
&& !childWithVisibleSummary
|| !showOnKeyguard))) {
entry.row.setVisibility(View.GONE);
- if (onKeyguard && showOnKeyguard && !childNotification) {
+ if (onKeyguard && showOnKeyguard && !childNotification && !suppressedSummary) {
mKeyguardIconOverflowContainer.getIconsView().addNotification(entry);
}
} else {
@@ -2082,7 +2082,8 @@
if (!childNotification) {
if (wasGone) {
// notify the scroller of a child addition
- mStackScroller.generateAddAnimation(entry.row, true /* fromMoreCard */);
+ mStackScroller.generateAddAnimation(entry.row,
+ !showOnKeyguard /* fromMoreCard */);
}
visibleNotifications++;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 22bb8eb..3b0cd2e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -1026,11 +1026,8 @@
private void onChildrenCountChanged() {
mIsSummaryWithChildren = BaseStatusBar.ENABLE_CHILD_NOTIFICATIONS
- && mGroupManager.hasGroupChildren(mStatusBarNotification);
+ && mChildrenContainer != null && mChildrenContainer.getChildCount() > 0;
if (mIsSummaryWithChildren) {
- if (mChildrenContainer == null) {
- mChildrenContainerStub.inflate();
- }
if (mNotificationHeader == null) {
recreateNotificationHeader();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
index d3681b7..bf7e8ed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationGroupManager.java
@@ -91,6 +91,7 @@
} else {
group.summary = null;
}
+ updateSuppression(group);
if (group.children.isEmpty()) {
if (group.summary == null) {
mGroupMap.remove(groupKey);
@@ -109,15 +110,25 @@
}
if (isGroupChild) {
group.children.add(added);
+ updateSuppression(group);
} else {
group.summary = added;
group.expanded = added.row.areChildrenExpanded();
+ updateSuppression(group);
if (!group.children.isEmpty()) {
mListener.onGroupCreatedFromChildren(group);
}
}
}
+ private void updateSuppression(NotificationGroup group) {
+ boolean prevSuppressed = group.suppressed;
+ group.suppressed = group.summary != null && group.children.size() == 1 && !group.expanded;
+ if (prevSuppressed != group.suppressed) {
+ mListener.onGroupsChanged();
+ }
+ }
+
public void onEntryUpdated(NotificationData.Entry entry,
StatusBarNotification oldNotification) {
if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
@@ -126,26 +137,17 @@
onEntryAdded(entry);
}
- public boolean isVisible(StatusBarNotification sbn) {
- if (!isGroupChild(sbn)) {
- return true;
- }
- NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
- if (group != null && (group.expanded || group.summary == null)) {
- return true;
- }
- return false;
+ public boolean isSummaryOfSuppressedGroup(StatusBarNotification sbn) {
+ return isGroupSuppressed(sbn) && sbn.getNotification().isGroupSummary();
}
- public boolean hasGroupChildren(StatusBarNotification sbn) {
- if (!isGroupSummary(sbn)) {
- return false;
- }
+ public boolean isChildInSuppressedGroup(StatusBarNotification sbn) {
+ return isGroupSuppressed(sbn) && sbn.getNotification().isGroupChild();
+ }
+
+ private boolean isGroupSuppressed(StatusBarNotification sbn) {
NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
- if (group == null) {
- return false;
- }
- return !group.children.isEmpty();
+ return group != null && group.suppressed;
}
public void setStatusBarState(int newState) {
@@ -163,6 +165,7 @@
if (group.expanded) {
setGroupExpanded(group, false);
}
+ updateSuppression(group);
}
}
@@ -174,7 +177,7 @@
return false;
}
NotificationGroup group = mGroupMap.get(getGroupKey(sbn));
- if (group == null || group.summary == null) {
+ if (group == null || group.summary == null || group.suppressed) {
return false;
}
return true;
@@ -258,7 +261,7 @@
mHeadsUpedEntries.add(sbn.getKey());
if (groupChild) {
onEntryAdded(entry);
- mListener.onChildIsolationChanged();
+ mListener.onGroupsChanged();
}
}
} else {
@@ -271,7 +274,7 @@
mHeadsUpedEntries.remove(sbn.getKey());
if (isolatedBefore) {
onEntryAdded(entry);
- mListener.onChildIsolationChanged();
+ mListener.onGroupsChanged();
}
}
}
@@ -281,6 +284,10 @@
public final HashSet<NotificationData.Entry> children = new HashSet<>();
public NotificationData.Entry summary;
public boolean expanded;
+ /**
+ * Is this notification group suppressed, i.e its summary is hidden
+ */
+ public boolean suppressed;
}
public interface OnGroupChangeListener {
@@ -301,8 +308,9 @@
void onGroupCreatedFromChildren(NotificationGroup group);
/**
- * The isolation of a child has changed i.e it's group changes.
+ * The groups have changed. This can happen if the isolation of a child has changes or if a
+ * group became suppressed / unsuppressed
*/
- void onChildIsolationChanged();
+ void onGroupsChanged();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index 6e345f0..a605a81 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -114,6 +114,9 @@
if (!PhoneStatusBar.isTopLevelChild(ent)) {
continue;
}
+ if (ent.row.getVisibility() == View.GONE) {
+ continue;
+ }
toShow.add(ent.icon);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index bf58611..e84d8fc 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -132,6 +132,7 @@
import com.android.systemui.statusbar.DragDownHelper;
import com.android.systemui.statusbar.EmptyShadeView;
import com.android.systemui.statusbar.ExpandableNotificationRow;
+import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyguardIndicationController;
import com.android.systemui.statusbar.NotificationData;
@@ -1632,16 +1633,14 @@
private void updateSpeedbump() {
int speedbumpIndex = -1;
int currentIndex = 0;
- ArrayList<Entry> activeNotifications = mNotificationData.getActiveNotifications();
- final int N = activeNotifications.size();
+ final int N = mStackScroller.getChildCount();
for (int i = 0; i < N; i++) {
- Entry entry = activeNotifications.get(i);
- boolean isChild = !isTopLevelChild(entry);
- if (isChild) {
+ View view = mStackScroller.getChildAt(i);
+ if (view.getVisibility() == View.GONE || !(view instanceof ExpandableNotificationRow)) {
continue;
}
- if (entry.row.getVisibility() != View.GONE &&
- mNotificationData.isAmbient(entry.key)) {
+ ExpandableNotificationRow row = (ExpandableNotificationRow) view;
+ if (mNotificationData.isAmbient(row.getStatusBarNotification().getKey())) {
speedbumpIndex = currentIndex;
break;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 686a712..e77b4d4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -694,11 +694,7 @@
mHeadsUpManager.addSwipedOutNotification(row.getStatusBarNotification().getKey());
}
}
- final View veto = v.findViewById(R.id.veto);
- if (veto != null && veto.getVisibility() != View.GONE) {
- veto.performClick();
- }
- if (DEBUG) Log.v(TAG, "onChildDismissed: " + v);
+ performDismiss(v);
mFalsingManager.onNotificationDismissed();
if (mFalsingManager.shouldEnforceBouncer()) {
@@ -707,6 +703,24 @@
}
}
+ private void performDismiss(View v) {
+ if (v instanceof ExpandableNotificationRow) {
+ ExpandableNotificationRow row = (ExpandableNotificationRow) v;
+ if (mGroupManager.isChildInSuppressedGroup(row.getStatusBarNotification())) {
+ ExpandableNotificationRow groupSummary =
+ mGroupManager.getGroupSummary(row.getStatusBarNotification());
+ if (groupSummary.isClearable()) {
+ performDismiss(groupSummary);
+ }
+ }
+ }
+ final View veto = v.findViewById(R.id.veto);
+ if (veto != null && veto.getVisibility() != View.GONE) {
+ veto.performClick();
+ }
+ if (DEBUG) Log.v(TAG, "onChildDismissed: " + v);
+ }
+
@Override
public void onChildSnappedBack(View animView, float targetLeft) {
mAmbientState.onDragFinished(animView);
@@ -3265,7 +3279,7 @@
}
@Override
- public void onChildIsolationChanged() {
+ public void onGroupsChanged() {
mPhoneStatusBar.requestNotificationUpdate();
}