From ea111fa8ce3901636ce96be08b13c9c59d876f50 Mon Sep 17 00:00:00 2001 From: Mark Renouf Date: Mon, 1 Apr 2019 14:17:37 -0400 Subject: [PATCH] Set system gesture exclusion rects for Bubbles When collapsed (stack of bubbles) or animating between collapsed or expanded states, the view bounds of the bubble stack are set as the system gesture exclusion zone. Test: manually w/fully gesture nav enabled Bug: 126360272 Change-Id: I8b517cd2bebf86be0fff7d676f304845907689a5 --- .../systemui/bubbles/BubbleStackView.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java index de4605b552722..d850dbc6addac 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java @@ -64,6 +64,8 @@ import com.android.systemui.statusbar.notification.collection.NotificationEntry; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.Collections; +import java.util.List; /** * Renders bubbles in a stack and handles animating expanded and collapsed states. @@ -164,6 +166,8 @@ public class BubbleStackView extends FrameLayout { int[] mTempLoc = new int[2]; RectF mTempRect = new RectF(); + private final List mSystemGestureExclusionRects = Collections.singletonList(new Rect()); + private ViewTreeObserver.OnPreDrawListener mViewUpdater = new ViewTreeObserver.OnPreDrawListener() { @Override @@ -175,6 +179,9 @@ public class BubbleStackView extends FrameLayout { } }; + private ViewTreeObserver.OnDrawListener mSystemGestureExcludeUpdater = + this::updateSystemGestureExcludeRects; + private ViewClippingUtil.ClippingParameters mClippingParameters = new ViewClippingUtil.ClippingParameters() { @@ -361,6 +368,19 @@ public class BubbleStackView extends FrameLayout { return false; } + private void updateSystemGestureExcludeRects() { + // Exclude the region occupied by the first BubbleView in the stack + Rect excludeZone = mSystemGestureExclusionRects.get(0); + if (mBubbleContainer.getChildCount() > 0) { + View firstBubble = mBubbleContainer.getChildAt(0); + excludeZone.set(firstBubble.getLeft(), firstBubble.getTop(), firstBubble.getRight(), + firstBubble.getBottom()); + } else { + excludeZone.setEmpty(); + } + mBubbleContainer.setSystemGestureExclusionRects(mSystemGestureExclusionRects); + } + /** * Updates the visibility of the 'dot' indicating an update on the bubble. * @param key the {@link NotificationEntry#key} associated with the bubble. @@ -669,12 +689,17 @@ public class BubbleStackView extends FrameLayout { updateExpandedBubble(); applyCurrentState(); + // This must be a separate OnDrawListener since it should be called for every draw. + getViewTreeObserver().addOnDrawListener(mSystemGestureExcludeUpdater); + mIsExpansionAnimating = true; Runnable updateAfter = () -> { applyCurrentState(); mIsExpansionAnimating = false; requestUpdate(); + getViewTreeObserver().removeOnDrawListener(mSystemGestureExcludeUpdater); + updateSystemGestureExcludeRects(); }; if (shouldExpand) {