summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorSvetoslav Ganov <svetoslavganov@google.com>2011-06-28 01:12:41 -0700
committerSvetoslav Ganov <svetoslavganov@google.com>2011-07-21 12:04:54 -0700
commit6179ea3196e9306d3f14361fe9ef14191b1edba6 (patch)
treed821da4d5840aebcddf4a714a3217ec595847bc9 /core/java
parentac4159549c10dbe428d42980278c0e43ecc8d93f (diff)
downloadframeworks_base-6179ea3196e9306d3f14361fe9ef14191b1edba6.zip
frameworks_base-6179ea3196e9306d3f14361fe9ef14191b1edba6.tar.gz
frameworks_base-6179ea3196e9306d3f14361fe9ef14191b1edba6.tar.bz2
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
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/StatusBarManager.java5
-rw-r--r--core/java/android/view/ViewGroup.java9
-rw-r--r--core/java/android/widget/AdapterView.java19
-rw-r--r--core/java/android/widget/ImageView.java13
-rw-r--r--core/java/com/android/internal/statusbar/IStatusBarService.aidl2
-rw-r--r--core/java/com/android/internal/statusbar/StatusBarIcon.java25
6 files changed, 41 insertions, 32 deletions
diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java
index 1af0983..ca64c88 100644
--- a/core/java/android/app/StatusBarManager.java
+++ b/core/java/android/app/StatusBarManager.java
@@ -97,9 +97,10 @@ public class StatusBarManager {
}
}
- public void setIcon(String slot, int iconId, int iconLevel) {
+ public void setIcon(String slot, int iconId, int iconLevel, String contentDescription) {
try {
- mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel);
+ mService.setIcon(slot, mContext.getPackageName(), iconId, iconLevel,
+ contentDescription);
} catch (RemoteException ex) {
// system process is dead anyway.
throw new RuntimeException(ex);
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 54fee3c..92a8ce7 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -2148,9 +2148,12 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
onPopulateAccessibilityEvent(event);
// Let our children have a shot in populating the event.
for (int i = 0, count = getChildCount(); i < count; i++) {
- boolean handled = getChildAt(i).dispatchPopulateAccessibilityEvent(event);
- if (handled) {
- return handled;
+ View child = getChildAt(i);
+ if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) {
+ boolean handled = getChildAt(i).dispatchPopulateAccessibilityEvent(event);
+ if (handled) {
+ return handled;
+ }
}
}
return false;
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java
index 755d4e0..00c75a9 100644
--- a/core/java/android/widget/AdapterView.java
+++ b/core/java/android/widget/AdapterView.java
@@ -902,15 +902,16 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup {
@Override
public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) {
- // Add a record for ourselves as well.
- AccessibilityEvent record = AccessibilityEvent.obtain();
- record.setSource(this);
- // Set the class since it is not populated in #dispatchPopulateAccessibilityEvent
- record.setClassName(getClass().getName());
- child.onInitializeAccessibilityEvent(record);
- child.dispatchPopulateAccessibilityEvent(record);
- event.appendRecord(record);
- return true;
+ if (super.onRequestSendAccessibilityEvent(child, event)) {
+ // Add a record for ourselves as well.
+ AccessibilityEvent record = AccessibilityEvent.obtain();
+ onInitializeAccessibilityEvent(record);
+ // Populate with the text of the requesting child.
+ child.dispatchPopulateAccessibilityEvent(record);
+ event.appendRecord(record);
+ return true;
+ }
+ return false;
}
@Override
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java
index 161b404..299e1ff 100644
--- a/core/java/android/widget/ImageView.java
+++ b/core/java/android/widget/ImageView.java
@@ -30,14 +30,15 @@ import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.Log;
import android.view.RemotableViewMethod;
import android.view.View;
import android.view.ViewDebug;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.RemoteViews.RemoteView;
-
/**
* Displays an arbitrary image, such as an icon. The ImageView class
* can load images from various sources (such as resources or content
@@ -208,7 +209,15 @@ public class ImageView extends View {
}
return false;
}
-
+
+ @Override
+ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ CharSequence contentDescription = getContentDescription();
+ if (!TextUtils.isEmpty(contentDescription)) {
+ event.getText().add(contentDescription);
+ }
+ }
+
/**
* Set this to true if you want the ImageView to adjust its bounds
* to preserve the aspect ratio of its drawable.
diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
index a9e5057..07430e7 100644
--- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl
+++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl
@@ -27,7 +27,7 @@ interface IStatusBarService
void expand();
void collapse();
void disable(int what, IBinder token, String pkg);
- void setIcon(String slot, String iconPackage, int iconId, int iconLevel);
+ void setIcon(String slot, String iconPackage, int iconId, int iconLevel, String contentDescription);
void setIconVisibility(String slot, boolean visible);
void removeIcon(String slot);
void topAppWindowChanged(boolean menuVisible);
diff --git a/core/java/com/android/internal/statusbar/StatusBarIcon.java b/core/java/com/android/internal/statusbar/StatusBarIcon.java
index ae2cac2..3333c82 100644
--- a/core/java/com/android/internal/statusbar/StatusBarIcon.java
+++ b/core/java/com/android/internal/statusbar/StatusBarIcon.java
@@ -19,42 +19,35 @@ package com.android.internal.statusbar;
import android.os.Parcel;
import android.os.Parcelable;
-/**
- * @hide
- */
public class StatusBarIcon implements Parcelable {
public String iconPackage;
public int iconId;
public int iconLevel;
public boolean visible = true;
public int number;
+ public CharSequence contentDescription;
- private StatusBarIcon() {
- }
-
- public StatusBarIcon(String iconPackage, int iconId, int iconLevel) {
- this.iconPackage = iconPackage;
- this.iconId = iconId;
- this.iconLevel = iconLevel;
- }
-
- public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number) {
+ public StatusBarIcon(String iconPackage, int iconId, int iconLevel, int number,
+ CharSequence contentDescription) {
this.iconPackage = iconPackage;
this.iconId = iconId;
this.iconLevel = iconLevel;
this.number = number;
+ this.contentDescription = contentDescription;
}
+ @Override
public String toString() {
return "StatusBarIcon(pkg=" + this.iconPackage + " id=0x" + Integer.toHexString(this.iconId)
+ " level=" + this.iconLevel + " visible=" + visible
+ " num=" + this.number + " )";
}
+ @Override
public StatusBarIcon clone() {
- StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel);
+ StatusBarIcon that = new StatusBarIcon(this.iconPackage, this.iconId, this.iconLevel,
+ this.number, this.contentDescription);
that.visible = this.visible;
- that.number = this.number;
return that;
}
@@ -71,6 +64,7 @@ public class StatusBarIcon implements Parcelable {
this.iconLevel = in.readInt();
this.visible = in.readInt() != 0;
this.number = in.readInt();
+ this.contentDescription = in.readCharSequence();
}
public void writeToParcel(Parcel out, int flags) {
@@ -79,6 +73,7 @@ public class StatusBarIcon implements Parcelable {
out.writeInt(this.iconLevel);
out.writeInt(this.visible ? 1 : 0);
out.writeInt(this.number);
+ out.writeCharSequence(this.contentDescription);
}
public int describeContents() {