Merge "Fixed a bug where the wrong group was HUNd" into nyc-dev

This commit is contained in:
Selim Cinek
2016-04-11 04:30:37 +00:00
committed by Android (Google) Code Review
3 changed files with 53 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import com.android.systemui.statusbar.policy.HeadsUpManager;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Objects;
/**
@@ -37,6 +38,7 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
private OnGroupChangeListener mListener;
private int mBarState = -1;
private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
private HeadsUpManager mHeadsUpManager;
public void setOnGroupChangeListener(OnGroupChangeListener listener) {
mListener = listener;
@@ -142,6 +144,9 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
&& group.summary.notification.getNotification().isGroupSummary()
&& hasIsolatedChildren(group)));
if (prevSuppressed != group.suppressed) {
if (group.suppressed) {
handleSuppressedSummaryHeadsUpped(group.summary);
}
mListener.onGroupsChanged();
}
}
@@ -160,6 +165,15 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
return count;
}
private NotificationData.Entry getIsolatedChild(String groupKey) {
for (StatusBarNotification sbn : mIsolatedEntries.values()) {
if (sbn.getGroupKey().equals(groupKey) && isIsolated(sbn)) {
return mGroupMap.get(sbn.getKey()).summary;
}
}
return null;
}
public void onEntryUpdated(NotificationData.Entry entry,
StatusBarNotification oldNotification) {
if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
@@ -332,6 +346,9 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
// it doesn't lead to an update.
updateSuppression(mGroupMap.get(entry.notification.getGroupKey()));
mListener.onGroupsChanged();
} else {
handleSuppressedSummaryHeadsUpped(entry);
}
} else {
if (mIsolatedEntries.containsKey(sbn.getKey())) {
@@ -344,6 +361,32 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
}
}
private void handleSuppressedSummaryHeadsUpped(NotificationData.Entry entry) {
StatusBarNotification sbn = entry.notification;
if (!isGroupSuppressed(sbn.getGroupKey())
|| !sbn.getNotification().isGroupSummary()
|| !entry.row.isHeadsUp()) {
return;
}
// The parent of a suppressed group got huned, lets hun the child!
NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
if (notificationGroup != null) {
Iterator<NotificationData.Entry> iterator = notificationGroup.children.iterator();
NotificationData.Entry child = iterator.hasNext() ? iterator.next() : null;
if (child == null) {
child = getIsolatedChild(sbn.getGroupKey());
}
if (child != null) {
if (mHeadsUpManager.isHeadsUp(child.key)) {
mHeadsUpManager.updateNotification(child, true);
} else {
mHeadsUpManager.showNotification(child);
}
}
}
mHeadsUpManager.releaseImmediately(entry.key);
}
private boolean shouldIsolate(StatusBarNotification sbn) {
NotificationGroup notificationGroup = mGroupMap.get(sbn.getGroupKey());
return (sbn.isGroup() && !sbn.getNotification().isGroupSummary())
@@ -360,6 +403,10 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
|| notificationGroup.summary.row.getTranslationY() < 0;
}
public void setHeadsUpManager(HeadsUpManager headsUpManager) {
mHeadsUpManager = headsUpManager;
}
public static class NotificationGroup {
public final HashSet<NotificationData.Entry> children = new HashSet<>();
public NotificationData.Entry summary;

View File

@@ -729,6 +729,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
mHeadsUpManager.addListener(mGroupManager);
mNotificationPanel.setHeadsUpManager(mHeadsUpManager);
mNotificationData.setHeadsUpManager(mHeadsUpManager);
mGroupManager.setHeadsUpManager(mHeadsUpManager);
if (MULTIUSER_DEBUG) {
mNotificationPanelDebugText = (TextView) mNotificationPanel.findViewById(

View File

@@ -185,6 +185,11 @@ public class HeadsUpManager implements ViewTreeObserver.OnComputeInternalInsetsL
if (alert) {
HeadsUpEntry headsUpEntry = mHeadsUpEntries.get(headsUp.key);
if (headsUpEntry == null) {
// the entry was released before this update (i.e by a listener) This can happen
// with the groupmanager
return;
}
headsUpEntry.updateEntry();
setEntryPinned(headsUpEntry, shouldHeadsUpBecomePinned(headsUp));
}