Search in sources :

Example 96 with Task

use of com.android.systemui.recents.model.Task in project platform_frameworks_base by android.

the class RecentsImpl method getThumbnailTransitionActivityOptions.

/**
     * Creates the activity options for an app->recents transition.
     */
private ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo runningTask, TaskStackView stackView, Rect windowOverrideRect) {
    if (runningTask != null && runningTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
        ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>();
        ArrayList<Task> tasks = stackView.getStack().getStackTasks();
        TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
        TaskStackViewScroller stackScroller = stackView.getScroller();
        stackView.updateLayoutAlgorithm(true);
        stackView.updateToInitialState();
        for (int i = tasks.size() - 1; i >= 0; i--) {
            Task task = tasks.get(i);
            if (task.isFreeformTask()) {
                mTmpTransform = stackLayout.getStackTransformScreenCoordinates(task, stackScroller.getStackScroll(), mTmpTransform, null, windowOverrideRect);
                Bitmap thumbnail = drawThumbnailTransitionBitmap(task, mTmpTransform, mThumbTransitionBitmapCache);
                Rect toTaskRect = new Rect();
                mTmpTransform.rect.round(toTaskRect);
                specs.add(new AppTransitionAnimationSpec(task.key.id, thumbnail, toTaskRect));
            }
        }
        AppTransitionAnimationSpec[] specsArray = new AppTransitionAnimationSpec[specs.size()];
        specs.toArray(specsArray);
        return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, specsArray, mHandler, null, this);
    } else {
        // Update the destination rect
        Task toTask = new Task();
        TaskViewTransform toTransform = getThumbnailTransitionTransform(stackView, toTask, windowOverrideRect);
        Bitmap thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform, mThumbTransitionBitmapCache);
        if (thumbnail != null) {
            RectF toTaskRect = toTransform.rect;
            return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, thumbnail, (int) toTaskRect.left, (int) toTaskRect.top, (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();
    }
}
Also used : TaskStackViewScroller(com.android.systemui.recents.views.TaskStackViewScroller) Task(com.android.systemui.recents.model.Task) Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) TaskViewTransform(com.android.systemui.recents.views.TaskViewTransform) TaskStackLayoutAlgorithm(com.android.systemui.recents.views.TaskStackLayoutAlgorithm)

Example 97 with Task

use of com.android.systemui.recents.model.Task in project platform_frameworks_base by android.

the class RecentsImpl method showNextTask.

/**
     * Transitions to the next recent task in the stack.
     */
public void showNextTask() {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    TaskStack focusedStack = plan.getTaskStack();
    // Return early if there are no tasks in the focused stack
    if (focusedStack == null || focusedStack.getTaskCount() == 0)
        return;
    // Return early if there is no running task
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    if (runningTask == null)
        return;
    // Find the task in the recents list
    boolean isRunningTaskInHomeStack = SystemServicesProxy.isHomeStack(runningTask.stackId);
    ArrayList<Task> tasks = focusedStack.getStackTasks();
    Task toTask = null;
    ActivityOptions launchOpts = null;
    int taskCount = tasks.size();
    for (int i = taskCount - 1; i >= 1; i--) {
        Task task = tasks.get(i);
        if (isRunningTaskInHomeStack) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_fast_toggle_app_home_exit);
            break;
        } else if (task.key.id == runningTask.id) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
            break;
        }
    }
    // Return early if there is no next task
    if (toTask == null) {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
        return;
    }
    // Launch the task
    ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) ActivityManager(android.app.ActivityManager) ActivityOptions(android.app.ActivityOptions)

Example 98 with Task

use of com.android.systemui.recents.model.Task in project platform_frameworks_base by android.

the class RecentsImpl method getThumbnailTransitionTransform.

/**
     * Returns the transition rect for the given task id.
     */
private TaskViewTransform getThumbnailTransitionTransform(TaskStackView stackView, Task runningTaskOut, Rect windowOverrideRect) {
    // Find the running task in the TaskStack
    TaskStack stack = stackView.getStack();
    Task launchTask = stack.getLaunchTarget();
    if (launchTask != null) {
        runningTaskOut.copyFrom(launchTask);
    } else {
        // If no task is specified or we can not find the task just use the front most one
        launchTask = stack.getStackFrontMostTask(true);
        runningTaskOut.copyFrom(launchTask);
    }
    // Get the transform for the running task
    stackView.updateLayoutAlgorithm(true);
    stackView.updateToInitialState();
    stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask, stackView.getScroller().getStackScroll(), mTmpTransform, null, windowOverrideRect);
    return mTmpTransform;
}
Also used : TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task)

Example 99 with Task

use of com.android.systemui.recents.model.Task in project platform_frameworks_base by android.

the class RecentsView method launchPreviousTask.

/** Launches the task that recents was launched from if possible */
public boolean launchPreviousTask() {
    if (mTaskStackView != null) {
        TaskStack stack = mTaskStackView.getStack();
        Task task = stack.getLaunchTarget();
        if (task != null) {
            TaskView taskView = mTaskStackView.getChildViewForTask(task);
            EventBus.getDefault().send(new LaunchTaskEvent(taskView, task, null, INVALID_STACK_ID, false));
            return true;
        }
    }
    return false;
}
Also used : TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent)

Example 100 with Task

use of com.android.systemui.recents.model.Task in project platform_frameworks_base by android.

