Merge "Fix bug: workspace screens not being rendered in spring-loaded mode" into honeycomb-mr1
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
index aa828b0..0dd56ac 100644
--- a/src/com/android/launcher2/AllAppsTabbed.java
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -177,8 +177,11 @@
             // Turn on hardware layers for performance
             setLayerType(LAYER_TYPE_HARDWARE, null);
             // Re-enable the rendering of the dimmed background in All Apps for performance reasons
-            mLauncher.getWorkspace().disableBackground();
-            mBackground.setVisibility(VISIBLE);
+            // if we're fading it in
+            if (mLauncher.getWorkspace().getBackgroundAlpha() == 0f) {
+                mLauncher.getWorkspace().disableBackground();
+                mBackground.setVisibility(VISIBLE);
+            }
             // just a sanity check that we don't build a layer before a call to onLayout
             if (!mFirstLayout) {
                 // force building the layer at the beginning of the animation, so you don't get a
@@ -199,8 +202,10 @@
         }
         // Move the rendering of the dimmed background to workspace after the all apps animation
         // is done, so that the background is not rendered *above* the mini workspace screens
-        mLauncher.getWorkspace().enableBackground();
-        mBackground.setVisibility(GONE);
+        if (mBackground.getVisibility() != GONE) {
+            mLauncher.getWorkspace().enableBackground();
+            mBackground.setVisibility(GONE);
+        }
         mAllApps.allowHardwareLayerCreation();
     }
 
diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/android/launcher2/AppWidgetResizeFrame.java
index 5f725b7..2b2662f 100644
--- a/src/com/android/launcher2/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher2/AppWidgetResizeFrame.java
@@ -48,7 +48,8 @@
 
     final int SNAP_DURATION = 150;
     final int BACKGROUND_PADDING = 24;
-    final float DIMMED_HANDLE_ALPHA = 0.3f;
+    final float DIMMED_HANDLE_ALPHA = 0f;
+    final float RESIZE_THRESHOLD = 0.66f;
 
     public static final int LEFT = 0;
     public static final int TOP = 1;
@@ -193,11 +194,21 @@
         int xThreshold = mCellLayout.getCellWidth() + mCellLayout.getWidthGap();
         int yThreshold = mCellLayout.getCellHeight() + mCellLayout.getHeightGap();
 
-        int hSpanInc = (int) Math.round(1.0f * mDeltaX / xThreshold) - mRunningHInc;
-        int vSpanInc = (int) Math.round(1.0f * mDeltaY / yThreshold) - mRunningVInc;
+        float hSpanIncF = 1.0f * mDeltaX / xThreshold - mRunningHInc;
+        float vSpanIncF = 1.0f * mDeltaY / yThreshold - mRunningVInc;
+
+        int hSpanInc = 0;
+        int vSpanInc = 0;
         int cellXInc = 0;
         int cellYInc = 0;
 
+        if (Math.abs(hSpanIncF) > RESIZE_THRESHOLD) {
+            hSpanInc = Math.round(hSpanIncF);
+        }
+        if (Math.abs(vSpanIncF) > RESIZE_THRESHOLD) {
+            vSpanInc = Math.round(vSpanIncF);
+        }
+
         if (hSpanInc == 0 && vSpanInc == 0) return;
 
         // Before we change the widget, we clear the occupied cells associated with it.
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 7956b45..e7865d2 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -733,11 +733,15 @@
 
     private float wallpaperOffsetForCurrentScroll() {
         Display display = mLauncher.getWindowManager().getDefaultDisplay();
+        final boolean isStaticWallpaper = (mWallpaperManager.getWallpaperInfo() == null);
         // The wallpaper travel width is how far, from left to right, the wallpaper will move
         // at this orientation (for example, in portrait mode we don't move all the way to the
         // edges of the wallpaper, or otherwise the parallax effect would be too strong)
         int wallpaperTravelWidth = (int) (display.getWidth() *
                 wallpaperTravelToScreenWidthRatio(display.getWidth(), display.getHeight()));
+        if (!isStaticWallpaper) {
+            wallpaperTravelWidth = mWallpaperWidth;
+        }
 
         // Set wallpaper offset steps (1 / (number of screens - 1))
         // We have 3 vertical offset states (centered, and then top/bottom aligned
@@ -751,7 +755,6 @@
         // you overscroll as far as you can in landscape mode. Only do this for static wallpapers
         // because live wallpapers (and probably 3rd party wallpaper providers) rely on the offset
         // being even intervals from 0 to 1 (eg [0, 0.25, 0.5, 0.75, 1])
-        final boolean isStaticWallpaper = (mWallpaperManager.getWallpaperInfo() == null);
         if (isStaticWallpaper) {
             int overscrollOffset = (int) (maxOverScroll() * display.getWidth());
             scrollProgressOffset += overscrollOffset / (float) getScrollRange();
@@ -761,7 +764,7 @@
         float scrollProgress =
             mScrollX / (float) scrollRange + scrollProgressOffset;
         float offsetInDips = wallpaperTravelWidth * scrollProgress +
-            (mWallpaperWidth - wallpaperTravelWidth) / 2;
+            (mWallpaperWidth - wallpaperTravelWidth) / 2; // center it
         float offset = offsetInDips / (float) mWallpaperWidth;
         return offset;
     }