tweaking parallax effect

- adding vertical parallax when switching to all apps/customize mode
- added effect to have parallax lag the rest of scrolling
- adjusted the amount of horizontal/vertical parallax in both portrait and landscape modes

Change-Id: I5ee778f78c1080337f642217bcf828b2392ddf70
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index f43f31e..e5d2299 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -27,13 +27,13 @@
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.animation.PropertyValuesHolder;
+import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
 import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.SearchManager;
 import android.app.StatusBarManager;
-import android.app.WallpaperManager;
 import android.appwidget.AppWidgetManager;
 import android.appwidget.AppWidgetProviderInfo;
 import android.content.ActivityNotFoundException;
@@ -77,7 +77,6 @@
 import android.text.TextUtils;
 import android.text.method.TextKeyListener;
 import android.util.Log;
-import android.view.Display;
 import android.view.HapticFeedbackConstants;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -309,7 +308,6 @@
 
         loadHotseats();
         checkForLocaleChange();
-        setWallpaperDimension();
         setContentView(R.layout.launcher);
         mHomeCustomizationDrawer = (TabHost) findViewById(R.id.customization_drawer);
         if (mHomeCustomizationDrawer != null) {
@@ -547,18 +545,6 @@
         }
     }
 
-    private void setWallpaperDimension() {
-        WallpaperManager wpm = (WallpaperManager)getSystemService(WALLPAPER_SERVICE);
-
-        Display display = getWindowManager().getDefaultDisplay();
-        boolean isPortrait = display.getWidth() < display.getHeight();
-        // find width and height when in portrait mode
-        final int width = isPortrait ? display.getWidth() : display.getHeight();
-        final int height = isPortrait ? display.getHeight() : display.getWidth();
-        wpm.suggestDesiredDimensions((int) (Math.max(width, height) * 1.5f),
-                Math.max(width, height));
-    }
-
     // Note: This doesn't do all the client-id magic that BrowserProvider does
     // in Browser. (http://b/2425179)
     private Uri getDefaultBrowserUri() {
@@ -1002,6 +988,7 @@
         workspace.setOnLongClickListener(this);
         workspace.setDragController(dragController);
         workspace.setLauncher(this);
+        workspace.setWallpaperDimension();
 
         deleteZone.setLauncher(this);
         deleteZone.setDragController(dragController);
@@ -1426,8 +1413,10 @@
             }
             if (!mWorkspace.isDefaultPageShowing()) {
                 // on the phone, we don't animate the change to the workspace if all apps is visible
-                mWorkspace.moveToDefaultScreen(alreadyOnHome &&
-                        (LauncherApplication.isScreenXLarge() || mState != State.ALL_APPS));
+                boolean animate = alreadyOnHome &&
+                    (LauncherApplication.isScreenXLarge() || mState != State.ALL_APPS);
+                mWorkspace.moveToDefaultScreen(animate);
+                if (!animate) mWorkspace.updateWallpaperOffsetImmediately();
             }
             showWorkspace(alreadyOnHome);
 
@@ -2747,6 +2736,8 @@
             toView.setVisibility(View.VISIBLE);
             hideAndShowToolbarButtons(toState, null, null);
         }
+        mWorkspace.setVerticalWallpaperOffset(toAllApps ?
+                Workspace.WallpaperVerticalOffset.TOP  : Workspace.WallpaperVerticalOffset.BOTTOM);
     }
 
     /**
@@ -2821,6 +2812,7 @@
                 hideAndShowToolbarButtons(State.WORKSPACE, null, null);
             }
         }
+        mWorkspace.setVerticalWallpaperOffset(Workspace.WallpaperVerticalOffset.MIDDLE);
     }
 
     /**
@@ -2898,6 +2890,8 @@
             toView.setVisibility(View.VISIBLE);
             hideAndShowToolbarButtons(toState, null, null);
         }
+        mWorkspace.setVerticalWallpaperOffset((toState == State.ALL_APPS) ?
+                Workspace.WallpaperVerticalOffset.TOP : Workspace.WallpaperVerticalOffset.BOTTOM);
     }
 
     void showAllApps(boolean animated) {