diff options
| author | 2022-01-11 12:57:55 -0800 | |
|---|---|---|
| committer | 2022-01-12 20:53:33 -0800 | |
| commit | 721c2957f2eaa57e39114f35da489fc577f45190 (patch) | |
| tree | 6aab4e09992f170f0f5ea77576a05aab3e7ef593 /libs | |
| parent | 2360c4eae094b964fb76a62b8671cfe9cf3b03b0 (diff) | |
Set correct bubble traversal order for a11y
Bug: 158006052
Test: atest SystemUITests
Test: manual, video recording: https://drive.google.com/file/d/19OrHgS6RmhD522_Kz-nzBptsdODpxGev/view?usp=sharing
Change-Id: Iec291bc9e32f82e1985803ad43cc5bfb24905493
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java | 2 | ||||
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java | 66 |
2 files changed, 56 insertions, 12 deletions
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 22bec3d63bcf..682363904a23 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 @@ -1348,7 +1348,7 @@ public class BubbleController { mStackView.updateContentDescription(); - mStackView.updateBubblesClickableStates(); + mStackView.updateBubblesAcessibillityStates(); } @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 7bf4439410f9..82382874efda 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 @@ -1486,19 +1486,63 @@ public class BubbleStackView extends FrameLayout } /** - * Update bubbles' icon views clickable states. + * Update bubbles' icon views accessibility states. */ - public void updateBubblesClickableStates() { + public void updateBubblesAcessibillityStates() { 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); + Bubble prevBubble = i > 0 ? mBubbleData.getBubbles().get(i - 1) : null; + Bubble bubble = mBubbleData.getBubbles().get(i); + + View bubbleIconView = bubble.getIconView(); + if (bubbleIconView == null) { + continue; + } + + if (mIsExpanded) { + // when stack is expanded + // all bubbles are important for accessibility + bubbleIconView + .setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); + + View prevBubbleIconView = prevBubble != null ? prevBubble.getIconView() : null; + + if (prevBubbleIconView != null) { + bubbleIconView.setAccessibilityDelegate(new View.AccessibilityDelegate() { + @Override + public void onInitializeAccessibilityNodeInfo(View v, + AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(v, info); + info.setTraversalAfter(prevBubbleIconView); + } + }); + } + } else { + // when stack is collapsed, only the top bubble is important for accessibility, + bubbleIconView.setImportantForAccessibility( + i == 0 ? View.IMPORTANT_FOR_ACCESSIBILITY_YES : + View.IMPORTANT_FOR_ACCESSIBILITY_NO); + } + } + + if (mIsExpanded) { + // make the overflow bubble last in the accessibility traversal order + + View bubbleOverflowIconView = + mBubbleOverflow != null ? mBubbleOverflow.getIconView() : null; + if (bubbleOverflowIconView != null && !mBubbleData.getBubbles().isEmpty()) { + Bubble lastBubble = + mBubbleData.getBubbles().get(mBubbleData.getBubbles().size() - 1); + View lastBubbleIconView = lastBubble.getIconView(); + if (lastBubbleIconView != null) { + bubbleOverflowIconView.setAccessibilityDelegate( + new View.AccessibilityDelegate() { + @Override + public void onInitializeAccessibilityNodeInfo(View v, + AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(v, info); + info.setTraversalAfter(lastBubbleIconView); + } + }); } } } |