Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f6f56b2 authored by Mady Mellor's avatar Mady Mellor Committed by Android (Google) Code Review
Browse files

Merge "Update group suppression for bubbles" into qt-r1-bubbles-dev

parents 952fa0d0 740d85de
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -261,6 +261,23 @@ public class BubbleController implements ConfigurationController.ConfigurationLi
        mNotificationEntryManager.addNotificationEntryListener(mEntryListener);
        mNotificationEntryManager.setNotificationRemoveInterceptor(mRemoveInterceptor);
        mNotificationGroupManager = groupManager;
        mNotificationGroupManager.addOnGroupChangeListener(
                new NotificationGroupManager.OnGroupChangeListener() {
                    @Override
                    public void onGroupSuppressionChanged(
                            NotificationGroupManager.NotificationGroup group,
                            boolean suppressed) {
                        // More notifications could be added causing summary to no longer
                        // be suppressed -- in this case need to remove the key.
                        final String groupKey = group.summary != null
                                ? group.summary.notification.getGroupKey()
                                : null;
                        if (!suppressed && groupKey != null
                                && mBubbleData.isSummarySuppressed(groupKey)) {
                            mBubbleData.removeSuppressedSummary(groupKey);
                        }
                    }
                });

        mStatusBarWindowController = statusBarWindowController;
        mStatusBarStateListener = new StatusBarStateListener();
@@ -746,6 +763,10 @@ public class BubbleController implements ConfigurationController.ConfigurationLi

            if (update.selectionChanged) {
                mStackView.setSelectedBubble(update.selectedBubble);
                if (update.selectedBubble != null) {
                    mNotificationGroupManager.updateSuppression(
                            update.selectedBubble.getEntry());
                }
            }

            // Expanding? Apply this last.
+34 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.util.ArraySet;
import android.util.Log;

import com.android.systemui.Dependency;
import com.android.systemui.bubbles.BubbleController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.statusbar.StatusBarState;
@@ -53,12 +54,20 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State
    private HashMap<String, StatusBarNotification> mIsolatedEntries = new HashMap<>();
    private HeadsUpManager mHeadsUpManager;
    private boolean mIsUpdatingUnchangedGroup;
    @Nullable private BubbleController mBubbleController = null;

    @Inject
    public NotificationGroupManager(StatusBarStateController statusBarStateController) {
        statusBarStateController.addCallback(this);
    }

    private BubbleController getBubbleController() {
        if (mBubbleController == null) {
            mBubbleController = Dependency.get(BubbleController.class);
        }
        return mBubbleController;
    }

    /**
     * Add a listener for changes to groups.
     *
@@ -187,12 +196,22 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State
        if (group == null) {
            return;
        }
        int childCount = 0;
        boolean hasBubbles = false;
        for (String key : group.children.keySet()) {
            if (!getBubbleController().isBubbleNotificationSuppressedFromShade(key)) {
                childCount++;
            } else {
                hasBubbles = true;
            }
        }

        boolean prevSuppressed = group.suppressed;
        group.suppressed = group.summary != null && !group.expanded
                && (group.children.size() == 1
                || (group.children.size() == 0
                && (childCount == 1
                || (childCount == 0
                        && group.summary.notification.getNotification().isGroupSummary()
                        && hasIsolatedChildren(group)));
                        && (hasIsolatedChildren(group) || hasBubbles)));
        if (prevSuppressed != group.suppressed) {
            for (OnGroupChangeListener listener : mListeners) {
                if (!mIsUpdatingUnchangedGroup) {
@@ -380,6 +399,17 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State
        return children;
    }

    /**
     * If there is a {@link NotificationGroup} associated with the provided entry, this method
     * will update the suppression of that group.
     */
    public void updateSuppression(NotificationEntry entry) {
        NotificationGroup group = mGroupMap.get(getGroupKey(entry.notification));
        if (group != null) {
            updateSuppression(group);
        }
    }

    /**
     * Get the group key. May differ from the one in the notification due to the notification
     * being temporarily isolated.
@@ -565,6 +595,7 @@ public class NotificationGroupManager implements OnHeadsUpChangedListener, State
                        ? Log.getStackTraceString(child.getDebugThrowable())
                        : "");
            }
            result += "\n    summary suppressed: " + suppressed;
            return result;
        }
    }