Keying off the Launcher state to determine wallpaper visibility (Bug 6396752)

Change-Id: I00c457d9c07113bf8ff4c7102e486efcb030ddc4
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 7a2c247..d3afc3b 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -471,17 +471,6 @@
             // Load the current page synchronously, and the neighboring pages asynchronously
             mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
             mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
-
-            // We had to enable the wallpaper visibility when launching apps from all apps (so that
-            // the transitions would be the same as when launching from workspace) so we need to
-            // re-disable the wallpaper visibility to ensure performance.
-            int duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
-            postDelayed(new Runnable() {
-                @Override
-                public void run() {
-                    mLauncher.updateWallpaperVisibility(false);
-                }
-            }, duration);
         }
     }
 
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 0d4b0d0..ff8e785 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1180,6 +1180,23 @@
                         // currently shown, because doing that may involve
                         // some communication back with the app.
                         mWorkspace.postDelayed(mBuildLayersRunnable, 500);
+
+                        // We had to enable the wallpaper visibility when launching apps from all
+                        // apps (so that the transitions would be the same as when launching from
+                        // workspace) so take this time to see if we need to re-disable the
+                        // wallpaper visibility to ensure performance.
+                        mWorkspace.post(new Runnable() {
+                            @Override
+                            public void run() {
+                                if (mState == State.APPS_CUSTOMIZE) {
+                                    if (mAppsCustomizeTabHost != null &&
+                                            !mAppsCustomizeTabHost.isTransitioning()) {
+                                        updateWallpaperVisibility(false);
+                                    }
+                                }
+                            }
+                        });
+
                         observer.removeOnPreDrawListener(this);
                         return true;
                     }