summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2016-04-23 01:45:00 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2016-04-23 01:45:02 +0000
commiteefff3742de62101341128a32b227a25ed22df06 (patch)
tree9225cd1445d262fd64a6672cb63d328ac14338fe
parentc3c45fa2e0c5779e3e847dd4878c2a9d1ba2fb36 (diff)
parenteba0582af1073cfbd1adbffe79fb7755087a6ed7 (diff)
Merge "Fix content description for notification icons" into nyc-dev
-rw-r--r--core/java/android/app/Notification.java5
-rw-r--r--packages/SystemUI/res/values/strings.xml3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java14
4 files changed, 21 insertions, 7 deletions
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 43c6ca58a16a..dd05392c9c98 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -3301,7 +3301,10 @@ public class Notification implements Parcelable
}
}
- private String loadHeaderAppName() {
+ /**
+ * @hide
+ */
+ public String loadHeaderAppName() {
CharSequence name = null;
final PackageManager pm = mContext.getPackageManager();
if (mN.extras.containsKey(EXTRA_SUBSTITUTE_APP_NAME)) {
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index f6c3dd4b28e9..81fa520ae57d 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1657,6 +1657,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 ef6d73ac49f2..be683444fb43 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 @@ public abstract class BaseStatusBar extends SystemUI implements
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 @@ public abstract class BaseStatusBar extends SystemUI implements
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 @@ public abstract class BaseStatusBar extends SystemUI implements
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 870447acf6e8..6d76763edc84 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 @@ public class StatusBarIconView extends AnimatedImageView {
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 class StatusBarIconView extends AnimatedImageView {
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);
+ }
}