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

Commit 43077f97 authored by Kevin Han's avatar Kevin Han
Browse files

Bind children dynamically in new pipeline (2/2)

Support setting a logical child count on the notification group view.
Since we are filtering out the notifications and their views entirely in
the new pipeline, we can't just use the number of children views on the
notification group view to determine the "+X" value in the group view UX
for how many children are in the unexanded group. So instead we set this
value directly.

Bug: 145748993
Test: add notification group and see overflow values are accurate in
both old and new pipeline

Change-Id: I60bc58994a77bc3801f062dedc41faaee1d48494
parent acaa911e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -1110,7 +1110,7 @@ public class BubbleController implements ConfigurationController.ConfigurationLi


    private void handleSummaryDismissalInterception(NotificationEntry summary) {
    private void handleSummaryDismissalInterception(NotificationEntry summary) {
        // current children in the row:
        // current children in the row:
        final List<NotificationEntry> children = summary.getChildren();
        final List<NotificationEntry> children = summary.getAttachedNotifChildren();
        if (children != null) {
        if (children != null) {
            for (int i = 0; i < children.size(); i++) {
            for (int i = 0; i < children.size(); i++) {
                NotificationEntry child = children.get(i);
                NotificationEntry child = children.get(i);
+1 −1
Original line number Original line Diff line number Diff line
@@ -148,7 +148,7 @@ public class NotificationHeaderUtil {
    }
    }


    public void updateChildrenHeaderAppearance() {
    public void updateChildrenHeaderAppearance() {
        List<ExpandableNotificationRow> notificationChildren = mRow.getNotificationChildren();
        List<ExpandableNotificationRow> notificationChildren = mRow.getAttachedChildren();
        if (notificationChildren == null) {
        if (notificationChildren == null) {
            return;
            return;
        }
        }
+12 −9
Original line number Original line Diff line number Diff line
@@ -307,17 +307,20 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
            }
            }


            ExpandableNotificationRow parent = (ExpandableNotificationRow) view;
            ExpandableNotificationRow parent = (ExpandableNotificationRow) view;
            List<ExpandableNotificationRow> children = parent.getNotificationChildren();
            List<ExpandableNotificationRow> children = parent.getAttachedChildren();
            List<NotificationEntry> orderedChildren = mTmpChildOrderMap.get(parent.getEntry());
            List<NotificationEntry> orderedChildren = mTmpChildOrderMap.get(parent.getEntry());

            if (orderedChildren == null) {
            for (int childIndex = 0; orderedChildren != null && childIndex < orderedChildren.size();
                // Not a group
                    childIndex++) {
                continue;
            }
            parent.setUntruncatedChildCount(orderedChildren.size());
            for (int childIndex = 0; childIndex < orderedChildren.size(); childIndex++) {
                ExpandableNotificationRow childView = orderedChildren.get(childIndex).getRow();
                ExpandableNotificationRow childView = orderedChildren.get(childIndex).getRow();
                if (children == null || !children.contains(childView)) {
                if (children == null || !children.contains(childView)) {
                    if (childView.getParent() != null) {
                    if (childView.getParent() != null) {
                        Log.wtf(TAG, "trying to add a notification child that already has " +
                        Log.wtf(TAG, "trying to add a notification child that already has "
                                "a parent. class:" + childView.getParent().getClass() +
                                + "a parent. class:" + childView.getParent().getClass()
                                "\n child: " + childView);
                                + "\n child: " + childView);
                        // This shouldn't happen. We can recover by removing it though.
                        // This shouldn't happen. We can recover by removing it though.
                        ((ViewGroup) childView.getParent()).removeView(childView);
                        ((ViewGroup) childView.getParent()).removeView(childView);
                    }
                    }
@@ -349,7 +352,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
            }
            }


            ExpandableNotificationRow parent = (ExpandableNotificationRow) view;
            ExpandableNotificationRow parent = (ExpandableNotificationRow) view;
            List<ExpandableNotificationRow> children = parent.getNotificationChildren();
            List<ExpandableNotificationRow> children = parent.getAttachedChildren();
            List<NotificationEntry> orderedChildren = mTmpChildOrderMap.get(parent.getEntry());
            List<NotificationEntry> orderedChildren = mTmpChildOrderMap.get(parent.getEntry());


            if (children != null) {
            if (children != null) {
@@ -454,7 +457,7 @@ public class NotificationViewHierarchyManager implements DynamicPrivacyControlle
            }
            }
            if (row.isSummaryWithChildren()) {
            if (row.isSummaryWithChildren()) {
                List<ExpandableNotificationRow> notificationChildren =
                List<ExpandableNotificationRow> notificationChildren =
                        row.getNotificationChildren();
                        row.getAttachedChildren();
                int size = notificationChildren.size();
                int size = notificationChildren.size();
                for (int i = size - 1; i >= 0; i--) {
                for (int i = size - 1; i >= 0; i--) {
                    stack.push(notificationChildren.get(i));
                    stack.push(notificationChildren.get(i));
+1 −1
Original line number Original line Diff line number Diff line
@@ -515,7 +515,7 @@ public class NotificationEntryManager implements
                // always cancelled. We only remove them if they were dismissed by the user.
                // always cancelled. We only remove them if they were dismissed by the user.
                return;
                return;
            }
            }
            List<NotificationEntry> childEntries = entry.getChildren();
            List<NotificationEntry> childEntries = entry.getAttachedNotifChildren();
            if (childEntries == null) {
            if (childEntries == null) {
                return;
                return;
            }
            }
+20 −0
Original line number Original line Diff line number Diff line
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.statusbar.notification.collection.coordinator.PreparationCoordinator;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
@@ -36,6 +37,7 @@ public class GroupEntry extends ListEntry {


    private final List<NotificationEntry> mUnmodifiableChildren =
    private final List<NotificationEntry> mUnmodifiableChildren =
            Collections.unmodifiableList(mChildren);
            Collections.unmodifiableList(mChildren);
    private int mUntruncatedChildCount;


    @VisibleForTesting
    @VisibleForTesting
    public GroupEntry(String key) {
    public GroupEntry(String key) {
@@ -62,6 +64,24 @@ public class GroupEntry extends ListEntry {
        mSummary = summary;
        mSummary = summary;
    }
    }


    /**
     * @see #getUntruncatedChildCount()
     */
    public void setUntruncatedChildCount(int childCount) {
        mUntruncatedChildCount = childCount;
    }

    /**
     * Get the untruncated number of children from the data model, including those that will not
     * have views bound. This includes children that {@link PreparationCoordinator} will filter out
     * entirely when they are beyond the last visible child.
     *
     * TODO: This should move to some shared class between the model and view hierarchy
     */
    public int getUntruncatedChildCount() {
        return mUntruncatedChildCount;
    }

    void clearChildren() {
    void clearChildren() {
        mChildren.clear();
        mChildren.clear();
    }
    }
Loading