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

Commit 1d017d32 authored by Andreas Miko's avatar Andreas Miko Committed by Android (Google) Code Review
Browse files

Merge changes If2376d2e,Iff637009 into main

* changes:
  Don't collapse bundles and bundled groups after dismissing a child
  Fix bundled groups not expanding on long press
parents 43843170 8ee06a58
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -370,6 +370,10 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
                            : mPagingTouchSlop;
                    if (Math.abs(delta) > pagingTouchSlop
                            && Math.abs(delta) > Math.abs(deltaPerpendicular)) {
                        if (NotificationBundleUi.isEnabled()
                                && mTouchedView instanceof ExpandableNotificationRow row) {
                            mTouchedView = mCallback.getSwipeTarget(row);
                        }
                        if (mCallback.canChildBeDragged(mTouchedView)) {
                            mIsSwiping = true;
                            mCallback.setMagneticAndRoundableTargets(mTouchedView);
@@ -688,10 +692,11 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (!mIsSwiping && !mMenuRowIntercepting && !mLongPressSent) {
            if (mCallback.getChildAtPosition(ev) != null) {
            View childAtPosition = mCallback.getChildAtPosition(ev);
            if (childAtPosition != null) {
                // We are dragging directly over a card, make sure that we also catch the gesture
                // even if nobody else wants the touch event.
                mTouchedView = mCallback.getChildAtPosition(ev);
                mTouchedView = childAtPosition;
                onInterceptTouchEvent(ev);
                return true;
            } else {
@@ -1028,6 +1033,13 @@ public class SwipeHelper implements Gefingerpoken, Dumpable {
         */
        void onLongPressSent(View v);

        /**
         * Get the swipe target based on the currently touched row. The swipe target may be the
         * parent of the touched row.
         * @return the ENR that should actually handle the swipe event
         */
        ExpandableNotificationRow getSwipeTarget(ExpandableNotificationRow row);

        /**
         * The snap back animation on a view overshoots for the first time.
         */
+33 −8
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import androidx.annotation.NonNull;
import com.android.systemui.Dumpable;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.statusbar.notification.collection.BundleEntry;
import com.android.systemui.statusbar.notification.collection.EntryAdapter;
import com.android.systemui.statusbar.notification.collection.GroupEntry;
import com.android.systemui.statusbar.notification.collection.NotifPipeline;
@@ -34,8 +35,10 @@ import com.android.systemui.statusbar.notification.shared.NotificationBundleUi;

import java.io.PrintWriter;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

import javax.inject.Inject;

@@ -81,17 +84,13 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
            }
        }

        final Set<NotificationEntry> renderingSummaries = new HashSet<>();
        for (PipelineEntry entry : entries) {
            if (entry instanceof GroupEntry groupEntry) {
                renderingSummaries.add(groupEntry.getRepresentativeEntry());
            }
        }

        if (NotificationBundleUi.isEnabled()) {
            final Set<PipelineEntry> renderingSummaries = new HashSet<>();
            findRenderingSummariesRecursive(entries, renderingSummaries);

            for (EntryAdapter entryAdapter : mExpandedCollections) {
                boolean isInPipeline = false;
                for (NotificationEntry entry : renderingSummaries) {
                for (PipelineEntry entry : renderingSummaries) {
                    if (entry.getKey().equals(entryAdapter.getKey())) {
                        isInPipeline = true;
                        break;
@@ -102,6 +101,13 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
                }
            }
        } else {
            final Set<NotificationEntry> renderingSummaries = new HashSet<>();
            for (PipelineEntry entry : entries) {
                if (entry instanceof GroupEntry groupEntry) {
                    renderingSummaries.add(groupEntry.getRepresentativeEntry());
                }
            }

            // If a group is in mExpandedGroups but not in the pipeline entries, collapse it.
            final var groupsToRemove = setDifference(mExpandedGroups, renderingSummaries);
            for (NotificationEntry entry : groupsToRemove) {
@@ -110,6 +116,25 @@ public class GroupExpansionManagerImpl implements GroupExpansionManager, Dumpabl
        }
    };

    private void findRenderingSummariesRecursive(List<PipelineEntry> entries,
            Set<PipelineEntry> renderingSummaries) {
        for (PipelineEntry entry : entries) {
            if (entry instanceof BundleEntry bundleEntry) {
                renderingSummaries.add(entry);
                List<PipelineEntry> children = bundleEntry.getChildren().stream().map(
                        child -> (PipelineEntry) child).collect(
                        Collectors.toList());
                findRenderingSummariesRecursive(children, renderingSummaries);
            } else if (entry instanceof GroupEntry groupEntry) {
                renderingSummaries.add(groupEntry.getRepresentativeEntry());
                List<PipelineEntry> children = groupEntry.getChildren().stream().map(
                        child -> (PipelineEntry) child).collect(
                        Collectors.toList());
                findRenderingSummariesRecursive(children, renderingSummaries);
            }
        }
    }

    public void attach(NotifPipeline pipeline) {
        mDumpManager.registerDumpable(this);
        pipeline.addOnBeforeRenderListListener(mNotifTracker);
+27 −1
Original line number Diff line number Diff line
@@ -649,7 +649,8 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                                && (parent.areGutsExposed()
                                || mSwipeHelper.getExposedMenuView() == parent
                                || (parent.getAttachedChildren().size() == 1
                                && mDismissibilityProvider.isDismissable(parent.getKey())))) {
                                && mDismissibilityProvider.isDismissable(parent.getKey())
                                && !NotificationBundleUi.isEnabled()))) {
                            // In this case the group is expanded and showing the menu for the
                            // group, further interaction should apply to the group, not any
                            // child notifications so we use the parent of the child. We also do the
@@ -660,6 +661,31 @@ public class NotificationStackScrollLayoutController implements Dumpable {
                    return child;
                }

                /**
                 * While {@code getChildAtPosition} already contains logic to change the touch
                 * interaction target to the parent based on some conditions, this method
                 * does the same but narrowed down to swipe interactions. This provides the
                 * opportunity to control the target based on the specific touch event.
                 * <p>
                 * For example: A long press may target the directly touched view but a swipe may
                 * target the containing group or bundle when it is dismissable and only has one
                 * child.
                 *
                 * @param row the ENR that has been touched
                 * @return the ENR that should actually handle the swipe event
                 */
                public ExpandableNotificationRow getSwipeTarget(ExpandableNotificationRow row) {
                    ExpandableNotificationRow parent = row.getNotificationParent();
                    if (parent != null && parent.areChildrenExpanded()
                            && parent.getAttachedChildren().size() == 1
                            && mDismissibilityProvider.isDismissable(parent.getKey())) {
                        // We run this recursively to get the parents parent for the case where
                        // you swipe a lonely child in a lonely group within a bundle
                        return getSwipeTarget(parent);
                    }
                    return row;
                }

                @Override
                public void onLongPressSent(View v) {
                    mLongPressedView = v;