Fixed a bug where groups would animate the wrong way

When updating a child of a group, the group would always
animate, because of the suppression logic. This doesn't
happen anymore.

Change-Id: Ie2b09c1e03f37a12ba8f995e5b7d0e3721e3651a
Fixes: 30608517
This commit is contained in:
Selim Cinek
2016-08-03 13:38:56 -07:00
parent 5f1450229b
commit 68bdff16a8
2 changed files with 11 additions and 17 deletions

View File

@@ -34,7 +34,6 @@ import java.io.PrintWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
@@ -343,7 +342,6 @@ public class NotificationData {
entry.notification.setOverrideGroupKey(overrideGroupKey); entry.notification.setOverrideGroupKey(overrideGroupKey);
mGroupManager.onEntryUpdated(entry, oldSbn); mGroupManager.onEntryUpdated(entry, oldSbn);
} }
//mGroupManager.onEntryBundlingUpdated(entry, getOverrideGroupKey(entry.key));
} }
} }
} }

View File

@@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Objects;
/** /**
* A class to handle notifications and their corresponding groups. * A class to handle notifications and their corresponding groups.
@@ -43,6 +42,7 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
private int mBarState = -1; private int mBarState = -1;
private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>(); private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
private HeadsUpManager mHeadsUpManager; private HeadsUpManager mHeadsUpManager;
private boolean mUpdatingSuppressionBlocked;
public void setOnGroupChangeListener(OnGroupChangeListener listener) { public void setOnGroupChangeListener(OnGroupChangeListener listener) {
mListener = listener; mListener = listener;
@@ -140,17 +140,8 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
} }
} }
public void onEntryBundlingUpdated(final NotificationData.Entry updated,
final String overrideGroupKey) {
final StatusBarNotification oldSbn = updated.notification.clone();
if (!Objects.equals(oldSbn.getOverrideGroupKey(), overrideGroupKey)) {
updated.notification.setOverrideGroupKey(overrideGroupKey);
onEntryUpdated(updated, oldSbn);
}
}
private void updateSuppression(NotificationGroup group) { private void updateSuppression(NotificationGroup group) {
if (group == null) { if (group == null || mUpdatingSuppressionBlocked) {
return; return;
} }
boolean prevSuppressed = group.suppressed; boolean prevSuppressed = group.suppressed;
@@ -192,19 +183,24 @@ public class NotificationGroupManager implements HeadsUpManager.OnHeadsUpChanged
public void onEntryUpdated(NotificationData.Entry entry, public void onEntryUpdated(NotificationData.Entry entry,
StatusBarNotification oldNotification) { StatusBarNotification oldNotification) {
String oldKey = oldNotification.getGroupKey();
String newKey = entry.notification.getGroupKey();
boolean groupKeysChanged = !oldKey.equals(newKey);
boolean wasGroupChild = isGroupChild(oldNotification);
boolean isGroupChild = isGroupChild(entry.notification);
mUpdatingSuppressionBlocked = !groupKeysChanged && wasGroupChild == isGroupChild;
if (mGroupMap.get(getGroupKey(oldNotification)) != null) { if (mGroupMap.get(getGroupKey(oldNotification)) != null) {
onEntryRemovedInternal(entry, oldNotification); onEntryRemovedInternal(entry, oldNotification);
} }
onEntryAdded(entry); onEntryAdded(entry);
mUpdatingSuppressionBlocked = false;
if (isIsolated(entry.notification)) { if (isIsolated(entry.notification)) {
mIsolatedEntries.put(entry.key, entry.notification); mIsolatedEntries.put(entry.key, entry.notification);
String oldKey = oldNotification.getGroupKey(); if (groupKeysChanged) {
String newKey = entry.notification.getGroupKey();
if (!oldKey.equals(newKey)) {
updateSuppression(mGroupMap.get(oldKey)); updateSuppression(mGroupMap.get(oldKey));
updateSuppression(mGroupMap.get(newKey)); updateSuppression(mGroupMap.get(newKey));
} }
} else if (!isGroupChild(oldNotification) && isGroupChild(entry.notification)) { } else if (!wasGroupChild && isGroupChild) {
onEntryBecomingChild(entry); onEntryBecomingChild(entry);
} }
} }