Animate launcher when launching recent tasks

- Scale up adjacent recent tasks and translate away from center
  - Workspace card instead recenters in the screen
- Translate hotseat offscreen

Clicking on one of the adjacent tasks will scale it up to the
center of the screen while the center and other adjacent task
parallax to the right beneath it.

Change-Id: If96eec987c100458b8444a6cd698ec7bf6e6ba6b
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index b87511a..ed8d39c 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -39,6 +39,7 @@
 import android.animation.ValueAnimator;
 import android.annotation.SuppressLint;
 import android.annotation.TargetApi;
+import android.app.ActivityOptions;
 import android.app.AlertDialog;
 import android.appwidget.AppWidgetHostView;
 import android.appwidget.AppWidgetManager;
@@ -1924,7 +1925,7 @@
             intent.setSourceBounds(getViewBounds(v));
             // If there is no target package, use the default intent chooser animation
             launchOptions = hasTargetPackage
-                    ? getActivityLaunchOptions(v, isInMultiWindowModeCompat())
+                    ? getActivityLaunchOptionsAsBundle(v, isInMultiWindowModeCompat())
                     : null;
         } else {
             launchOptions = null;
@@ -1979,8 +1980,13 @@
         }
     }
 
+    public Bundle getActivityLaunchOptionsAsBundle(View v, boolean useDefaultLaunchOptions) {
+        ActivityOptions activityOptions = getActivityLaunchOptions(v, useDefaultLaunchOptions);
+        return activityOptions == null ? null : activityOptions.toBundle();
+    }
+
     @TargetApi(Build.VERSION_CODES.M)
-    public Bundle getActivityLaunchOptions(View v, boolean useDefaultLaunchOptions) {
+    public ActivityOptions getActivityLaunchOptions(View v, boolean useDefaultLaunchOptions) {
         return useDefaultLaunchOptions
                 ? mAppTransitionManager.getDefaultActivityLaunchOptions(this, v)
                 : mAppTransitionManager.getActivityLaunchOptions(this, v);
@@ -2004,7 +2010,7 @@
         boolean useLaunchAnimation = (v != null) &&
                 !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
         Bundle optsBundle = useLaunchAnimation
-                ? getActivityLaunchOptions(v, isInMultiWindowModeCompat())
+                ? getActivityLaunchOptionsAsBundle(v, isInMultiWindowModeCompat())
                 : null;
 
         UserHandle user = item == null ? null : item.user;
diff --git a/src/com/android/launcher3/LauncherAppTransitionManager.java b/src/com/android/launcher3/LauncherAppTransitionManager.java
index 43d5e62..19fa3d4 100644
--- a/src/com/android/launcher3/LauncherAppTransitionManager.java
+++ b/src/com/android/launcher3/LauncherAppTransitionManager.java
@@ -21,7 +21,6 @@
 import android.content.Context;
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
-import android.os.Bundle;
 import android.view.View;
 
 /**
@@ -34,7 +33,7 @@
                 context, R.string.app_transition_manager_class);
     }
 
-    public Bundle getDefaultActivityLaunchOptions(Launcher launcher, View v) {
+    public ActivityOptions getDefaultActivityLaunchOptions(Launcher launcher, View v) {
         if (Utilities.ATLEAST_MARSHMALLOW) {
             int left = 0, top = 0;
             int width = v.getMeasuredWidth(), height = v.getMeasuredHeight();
@@ -49,23 +48,27 @@
                     height = bounds.height();
                 }
             }
-            return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height)
-                    .toBundle();
+            return ActivityOptions.makeClipRevealAnimation(v, left, top, width, height);
         } else if (Utilities.ATLEAST_LOLLIPOP_MR1) {
             // On L devices, we use the device default slide-up transition.
             // On L MR1 devices, we use a custom version of the slide-up transition which
             // doesn't have the delay present in the device default.
             return ActivityOptions.makeCustomAnimation(launcher, R.anim.task_open_enter,
-                    R.anim.no_anim).toBundle();
+                    R.anim.no_anim);
         }
         return null;
     }
 
-    public Bundle getActivityLaunchOptions(Launcher launcher, View v) {
+    public ActivityOptions getActivityLaunchOptions(Launcher launcher, View v) {
         return getDefaultActivityLaunchOptions(launcher, v);
     }
 
     /** Cancels the current Launcher transition animation */
     public void finishLauncherAnimation() {
     }
+
+    public boolean isAnimating() {
+        // We don't know when the activity options are being used.
+        return false;
+    }
 }
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index d2bcd18..32fd063 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -82,7 +82,7 @@
                 @Override
                 public void onClick(View view) {
                     Rect sourceBounds = launcher.getViewBounds(view);
-                    Bundle opts = launcher.getActivityLaunchOptions(view, false);
+                    Bundle opts = launcher.getActivityLaunchOptionsAsBundle(view, false);
                     InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, sourceBounds, opts);
                     launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
                             ControlType.APPINFO_TARGET, view);