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

Commit 192086eb authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Implement transition for docking task in recents #1

- When the docking transition is happening, defer updating
the bounds of the home stack until the transition is done.
This is to preserve the scrim which is drawn in the recents
activity.
- Use the PROLONG_AT_START infrastructure to hide the task
in recents when starting the app transition.
- When recents finally get resized at the end of the transition,
reset it's draw state so we don't move the old surface around,
and the new surface gets drawn at the new position, to avoid
flickering.
- Remove hack around not layouting docked divider if it's not
visible, it's not needed anymore and resulted in a wrong
initial position.
- Fix animation selection for docked stack divider.
- Make sure win.moved() always gets called.

Bug: 27607141
Change-Id: I76c35f09461f044a90e2c88335008284b5839cc0
parent 2adba07d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -114,4 +114,15 @@ public abstract class ActivityManagerInternal {
     *               values.
     */
    public abstract void notifyAppTransitionStarting(int reason);

    /**
     * Callback for window manager to let activity manager know that the app transition was
     * cancelled.
     */
    public abstract void notifyAppTransitionCancelled();

    /**
     * Callback for window manager to let activity manager know that the app transition is finished.
     */
    public abstract void notifyAppTransitionFinished();
}
+6 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnim
import com.android.systemui.recents.events.activity.ConfigurationChangedEvent;
import com.android.systemui.recents.events.activity.DebugFlagsChangedEvent;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.DockedFirstAnimationFrameEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowLastAnimationFrameEvent;
import com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent;
@@ -602,6 +603,11 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
        mRecentsView.invalidate();
    }

    public final void onBusEvent(DockedFirstAnimationFrameEvent event) {
        mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
        mRecentsView.invalidate();
    }

    public final void onBusEvent(CancelEnterRecentsWindowAnimationEvent event) {
        RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
        int launchToTaskId = launchState.launchedToTaskId;
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.recents.events.activity;

import com.android.systemui.recents.events.EventBus.Event;

/**
 * Sent when the window animation has started when docking a task
 */
public class DockedFirstAnimationFrameEvent extends Event {
}
+4 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.provider.Settings.Global.DEVELOPMENT_ENABLE_FREEFORM_WINDO
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
import android.app.ActivityOptions;
import android.app.ActivityOptions.OnAnimationStartedListener;
import android.app.AppGlobals;
import android.app.IActivityManager;
import android.app.ITaskStackListener;
@@ -401,13 +402,14 @@ public class SystemServicesProxy {
    }

    /** Docks a task to the side of the screen and starts it. */
    public void startTaskInDockedMode(Context context, View view, int taskId, int createMode) {
    public void startTaskInDockedMode(Context context, View view, int taskId, int createMode,
            Handler handler, OnAnimationStartedListener startedListener) {
        if (mIam == null) return;

        try {
            // TODO: Determine what animation we want for the incoming task
            final ActivityOptions options = ActivityOptions.makeThumbnailAspectScaleUpAnimation(
                    view, null, 0, 0, view.getWidth(), view.getHeight(), null, null);
                    view, null, 0, 0, view.getWidth(), view.getHeight(), handler, startedListener);
            options.setDockCreateMode(createMode);
            options.setLaunchStackId(DOCKED_STACK_ID);
            mIam.startActivityFromRecents(taskId, options.toBundle());
+14 −8
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.app.ActivityOptions.OnAnimationStartedListener;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -51,7 +52,10 @@ import com.android.systemui.recents.RecentsActivityLaunchState;
import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.events.EventBus;
import com.android.systemui.recents.events.EventBus.Event;
import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted;
import com.android.systemui.recents.events.activity.DockedFirstAnimationFrameEvent;
import com.android.systemui.recents.events.activity.DockedTopTaskEvent;
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.activity.HideStackActionButtonEvent;
import com.android.systemui.recents.events.activity.LaunchTaskEvent;
@@ -491,6 +495,14 @@ public class RecentsView extends FrameLayout {
            tmpTransform.alpha = 0;
            tmpTransform.scale = 1f;
            tmpTransform.rect.set(taskViewRect);
            final OnAnimationStartedListener startedListener = new OnAnimationStartedListener() {
                @Override
                public void onAnimationStarted() {
                    EventBus.getDefault().send(new DockedFirstAnimationFrameEvent());
                    mTaskStackView.getStack().removeTask(event.task, AnimationProps.IMMEDIATE,
                            true /* fromDockGesture */);
                }
            };
            mTaskStackView.updateTaskViewToTransform(event.taskView, tmpTransform,
                    new AnimationProps(125, Interpolators.ALPHA_OUT,
                            new AnimatorListenerAdapter() {
@@ -499,14 +511,8 @@ public class RecentsView extends FrameLayout {
                                    // Dock the task and launch it
                                    SystemServicesProxy ssp = Recents.getSystemServices();
                                    ssp.startTaskInDockedMode(getContext(), event.taskView,
                                            event.task.key.id, dockState.createMode);

                                    // Animate the stack accordingly
                                    AnimationProps stackAnim = new AnimationProps(
                                            TaskStackView.DEFAULT_SYNC_STACK_DURATION,
                                            Interpolators.FAST_OUT_SLOW_IN);
                                    mTaskStackView.getStack().removeTask(event.task, stackAnim,
                                            true /* fromDockGesture */);
                                            event.task.key.id, dockState.createMode,
                                            mHandler, startedListener);
                                }
                            }));

Loading