Merge branch 'master' into honeycomb-release
diff --git a/res/values-xlarge/colors.xml b/res/values-xlarge/colors.xml
deleted file mode 100644
index d4c6fad..0000000
--- a/res/values-xlarge/colors.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-**
-** Copyright 2010, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-**     http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
--->
-<resources>
-    <color name="app_info_filter">#A50000FE</color>
-    <color name="dimmed_view_color">#FF7F7F7F</color>
-</resources>
\ No newline at end of file
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 9b9700f..24e1b67 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -28,4 +28,8 @@
 
     <color name="gesture_color">#ff0563c1</color>
     <color name="uncertain_gesture_color">#ff848484</color>
+
+    <color name="app_info_filter">#A50000FE</color>
+    <color name="dimmed_view_color">#FF7F7F7F</color>
+
 </resources>
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index d26b2f9..164d7c5 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -18,6 +18,7 @@
 
 import com.android.launcher.R;
 
+import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
 import android.animation.ValueAnimator.AnimatorUpdateListener;
 import android.app.WallpaperManager;
@@ -38,7 +39,6 @@
 import android.view.ViewGroup;
 import android.view.animation.Animation;
 import android.view.animation.DecelerateInterpolator;
-import android.view.animation.Interpolator;
 import android.view.animation.LayoutAnimationController;
 
 public class CellLayout extends ViewGroup implements Dimmable {
@@ -161,7 +161,7 @@
 
         mDragRectDrawable = res.getDrawable(R.drawable.rounded_rect_green);
         mCrosshairsDrawable = res.getDrawable(R.drawable.gardening_crosshairs);
-        Interpolator interp = new DecelerateInterpolator(2.5f); // Quint ease out
+        TimeInterpolator interp = new DecelerateInterpolator(2.5f); // Quint ease out
 
         // Set up the animation for fading the crosshairs in and out
         int animDuration = res.getInteger(R.integer.config_crosshairsFadeInTime);
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 578bbcc..2a96736 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -649,14 +649,14 @@
 
                 // check if this can be the beginning of a tap on the side of the pages
                 // to scroll the current page
-                if ((mTouchState != TOUCH_STATE_PREV_PAGE) &&
+                if ((mTouchState != TOUCH_STATE_PREV_PAGE) && !handlePagingClicks() &&
                         (mTouchState != TOUCH_STATE_NEXT_PAGE)) {
                     if (getChildCount() > 0) {
                         int width = getMeasuredWidth();
                         int offset = getRelativeChildOffset(mCurrentPage);
-                        if (x < offset) {
+                        if (x < offset - mPageSpacing) {
                             mTouchState = TOUCH_STATE_PREV_PAGE;
-                        } else if (x > (width - offset)) {
+                        } else if (x > (width - offset + mPageSpacing)) {
                             mTouchState = TOUCH_STATE_NEXT_PAGE;
                         }
                     }
@@ -741,6 +741,10 @@
         }
     }
 
+    protected boolean handlePagingClicks() {
+        return false;
+    }
+
     @Override
     public boolean onTouchEvent(MotionEvent ev) {
         if (mVelocityTracker == null) {
@@ -835,7 +839,7 @@
                     mVelocityTracker.recycle();
                     mVelocityTracker = null;
                 }
-            } else if (mTouchState == TOUCH_STATE_PREV_PAGE) {
+            } else if (mTouchState == TOUCH_STATE_PREV_PAGE && !handlePagingClicks()) {
                 // at this point we have not moved beyond the touch slop
                 // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
                 // we can just page
@@ -845,7 +849,7 @@
                 } else {
                     snapToDestination();
                 }
-            } else if (mTouchState == TOUCH_STATE_NEXT_PAGE) {
+            } else if (mTouchState == TOUCH_STATE_NEXT_PAGE && !handlePagingClicks()) {
                 // at this point we have not moved beyond the touch slop
                 // (otherwise mTouchState would be TOUCH_STATE_SCROLLING), so
                 // we can just page
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 881fb59..6802966 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -89,6 +89,8 @@
 
     private boolean mWaitingToShrinkToBottom = false;
 
+    private boolean mPageMoving = false;
+
     /**
      * CellInfo for the cell that is currently being dragged
      */
@@ -207,6 +209,7 @@
         if (!(child instanceof CellLayout)) {
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
+        ((CellLayout) child).setOnInterceptTouchListener(this);
         super.addView(child, index, params);
     }
 
@@ -215,6 +218,7 @@
         if (!(child instanceof CellLayout)) {
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
+        ((CellLayout) child).setOnInterceptTouchListener(this);
         super.addView(child);
     }
 
@@ -223,6 +227,7 @@
         if (!(child instanceof CellLayout)) {
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
+        ((CellLayout) child).setOnInterceptTouchListener(this);
         super.addView(child, index);
     }
 
@@ -231,6 +236,7 @@
         if (!(child instanceof CellLayout)) {
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
+        ((CellLayout) child).setOnInterceptTouchListener(this);
         super.addView(child, width, height);
     }
 
@@ -239,6 +245,7 @@
         if (!(child instanceof CellLayout)) {
             throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
         }
+        ((CellLayout) child).setOnInterceptTouchListener(this);
         super.addView(child, params);
     }
 
@@ -367,6 +374,14 @@
         if (mIsSmall || mIsInUnshrinkAnimation) {
             mLauncher.onWorkspaceClick((CellLayout) v);
             return true;
+        } else if (!mPageMoving) {
+            if (v == getChildAt(mCurrentPage - 1)) {
+                snapToPage(mCurrentPage - 1);
+                return true;
+            } else if (v == getChildAt(mCurrentPage + 1)) {
+                snapToPage(mCurrentPage + 1);
+                return true;
+            }
         }
         return false;
     }
