From f4715974b80d06993342ca62b1298e4d90e2fab8 Mon Sep 17 00:00:00 2001 From: Vadim Tryshev Date: Fri, 8 May 2015 17:21:03 -0700 Subject: [PATCH] Fixing accessibility scrolling events generated by PagedView: 1. Not generating scroll events from snapToPage(). It already gets generated from computeScrollHelper(). 2. Not setting action because doing so is not mentioned here: http://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html. 3. Not generating scroll event when the page stays same (before it was generated, say, when we simply returned from the AllApps view to Workspace). 4. From/To index is not the old and new page numbers; they are indices of the first and last item; in our case, the item is the page, and both FromIndex and ToIndex should be set to this page number. Bug: 18761184 Change-Id: I3dadf816c3d45b8bd42a13930344874584467499 --- src/com/android/launcher3/PagedView.java | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java index 0739babea1..f77ad0564f 100644 --- a/src/com/android/launcher3/PagedView.java +++ b/src/com/android/launcher3/PagedView.java @@ -712,21 +712,15 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc AccessibilityManager am = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); if (am.isEnabled()) { - AccessibilityEvent ev = - AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED); - ev.setItemCount(getChildCount()); - ev.setFromIndex(mCurrentPage); - ev.setToIndex(getNextPage()); + if (mCurrentPage != getNextPage()) { + AccessibilityEvent ev = + AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED); + ev.setItemCount(getChildCount()); + ev.setFromIndex(getNextPage()); + ev.setToIndex(getNextPage()); - final int action; - if (getNextPage() >= mCurrentPage) { - action = AccessibilityNodeInfo.ACTION_SCROLL_FORWARD; - } else { - action = AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD; + sendAccessibilityEventUnchecked(ev); } - - ev.setAction(action); - sendAccessibilityEventUnchecked(ev); } } @@ -2301,8 +2295,6 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc focusedChild.clearFocus(); } - sendScrollAccessibilityEvent(); - pageBeginMoving(); awakenScrollBars(duration); if (immediate) {