Merge "Fixing issue where shortcuts and widgets were not being removed when the package was uninstalled (Bug 2657997, Bug 6335843)" into jb-dev
diff --git a/res/values-land/dimens.xml b/res/values-land/dimens.xml
index 69d68be..e94d780 100644
--- a/res/values-land/dimens.xml
+++ b/res/values-land/dimens.xml
@@ -20,8 +20,6 @@
     <dimen name="toolbar_button_horizontal_padding">4dip</dimen>
 
 <!-- Workspace -->
-    <dimen name="workspace_cell_width">106dp</dimen>
-    <dimen name="workspace_cell_height">74dp</dimen>
     <dimen name="hotseat_cell_width">64dp</dimen>
     <dimen name="hotseat_cell_height">58dp</dimen>
     <!-- We really want the page spacing to be the max of either the button bar
@@ -77,4 +75,10 @@
 <!-- Folders -->
     <!-- The size of the image which sits behind the preview of the folder contents -->
     <dimen name="folder_preview_size">58dp</dimen>
+
+<!-- Workspace cell size -->
+    <dimen name="workspace_cell_width">@dimen/workspace_cell_width_land</dimen>
+    <dimen name="workspace_cell_height">@dimen/workspace_cell_height_land</dimen>
+    <dimen name="workspace_width_gap">@dimen/workspace_width_gap_land</dimen>
+    <dimen name="workspace_height_gap">@dimen/workspace_height_gap_land</dimen>
 </resources>
diff --git a/res/values-port/dimens.xml b/res/values-port/dimens.xml
index 193f331..969d335 100644
--- a/res/values-port/dimens.xml
+++ b/res/values-port/dimens.xml
@@ -50,4 +50,10 @@
     <dimen name="apps_customize_widget_cell_height_gap">10dp</dimen>
     <integer name="apps_customize_widget_cell_count_x">2</integer>
     <integer name="apps_customize_widget_cell_count_y">3</integer>
+
+<!-- Workspace cell size -->
+    <dimen name="workspace_cell_width">@dimen/workspace_cell_width_port</dimen>
+    <dimen name="workspace_cell_height">@dimen/workspace_cell_height_port</dimen>
+    <dimen name="workspace_width_gap">@dimen/workspace_width_gap_port</dimen>
+    <dimen name="workspace_height_gap">@dimen/workspace_height_gap_port</dimen>
 </resources>
diff --git a/res/values-sw340dp/dimens.xml b/res/values-sw340dp/dimens.xml
index 8f5a367..42fbb47 100644
--- a/res/values-sw340dp/dimens.xml
+++ b/res/values-sw340dp/dimens.xml
@@ -18,10 +18,6 @@
     <!-- Drag padding to add to the bottom of drop targets -->
     <dimen name="drop_target_drag_padding">20dp</dimen>
 
-<!-- Workspace -->
-    <dimen name="workspace_width_gap">0dp</dimen>
-    <dimen name="workspace_height_gap">0dp</dimen>
-
 <!-- Hotseat -->
     <dimen name="hotseat_width_gap">0dp</dimen>
     <dimen name="hotseat_height_gap">0dp</dimen>
@@ -35,12 +31,18 @@
     <dimen name="button_bar_height_plus_padding">80dp</dimen>
 
 <!-- CellLayout padding land / port-->
-    <dimen name="cell_layout_left_padding_portrait">8dp</dimen>
-    <dimen name="cell_layout_left_padding_landscape">8dp</dimen>
-    <dimen name="cell_layout_right_padding_portrait">8dp</dimen>
-    <dimen name="cell_layout_right_padding_landscape">8dp</dimen>
-    <dimen name="cell_layout_top_padding_portrait">8dp</dimen>
-    <dimen name="cell_layout_top_padding_landscape">8dp</dimen>
-    <dimen name="cell_layout_bottom_padding_portrait">8dp</dimen>
-    <dimen name="cell_layout_bottom_padding_landscape">8dp</dimen>
+    <dimen name="cell_layout_left_padding_port">8dp</dimen>
+    <dimen name="cell_layout_left_padding_land">8dp</dimen>
+    <dimen name="cell_layout_right_padding_port">8dp</dimen>
+    <dimen name="cell_layout_right_padding_land">8dp</dimen>
+    <dimen name="cell_layout_top_padding_port">8dp</dimen>
+    <dimen name="cell_layout_top_padding_land">8dp</dimen>
+    <dimen name="cell_layout_bottom_padding_port">8dp</dimen>
+    <dimen name="cell_layout_bottom_padding_land">8dp</dimen>
+
+<!-- Workspace cell size -->
+    <dimen name="workspace_width_gap_land">0dp</dimen>
+    <dimen name="workspace_width_gap_port">0dp</dimen>
+    <dimen name="workspace_height_gap_land">0dp</dimen>
+    <dimen name="workspace_height_gap_port">0dp</dimen>
 </resources>
