Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 14df4a50 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Removing hacks to delay app animations until window animations complete."

parents 8c0886fe 3fb67562
Loading
Loading
Loading
Loading
+31 −26
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import com.android.systemui.R;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.AppWidgetProviderChangedEvent;
import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationStartedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
@@ -115,29 +115,33 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    });

    /**
     * A common Runnable to finish Recents either by calling finish() (with a custom animation) or
     * launching Home with some ActivityOptions.  Generally we always launch home when we exit
     * Recents rather than just finishing the activity since we don't know what is behind Recents in
     * the task stack.  The only case where we finish() directly is when we are cancelling the full
     * screen transition from the app.
     * A common Runnable to finish Recents by launching Home with an animation depending on the
     * last activity launch state.  Generally we always launch home when we exit Recents rather than
     * just finishing the activity since we don't know what is behind Recents in the task stack.
     */
    class FinishRecentsRunnable implements Runnable {
        Intent mLaunchIntent;
        ActivityOptions mLaunchOpts;

        /**
         * Creates a finish runnable that starts the specified intent, using the given
         * ActivityOptions.
         * Creates a finish runnable that starts the specified intent.
         */
        public FinishRecentsRunnable(Intent launchIntent, ActivityOptions opts) {
        public FinishRecentsRunnable(Intent launchIntent) {
            mLaunchIntent = launchIntent;
            mLaunchOpts = opts;
        }

        @Override
        public void run() {
            try {
                startActivityAsUser(mLaunchIntent, mLaunchOpts.toBundle(), UserHandle.CURRENT);
                RecentsActivityLaunchState launchState =
                        Recents.getConfiguration().getLaunchState();
                ActivityOptions opts = ActivityOptions.makeCustomAnimation(RecentsActivity.this,
                        launchState.launchedFromSearchHome ?
                                R.anim.recents_to_search_launcher_enter :
                                R.anim.recents_to_launcher_enter,
                        launchState.launchedFromSearchHome ?
                                R.anim.recents_to_search_launcher_exit :
                                R.anim.recents_to_launcher_exit);
                startActivityAsUser(mLaunchIntent, opts.toBundle(), UserHandle.CURRENT);
            } catch (Exception e) {
                Log.e(TAG, getString(R.string.recents_launch_error_message, "Home"), e);
            }
@@ -191,18 +195,6 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
            mRecentsView.setTaskStack(stack);
        }

        // Create the home intent runnable
        Intent homeIntent = new Intent(Intent.ACTION_MAIN, null);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent,
            ActivityOptions.makeCustomAnimation(this,
                    launchState.launchedFromSearchHome ? R.anim.recents_to_search_launcher_enter :
                        R.anim.recents_to_launcher_enter,
                    launchState.launchedFromSearchHome ? R.anim.recents_to_search_launcher_exit :
                        R.anim.recents_to_launcher_exit));

        // Mark the task that is the launch target
        int launchTaskIndexInStack = 0;
        if (launchState.launchedToTaskId != -1) {
@@ -361,6 +353,13 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        mEmptyViewStub = (ViewStub) findViewById(R.id.empty_view_stub);
        mScrimViews = new SystemBarScrimViews(this);

        // Create the home intent runnable
        Intent homeIntent = new Intent(Intent.ACTION_MAIN, null);
        homeIntent.addCategory(Intent.CATEGORY_HOME);
        homeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
                Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
        mFinishLaunchHomeRunnable = new FinishRecentsRunnable(homeIntent);

        // Bind the search app widget when we first start up
        if (!Constants.DebugFlags.App.DisableSearchBar) {
            mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(this, mAppWidgetHost);
@@ -396,7 +395,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        boolean wasLaunchedByAm = !launchState.launchedFromHome &&
                !launchState.launchedFromAppWithThumbnail;
        if (launchState.launchedHasConfigurationChanged || wasLaunchedByAm) {
            EventBus.getDefault().send(new EnterRecentsWindowAnimationStartedEvent());
            EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
        }

        if (!launchState.launchedHasConfigurationChanged) {
@@ -421,6 +420,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        }
    }

    @Override
    public void onEnterAnimationComplete() {
        super.onEnterAnimationComplete();
        EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
    }

    @Override
    protected void onPause() {
        super.onPause();
@@ -603,7 +608,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        }
    }

    public final void onBusEvent(EnterRecentsWindowAnimationStartedEvent event) {
    public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
        // Try and start the enter animation (or restart it on configuration changed)
        ReferenceCountedTrigger t = new ReferenceCountedTrigger(this, null, null, null);
        ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t);
+8 −21
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ import com.android.systemui.Prefs;
import com.android.systemui.R;
import com.android.systemui.SystemUIApplication;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationStartedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.HideRecentsEvent;
import com.android.systemui.recents.events.activity.IterateRecentsEvent;
@@ -70,7 +69,7 @@ import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
 * be called remotely from the system user.
 */
public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
        implements ActivityOptions.OnAnimationStartedListener, ActivityOptions.OnAnimationFinishedListener {
        implements ActivityOptions.OnAnimationFinishedListener {

    private final static String TAG = "RecentsImpl";
    private final static boolean DEBUG = false;
@@ -140,7 +139,6 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
    TaskStackListenerImpl mTaskStackListener;
    RecentsAppWidgetHost mAppWidgetHost;
    boolean mBootCompleted;
    boolean mStartAnimationTriggered;
    boolean mCanReuseTaskStackViews = true;

    // Task launching
@@ -613,7 +611,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
        final Task toTask = new Task();
        final TaskViewTransform toTransform = getThumbnailTransitionTransform(stack, stackView,
                topTask.id, toTask);
        ForegroundThread.getHandler().post(new Runnable() {
        ForegroundThread.getHandler().postAtFrontOfQueue(new Runnable() {
            @Override
            public void run() {
                final Bitmap transitionBitmap = drawThumbnailTransitionBitmap(toTask, toTransform);
@@ -635,7 +633,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
        return ActivityOptions.makeCustomAnimation(mContext,
                R.anim.recents_from_unknown_enter,
                R.anim.recents_from_unknown_exit,
                mHandler, this);
                mHandler, null);
    }

    /**
@@ -646,12 +644,12 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
            return ActivityOptions.makeCustomAnimation(mContext,
                    R.anim.recents_from_search_launcher_enter,
                    R.anim.recents_from_search_launcher_exit,
                    mHandler, this);
                    mHandler, null);
        }
        return ActivityOptions.makeCustomAnimation(mContext,
                R.anim.recents_from_launcher_enter,
                R.anim.recents_from_launcher_exit,
                mHandler, this);
                mHandler, null);
    }

    /**
@@ -677,7 +675,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
            AppTransitionAnimationSpec[] specsArray = new AppTransitionAnimationSpec[specs.size()];
            specs.toArray(specsArray);
            return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView,
                    specsArray, mHandler, this, this);
                    specsArray, mHandler, null, this);
        } else {
            // Update the destination rect
            Task toTask = new Task();
@@ -688,7 +686,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
            if (thumbnail != null) {
                return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView,
                        thumbnail, (int) toTaskRect.left, (int) toTaskRect.top,
                        (int) toTaskRect.width(), (int) toTaskRect.height(), mHandler, this);
                        (int) toTaskRect.width(), (int) toTaskRect.height(), mHandler, null);
            }
            // If both the screenshot and thumbnail fails, then just fall back to the default transition
            return getUnknownTransitionActivityOptions();
@@ -841,8 +839,6 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
    private void startRecentsActivity(ActivityManager.RunningTaskInfo topTask,
              ActivityOptions opts, boolean fromHome, boolean fromSearchHome, boolean fromThumbnail,
              TaskStackLayoutAlgorithm.VisibilityReport vr) {
        mStartAnimationTriggered = false;

        // Update the configuration based on the launch options
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
@@ -870,16 +866,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub
        mCanReuseTaskStackViews = true;
    }

    /**** OnAnimationStartedListener Implementation ****/

    @Override
    public void onAnimationStarted() {
        // Notify recents to start the enter animation
        if (!mStartAnimationTriggered) {
            mStartAnimationTriggered = true;
            EventBus.getDefault().post(new EnterRecentsWindowAnimationStartedEvent());
        }
    }
    /**** OnAnimationFinishedListener Implementation ****/

    @Override
    public void onAnimationFinished() {
+4 −2
Original line number Diff line number Diff line
@@ -19,8 +19,10 @@ package com.android.systemui.recents.events.activity;
import com.android.systemui.recents.events.EventBus;

/**
 * This is sent when the window animation into Recents starts.
 * This is sent when the window animation into Recents completes.  We use this signal to know when
 * we can start in-app animations so that they don't conflict with the window transition into
 * Recents.
 */
public class EnterRecentsWindowAnimationStartedEvent extends EventBus.Event {
public class EnterRecentsWindowAnimationCompletedEvent extends EventBus.Event {
    // Simple event
}
+2 −15
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ import com.android.systemui.recents.Recents;
import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationStartedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;

/** Manages the scrims for the various system bars. */
public class SystemBarScrimViews {
@@ -81,21 +81,11 @@ public class SystemBarScrimViews {
    /**
     * Starts animating the scrim views when entering Recents.
     */
    public final void onBusEvent(EnterRecentsWindowAnimationStartedEvent event) {
        RecentsConfiguration config = Recents.getConfiguration();
        RecentsActivityLaunchState launchState = config.getLaunchState();
        int transitionEnterFromAppDelay = mContext.getResources().getInteger(
                R.integer.recents_enter_from_app_transition_duration);
        int transitionEnterFromHomeDelay = mContext.getResources().getInteger(
                R.integer.recents_enter_from_home_transition_duration);

    public final void onBusEvent(EnterRecentsWindowAnimationCompletedEvent event) {
        if (mHasStatusBarScrim && mShouldAnimateStatusBarScrim) {
            mStatusBarScrimView.setTranslationY(-mStatusBarScrimView.getMeasuredHeight());
            mStatusBarScrimView.animate()
                    .translationY(0)
                    .setStartDelay(launchState.launchedFromHome ?
                            transitionEnterFromHomeDelay :
                            transitionEnterFromAppDelay)
                    .setDuration(mNavBarScrimEnterDuration)
                    .setInterpolator(mQuintOutInterpolator)
                    .withStartAction(new Runnable() {
@@ -110,9 +100,6 @@ public class SystemBarScrimViews {
            mNavBarScrimView.setTranslationY(mNavBarScrimView.getMeasuredHeight());
            mNavBarScrimView.animate()
                    .translationY(0)
                    .setStartDelay(launchState.launchedFromHome ?
                            transitionEnterFromHomeDelay :
                            transitionEnterFromAppDelay)
                    .setDuration(mNavBarScrimEnterDuration)
                    .setInterpolator(mQuintOutInterpolator)
                    .withStartAction(new Runnable() {
+1 −1
Original line number Diff line number Diff line
@@ -1161,7 +1161,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
            TaskView frontTv = getChildViewForTask(newFrontMostTask);
            if (frontTv != null) {
                frontTv.onTaskBound(newFrontMostTask);
                frontTv.fadeInActionButton(0, getResources().getInteger(
                frontTv.fadeInActionButton(getResources().getInteger(
                        R.integer.recents_task_enter_from_app_duration));
            }
        }
Loading