Merge "Adjusting Launcher grid, issue 5067941"
diff --git a/res/values-large/styles.xml b/res/values-large/styles.xml
index c4203fd..bc21a3a 100644
--- a/res/values-large/styles.xml
+++ b/res/values-large/styles.xml
@@ -54,13 +54,8 @@
         <item name="android:textSize">13dip</item>
     </style>
 
-    <style name="Theme" parent="android:Theme.Holo">
-        <item name="android:windowNoTitle">true</item>
+    <style name="Theme" parent="android:Theme.Holo.Wallpaper.NoTitleBar">
         <item name="android:windowActionModeOverlay">true</item>
-
-        <item name="android:windowBackground">@android:color/transparent</item>
-        <item name="android:colorBackgroundCacheHint">@null</item>
-        <item name="android:windowShowWallpaper">true</item>
     </style>
 
     <style name="Theme.WallpaperPicker">
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 6ed830a..62244a6 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -22,11 +22,7 @@
         <item name="android:screenOrientation">nosensor</item>
     </style>
 
-    <style name="Theme.Base" parent="android:Theme.Wallpaper">
-    </style>
-
-    <style name="Theme" parent="Theme.Base">
-        <item name="android:windowNoTitle">true</item>
+    <style name="Theme" parent="@android:style/Theme.Holo.Wallpaper.NoTitleBar">
     </style>
 
     <style name="WorkspaceIcon">
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 5839d40..efdc6b0 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -43,16 +43,11 @@
 import android.content.Intent.ShortcutIconResource;
 import android.content.pm.ActivityInfo;
 import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.res.Configuration;
 import android.content.res.Resources;
-import android.content.res.TypedArray;
 import android.database.ContentObserver;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
 import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.AsyncTask;
@@ -79,7 +74,6 @@
 import android.view.Surface;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.View.OnClickListener;
 import android.view.View.OnLongClickListener;
 import android.view.accessibility.AccessibilityEvent;
 import android.view.animation.DecelerateInterpolator;
@@ -87,14 +81,11 @@
 import android.widget.Advanceable;
 import android.widget.EditText;
 import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.PopupWindow;
 import android.widget.TextView;
 import android.widget.Toast;
 
 import com.android.common.Search;
 import com.android.launcher.R;
-import com.android.launcher2.Workspace.State;
 
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
@@ -102,7 +93,6 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 
 /**
  * Default launcher application.
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index a198c6d..23b8c2d 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -991,38 +991,59 @@
         mDrawBackground = true;
     }
 
-    private void showBackgroundGradientForAllApps() {
-        showBackgroundGradient();
+    private void showBackgroundGradientForAllApps(boolean animated) {
+        showBackgroundGradient(animated);
     }
 
-    private void showBackgroundGradient() {
+    private void showBackgroundGradient(boolean animated) {
         if (mBackground == null) return;
-        if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
-        if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
-        mBackgroundFadeInAnimation = ValueAnimator.ofFloat(getBackgroundAlpha(), 1f);
-        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();
+        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) {
+    private void hideBackgroundGradient(float finalAlpha, boolean animated) {
         if (mBackground == null) return;
-        if (mBackgroundFadeInAnimation != null) mBackgroundFadeInAnimation.cancel();
-        if (mBackgroundFadeOutAnimation != null) mBackgroundFadeOutAnimation.cancel();
-        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();
+        if (mBackgroundFadeInAnimation != null) {
+            mBackgroundFadeInAnimation.cancel();
+            mBackgroundFadeInAnimation = null;
+        }
+        if (mBackgroundFadeOutAnimation != null) {
+            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);
+        }
     }
 
     public void setBackgroundAlpha(float alpha) {
@@ -1523,7 +1544,7 @@
         }
         setChildrenDrawnWithCacheEnabled(true);
 
-        showBackgroundGradientForAllApps();
+        showBackgroundGradientForAllApps(animated);
     }
 
     @Override
@@ -1876,7 +1897,7 @@
         }
 
         hideBackgroundGradient(springLoaded ? getResources().getInteger(
-                R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f);
+                R.integer.config_appsCustomizeSpringLoadedBgAlpha) / 100f : 0f, animated);
     }
 
     /**