Fix content description for notification icons
Change-Id: Icb4c6d8a77211d0c8922e28958609a332b19dfcc
Fixes: 27552350
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index c78efe2..7ebb49d 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1635,6 +1635,9 @@
<!-- Accessibility label for window when QS editing is happening [CHAR LIMIT=NONE] -->
<string name="accessibility_desc_quick_settings_edit">Quick settings editor.</string>
+ <!-- Accessibility label for the notification icons in the collapsed status bar. Not shown on screen [CHAR LIMIT=NONE] -->
+ <string name="accessibility_desc_notification_icon"><xliff:g name="app_name" example="Gmail">%1$s</xliff:g> notification: <xliff:g name="notification_text" example="5 new messages">%2$s</xliff:g></string>
+
<!-- Multi-Window strings -->
<!-- Text that gets shown on top of current activity to inform the user that the system force-resized the current activity and that things might crash/not work properly [CHAR LIMIT=NONE] -->
<string name="dock_forced_resizable">App may not work with split-screen.</string>
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index ef6d73a..be68344 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -2114,7 +2114,7 @@
smallIcon,
n.iconLevel,
n.number,
- n.tickerText);
+ StatusBarIconView.contentDescForNotification(mContext, n));
if (!iconView.set(ic)) {
handleNotificationError(sbn, "Couldn't create icon: " + ic);
return null;
@@ -2283,7 +2283,7 @@
n.getSmallIcon(),
n.iconLevel,
n.number,
- n.tickerText);
+ StatusBarIconView.contentDescForNotification(mContext, n));
entry.icon.setNotification(n);
if (!entry.icon.set(ic)) {
handleNotificationError(notification, "Couldn't update icon: " + ic);
@@ -2307,7 +2307,7 @@
n.getSmallIcon(),
n.iconLevel,
n.number,
- n.tickerText);
+ StatusBarIconView.contentDescForNotification(mContext, n));
entry.icon.setNotification(n);
entry.icon.set(ic);
inflateViews(entry, mStackScroller);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index 870447a..6d76763e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -307,9 +307,9 @@
private void setContentDescription(Notification notification) {
if (notification != null) {
- CharSequence tickerText = notification.tickerText;
- if (!TextUtils.isEmpty(tickerText)) {
- setContentDescription(tickerText);
+ String d = contentDescForNotification(mContext, notification);
+ if (!TextUtils.isEmpty(d)) {
+ setContentDescription(d);
}
}
}
@@ -322,4 +322,12 @@
public String getSlot() {
return mSlot;
}
+
+
+ public static String contentDescForNotification(Context c, Notification n) {
+ Notification.Builder builder = Notification.Builder.recoverBuilder(c, n);
+ String appName = builder.loadHeaderAppName();
+ CharSequence ticker = n.tickerText;
+ return c.getString(R.string.accessibility_desc_notification_icon, appName, ticker);
+ }
}