Merge "Grid spacing fixes"
diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml
index c277153..788d4c3 100644
--- a/res/layout/apps_customize_pane.xml
+++ b/res/layout/apps_customize_pane.xml
@@ -15,7 +15,8 @@
 -->
 <com.android.launcher2.AppsCustomizeTabHost
     xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher">
+    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"
+    android:background="#FF000000">
     <LinearLayout
         android:orientation="vertical"
         android:layout_width="match_parent"
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index ac85f98..c025638 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1195,43 +1195,6 @@
             appSearchData, globalSearch);
     }
 
-    @Override
-    public boolean onCreateOptionsMenu(Menu menu) {
-        super.onCreateOptionsMenu(menu);
-        return true;
-    }
-
-    @Override
-    public boolean onPrepareOptionsMenu(Menu menu) {
-        super.onPrepareOptionsMenu(menu);
-
-        startWallpaper();
-        return true;
-    }
-
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
-        switch (item.getItemId()) {
-            case MENU_ADD:
-                addItems();
-                return true;
-            case MENU_MANAGE_APPS:
-                manageApps();
-                return true;
-            case MENU_WALLPAPER_SETTINGS:
-                startWallpaper();
-                return true;
-            case MENU_SEARCH:
-                onSearchRequested();
-                return true;
-            case MENU_NOTIFICATIONS:
-                showNotifications();
-                return true;
-        }
-
-        return super.onOptionsItemSelected(item);
-    }
-
     /**
      * Indicates that we want global search for this activity by setting the globalSearch
      * argument for {@link #startSearch} to true.
@@ -2210,7 +2173,12 @@
             @Override
             public void run() {
                 exitSpringLoadedDragMode();
+
                 if (successfulDrop) {
+                    // Before we show workspace, hide all apps again because
+                    // exitSpringLoadedDragMode made it visible. This is a bit hacky; we should
+                    // clean up our state transition functions
+                    mAppsCustomizeTabHost.setVisibility(View.GONE);
                     showWorkspace(true);
                 }
             }
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index ec85af3..ce3aad4 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1000,37 +1000,7 @@
         mDrawBackground = true;
     }
 
-    private void showBackgroundGradientForAllApps(boolean animated) {
-        showBackgroundGradient(animated);
-    }
-
-    private void showBackgroundGradient(boolean animated) {
-        if (mBackground == null) return;
-        if (mBackgroundFadeOutAnimation != null) {
-            mBackgroundFadeOutAnimation.cancel();
-            mBackgroundFadeOutAnimation = null;
-        }
-        if (mBackgroundFadeInAnimation != null) {
-            mBackgroundFadeInAnimation.cancel();
-            mBackgroundFadeInAnimation = null;
-        }
-        final float finalAlpha = 1f;
-        if (animated) {
-            mBackgroundFadeInAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha);
-            mBackgroundFadeInAnimation.addUpdateListener(new AnimatorUpdateListener() {
-                public void onAnimationUpdate(ValueAnimator animation) {
-                    setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue());
-                }
-            });
-            mBackgroundFadeInAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
-            mBackgroundFadeInAnimation.setDuration(BACKGROUND_FADE_IN_DURATION);
-            mBackgroundFadeInAnimation.start();
-        } else {
-            setBackgroundAlpha(finalAlpha);
-        }
-    }
-
-    private void hideBackgroundGradient(float finalAlpha, boolean animated) {
+    private void animateBackgroundGradient(float finalAlpha, boolean animated) {
         if (mBackground == null) return;
         if (mBackgroundFadeInAnimation != null) {
             mBackgroundFadeInAnimation.cancel();
@@ -1040,18 +1010,21 @@
             mBackgroundFadeOutAnimation.cancel();
             mBackgroundFadeOutAnimation = null;
         }
-        if (animated) {
-            mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), finalAlpha);
-            mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() {
-                public void onAnimationUpdate(ValueAnimator animation) {
-                    setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue());
-                }
-            });
-            mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
-            mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
-            mBackgroundFadeOutAnimation.start();
-        } else {
-            setBackgroundAlpha(finalAlpha);
+        float startAlpha = getBackgroundAlpha();
+        if (finalAlpha != startAlpha) {
+            if (animated) {
+                mBackgroundFadeOutAnimation = ValueAnimator.ofFloat(startAlpha, finalAlpha);
+                mBackgroundFadeOutAnimation.addUpdateListener(new AnimatorUpdateListener() {
+                    public void onAnimationUpdate(ValueAnimator animation) {
+                        setBackgroundAlpha(((Float) animation.getAnimatedValue()).floatValue());
+                    }
+                });
+                mBackgroundFadeOutAnimation.setInterpolator(new DecelerateInterpolator(1.5f));
+                mBackgroundFadeOutAnimation.setDuration(BACKGROUND_FADE_OUT_DURATION);
+                mBackgroundFadeOutAnimation.start();
+            } else {
+                setBackgroundAlpha(finalAlpha);
+            }
         }
     }
 
@@ -1552,8 +1525,6 @@
             updateWallpaperOffsetImmediately();
         }
         setChildrenDrawnWithCacheEnabled(true);
-
-        showBackgroundGradientForAllApps(animated);
     }
 
     @Override
@@ -1925,8 +1896,16 @@
             }
         }
 
-        hideBackgroundGradient(springLoaded ? getResources().getInteger(
-                R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f, animated);
+        if (springLoaded) {
+            // Right now we're covered by Apps Customize
+            // Show the background gradient immediately, so the gradient will
+            // be showing once AppsCustomize disappears
+            animateBackgroundGradient(getResources().getInteger(
+                    R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f, false);
+        } else {
+            // Fade the background gradient away
+            animateBackgroundGradient(0f, true);
+        }
     }
 
     /**