diff options
6 files changed, 67 insertions, 45 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index bb4a771ec3d6..7119559c19ae 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 @@ public abstract class BaseStatusBar extends SystemUI implements } 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 @@ public abstract class BaseStatusBar extends SystemUI implements 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 22bb8ebb2dc4..3b0cd2e25c78 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 @@ public class ExpandableNotificationRow extends ActivatableNotificationView { 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 d3681b72372b..bf7e8ed59e8f 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 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged } else { group.summary = null; } + updateSuppression(group); if (group.children.isEmpty()) { if (group.summary == null) { mGroupMap.remove(groupKey); @@ -109,15 +110,25 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged } 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 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged 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 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged if (group.expanded) { setGroupExpanded(group, false); } + updateSuppression(group); } } @@ -174,7 +177,7 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged 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 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged mHeadsUpedEntries.add(sbn.getKey()); if (groupChild) { onEntryAdded(entry); - mListener.onChildIsolationChanged(); + mListener.onGroupsChanged(); } } } else { @@ -271,7 +274,7 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged mHeadsUpedEntries.remove(sbn.getKey()); if (isolatedBefore) { onEntryAdded(entry); - mListener.onChildIsolationChanged(); + mListener.onGroupsChanged(); } } } @@ -281,6 +284,10 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged 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 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged 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 6e345f088b5d..a605a81bb504 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 @@ public class NotificationIconAreaController { 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 bf5861107b09..e84d8fc81903 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.DismissView; 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 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, 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 686a71211dc9..e77b4d4b7c1f 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 @@ public class NotificationStackScrollLayout extends ViewGroup 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 @@ public class NotificationStackScrollLayout extends ViewGroup } } + 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 @@ public class NotificationStackScrollLayout extends ViewGroup } @Override - public void onChildIsolationChanged() { + public void onGroupsChanged() { mPhoneStatusBar.requestNotificationUpdate(); } |