diff --git a/res/values-sw600dp-land/dimens.xml b/res/values-sw600dp-land/dimens.xml
index 7db0a8a..3e18417 100644
--- a/res/values-sw600dp-land/dimens.xml
+++ b/res/values-sw600dp-land/dimens.xml
@@ -22,12 +22,6 @@
 <!-- Hotseat -->
     <dimen name="hotseat_cell_width">75dp</dimen>
     <dimen name="hotseat_cell_height">75dp</dimen>
-
-<!-- Workspace -->
-    <dimen name="workspace_cell_width">96dp</dimen>
-    <dimen name="workspace_cell_height">86dp</dimen>
-    <dimen name="workspace_width_gap">32dp</dimen>
-    <dimen name="workspace_height_gap">0dp</dimen>
     <dimen name="workspace_icon_text_size">11sp</dimen>
 
 <!-- Folders -->
diff --git a/res/values-sw600dp-port/dimens.xml b/res/values-sw600dp-port/dimens.xml
index 9565992..c813725 100644
--- a/res/values-sw600dp-port/dimens.xml
+++ b/res/values-sw600dp-port/dimens.xml
@@ -17,8 +17,6 @@
 <resources>
 <!-- Workspace -->
     <integer name="app_icon_scale_percent">-1</integer>
-    <dimen name="workspace_width_gap">0dp</dimen>
-    <dimen name="workspace_height_gap">32dp</dimen>
 
 <!-- AppsCustomize -->
     <dimen name="apps_customize_cell_width">96dp</dimen>
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index a0d7ec8..0797632 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -20,10 +20,6 @@
     <dimen name="app_icon_drawable_padding">3dp</dimen>
     <dimen name="app_icon_padding_top">4dp</dimen>
 
-<!-- Workspace -->
-    <dimen name="workspace_cell_width">96dp</dimen>
-    <dimen name="workspace_cell_height">96dp</dimen>
-
 <!-- Hotseat -->
     <dimen name="hotseat_width_gap">-1dp</dimen>
     <dimen name="hotseat_height_gap">-1dp</dimen>
@@ -50,4 +46,15 @@
     <dimen name="apps_customize_tab_bar_margin_top">8dp</dimen>
     <dimen name="apps_customize_widget_cell_width_gap">36dp</dimen>
     <dimen name="apps_customize_widget_cell_height_gap">36dp</dimen>
+
+<!-- Workspace cell size -->
+    <dimen name="workspace_cell_width_land">96dp</dimen>
+    <dimen name="workspace_cell_width_port">96dp</dimen>
+    <dimen name="workspace_cell_height_land">86dp</dimen>
+    <dimen name="workspace_cell_height_port">96dp</dimen>
+    <dimen name="workspace_width_gap_land">32dp</dimen>
+    <dimen name="workspace_width_gap_port">0dp</dimen>
+    <dimen name="workspace_height_gap_land">0dp</dimen>
+    <dimen name="workspace_height_gap_port">32dp</dimen>
+
 </resources>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 2d39fc7..8252450 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -22,8 +22,6 @@
     <dimen name="apps_customize_pageLayoutPaddingRight">16dp</dimen>
 
 <!-- Workspace -->
-    <dimen name="workspace_width_gap">32dp</dimen>
-    <dimen name="workspace_height_gap">2dp</dimen>
     <dimen name="workspace_page_spacing">50dp</dimen>
 
     <!-- the area at the edge of the screen that makes the workspace go left
