From 79623ef98d12fcbce41023b04853fa68e903eb5c Mon Sep 17 00:00:00 2001 From: Sergey Serokurov Date: Fri, 7 Jan 2022 09:09:10 -0800 Subject: [PATCH] Make only top bubble clickable when stack is collapsed Bug: 157934340 Test: atest SystemUITests Test: manual, screen recording https://drive.google.com/file/d/12itDLsVQZrCQVYMjgJhuWlTslOJdyGqy/view?usp=sharing Change-Id: I865a8d508965e88e78e516143915fd895d4f3782 --- .../wm/shell/bubbles/BubbleController.java | 3 +++ .../wm/shell/bubbles/BubbleStackView.java | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 2d1d7cdae2257..7903a5102ddec 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -1319,6 +1319,7 @@ public class BubbleController { * Updates the visibility of the bubbles based on current state. * Does not un-bubble, just hides or un-hides. * Updates stack description for TalkBack focus. + * Updates bubbles' icon views clickable states */ public void updateStack() { if (mStackView == null) { @@ -1336,6 +1337,8 @@ public class BubbleController { } mStackView.updateContentDescription(); + + mStackView.updateBubblesClickableStates(); } @VisibleForTesting diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index f8d82c28baeab..7bf4439410f95 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -1485,6 +1485,25 @@ public class BubbleStackView extends FrameLayout } } + /** + * Update bubbles' icon views clickable states. + */ + public void updateBubblesClickableStates() { + for (int i = 0; i < mBubbleData.getBubbles().size(); i++) { + final Bubble bubble = mBubbleData.getBubbles().get(i); + if (bubble.getIconView() != null) { + if (mIsExpanded) { + // when stack is expanded all bubbles are clickable + bubble.getIconView().setClickable(true); + } else { + // when stack is collapsed, only the top bubble needs to be clickable, + // so that a11y ignores all the inaccessible bubbles in the stack + bubble.getIconView().setClickable(i == 0); + } + } + } + } + private void updateSystemGestureExcludeRects() { // Exclude the region occupied by the first BubbleView in the stack Rect excludeZone = mSystemGestureExclusionRects.get(0);