Merge "Hiding the summary of notification groups with a single child now" into nyc-dev

This commit is contained in:
Selim Cinek
2016-03-22 17:53:40 +00:00
committed by Android (Google) Code Review
6 changed files with 67 additions and 45 deletions

View File

@@ -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++;
}

View File

@@ -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();
}

View File

@@ -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();
}
}

View File

@@ -114,6 +114,9 @@ public class NotificationIconAreaController {
if (!PhoneStatusBar.isTopLevelChild(ent)) {
continue;
}
if (ent.row.getVisibility() == View.GONE) {
continue;
}
toShow.add(ent.icon);
}

View File

@@ -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;
}

View File

@@ -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();
}