diff --git a/res/values-sw720dp-port/dimens.xml b/res/values-sw720dp-port/dimens.xml
index 9a0261b..9cf37ff 100644
--- a/res/values-sw720dp-port/dimens.xml
+++ b/res/values-sw720dp-port/dimens.xml
@@ -31,8 +31,6 @@
     <!-- the area at the edge of the screen that makes the workspace go left
          or right while you're dragging. -->
     <dimen name="scroll_zone">40dp</dimen>
-    <dimen name="workspace_width_gap">0dp</dimen>
-    <dimen name="workspace_height_gap">32dp</dimen>
     <dimen name="workspace_page_spacing">24dp</dimen>
 
     <integer name="apps_customize_cling_focused_x">2</integer>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index dc1c65a..37f62b8 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -24,8 +24,6 @@
     <!-- This should be @dimen/qsb_bar_height - @dimen/workspace_top_padding
          to fix the extra space given to draw portals -->
     <dimen name="workspace_content_large_only_top_margin">36dp</dimen>
-    <dimen name="workspace_cell_width">96dip</dimen>
-    <dimen name="workspace_cell_height">96dip</dimen>
 
     <dimen name="folder_cell_width">96dp</dimen>
     <dimen name="folder_cell_height">96dp</dimen>
@@ -55,14 +53,14 @@
     <dimen name="dragViewOffsetY">0dp</dimen>
 
 <!-- CellLayout padding land / port-->
-    <dimen name="cell_layout_left_padding_portrait">15dp</dimen>
-    <dimen name="cell_layout_left_padding_landscape">24dp</dimen>
-    <dimen name="cell_layout_right_padding_portrait">15dp</dimen>
-    <dimen name="cell_layout_right_padding_landscape">24dp</dimen>
-    <dimen name="cell_layout_top_padding_portrait">25dp</dimen>
-    <dimen name="cell_layout_top_padding_landscape">12dp</dimen>
-    <dimen name="cell_layout_bottom_padding_portrait">25dp</dimen>
-    <dimen name="cell_layout_bottom_padding_landscape">12dp</dimen>
+    <dimen name="cell_layout_left_padding_port">15dp</dimen>
+    <dimen name="cell_layout_left_padding_land">24dp</dimen>
+    <dimen name="cell_layout_right_padding_port">15dp</dimen>
+    <dimen name="cell_layout_right_padding_land">24dp</dimen>
+    <dimen name="cell_layout_top_padding_port">25dp</dimen>
+    <dimen name="cell_layout_top_padding_land">12dp</dimen>
+    <dimen name="cell_layout_bottom_padding_port">25dp</dimen>
+    <dimen name="cell_layout_bottom_padding_land">12dp</dimen>
 
 <!-- Workspace padding -->
     <dimen name="workspace_left_padding_port">0dp</dimen>
@@ -73,4 +71,14 @@
     <dimen name="workspace_top_padding_land">@dimen/workspace_content_large_only_top_margin</dimen>
     <dimen name="workspace_bottom_padding_port">0dp</dimen>
     <dimen name="workspace_bottom_padding_land">0dp</dimen>
+
+<!-- Workspace cell size -->
+    <dimen name="workspace_cell_width_land">96dp</dimen>
+    <dimen name="workspace_cell_width_port">96dp</dimen>
+    <dimen name="workspace_cell_height_land">96dp</dimen>
+    <dimen name="workspace_cell_height_port">96dp</dimen>
+    <dimen name="workspace_width_gap_land">32dp</dimen>
+    <dimen name="workspace_width_gap_port">0dp</dimen>
+    <dimen name="workspace_height_gap_land">2dp</dimen>
+    <dimen name="workspace_height_gap_port">32dp</dimen>
 </resources>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index ff17ec4..d3b9c1e 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -30,10 +30,6 @@
     <dimen name="qsb_padding_left">0dp</dimen>
     <dimen name="qsb_padding_right">0dp</dimen>
     <dimen name="search_bar_height">40dp</dimen>
-    <dimen name="workspace_cell_width">80dp</dimen>
-    <dimen name="workspace_cell_height">100dp</dimen>
-    <dimen name="workspace_width_gap">-1dp</dimen>
-    <dimen name="workspace_height_gap">-1dp</dimen>
     <dimen name="workspace_max_gap">16dp</dimen>
     <dimen name="folder_cell_width">74dp</dimen>
     <dimen name="folder_cell_height">82dp</dimen>
