Merge "Fix a11y issues." into rvc-dev am: b24071b704

Change-Id: I8f7c8f069b3ffe4ee77efaecb3d021111cce346e
This commit is contained in:
Josh Tsuji
2020-04-29 19:48:08 +00:00
committed by Automerger Merge Worker
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 -->
<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] -->
<string name="accessibility_desc_notification_shade">Notification shade.</string>
<!-- 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;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
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.TAG_BUBBLES;
@@ -772,7 +773,7 @@ public class BubbleData {
/**
* The set of bubbles in row.
*/
@VisibleForTesting(visibility = PRIVATE)
@VisibleForTesting(visibility = PACKAGE)
public List<Bubble> getBubbles() {
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.
if (action == AccessibilityNodeInfo.ACTION_DISMISS) {
mBubbleData.dismissAll(BubbleController.DISMISS_ACCESSIBILITY_ACTION);
announceForAccessibility(
getResources().getString(R.string.accessibility_bubble_dismissed));
return true;
} else if (action == AccessibilityNodeInfo.ACTION_COLLAPSE) {
mBubbleData.setExpanded(false);
@@ -1136,32 +1138,29 @@ public class BubbleStackView extends FrameLayout {
if (mBubbleData.getBubbles().isEmpty()) {
return;
}
Bubble topBubble = mBubbleData.getBubbles().get(0);
String appName = topBubble.getAppName();
Notification notification = topBubble.getEntry().getSbn().getNotification();
CharSequence titleCharSeq = notification.extras.getCharSequence(Notification.EXTRA_TITLE);
String titleStr = getResources().getString(R.string.notification_bubble_title);
if (titleCharSeq != null) {
titleStr = titleCharSeq.toString();
}
int moreCount = mBubbleContainer.getChildCount() - 1;
// Example: Title from app name.
String singleDescription = getResources().getString(
R.string.bubble_content_description_single, titleStr, appName);
for (int i = 0; i < mBubbleData.getBubbles().size(); i++) {
final Bubble bubble = mBubbleData.getBubbles().get(i);
final String appName = bubble.getAppName();
final Notification notification = bubble.getEntry().getSbn().getNotification();
final CharSequence titleCharSeq =
notification.extras.getCharSequence(Notification.EXTRA_TITLE);
// Example: Title from app name and 4 more.
String stackDescription = getResources().getString(
R.string.bubble_content_description_stack, titleStr, appName, moreCount);
String titleStr = getResources().getString(R.string.notification_bubble_title);
if (titleCharSeq != null) {
titleStr = titleCharSeq.toString();
}
if (mIsExpanded) {
// TODO(b/129522932) - update content description for each bubble in expanded view.
} else {
// Collapsed stack.
if (moreCount > 0) {
mBubbleContainer.setContentDescription(stackDescription);
} else {
mBubbleContainer.setContentDescription(singleDescription);
if (bubble.getIconView() != null) {
if (mIsExpanded || i > 0) {
bubble.getIconView().setContentDescription(getResources().getString(
R.string.bubble_content_description_single, titleStr, appName));
} else {
final int moreCount = mBubbleContainer.getChildCount() - 1;
bubble.getIconView().setContentDescription(getResources().getString(
R.string.bubble_content_description_stack,
titleStr, appName, moreCount));
}
}
}
}