Adding accessibility support to the Status Bar.
1. Added content description to pretty much all animals
in the zoo including buttons in the navigation bar,
notifications and status icons for battery, signal,
data, etc.
2. Rectored to avoid ovelaying views since they block
touch exploratino. In general overlaying views
cause trouble for touch exploration and accessibility
in general.
3. Avoid sending accessibility events in case the user is
touching outside of the StatauBAr panels to avoid
confusion.
4. Added records to accessibility events in the places where
this would help the presentation. So the event comes from
a given "leaf" view and its predecessor is adding a record
to the event for itself to provide more cotext. It is up
to the accessiiblity service to choose how to present that.
bug:4686943
Change-Id: I1c1bd123d828fb10911bca92130e9a05c1f020b3
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index d9d9c06..be4b395 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar;
+import android.app.Notification;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -23,11 +24,11 @@
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
+import android.text.TextUtils;
import android.util.Slog;
import android.util.Log;
-import android.view.View;
import android.view.ViewDebug;
-import android.widget.FrameLayout;
+import android.view.accessibility.AccessibilityEvent;
import java.text.NumberFormat;
@@ -45,8 +46,9 @@
private int mNumberX;
private int mNumberY;
private String mNumberText;
+ private Notification mNotification;
- public StatusBarIconView(Context context, String slot) {
+ public StatusBarIconView(Context context, String slot, Notification notification) {
super(context);
final Resources res = context.getResources();
mSlot = slot;
@@ -54,6 +56,8 @@
mNumberPain.setTextAlign(Paint.Align.CENTER);
mNumberPain.setColor(res.getColor(R.drawable.notification_number_text_color));
mNumberPain.setAntiAlias(true);
+ mNotification = notification;
+ setContentDescription(notification);
}
private static boolean streq(String a, String b) {
@@ -83,6 +87,7 @@
final boolean numberEquals = mIcon != null
&& mIcon.number == icon.number;
mIcon = icon.clone();
+ setContentDescription(icon.contentDescription);
if (!iconEquals) {
Drawable drawable = getIcon(icon);
if (drawable == null) {
@@ -159,6 +164,15 @@
return mIcon;
}
+ @Override
+ public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
+ super.onInitializeAccessibilityEvent(event);
+ if (mNotification != null) {
+ event.setParcelableData(mNotification);
+ }
+ }
+
+ @Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
if (mNumberBackground != null) {
@@ -166,6 +180,7 @@
}
}
+ @Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
@@ -175,6 +190,7 @@
}
}
+ @Override
protected void debug(int depth) {
super.debug(depth);
Log.d("View", debugIndent(depth) + "slot=" + mSlot);
@@ -213,4 +229,13 @@
mNumberY = h-r.bottom-((dh-r.top-th-r.bottom)/2);
mNumberBackground.setBounds(w-dw, h-dh, w, h);
}
+
+ private void setContentDescription(Notification notification) {
+ if (notification != null) {
+ CharSequence tickerText = notification.tickerText;
+ if (!TextUtils.isEmpty(tickerText)) {
+ setContentDescription(tickerText);
+ }
+ }
+ }
}