Merge "fixed crash during animation to all apps"
diff --git a/res/layout-xlarge/launcher.xml b/res/layout-xlarge/launcher.xml
index 0dd25d2..fa9c881 100644
--- a/res/layout-xlarge/launcher.xml
+++ b/res/layout-xlarge/launcher.xml
@@ -26,7 +26,7 @@
         layout="@layout/all_apps_tabbed"
         android:id="@+id/all_apps_view"
         android:layout_width="match_parent"
-        android:layout_height="500dip"
+        android:layout_height="550dip"
         android:layout_gravity="top"/>
 
     <!-- The workspace contains 5 screens of cells -->
diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml
index 8279492..9e98e46 100644
--- a/res/values-xlarge/dimens.xml
+++ b/res/values-xlarge/dimens.xml
@@ -17,4 +17,11 @@
 <resources>
     <dimen name="workspace_cell_width">76dip</dimen>
     <dimen name="workspace_cell_height">76dip</dimen>
+
+    <!-- horizontal spacing between mini screen thumbnails ie. in all
+         apps and in customization mode -->
+    <dimen name="smallScreenSpacing">10dip</dimen>
+
+    <!-- vertical spacing between edge of screen and mini screen thumbnails -->
+    <dimen name="smallScreenVerticalMargin">20dip</dimen>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 38936ce..790f835 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -37,11 +37,4 @@
     
     <!-- delete_zone_size_full - button_bar_height_portrait -->
     <dimen name="delete_zone_padding">14dip</dimen>
-
-    <!-- horizontal spacing between mini screen thumbnails ie. in all
-         apps and in customization mode -->
-    <dimen name="smallScreenSpacing">10dip</dimen>
-
-    <!-- vertical spacing between edge of screen and mini screen thumbnails -->
-    <dimen name="smallScreenVerticalMargin">20dip</dimen>
 </resources>
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index 653f355..e975fa1 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -1135,14 +1135,17 @@
             ProgramFragment.Builder bf = new ProgramFragment.Builder(sRS);
             bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
                           ProgramFragment.Builder.Format.RGBA, 0);
+            bf.setVaryingColor(true);
             ProgramFragment pfTexMip = bf.create();
             pfTexMip.bindSampler(linear, 0);
 
+            bf.setVaryingColor(false);
             ProgramFragment pfTexNearest = bf.create();
             pfTexNearest.bindSampler(nearest, 0);
 
             bf.setTexture(ProgramFragment.Builder.EnvMode.MODULATE,
                           ProgramFragment.Builder.Format.ALPHA, 0);
+            bf.setVaryingColor(true);
             ProgramFragment pfTexMipAlpha = bf.create();
             pfTexMipAlpha.bindSampler(linear, 0);
 
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 2a8c573..2488e6e 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -764,7 +764,9 @@
         final int countX = mCountX;
         final int countY = mCountY;
 
-        pointToCellRounded(originX, originY, result);
+        // originX and originY give the top left of the cell, but pointToCellRounded
+        // compares center-to-center, so pass in the middle coordinates
+        pointToCellRounded(originX + (mCellWidth / 2), originY + (mCellHeight / 2), result);
 
         // If the item isn't fully on this screen, snap to the edges
         int rightOverhang = result[0] + spanX - countX;
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 35a767d..2bb1b7f 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -744,6 +744,20 @@
         return super.dispatchTouchEvent(ev);
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
+        if (disallowIntercept) {
+            // We need to make sure to cancel our long press if
+            // a scrollable widget takes over touch events
+            final View currentScreen = getChildAt(mCurrentScreen);
+            currentScreen.cancelLongPress();
+        }
+        super.requestDisallowInterceptTouchEvent(disallowIntercept);
+    }
+
     @Override
     public boolean onInterceptTouchEvent(MotionEvent ev) {
         final boolean workspaceLocked = mLauncher.isWorkspaceLocked();
@@ -1355,8 +1369,8 @@
     public void onDragOver(DragSource source, int x, int y, int xOffset, int yOffset,
             DragView dragView, Object dragInfo) {
 
-        ItemInfo item = (ItemInfo)dragInfo;
-        CellLayout currentLayout = getCurrentDropLayout();
+        final ItemInfo item = (ItemInfo)dragInfo;
+        final CellLayout currentLayout = getCurrentDropLayout();
 
         if (dragInfo instanceof LauncherAppWidgetInfo) {
             LauncherAppWidgetInfo widgetInfo = (LauncherAppWidgetInfo)dragInfo;
@@ -1379,6 +1393,17 @@
         int originX = x - xOffset;
         int originY = y - yOffset;
 
+        // If not dragging from the Workspace, the size of dragView might not match the cell size
+        if (!source.equals(this)) {
+            // Break the drag view up into evenly sized chunks based on its spans
+            int chunkWidth = dragView.getWidth() / item.spanX;
+            int chunkHeight = dragView.getHeight() / item.spanY;
+
+            // Adjust the origin for a cell centered at the top left chunk
+            originX += (chunkWidth - currentLayout.getCellWidth()) / 2;
+            originY += (chunkHeight - currentLayout.getCellHeight()) / 2;
+        }
+
         final View child = (mDragInfo == null) ? null : mDragInfo.cell;
         currentLayout.visualizeDropLocation(child, originX, originY, item.spanX, item.spanY);
     }
diff --git a/src/com/android/launcher2/allapps.rs b/src/com/android/launcher2/allapps.rs
index 0c55eea..64c99db 100644
--- a/src/com/android/launcher2/allapps.rs
+++ b/src/com/android/launcher2/allapps.rs
@@ -235,7 +235,6 @@
 static void
 draw_home_button()
 {
-    color(1.0f, 1.0f, 1.0f, 1.0f);
     rsgBindTexture(gPFTexNearest, 0, gHomeButton);
 
     float w = rsgGetWidth();
@@ -282,7 +281,6 @@
 
     vpConstants->Position.z = p;
 
-    color(1.0f, 1.0f, 1.0f, 1.0f);
     for (row = -5; row < 15; row++) {
         float y = yoff - ((-rowFrac + row) * rowHeight);