Limit workspace flings to one screen at a time.

This prevents users from scrolling left slightly, flinging right,
and scrolling by two screens as a result (and vice versa).

Change-Id: I04c60438c022b24defcd8e4cbedf1c6b07c24423
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index cb4ba11..7a17516 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -838,13 +838,20 @@
                 
                 final int screenWidth = getWidth();
                 final int whichScreen = (mScrollX + (screenWidth / 2)) / screenWidth;
+                final float scrolledPos = (float) mScrollX / screenWidth;
                 
                 if (velocityX > SNAP_VELOCITY && mCurrentScreen > 0) {
-                    // Fling hard enough to move left
-                    snapToScreen(Math.min(whichScreen, mCurrentScreen - 1));
+                    // Fling hard enough to move left.
+                    // Don't fling across more than one screen at a time.
+                    final int bound = scrolledPos < whichScreen ?
+                            mCurrentScreen - 1 : mCurrentScreen;
+                    snapToScreen(Math.min(whichScreen, bound));
                 } else if (velocityX < -SNAP_VELOCITY && mCurrentScreen < getChildCount() - 1) {
                     // Fling hard enough to move right
-                    snapToScreen(Math.max(whichScreen, mCurrentScreen + 1));
+                    // Don't fling across more than one screen at a time.
+                    final int bound = scrolledPos > whichScreen ?
+                            mCurrentScreen + 1 : mCurrentScreen;
+                    snapToScreen(Math.max(whichScreen, bound));
                 } else {
                     snapToDestination();
                 }