Merge "Fix a11y issues." into rvc-dev

This commit is contained in:
Josh Tsuji
2020-04-29 19:41:28 +00:00
committed by Android (Google) Code Review
3 changed files with 27 additions and 24 deletions

View File

@@ -644,6 +644,9 @@
<!-- Content description to tell the user a notification has been removed from the notification shade --> <!-- Content description to tell the user a notification has been removed from the notification shade -->
<string name="accessibility_notification_dismissed">Notification dismissed.</string> <string name="accessibility_notification_dismissed">Notification dismissed.</string>
<!-- Content description to tell the user a bubble has been dismissed. -->
<string name="accessibility_bubble_dismissed">Bubble dismissed.</string>
<!-- Content description for the notification shade panel (not shown on the screen). [CHAR LIMIT=NONE] --> <!-- Content description for the notification shade panel (not shown on the screen). [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_notification_shade">Notification shade.</string> <string name="accessibility_desc_notification_shade">Notification shade.</string>
<!-- Content description for the quick settings panel (not shown on the screen). [CHAR LIMIT=NONE] --> <!-- Content description for the quick settings panel (not shown on the screen). [CHAR LIMIT=NONE] -->

View File

@@ -15,6 +15,7 @@
*/ */
package com.android.systemui.bubbles; package com.android.systemui.bubbles;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE; import static com.android.internal.annotations.VisibleForTesting.Visibility.PRIVATE;
import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_DATA; import static com.android.systemui.bubbles.BubbleDebugConfig.DEBUG_BUBBLE_DATA;
import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES; import static com.android.systemui.bubbles.BubbleDebugConfig.TAG_BUBBLES;
@@ -772,7 +773,7 @@ public class BubbleData {
/** /**
* The set of bubbles in row. * The set of bubbles in row.
*/ */
@VisibleForTesting(visibility = PRIVATE) @VisibleForTesting(visibility = PACKAGE)
public List<Bubble> getBubbles() { public List<Bubble> getBubbles() {
return Collections.unmodifiableList(mBubbles); return Collections.unmodifiableList(mBubbles);
} }

View File

@@ -1106,6 +1106,8 @@ public class BubbleStackView extends FrameLayout {
// R constants are not final so we cannot use switch-case here. // R constants are not final so we cannot use switch-case here.
if (action == AccessibilityNodeInfo.ACTION_DISMISS) { if (action == AccessibilityNodeInfo.ACTION_DISMISS) {
mBubbleData.dismissAll(BubbleController.DISMISS_ACCESSIBILITY_ACTION); mBubbleData.dismissAll(BubbleController.DISMISS_ACCESSIBILITY_ACTION);
announceForAccessibility(
getResources().getString(R.string.accessibility_bubble_dismissed));
return true; return true;
} else if (action == AccessibilityNodeInfo.ACTION_COLLAPSE) { } else if (action == AccessibilityNodeInfo.ACTION_COLLAPSE) {
mBubbleData.setExpanded(false); mBubbleData.setExpanded(false);
@@ -1136,32 +1138,29 @@ public class BubbleStackView extends FrameLayout {
if (mBubbleData.getBubbles().isEmpty()) { if (mBubbleData.getBubbles().isEmpty()) {
return; return;
} }
Bubble topBubble = mBubbleData.getBubbles().get(0);
String appName = topBubble.getAppName(); for (int i = 0; i < mBubbleData.getBubbles().size(); i++) {
Notification notification = topBubble.getEntry().getSbn().getNotification(); final Bubble bubble = mBubbleData.getBubbles().get(i);
CharSequence titleCharSeq = notification.extras.getCharSequence(Notification.EXTRA_TITLE); final String appName = bubble.getAppName();
final Notification notification = bubble.getEntry().getSbn().getNotification();
final CharSequence titleCharSeq =
notification.extras.getCharSequence(Notification.EXTRA_TITLE);
String titleStr = getResources().getString(R.string.notification_bubble_title); String titleStr = getResources().getString(R.string.notification_bubble_title);
if (titleCharSeq != null) { if (titleCharSeq != null) {
titleStr = titleCharSeq.toString(); titleStr = titleCharSeq.toString();
} }
int moreCount = mBubbleContainer.getChildCount() - 1;
// Example: Title from app name. if (bubble.getIconView() != null) {
String singleDescription = getResources().getString( if (mIsExpanded || i > 0) {
R.string.bubble_content_description_single, titleStr, appName); bubble.getIconView().setContentDescription(getResources().getString(
R.string.bubble_content_description_single, titleStr, appName));
// Example: Title from app name and 4 more.
String stackDescription = getResources().getString(
R.string.bubble_content_description_stack, titleStr, appName, moreCount);
if (mIsExpanded) {
// TODO(b/129522932) - update content description for each bubble in expanded view.
} else { } else {
// Collapsed stack. final int moreCount = mBubbleContainer.getChildCount() - 1;
if (moreCount > 0) { bubble.getIconView().setContentDescription(getResources().getString(
mBubbleContainer.setContentDescription(stackDescription); R.string.bubble_content_description_stack,
} else { titleStr, appName, moreCount));
mBubbleContainer.setContentDescription(singleDescription); }
} }
} }
} }