Animate the "Manage" notification app launch (1/2)

This CL animates the app launch when clicking the "Manage" button in the
shade.

This CL also tunes the interpolators used during the animation, as
discussed in b/184726377.

See b/174217097#comment2 for before/after videos.

Bug: 174217097
Bug: 184726377
Test: Click the "Manage" button in the Shade.
Change-Id: I2d8484d8014956815e331bd661d37b17719c0db1
diff --git a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt
index da78a7c..0c3c3cc 100644
--- a/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt
+++ b/packages/SystemUI/animation/src/com/android/systemui/animation/ActivityLaunchAnimator.kt
@@ -31,14 +31,16 @@
     companion object {
         const val ANIMATION_DURATION = 500L
         const val ANIMATION_DURATION_FADE_OUT_CONTENT = 183L
-        const val ANIMATION_DURATION_FADE_IN_WINDOW = 216L
-        const val ANIMATION_DELAY_FADE_IN_WINDOW = 166L
+        const val ANIMATION_DURATION_FADE_IN_WINDOW = 217L
+        const val ANIMATION_DELAY_FADE_IN_WINDOW = 167L
         private const val ANIMATION_DURATION_NAV_FADE_IN = 266L
         private const val ANIMATION_DURATION_NAV_FADE_OUT = 133L
         private const val ANIMATION_DELAY_NAV_FADE_IN =
                 ANIMATION_DURATION - ANIMATION_DURATION_NAV_FADE_IN
         private const val LAUNCH_TIMEOUT = 1000L
 
+        private val CONTENT_FADE_OUT_INTERPOLATOR = PathInterpolator(0f, 0f, 0.2f, 1f)
+        private val WINDOW_FADE_IN_INTERPOLATOR = PathInterpolator(0f, 0f, 0.6f, 1f)
         private val NAV_FADE_IN_INTERPOLATOR = PathInterpolator(0f, 0f, 0f, 1f)
         private val NAV_FADE_OUT_INTERPOLATOR = PathInterpolator(0.2f, 0f, 1f, 1f)
 
@@ -416,12 +418,12 @@
                 val contentAlphaProgress = getProgress(linearProgress, 0,
                         ANIMATION_DURATION_FADE_OUT_CONTENT)
                 state.contentAlpha =
-                        1 - Interpolators.ALPHA_OUT.getInterpolation(contentAlphaProgress)
+                        1 - CONTENT_FADE_OUT_INTERPOLATOR.getInterpolation(contentAlphaProgress)
 
                 val backgroundAlphaProgress = getProgress(linearProgress,
                         ANIMATION_DELAY_FADE_IN_WINDOW, ANIMATION_DURATION_FADE_IN_WINDOW)
                 state.backgroundAlpha =
-                        1 - Interpolators.ALPHA_IN.getInterpolation(backgroundAlphaProgress)
+                        1 - WINDOW_FADE_IN_INTERPOLATOR.getInterpolation(backgroundAlphaProgress)
 
                 applyStateToWindow(window, state)
                 navigationBar?.let { applyStateToNavigationBar(it, state, linearProgress) }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationActivityStarter.java
index 5748c4a..2537b19 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationActivityStarter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationActivityStarter.java
@@ -18,6 +18,7 @@
 
 import android.content.Intent;
 import android.service.notification.StatusBarNotification;
+import android.view.View;
 
 import com.android.systemui.statusbar.notification.row.ExpandableNotificationRow;
 
@@ -33,7 +34,8 @@
     void startNotificationGutsIntent(Intent intent, int appUid,
             ExpandableNotificationRow row);
 
-    void startHistoryIntent(boolean showHistory);
+    /** Called when the user clicks "Manage" or "History" in the Shade. */
+    void startHistoryIntent(View view, boolean showHistory);
 
     default boolean isCollapsingToShowActivityOverLockscreen() {
         return false;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java
index 4ed5056..3bf0ddb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/FooterView.java
@@ -106,10 +106,6 @@
         showHistory(mShowHistory);
     }
 
-    public boolean isButtonVisible() {
-        return mManageButton.getAlpha() != 0.0f;
-    }
-
     @Override
     public ExpandableViewState createExpandableViewState() {
         return new FooterViewState();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index fb72ac3..f5fdd36 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -4849,7 +4849,7 @@
             clearNotifications(ROWS_ALL, true /* closeShade */);
         });
         footerView.setManageButtonClickListener(v -> {
-            mNotificationActivityStarter.startHistoryIntent(mFooterView.isHistoryShown());
+            mNotificationActivityStarter.startHistoryIntent(v, mFooterView.isHistoryShown());
         });
         setFooterView(footerView);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java
index 3404528..4356b52 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarNotificationActivityStarter.java
@@ -39,6 +39,7 @@
 import android.service.notification.StatusBarNotification;
 import android.text.TextUtils;
 import android.util.EventLog;
+import android.view.View;
 
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.statusbar.NotificationVisibility;
@@ -462,7 +463,7 @@
         mActivityStarter.dismissKeyguardThenExecute(() -> {
             AsyncTask.execute(() -> {
                 ActivityLaunchAnimator.Controller animationController = null;
-                if (!mStatusBar.isOccluded() && mStatusBar.areLaunchAnimationsEnabled()) {
+                if (mStatusBar.areLaunchAnimationsEnabled()) {
                     animationController = new StatusBarLaunchAnimatorController(
                             mNotificationAnimationProvider.getAnimatorController(row), mStatusBar,
                             true /* isActivityIntent */);
@@ -495,7 +496,7 @@
     }
 
     @Override
-    public void startHistoryIntent(boolean showHistory) {
+    public void startHistoryIntent(View view, boolean showHistory) {
         mActivityStarter.dismissKeyguardThenExecute(() -> {
             AsyncTask.execute(() -> {
                 Intent intent = showHistory ? new Intent(
@@ -506,11 +507,27 @@
                 if (showHistory) {
                     tsb.addNextIntent(intent);
                 }
-                tsb.startActivities(null, UserHandle.CURRENT);
 
-                // Putting it back on the main thread, since we're touching views
-                mMainThreadHandler.post(() -> mCommandQueue.animateCollapsePanels(
-                        CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */));
+                ActivityLaunchAnimator.Controller animationController = null;
+                if (mStatusBar.areLaunchAnimationsEnabled()) {
+                    animationController = new StatusBarLaunchAnimatorController(
+                            ActivityLaunchAnimator.Controller.fromView(view), mStatusBar,
+                            true /* isActivityIntent */);
+                }
+
+                mActivityLaunchAnimator.startIntentWithAnimation(animationController,
+                        (adapter) -> tsb.startActivities(
+                                getActivityOptions(mStatusBar.getDisplayId(), adapter),
+                                UserHandle.CURRENT));
+
+                // Note that other cases when we should still collapse (like activity already on
+                // top) is handled by the StatusBarLaunchAnimatorController.
+                boolean shouldCollapse = animationController == null;
+                if (shouldCollapse) {
+                    // Putting it back on the main thread, since we're touching views
+                    mMainThreadHandler.post(() -> mCommandQueue.animateCollapsePanels(
+                            CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */));
+                }
             });
             return true;
         }, null, false /* afterKeyguardGone */);