@@ -399,15 +414,16 @@
             enableChildrenCache(mCurrentPage - 1, mCurrentPage + 1);
         }
         showOutlines();
+        mPageMoving = true;
     }
 
     protected void onPageEndMoving() {
         clearChildrenCache();
-
         // Hide the outlines, as long as we're not dragging
         if (!mDragController.dragging()) {
             hideOutlines();
         }
+        mPageMoving = false;
     }
 
     @Override
@@ -444,10 +460,6 @@
         }
     }
 
-    private float getScaleXForRotation(float degrees) {
-        return (float) (1.0f / Math.cos(Math.PI * degrees / 180.0f));
-    }
-
     public void showOutlines() {
         if (mBackgroundFadeOut != null) mBackgroundFadeOut.cancel();
         if (mBackgroundFadeIn != null) mBackgroundFadeIn.cancel();
@@ -479,62 +491,20 @@
 
     @Override
     protected void screenScrolled(int screenCenter) {
-        CellLayout cur = (CellLayout) getChildAt(mCurrentPage);
-        CellLayout toRight = (CellLayout) getChildAt(mCurrentPage + 1);
-        CellLayout toLeft = (CellLayout) getChildAt(mCurrentPage - 1);
-
-        for (int i = 0; i < mCurrentPage - 1; i++) {
+        final int halfScreenSize = getMeasuredWidth() / 2;
+        for (int i = 0; i < getChildCount(); i++) {
             View v = getChildAt(i);
             if (v != null) {
-                v.setRotationY(WORKSPACE_ROTATION);
-                v.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION));
-            }
-        }
-        for (int i = mCurrentPage + 1; i < getChildCount(); i++) {
-            View v = getChildAt(i);
-            if (v != null) {
-                v.setRotationY(-WORKSPACE_ROTATION);
-                v.setScaleX(getScaleXForRotation(-WORKSPACE_ROTATION));
-            }
-        }
+                int totalDistance = v.getMeasuredWidth() + mPageSpacing;
+                int delta = screenCenter - (getChildOffset(i) -
+                        getRelativeChildOffset(i) + halfScreenSize);
 
-        int halfScreenSize = getMeasuredWidth() / 2;
-        int pageWidth = cur.getMeasuredWidth();
-        int delta = screenCenter - (getChildOffset(mCurrentPage) -
-                getRelativeChildOffset(mCurrentPage) + halfScreenSize);
+                float scrollProgress = delta/(totalDistance*1.0f);
+                scrollProgress = Math.min(scrollProgress, 1.0f);
+                scrollProgress = Math.max(scrollProgress, -1.0f);
 
-        float scrollProgress = Math.abs(delta/(pageWidth*1.0f + mPageSpacing));
-        boolean scrollRight = (delta <= 0);
-
-        float rotation;
-
-        if (scrollRight) {
-            rotation = -scrollProgress * WORKSPACE_ROTATION;
-            cur.setRotationY(rotation);
-            cur.setScaleX(getScaleXForRotation(rotation));
-
-            if (toLeft != null) {
-                rotation = WORKSPACE_ROTATION * (1 - scrollProgress);
-                toLeft.setRotationY(rotation);
-                toLeft.setScaleX(getScaleXForRotation(rotation));
-            }
-            if (toRight != null) {
-                toRight.setRotationY(-WORKSPACE_ROTATION);
-                toRight.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION));
-            }
-        } else {
-            rotation = scrollProgress * WORKSPACE_ROTATION;
-            cur.setRotationY(rotation);
-            cur.setScaleX(getScaleXForRotation(rotation));
-
-            if (toRight != null) {
-                rotation = -WORKSPACE_ROTATION * (1 - scrollProgress);
-                toRight.setRotationY(rotation);
-                toRight.setScaleX(getScaleXForRotation(rotation));
-            }
-            if (toLeft != null) {
-                toLeft.setRotationY(WORKSPACE_ROTATION);
-                toLeft.setScaleX(getScaleXForRotation(WORKSPACE_ROTATION));
+                float rotation = WORKSPACE_ROTATION * scrollProgress;
+                v.setRotationY(rotation);
             }
         }
     }
@@ -764,7 +734,6 @@
             }
             // increment newX for the next screen
             newX += scaledPageWidth + extraScaledSpacing;
-            cl.setOnInterceptTouchListener(this);
         }
         setChildrenDrawnWithCacheEnabled(true);
     }
@@ -781,6 +750,11 @@
         unshrink(newCurrentPage);
     }
 
+    @Override
+    protected boolean handlePagingClicks() {
+        return true;
+    }
+
     private void unshrink(int newCurrentPage) {
         if (mIsSmall) {
             int newX = getChildOffset(newCurrentPage) - getRelativeChildOffset(newCurrentPage);