diff options
author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-09-23 13:26:18 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-09-23 13:26:18 -0700 |
commit | 83a559e78f57703645066c822a1ec7257c06ba56 (patch) | |
tree | d2e27c4300e5afc259f445df2f4fbef3ce679bf0 /core | |
parent | e7d70563839bbf0ce8d548fe7223229ec2ecd635 (diff) | |
parent | b84b94e1a04cd1f396dd6fef98d65ca1a2729c92 (diff) | |
download | frameworks_base-83a559e78f57703645066c822a1ec7257c06ba56.zip frameworks_base-83a559e78f57703645066c822a1ec7257c06ba56.tar.gz frameworks_base-83a559e78f57703645066c822a1ec7257c06ba56.tar.bz2 |
Merge "Scroll accessibility events should not populate text."
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/View.java | 6 | ||||
-rw-r--r-- | core/java/android/view/ViewGroup.java | 8 | ||||
-rw-r--r-- | core/java/android/widget/AbsListView.java | 10 | ||||
-rw-r--r-- | core/java/android/widget/AdapterView.java | 31 |
4 files changed, 26 insertions, 29 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index ec9a2d0..3c67521 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -3894,6 +3894,12 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal * Note: Called from the default {@link AccessibilityDelegate}. */ boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) { + // Do not populate text to scroll events. They describe position change + // and usually come from container with a lot of text which is not very + // informative for accessibility purposes. Also they are fired frequently. + if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) { + return true; + } onPopulateAccessibilityEvent(event); return false; } diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java index b678c7d..a29cf13 100644 --- a/core/java/android/view/ViewGroup.java +++ b/core/java/android/view/ViewGroup.java @@ -2176,13 +2176,15 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager @Override boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) { - // We first get a chance to populate the event. - super.dispatchPopulateAccessibilityEventInternal(event); + boolean handled = super.dispatchPopulateAccessibilityEventInternal(event); + if (handled) { + return handled; + } // Let our children have a shot in populating the event. for (int i = 0, count = getChildCount(); i < count; i++) { View child = getChildAt(i); if ((child.mViewFlags & VISIBILITY_MASK) == VISIBLE) { - boolean handled = getChildAt(i).dispatchPopulateAccessibilityEvent(event); + handled = getChildAt(i).dispatchPopulateAccessibilityEvent(event); if (handled) { return handled; } diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index ba89ef3..7b8c7f2 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -1304,16 +1304,6 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te } } - @Override - public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - // Do not append text content to scroll events they are fired frequently - // and the client has already received another event type with the text. - if (event.getEventType() != AccessibilityEvent.TYPE_VIEW_SCROLLED) { - super.dispatchPopulateAccessibilityEvent(event); - } - return false; - } - /** * Indicates whether the children's drawing cache is used during a scroll. * By default, the drawing cache is enabled but this will consume more memory. diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java index 5392c2e..a4b4e78 100644 --- a/core/java/android/widget/AdapterView.java +++ b/core/java/android/widget/AdapterView.java @@ -881,31 +881,30 @@ public abstract class AdapterView<T extends Adapter> extends ViewGroup { @Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { - // This is an exceptional case which occurs when a window gets the - // focus and sends a focus event via its focused child to announce - // current focus/selection. AdapterView fires selection but not focus - // events so we change the event type here. - if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) { - event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED); + final int eventType = event.getEventType(); + switch (eventType) { + case AccessibilityEvent.TYPE_VIEW_SCROLLED: + // Do not populate the text of scroll events. + return true; + case AccessibilityEvent.TYPE_VIEW_FOCUSED: + // This is an exceptional case which occurs when a window gets the + // focus and sends a focus event via its focused child to announce + // current focus/selection. AdapterView fires selection but not focus + // events so we change the event type here. + if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_FOCUSED) { + event.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED); + } + break; } View selectedView = getSelectedView(); if (selectedView != null && selectedView.getVisibility() == VISIBLE) { - // We first get a chance to populate the event. - onPopulateAccessibilityEvent(event); + getSelectedView().dispatchPopulateAccessibilityEvent(event); } return false; } @Override - public void onPopulateAccessibilityEvent(AccessibilityEvent event) { - super.onPopulateAccessibilityEvent(event); - // We send selection events only from AdapterView to avoid - // generation of such event for each child. - getSelectedView().dispatchPopulateAccessibilityEvent(event); - } - - @Override public boolean onRequestSendAccessibilityEvent(View child, AccessibilityEvent event) { if (super.onRequestSendAccessibilityEvent(child, event)) { // Add a record for ourselves as well. |