summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Powell <adamp@google.com>2011-08-26 18:29:58 -0700
committerAdam Powell <adamp@google.com>2011-08-26 18:31:47 -0700
commit7bc3ca0dc52be52ecad1c0de8c62a6a4bf8141ca (patch)
tree7071a6bbbb2a8b635334cfb5291c17d1faeeeb2f
parentfdfbbf62e61020b6b6170862eaabd72b43bca4ea (diff)
downloadframeworks_base-7bc3ca0dc52be52ecad1c0de8c62a6a4bf8141ca.zip
frameworks_base-7bc3ca0dc52be52ecad1c0de8c62a6a4bf8141ca.tar.gz
frameworks_base-7bc3ca0dc52be52ecad1c0de8c62a6a4bf8141ca.tar.bz2
Accessibility fixes for action bars
Fix bug 5220543 - fix accessibility events for action buttons Fix bug 5224260 - fix accessibility events for home/up Change-Id: I7d55b4819862e1eda0809da92c52ec2d97f36af0
-rw-r--r--core/java/com/android/internal/view/menu/ActionMenuItemView.java27
-rw-r--r--core/java/com/android/internal/view/menu/ActionMenuPresenter.java3
-rw-r--r--core/java/com/android/internal/view/menu/ActionMenuView.java5
-rw-r--r--core/java/com/android/internal/widget/ActionBarView.java25
4 files changed, 57 insertions, 3 deletions
diff --git a/core/java/com/android/internal/view/menu/ActionMenuItemView.java b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
index cde9a49..e245960 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuItemView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuItemView.java
@@ -23,7 +23,9 @@ import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.Gravity;
+import android.view.MotionEvent;
import android.view.View;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
@@ -157,14 +159,33 @@ public class ActionMenuItemView extends LinearLayout
public void setTitle(CharSequence title) {
mTitle = title;
- // populate accessibility description with title
- setContentDescription(title);
-
mTextButton.setText(mTitle);
+ setContentDescription(mTitle);
updateTextButtonVisibility();
}
+ @Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ onPopulateAccessibilityEvent(event);
+ return true;
+ }
+
+ @Override
+ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ super.onPopulateAccessibilityEvent(event);
+ final CharSequence cdesc = getContentDescription();
+ if (!TextUtils.isEmpty(cdesc)) {
+ event.getText().add(cdesc);
+ }
+ }
+
+ @Override
+ public boolean dispatchHoverEvent(MotionEvent event) {
+ // Don't allow children to hover; we want this to be treated as a single component.
+ return onHoverEvent(event);
+ }
+
public boolean showsIcon() {
return true;
}
diff --git a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
index 246c4de..fba6a5a 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
@@ -30,6 +30,9 @@ import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.ImageButton;
import java.util.ArrayList;
diff --git a/core/java/com/android/internal/view/menu/ActionMenuView.java b/core/java/com/android/internal/view/menu/ActionMenuView.java
index b355c41..8d8c72c 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuView.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuView.java
@@ -22,6 +22,7 @@ import android.view.Gravity;
import android.view.View;
import android.view.ViewDebug;
import android.view.ViewGroup;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.LinearLayout;
/**
@@ -511,6 +512,10 @@ public class ActionMenuView extends LinearLayout implements MenuBuilder.ItemInvo
return result;
}
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ return false;
+ }
+
public interface ActionMenuChildView {
public boolean needsDividerBefore();
public boolean needsDividerAfter();
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 8988c9f..a0f6259 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -46,10 +46,12 @@ import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.Window;
+import android.view.accessibility.AccessibilityEvent;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
@@ -220,6 +222,8 @@ public class ActionBarView extends AbsActionBarView {
mExpandedHomeLayout = (HomeView) inflater.inflate(homeResId, this, false);
mExpandedHomeLayout.setUp(true);
mExpandedHomeLayout.setOnClickListener(mExpandedActionViewUpListener);
+ mExpandedHomeLayout.setContentDescription(getResources().getText(
+ R.string.action_bar_up_description));
mTitleStyleRes = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
mSubtitleStyleRes = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
@@ -1191,6 +1195,27 @@ public class ActionBarView extends AbsActionBarView {
}
@Override
+ public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
+ onPopulateAccessibilityEvent(event);
+ return true;
+ }
+
+ @Override
+ public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
+ super.onPopulateAccessibilityEvent(event);
+ final CharSequence cdesc = getContentDescription();
+ if (!TextUtils.isEmpty(cdesc)) {
+ event.getText().add(cdesc);
+ }
+ }
+
+ @Override
+ public boolean dispatchHoverEvent(MotionEvent event) {
+ // Don't allow children to hover; we want this to be treated as a single component.
+ return onHoverEvent(event);
+ }
+
+ @Override
protected void onFinishInflate() {
mUpView = findViewById(com.android.internal.R.id.up);
mIconView = (ImageView) findViewById(com.android.internal.R.id.home);