@@ -140,4 +136,13 @@
     <dimen name="workspace_bottom_padding_port">@dimen/button_bar_height</dimen>
     <dimen name="workspace_bottom_padding_land">0dp</dimen>
 
+<!-- Workspace cell size -->
+    <dimen name="workspace_cell_width_land">106dp</dimen>
+    <dimen name="workspace_cell_width_port">80dp</dimen>
+    <dimen name="workspace_cell_height_land">74dp</dimen>
+    <dimen name="workspace_cell_height_port">100dp</dimen>
+    <dimen name="workspace_width_gap_land">-1dp</dimen>
+    <dimen name="workspace_width_gap_port">-1dp</dimen>
+    <dimen name="workspace_height_gap_land">-1dp</dimen>
+    <dimen name="workspace_height_gap_port">-1dp</dimen>
 </resources>
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 01c08c9..7a2c247 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -164,8 +164,9 @@
     }
 
      public boolean onInterceptTouchEvent(MotionEvent ev) {
-         // If we are mid transition then intercept touch events here so we can ignore them
-         if (mInTransition) {
+         // If we are mid transitioning to the workspace, then intercept touch events here so we
+         // can ignore them, otherwise we just let all apps handle the touch events.
+         if (mInTransition && mTransitioningToWorkspace) {
              return true;
          }
          return super.onInterceptTouchEvent(ev);
@@ -173,11 +174,9 @@
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
-        // Allow touch events to fall through if we are transitioning to the workspace
-        if (mInTransition) {
-            if (mTransitioningToWorkspace) {
-                return super.onTouchEvent(event);
-            }
+        // Allow touch events to fall through to the workspace if we are transitioning there
+        if (mInTransition && mTransitioningToWorkspace) {
+            return super.onTouchEvent(event);
         }
 
         // Intercept all touch events up to the bottom of the AppsCustomizePane so they do not fall
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 10eb8f8..24e4047 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -58,8 +58,6 @@
     static final String TAG = "CellLayout";
 
     private Launcher mLauncher;
-    private int mOriginalCellWidth;
-    private int mOriginalCellHeight;
     private int mCellWidth;
     private int mCellHeight;
 
@@ -178,10 +176,8 @@
 
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CellLayout, defStyle, 0);
 
-        mOriginalCellWidth =
-            mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
-        mOriginalCellHeight =
-            mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
+        mCellWidth = a.getDimensionPixelSize(R.styleable.CellLayout_cellWidth, 10);
+        mCellHeight = a.getDimensionPixelSize(R.styleable.CellLayout_cellHeight, 10);
         mWidthGap = mOriginalWidthGap = a.getDimensionPixelSize(R.styleable.CellLayout_widthGap, 0);
         mHeightGap = mOriginalHeightGap = a.getDimensionPixelSize(R.styleable.CellLayout_heightGap, 0);
         mMaxGap = a.getDimensionPixelSize(R.styleable.CellLayout_maxGap, 0);
@@ -914,6 +910,54 @@
         return r;
     }
 
+    final int LANDSCAPE = 0;
+    final int PORTRAIT = 1;
+    void getCellLayoutMetrics(int measureWidth, int measureHeight, int orientation, Rect metrics) {
+        int numWidthGaps = mCountX - 1;
+        int numHeightGaps = mCountY - 1;
+
+        int widthGap;
+        int heightGap;
+        int cellWidth;
+        int cellHeight;
+        int paddingLeft;
+        int paddingRight;
+        int paddingTop;
+        int paddingBottom;
+
+        Resources res = getContext().getResources();
+        if (orientation == LANDSCAPE) {
+            cellWidth = res.getDimensionPixelSize(R.dimen.workspace_cell_width_land);
+            cellHeight = res.getDimensionPixelSize(R.dimen.workspace_cell_height_land);
+            widthGap = res.getDimensionPixelSize(R.dimen.workspace_width_gap_land);
+            heightGap = res.getDimensionPixelSize(R.dimen.workspace_height_gap_land);
+            paddingLeft = res.getDimensionPixelSize(R.dimen.cell_layout_left_padding_land);
+            paddingRight = res.getDimensionPixelSize(R.dimen.cell_layout_right_padding_land);
+            paddingTop = res.getDimensionPixelSize(R.dimen.cell_layout_top_padding_land);
+            paddingBottom = res.getDimensionPixelSize(R.dimen.cell_layout_bottom_padding_land);
+        } else {
+            // PORTRAIT
+            cellWidth = res.getDimensionPixelSize(R.dimen.workspace_cell_width_port);
+            cellHeight = res.getDimensionPixelSize(R.dimen.workspace_cell_height_port);
+            widthGap = res.getDimensionPixelSize(R.dimen.workspace_width_gap_port);
+            heightGap = res.getDimensionPixelSize(R.dimen.workspace_height_gap_port);
+            paddingLeft = res.getDimensionPixelSize(R.dimen.cell_layout_left_padding_port);
+            paddingRight = res.getDimensionPixelSize(R.dimen.cell_layout_right_padding_port);
+            paddingTop = res.getDimensionPixelSize(R.dimen.cell_layout_top_padding_port);
+            paddingBottom = res.getDimensionPixelSize(R.dimen.cell_layout_bottom_padding_port);
+        }
+
+        if (widthGap < 0 || heightGap < 0) {
+            int hSpace = measureWidth - paddingLeft - paddingRight;
+            int vSpace = measureHeight - paddingTop - paddingBottom;
+            int hFreeSpace = hSpace - (mCountX * cellWidth);
+            int vFreeSpace = vSpace - (mCountY * cellHeight);
+            widthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
+            heightGap = Math.min(mMaxGap, numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
+        }
+        metrics.set(cellWidth, cellHeight, widthGap, heightGap);
+    }
+
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         // TODO: currently ignoring padding
@@ -932,10 +976,10 @@
         int numHeightGaps = mCountY - 1;
 
         if (mOriginalWidthGap < 0 || mOriginalHeightGap < 0) {
-            int hSpace = widthSpecSize - getPaddingLeft() - getPaddingRight();
-            int vSpace = heightSpecSize - getPaddingTop() - getPaddingBottom();
-            int hFreeSpace = hSpace - (mCountX * mOriginalCellWidth);
-            int vFreeSpace = vSpace - (mCountY * mOriginalCellHeight);
+            int hSpace = widthSpecSize - mPaddingLeft - mPaddingRight;
+            int vSpace = heightSpecSize - mPaddingTop - mPaddingBottom;
+            int hFreeSpace = hSpace - (mCountX * mCellWidth);
+            int vFreeSpace = vSpace - (mCountY * mCellHeight);
             mWidthGap = Math.min(mMaxGap, numWidthGaps > 0 ? (hFreeSpace / numWidthGaps) : 0);
             mHeightGap = Math.min(mMaxGap,numHeightGaps > 0 ? (vFreeSpace / numHeightGaps) : 0);
             mShortcutsAndWidgets.setCellDimensions(mCellWidth, mCellHeight, mWidthGap, mHeightGap);
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index 4be4e8f..b9d7dd4 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -520,6 +520,7 @@
             mScrollState = SCROLL_OUTSIDE_ZONE;
             mScrollRunnable.setDirection(SCROLL_RIGHT);
             mDragScroller.onExitScrollArea();
+            mLauncher.getDragLayer().onExitScrollArea();
         }
     }
 
@@ -564,6 +565,7 @@
             if (mScrollState == SCROLL_OUTSIDE_ZONE) {
                 mScrollState = SCROLL_WAITING_IN_ZONE;
                 if (mDragScroller.onEnterScrollArea(x, y, SCROLL_LEFT)) {
+                    mLauncher.getDragLayer().onEnterScrollArea(SCROLL_LEFT);
                     mScrollRunnable.setDirection(SCROLL_LEFT);
                     mHandler.postDelayed(mScrollRunnable, delay);
                 }
@@ -572,6 +574,7 @@
             if (mScrollState == SCROLL_OUTSIDE_ZONE) {
                 mScrollState = SCROLL_WAITING_IN_ZONE;
                 if (mDragScroller.onEnterScrollArea(x, y, SCROLL_RIGHT)) {
+                    mLauncher.getDragLayer().onEnterScrollArea(SCROLL_RIGHT);
                     mScrollRunnable.setDirection(SCROLL_RIGHT);
                     mHandler.postDelayed(mScrollRunnable, delay);
                 }
@@ -834,6 +837,7 @@
                 mScrollState = SCROLL_OUTSIDE_ZONE;
                 mDistanceSinceScroll = 0;
                 mDragScroller.onExitScrollArea();
+                mLauncher.getDragLayer().onExitScrollArea();
 
                 if (isDragging()) {
                     // Force an update so that we can requeue the scroller if necessary
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index 69ed053..379e599 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -23,7 +23,11 @@
 import android.animation.ValueAnimator.AnimatorUpdateListener;
 import android.content.Context;
 import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
 import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
 import android.util.AttributeSet;
 import android.view.KeyEvent;
 import android.view.MotionEvent;
@@ -85,6 +89,9 @@
         setMotionEventSplittingEnabled(false);
         setChildrenDrawingOrderEnabled(true);
         setOnHierarchyChangeListener(this);
+
+        mLeftHoverDrawable = getResources().getDrawable(R.drawable.page_hover_left_holo);
+        mRightHoverDrawable = getResources().getDrawable(R.drawable.page_hover_right_holo);
     }
 
     public void setup(Launcher launcher, DragController controller) {
@@ -720,4 +727,44 @@
             return i;
         }
     }
+
+    private boolean mInScrollArea;
+    private Drawable mLeftHoverDrawable;
+    private Drawable mRightHoverDrawable;
+
+    void onEnterScrollArea(int direction) {
+        mInScrollArea = true;
+        invalidate();
+    }
+
+    void onExitScrollArea() {
+        mInScrollArea = false;
+        invalidate();
+    }
+
+    @Override
+    protected void dispatchDraw(Canvas canvas) {
+        super.dispatchDraw(canvas);
+
+        if (mInScrollArea && !LauncherApplication.isScreenLarge()) {
+            Workspace workspace = mLauncher.getWorkspace();
+            int width = workspace.getWidth();
+            Rect childRect = new Rect();
+            getDescendantRectRelativeToSelf(workspace.getChildAt(0), childRect);
+
+            int page = workspace.getNextPage();
+            CellLayout leftPage = (CellLayout) workspace.getChildAt(page - 1);
+            CellLayout rightPage = (CellLayout) workspace.getChildAt(page + 1);
+
+            if (leftPage != null && leftPage.getIsDragOverlapping()) {
+                mLeftHoverDrawable.setBounds(0, childRect.top,
+                        mLeftHoverDrawable.getIntrinsicWidth(), childRect.bottom);
+                mLeftHoverDrawable.draw(canvas);
+            } else if (rightPage != null && rightPage.getIsDragOverlapping()) {
+                mRightHoverDrawable.setBounds(width - mRightHoverDrawable.getIntrinsicWidth(),
+                        childRect.top, width, childRect.bottom);
+                mRightHoverDrawable.draw(canvas);
+            }
+        }
+    }
 }
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java
index eda82e0..66b3f5f 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/android/launcher2/InstallShortcutReceiver.java
@@ -113,6 +113,10 @@
             if (intent != null) {
                 if (intent.getAction() == null) {
                     intent.setAction(Intent.ACTION_VIEW);
+                } else if (intent.getAction().equals(Intent.ACTION_MAIN) &&
+                        intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
+                    intent.addFlags(
+                        Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                 }
 
                 // By default, we allow for duplicate entries (located in
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index ea974d3..967254b 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -568,7 +568,13 @@
         if (isWidgetDrop) {
             int appWidgetId = data != null ?
                     data.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1) : -1;
-            completeTwoStageWidgetDrop(resultCode, appWidgetId);
+            if (appWidgetId < 0) {
+                Log.e(TAG, "Error: appWidgetId (EXTRA_APPWIDGET_ID) was not returned from the \\" +
+                        "widget configuration activity.");
+                completeTwoStageWidgetDrop(RESULT_CANCELED, appWidgetId);
+            } else {
+                completeTwoStageWidgetDrop(resultCode, appWidgetId);
+            }
             return;
         }
 
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index 892faf0..6d1cc75 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1070,6 +1070,15 @@
                                 info = getShortcutInfo(c, context, iconTypeIndex,
                                         iconPackageIndex, iconResourceIndex, iconIndex,
                                         titleIndex);
+
+                                // App shortcuts that used to be automatically added to Launcher
+                                // didn't always have the correct intent flags set, so do that here
+                                if (intent.getAction().equals(Intent.ACTION_MAIN) &&
+                                        intent.getCategories().contains(Intent.CATEGORY_LAUNCHER)) {
+                                    intent.addFlags(
+                                        Intent.FLAG_ACTIVITY_NEW_TASK |
+                                        Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+                                }
                             }
 
                             if (info != null) {
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 83b688d..4bcb4c7 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -270,6 +270,9 @@
     int getCurrentPage() {
         return mCurrentPage;
     }
+    int getNextPage() {
+        return (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
+    }
 
     int getPageCount() {
         return getChildCount();
@@ -1858,9 +1861,8 @@
     }
 
     protected String getCurrentPageDescription() {
-        int page = (mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage;
         return String.format(getContext().getString(R.string.default_scroll_format),
-                page + 1, getChildCount());
+                 getNextPage() + 1, getChildCount());
     }
 
     @Override
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index aa378df..84787a2 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -38,6 +38,8 @@
 import android.graphics.Paint;
 import android.graphics.Point;
 import android.graphics.PointF;
+import android.graphics.PorterDuff;
+import android.graphics.PorterDuffColorFilter;
 import android.graphics.Rect;
 import android.graphics.Region.Op;
 import android.graphics.drawable.Drawable;
@@ -1314,38 +1316,6 @@
     }
 
     @Override
-    protected void dispatchDraw(Canvas canvas) {
-        super.dispatchDraw(canvas);
-
-        if (mInScrollArea && !LauncherApplication.isScreenLarge()) {
-            final int width = getWidth();
-            final int height = getHeight();
-            final int pageHeight = getChildAt(0).getHeight();
-
-            // Set the height of the outline to be the height of the page
-            final int offset = (height - pageHeight - getPaddingTop() - getPaddingBottom()) / 2;
-            final int paddingTop = getPaddingTop() + offset;
-            final int paddingBottom = getPaddingBottom() + offset;
-
-            final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage);
-            final CellLayout leftPage = (CellLayout) getChildAt(page - 1);
-            final CellLayout rightPage = (CellLayout) getChildAt(page + 1);
-
-            if (leftPage != null && leftPage.getIsDragOverlapping()) {
-                final Drawable d = getResources().getDrawable(R.drawable.page_hover_left_holo);
-                d.setBounds(getScrollX(), paddingTop, getScrollX() + d.getIntrinsicWidth(),
-                        height - paddingBottom);
-                d.draw(canvas);
-            } else if (rightPage != null && rightPage.getIsDragOverlapping()) {
-                final Drawable d = getResources().getDrawable(R.drawable.page_hover_right_holo);
-                d.setBounds(getScrollX() + width - d.getIntrinsicWidth(), paddingTop,
-                        getScrollX() + width, height - paddingBottom);
-                d.draw(canvas);
-            }
-        }
-    }
-
-    @Override
     protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
         if (!mLauncher.isAllAppsVisible()) {
             final Folder openFolder = getOpenFolder();
@@ -1564,7 +1534,7 @@
         AnimatorSet anim = animated ? new AnimatorSet() : null;
 
         // Stop any scrolling, move to the current page right away
-        setCurrentPage((mNextPage != INVALID_PAGE) ? mNextPage : mCurrentPage);
+        setCurrentPage(getNextPage());
 
         final State oldState = mState;
         final boolean oldStateIsNormal = (oldState == State.NORMAL);
@@ -3289,7 +3259,7 @@
      * screen while a scroll is in progress.
      */
     public CellLayout getCurrentDropLayout() {
-        return (CellLayout) getChildAt(mNextPage == INVALID_PAGE ? mCurrentPage : mNextPage);
+        return (CellLayout) getChildAt(getNextPage());
     }
 
     /**
@@ -3441,7 +3411,7 @@
         if (!isSmall() && !mIsSwitchingState) {
             mInScrollArea = true;
 
-            final int page = (mNextPage != INVALID_PAGE ? mNextPage : mCurrentPage) +
+            final int page = getNextPage() +
                        (direction == DragController.SCROLL_LEFT ? -1 : 1);
 
             // We always want to exit the current layout to ensure parity of enter / exit