Search in sources :

Example 1 with RemoteTransitionCompat

use of com.android.systemui.shared.system.RemoteTransitionCompat in project android_packages_apps_Launcher3 by crdroidandroid.

the class TaskAnimationManager method startRecentsAnimation.

/**
 * Starts a new recents animation for the activity with the given {@param intent}.
 */
@UiThread
public RecentsAnimationCallbacks startRecentsAnimation(GestureState gestureState, Intent intent, RecentsAnimationCallbacks.RecentsAnimationListener listener) {
    // Notify if recents animation is still running
    if (mController != null) {
        String msg = "New recents animation started before old animation completed";
        if (FeatureFlags.IS_STUDIO_BUILD) {
            throw new IllegalArgumentException(msg);
        } else {
            Log.e("TaskAnimationManager", msg, new Exception());
        }
    }
    // But force-finish it anyways
    finishRunningRecentsAnimation(false);
    final BaseActivityInterface activityInterface = gestureState.getActivityInterface();
    mLastGestureState = gestureState;
    mCallbacks = new RecentsAnimationCallbacks(activityInterface.allowMinimizeSplitScreen());
    mCallbacks.addListener(new RecentsAnimationCallbacks.RecentsAnimationListener() {

        @Override
        public void onRecentsAnimationStart(RecentsAnimationController controller, RecentsAnimationTargets targets) {
            if (mCallbacks == null) {
                // handling this call entirely
                return;
            }
            mController = controller;
            mTargets = targets;
            mLastAppearedTaskTarget = mTargets.findTask(mLastGestureState.getRunningTaskId());
            mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
        }

        @Override
        public void onRecentsAnimationCanceled(ThumbnailData thumbnailData) {
            cleanUpRecentsAnimation();
        }

        @Override
        public void onRecentsAnimationFinished(RecentsAnimationController controller) {
            cleanUpRecentsAnimation();
        }

        @Override
        public void onTaskAppeared(RemoteAnimationTargetCompat appearedTaskTarget) {
            BaseActivityInterface activityInterface = mLastGestureState.getActivityInterface();
            if (ENABLE_QUICKSTEP_LIVE_TILE.get() && activityInterface.isInLiveTileMode() && activityInterface.getCreatedActivity() != null) {
                RecentsView recentsView = activityInterface.getCreatedActivity().getOverviewPanel();
                if (recentsView != null) {
                    RemoteAnimationTargetCompat[] apps = new RemoteAnimationTargetCompat[1];
                    apps[0] = appearedTaskTarget;
                    recentsView.launchSideTaskInLiveTileMode(appearedTaskTarget.taskId, apps, new RemoteAnimationTargetCompat[0], /* wallpaper */
                    new RemoteAnimationTargetCompat[0]);
                    return;
                }
            }
            if (mController != null) {
                if (mLastAppearedTaskTarget == null || appearedTaskTarget.taskId != mLastAppearedTaskTarget.taskId) {
                    if (mLastAppearedTaskTarget != null) {
                        mController.removeTaskTarget(mLastAppearedTaskTarget);
                    }
                    mLastAppearedTaskTarget = appearedTaskTarget;
                    mLastGestureState.updateLastAppearedTaskTarget(mLastAppearedTaskTarget);
                }
            }
        }
    });
    final long eventTime = gestureState.getSwipeUpStartTimeMs();
    mCallbacks.addListener(gestureState);
    mCallbacks.addListener(listener);
    if (ENABLE_SHELL_TRANSITIONS) {
        RemoteTransitionCompat transition = new RemoteTransitionCompat(mCallbacks, mController != null ? mController.getController() : null);
        Bundle options = ActivityOptionsCompat.makeRemoteTransition(transition).setTransientLaunch().toBundle();
        mCtx.startActivity(intent, options);
    } else {
        UI_HELPER_EXECUTOR.execute(() -> ActivityManagerWrapper.getInstance().startRecentsActivity(intent, eventTime, mCallbacks, null, null));
    }
    gestureState.setState(STATE_RECENTS_ANIMATION_INITIALIZED);
    return mCallbacks;
}
Also used : Bundle(android.os.Bundle) RemoteAnimationTargetCompat(com.android.systemui.shared.system.RemoteAnimationTargetCompat) ThumbnailData(com.android.systemui.shared.recents.model.ThumbnailData) RecentsView(com.android.quickstep.views.RecentsView) RemoteTransitionCompat(com.android.systemui.shared.system.RemoteTransitionCompat) UiThread(androidx.annotation.UiThread)

