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
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 0739bab..f77ad05 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -712,21 +712,15 @@
         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 @@
             focusedChild.clearFocus();
         }
 
-        sendScrollAccessibilityEvent();
-
         pageBeginMoving();
         awakenScrollBars(duration);
         if (immediate) {