Search in sources :

Example 1 with Task

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

the class TaskStackLayoutAlgorithm method addUnfocusedTaskOverride.

/**
     * Adds and override task progress for the given task when transitioning from focused to
     * unfocused state.
     */
public void addUnfocusedTaskOverride(TaskView taskView, float stackScroll) {
    mFocusedRange.offset(stackScroll);
    mUnfocusedRange.offset(stackScroll);
    Task task = taskView.getTask();
    int top = taskView.getTop() - mTaskRect.top;
    float focusedRangeX = getNormalizedXFromFocusedY(top, FROM_TOP);
    float unfocusedRangeX = getNormalizedXFromUnfocusedY(top, FROM_TOP);
    float unfocusedTaskProgress = stackScroll + mUnfocusedRange.getAbsoluteX(unfocusedRangeX);
    if (Float.compare(focusedRangeX, unfocusedRangeX) != 0) {
        mTaskIndexOverrideMap.put(task.key.id, unfocusedTaskProgress);
    }
}
Also used : Task(com.android.systemui.recents.model.Task)

Example 2 with Task

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

the class RecentsTransitionHelper method composeDockAnimationSpec.

/**
     * Composes the transition spec when docking a task, which includes a full task bitmap.
     */
public List<AppTransitionAnimationSpec> composeDockAnimationSpec(TaskView taskView, Rect bounds) {
    mTmpTransform.fillIn(taskView);
    Task task = taskView.getTask();
    Bitmap thumbnail = RecentsTransitionHelper.composeTaskBitmap(taskView, mTmpTransform);
    return Collections.singletonList(new AppTransitionAnimationSpec(task.key.id, thumbnail, bounds));
}
Also used : Task(com.android.systemui.recents.model.Task) Bitmap(android.graphics.Bitmap) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec)

Example 3 with Task

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

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) * mEnterAndExitFromHomeTranslationOffset).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)

Example 4 with Task

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

the class TaskStackAnimationHelper method startNewStackScrollAnimation.

/**
     * Starts the animation to go to the initial stack layout with a task focused.  In addition, the
     * previous task will be animated in after the scroll completes.
     */
