diff options
| author | Svetoslav Ganov <svetoslavganov@google.com> | 2011-09-22 19:26:56 -0700 |
|---|---|---|
| committer | Svetoslav Ganov <svetoslavganov@google.com> | 2011-09-22 19:55:47 -0700 |
| commit | b84b94e1a04cd1f396dd6fef98d65ca1a2729c92 (patch) | |
| tree | 868cc12ef3355e3520e7e1c2f77c39085afe8807 /core/java/android/widget/AdapterView.java | |
| parent | 04ef5b8dd7262ee90b56df9c992f103695d0a21c (diff) | |
Scroll accessibility events should not populate text.
Scroll events are used to report position change and should not
contain the text content of the view that fires them because it
is usiually a containter for many other views and the text will
be long and not informative for accessibility purposes. Also
such evens are fired relatively frequently. If a client wants
to fetch some textual content for a scroll event he can use
the interrogation APIs.
bug:5352059
Change-Id: I43e02aca895c8ab16ba82ebe1cee3aea8ce7711a
Diffstat (limited to 'core/java/android/widget/AdapterView.java')
| -rw-r--r-- | core/java/android/widget/AdapterView.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/core/java/android/widget/AdapterView.java b/core/java/android/widget/AdapterView.java index 5392c2e5f5ad..a4b4e783def9 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. |
