Add content description to bubble bar and bubbles
Set content description on the bubble bar when it is collapsed. Only allow focus on the bar itself. In collapsed mode, bubbles in the bar can't be focused. Content description for the bar matches what we have in floating mode. We include the text for the first bubble and then how many bubbles are there more. Set content description on bubbles in bubble bar. When bubble bar is expanded, only the bubbles are focusable. Bubble content description matches the floating bubbles content description. Includes the notification title and app name. Bug: 344670947 Flag: com.android.wm.shell.enable_bubble_bar Test: enable talkback, focus on bubble bar when it is collapsed, check that only bubble bar receives focus Test: enable talkback and expand bubble bar, check that only the bubbles receive focus Change-Id: Id931f0360b9ebadd01dd16b05b75546fcc4df803
This commit is contained in:
1 parent
1507a2c59e
commit
cd4c9d153d
4 files changed
+66
-1
No files matched your search
@@ -623,6 +623,8 @@ public class BubbleBarView extends FrameLayout {
|
||||
}
|
||||
super.addView(child, index, params);
|
||||
updateWidth();
|
||||
updateBubbleAccessibilityStates();
|
||||
updateContentDescription();
|
||||
}
|
||||
|
||||
// TODO: (b/283309949) animate it
|
||||
@@ -634,6 +636,8 @@ public class BubbleBarView extends FrameLayout {
|
||||
mBubbleBarBackground.showArrow(false);
|
||||
}
|
||||
updateWidth();
|
||||
updateBubbleAccessibilityStates();
|
||||
updateContentDescription();
|
||||
}
|
||||
|
||||
private void updateWidth() {
|
||||
@@ -799,6 +803,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
updateChildrenRenderNodeProperties(mBubbleBarLocation);
|
||||
updateContentDescription();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -927,6 +932,7 @@ public class BubbleBarView extends FrameLayout {
|
||||
} else {
|
||||
mWidthAnimator.reverse();
|
||||
}
|
||||
updateBubbleAccessibilityStates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -998,6 +1004,47 @@ public class BubbleBarView extends FrameLayout {
|
||||
return mIsAnimatingNewBubble;
|
||||
}
|
||||
|
||||
private boolean hasOverview() {
|
||||
// Overview is always the last bubble
|
||||
View lastChild = getChildAt(getChildCount() - 1);
|
||||
if (lastChild instanceof BubbleView bubbleView) {
|
||||
return bubbleView.getBubble() instanceof BubbleBarOverflow;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void updateBubbleAccessibilityStates() {
|
||||
final int childA11y;
|
||||
if (mIsBarExpanded) {
|
||||
// Bar is expanded, focus on the bubbles
|
||||
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
||||
childA11y = View.IMPORTANT_FOR_ACCESSIBILITY_YES;
|
||||
} else {
|
||||
// Bar is collapsed, only focus on the bar
|
||||
setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
||||
childA11y = View.IMPORTANT_FOR_ACCESSIBILITY_NO;
|
||||
}
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
getChildAt(i).setImportantForAccessibility(childA11y);
|
||||
// Only allowing focusing on bubbles when bar is expanded. Otherwise, in talkback mode,
|
||||
// bubbles can be navigates to in collapsed mode.
|
||||
getChildAt(i).setFocusable(mIsBarExpanded);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateContentDescription() {
|
||||
View firstChild = getChildAt(0);
|
||||
CharSequence contentDesc = firstChild != null ? firstChild.getContentDescription() : "";
|
||||
|
||||
// Don't count overflow if it exists
|
||||
int bubbleCount = getChildCount() - (hasOverview() ? 1 : 0);
|
||||
if (bubbleCount > 1) {
|
||||
contentDesc = getResources().getString(R.string.bubble_bar_description_multiple_bubbles,
|
||||
contentDesc, bubbleCount - 1);
|
||||
}
|
||||
setContentDescription(contentDesc);
|
||||
}
|
||||
|
||||
/** Interface for BubbleBarView to communicate with its controller. */
|
||||
interface Controller {
|
||||
|
||||
|
||||
Reference in new issue
Block a user