the class TaskStackAnimationHelper method startEnterAnimation.

/**
     * Starts the in-app enter animation, which animates the {@link TaskView}s to their final places
     * depending on how Recents was triggered.
     */
public void startEnterAnimation(final ReferenceCountedTrigger postAnimationTrigger) {
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    Resources res = mStackView.getResources();
    Resources appRes = mStackView.getContext().getApplicationContext().getResources();
    TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
    TaskStackViewScroller stackScroller = mStackView.getScroller();
    TaskStack stack = mStackView.getStack();
    Task launchTargetTask = stack.getLaunchTarget();
    // Break early if there are no tasks
    if (stack.getTaskCount() == 0) {
        return;
    }
    int taskViewEnterFromAppDuration = res.getInteger(R.integer.recents_task_enter_from_app_duration);
    int taskViewEnterFromAffiliatedAppDuration = res.getInteger(R.integer.recents_task_enter_from_affiliated_app_duration);
    int dockGestureAnimDuration = appRes.getInteger(R.integer.long_press_dock_anim_duration);
    // Create enter animations for each of the views from front to back
    List<TaskView> taskViews = mStackView.getTaskViews();
    int taskViewCount = taskViews.size();
    for (int i = taskViewCount - 1; i >= 0; i--) {
        int taskIndexFromFront = taskViewCount - i - 1;
        int taskIndexFromBack = i;
        final TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        boolean currentTaskOccludesLaunchTarget = launchTargetTask != null && launchTargetTask.group != null && launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
        // Get the current transform for the task, which will be updated to the final transform
        // to animate to depending on how recents was invoked
        stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform, null);
        if (launchState.launchedFromApp && !launchState.launchedViaDockGesture) {
            if (task.isLaunchTarget) {
                tv.onStartLaunchTargetEnterAnimation(mTmpTransform, taskViewEnterFromAppDuration, mStackView.mScreenPinningEnabled, postAnimationTrigger);
            } else {
                // Animate the task up if it was occluding the launch target
                if (currentTaskOccludesLaunchTarget) {
                    AnimationProps taskAnimation = new AnimationProps(taskViewEnterFromAffiliatedAppDuration, Interpolators.ALPHA_IN, new AnimatorListenerAdapter() {

                        @Override
                        public void onAnimationEnd(Animator animation) {
                            postAnimationTrigger.decrement();
                            tv.setClipViewInStack(true);
                        }
                    });
                    postAnimationTrigger.increment();
                    mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
                }
            }
        } else if (launchState.launchedFromHome) {
            // Animate the tasks up, but offset the animations to be relative to the front-most
            // task animation
            AnimationProps taskAnimation = new AnimationProps().setInitialPlayTime(AnimationProps.BOUNDS, Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * DOUBLE_FRAME_OFFSET_MS).setStartDelay(AnimationProps.ALPHA, Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * FRAME_OFFSET_MS).setDuration(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_DURATION).setDuration(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_DURATION).setInterpolator(AnimationProps.BOUNDS, ENTER_FROM_HOME_TRANSLATION_INTERPOLATOR).setInterpolator(AnimationProps.ALPHA, ENTER_FROM_HOME_ALPHA_INTERPOLATOR).setListener(postAnimationTrigger.decrementOnAnimationEnd());
            postAnimationTrigger.increment();
            mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
            if (i == taskViewCount - 1) {
                tv.onStartFrontTaskEnterAnimation(mStackView.mScreenPinningEnabled);
            }
        } else if (launchState.launchedViaDockGesture) {
            // Animate the tasks up - add some delay to match the divider animation
            AnimationProps taskAnimation = new AnimationProps().setDuration(AnimationProps.BOUNDS, dockGestureAnimDuration + (taskIndexFromBack * DOUBLE_FRAME_OFFSET_MS)).setInterpolator(AnimationProps.BOUNDS, ENTER_WHILE_DOCKING_INTERPOLATOR).setStartDelay(AnimationProps.BOUNDS, 48).setListener(postAnimationTrigger.decrementOnAnimationEnd());
            postAnimationTrigger.increment();
            mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
        }
    }
}
Also used : Task(com.android.systemui.recents.model.Task) TaskStack(com.android.systemui.recents.model.TaskStack) Animator(android.animation.Animator) ValueAnimator(android.animation.ValueAnimator) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) Resources(android.content.res.Resources)

Aggregations

Task (com.android.systemui.recents.model.Task)225 TaskStack (com.android.systemui.recents.model.TaskStack)56 GridTaskView (com.android.systemui.recents.views.grid.GridTaskView)43 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)30 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)25 ArrayList (java.util.ArrayList)23 ActivityOptions (android.app.ActivityOptions)20 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)20 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)20 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)20 Resources (android.content.res.Resources)15 AppTransitionAnimationSpec (android.view.AppTransitionAnimationSpec)15 LaunchTaskEvent (com.android.systemui.recents.events.activity.LaunchTaskEvent)11 TimeInterpolator (android.animation.TimeInterpolator)10 ActivityManager (android.app.ActivityManager)10 Bitmap (android.graphics.Bitmap)10 Rect (android.graphics.Rect)10 RectF (android.graphics.RectF)10 Interpolator (android.view.animation.Interpolator)10 PathInterpolator (android.view.animation.PathInterpolator)10