Example 2 with RemoteTransitionCompat

use of com.android.systemui.shared.system.RemoteTransitionCompat in project android_packages_apps_Launcher3 by crdroidandroid.

the class SplitSelectStateController method setSecondTaskId.

/**
 * To be called after second task selected
 */
public void setSecondTaskId(TaskView taskView) {
    if (TaskAnimationManager.ENABLE_SHELL_TRANSITIONS) {
        // Assume initial task is for top/left part of screen
        final int[] taskIds = mInitialPosition.mStagePosition == STAGE_POSITION_TOP_OR_LEFT ? new int[] { mInitialTaskView.getTask().key.id, taskView.getTask().key.id } : new int[] { taskView.getTask().key.id, mInitialTaskView.getTask().key.id };
        RemoteSplitLaunchAnimationRunner animationRunner = new RemoteSplitLaunchAnimationRunner(mInitialTaskView, taskView);
        mSystemUiProxy.startTasks(taskIds[0], null, /* mainOptions */
        taskIds[1], null, /* sideOptions */
        STAGE_POSITION_BOTTOM_OR_RIGHT, new RemoteTransitionCompat(animationRunner, MAIN_EXECUTOR));
        return;
    }
    // Assume initial mInitialTaskId is for top/left part of screen
    RemoteAnimationFactory initialSplitRunnerWrapped = new SplitLaunchAnimationRunner(mInitialTaskView, 0);
    RemoteAnimationFactory secondarySplitRunnerWrapped = new SplitLaunchAnimationRunner(taskView, 1);
    RemoteAnimationRunnerCompat initialSplitRunner = new LauncherAnimationRunner(new Handler(Looper.getMainLooper()), initialSplitRunnerWrapped, true);
    RemoteAnimationRunnerCompat secondarySplitRunner = new LauncherAnimationRunner(new Handler(Looper.getMainLooper()), secondarySplitRunnerWrapped, true);
    ActivityOptions initialOptions = ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(initialSplitRunner, 300, 150));
    ActivityOptions secondaryOptions = ActivityOptionsCompat.makeRemoteAnimation(new RemoteAnimationAdapterCompat(secondarySplitRunner, 300, 150));
    mSystemUiProxy.startTask(mInitialTaskView.getTask().key.id, mInitialPosition.mStageType, mInitialPosition.mStagePosition, /*null*/
    initialOptions.toBundle());
    Pair<Integer, Integer> compliment = getComplimentaryStageAndPosition(mInitialPosition);
    mSystemUiProxy.startTask(taskView.getTask().key.id, compliment.first, compliment.second, /*null*/
    secondaryOptions.toBundle());
    // After successful launch, call resetState
    resetState();
}
Also used : RemoteAnimationAdapterCompat(com.android.systemui.shared.system.RemoteAnimationAdapterCompat) RemoteAnimationFactory(com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory) Handler(android.os.Handler) LauncherAnimationRunner(com.android.launcher3.LauncherAnimationRunner) RemoteTransitionCompat(com.android.systemui.shared.system.RemoteTransitionCompat) RemoteAnimationRunnerCompat(com.android.systemui.shared.system.RemoteAnimationRunnerCompat) ActivityOptions(android.app.ActivityOptions)

Aggregations

RemoteTransitionCompat (com.android.systemui.shared.system.RemoteTransitionCompat)2 ActivityOptions (android.app.ActivityOptions)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 UiThread (androidx.annotation.UiThread)1 LauncherAnimationRunner (com.android.launcher3.LauncherAnimationRunner)1 RemoteAnimationFactory (com.android.launcher3.LauncherAnimationRunner.RemoteAnimationFactory)1 RecentsView (com.android.quickstep.views.RecentsView)1 ThumbnailData (com.android.systemui.shared.recents.model.ThumbnailData)1 RemoteAnimationAdapterCompat (com.android.systemui.shared.system.RemoteAnimationAdapterCompat)1 RemoteAnimationRunnerCompat (com.android.systemui.shared.system.RemoteAnimationRunnerCompat)1 RemoteAnimationTargetCompat (com.android.systemui.shared.system.RemoteAnimationTargetCompat)1