Fixing issue where we weren't picking up minute touch movements. (3413433)

Change-Id: I5920e5e7ad6fa758093deeb545d6d3b81f730198
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 6138b86..877f9d9 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -79,6 +79,7 @@
 
     private float mDownMotionX;
     protected float mLastMotionX;
+    protected float mLastMotionXRemainder;
     protected float mLastMotionY;
     private int mLastScreenCenter = -1;
 
@@ -761,6 +762,7 @@
                 mDownMotionX = x;
                 mLastMotionX = x;
                 mLastMotionY = y;
+                mLastMotionXRemainder = 0;
                 mActivePointerId = ev.getPointerId(0);
                 mAllowLongPress = true;
 
@@ -854,6 +856,7 @@
                 // Scroll if the user moved far enough along the X axis
                 mTouchState = TOUCH_STATE_SCROLLING;
                 mLastMotionX = x;
+                mLastMotionXRemainder = 0;
                 mTouchX = mScrollX;
                 mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
                 pageBeginMoving();
@@ -934,6 +937,7 @@
 
             // Remember where the motion event started
             mDownMotionX = mLastMotionX = ev.getX();
+            mLastMotionXRemainder = 0;
             mActivePointerId = ev.getPointerId(0);
             if (mTouchState == TOUCH_STATE_SCROLLING) {
                 pageBeginMoving();
@@ -945,17 +949,21 @@
                 // Scroll to follow the motion event
                 final int pointerIndex = ev.findPointerIndex(mActivePointerId);
                 final float x = ev.getX(pointerIndex);
-                final int deltaX = (int) (mLastMotionX - x);
-                mLastMotionX = x;
+                final float deltaX = mLastMotionX + mLastMotionXRemainder - x;
 
-                if (deltaX != 0) {
+                // Only scroll and update mLastMotionX if we have moved some discrete amount.  We
+                // keep the remainder because we are actually testing if we've moved from the last
+                // scrolled position (which is discrete).
+                if (Math.abs(deltaX) >= 1.0f) {
                     mTouchX += deltaX;
                     mSmoothingTime = System.nanoTime() / NANOTIME_DIV;
                     if (!mDeferScrollUpdate) {
-                        scrollBy(deltaX, 0);
+                        scrollBy((int) deltaX, 0);
                     } else {
                         invalidate();
                     }
+                    mLastMotionX = x;
+                    mLastMotionXRemainder = deltaX - (int) deltaX;
                 } else {
                     awakenScrollBars();
                 }
@@ -1057,6 +1065,7 @@
             final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
             mLastMotionX = mDownMotionX = ev.getX(newPointerIndex);
             mLastMotionY = ev.getY(newPointerIndex);
+            mLastMotionXRemainder = 0;
             mActivePointerId = ev.getPointerId(newPointerIndex);
             if (mVelocityTracker != null) {
                 mVelocityTracker.clear();