public void startNewStackScrollAnimation(TaskStack newStack, ReferenceCountedTrigger animationTrigger) {
    TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
    TaskStackViewScroller stackScroller = mStackView.getScroller();
    // Get the current set of task transforms
    ArrayList<Task> stackTasks = newStack.getStackTasks();
    mStackView.getCurrentTaskTransforms(stackTasks, mTmpCurrentTaskTransforms);
    // Update the stack
    mStackView.setTasks(newStack, false);
    mStackView.updateLayoutAlgorithm(false);
    // Pick up the newly visible views after the scroll
    final float newScroll = stackLayout.mInitialScrollP;
    mStackView.bindVisibleTaskViews(newScroll);
    // Update the internal state
    stackLayout.setFocusState(TaskStackLayoutAlgorithm.STATE_UNFOCUSED);
    stackLayout.setTaskOverridesForInitialState(newStack, true);
    stackScroller.setStackScroll(newScroll);
    mStackView.cancelDeferredTaskViewLayoutAnimation();
    // Get the final set of task transforms
    mStackView.getLayoutTaskTransforms(newScroll, stackLayout.getFocusState(), stackTasks, false, /* ignoreTaskOverrides */
    mTmpFinalTaskTransforms);
    // Hide the front most task view until the scroll is complete
    Task frontMostTask = newStack.getStackFrontMostTask(false);
    final TaskView frontMostTaskView = mStackView.getChildViewForTask(frontMostTask);
    final TaskViewTransform frontMostTransform = mTmpFinalTaskTransforms.get(stackTasks.indexOf(frontMostTask));
    if (frontMostTaskView != null) {
        mStackView.updateTaskViewToTransform(frontMostTaskView, stackLayout.getFrontOfStackTransform(), AnimationProps.IMMEDIATE);
    }
    // Setup the end listener to return all the hidden views to the view pool after the
    // focus animation
    animationTrigger.addLastDecrementRunnable(new Runnable() {

        @Override
        public void run() {
            mStackView.bindVisibleTaskViews(newScroll);
            // Now, animate in the front-most task
            if (frontMostTaskView != null) {
                mStackView.updateTaskViewToTransform(frontMostTaskView, frontMostTransform, new AnimationProps(75, 250, FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR));
            }
        }
    });
    List<TaskView> taskViews = mStackView.getTaskViews();
    int taskViewCount = taskViews.size();
    for (int i = 0; i < taskViewCount; i++) {
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (mStackView.isIgnoredTask(task)) {
            continue;
        }
        if (task == frontMostTask && frontMostTaskView != null) {
            continue;
        }
        int taskIndex = stackTasks.indexOf(task);
        TaskViewTransform fromTransform = mTmpCurrentTaskTransforms.get(taskIndex);
        TaskViewTransform toTransform = mTmpFinalTaskTransforms.get(taskIndex);
        // Update the task to the initial state (for the newly picked up tasks)
        mStackView.updateTaskViewToTransform(tv, fromTransform, AnimationProps.IMMEDIATE);
        int duration = calculateStaggeredAnimDuration(i);
        Interpolator interpolator = FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR;
        AnimationProps anim = new AnimationProps().setDuration(AnimationProps.BOUNDS, duration).setInterpolator(AnimationProps.BOUNDS, interpolator).setListener(animationTrigger.decrementOnAnimationEnd());
        animationTrigger.increment();
        mStackView.updateTaskViewToTransform(tv, toTransform, anim);
    }
}
Also used : Task(com.android.systemui.recents.model.Task) TimeInterpolator(android.animation.TimeInterpolator) PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator)

Example 5 with Task

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

the class TaskStackLayoutAlgorithm method setTaskOverridesForInitialState.

/**
     * Creates task overrides to ensure the initial stack layout if necessary.
     */
public void setTaskOverridesForInitialState(TaskStack stack, boolean ignoreScrollToFront) {
    RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
    mTaskIndexOverrideMap.clear();
    boolean scrollToFront = launchState.launchedFromHome || launchState.launchedFromBlacklistedApp || launchState.launchedViaDockGesture;
    if (getInitialFocusState() == STATE_UNFOCUSED && mNumStackTasks > 1) {
        if (ignoreScrollToFront || (!launchState.launchedWithAltTab && !scrollToFront)) {
            // Set the initial scroll to the predefined state (which differs from the stack)
            float[] initialNormX = null;
            float minBottomTaskNormX = getNormalizedXFromUnfocusedY(mSystemInsets.bottom + mInitialBottomOffset, FROM_BOTTOM);
            float maxBottomTaskNormX = getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight + mTaskRect.height() - mMinMargin, FROM_TOP);
            if (mNumStackTasks <= 2) {
                // For small stacks, position the tasks so that they are top aligned to under
                // the action button, but ensure that it is at least a certain offset from the
                // bottom of the stack
                initialNormX = new float[] { Math.min(maxBottomTaskNormX, minBottomTaskNormX), getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight, FROM_TOP) };
            } else {
                initialNormX = new float[] { minBottomTaskNormX, getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP) };
            }
            mUnfocusedRange.offset(0f);
            List<Task> tasks = stack.getStackTasks();
            int taskCount = tasks.size();
            for (int i = taskCount - 1; i >= 0; i--) {
                int indexFromFront = taskCount - i - 1;
                if (indexFromFront >= initialNormX.length) {
                    break;
                }
                float newTaskProgress = mInitialScrollP + mUnfocusedRange.getAbsoluteX(initialNormX[indexFromFront]);
                mTaskIndexOverrideMap.put(tasks.get(i).key.id, newTaskProgress);
            }
        }
    }
}
Also used : Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState)

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