Search in sources :

Example 11 with Task

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

the class TaskStackView method onBusEvent.

public final void onBusEvent(UpdateFreeformTaskViewVisibilityEvent event) {
    List<TaskView> taskViews = getTaskViews();
    int taskViewCount = taskViews.size();
    for (int i = 0; i < taskViewCount; i++) {
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (task.isFreeformTask()) {
            tv.setVisibility(event.visible ? View.VISIBLE : View.INVISIBLE);
        }
    }
}
Also used : Task(com.android.systemui.recents.model.Task)

Example 12 with Task

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

the class TaskStackViewTouchHandler method onBeginDrag.

@Override
public void onBeginDrag(View v) {
    TaskView tv = (TaskView) v;
    // Disable clipping with the stack while we are swiping
    tv.setClipViewInStack(false);
    // Disallow touch events from this task view
    tv.setTouchEnabled(false);
    // Disallow parents from intercepting touch events
    final ViewParent parent = mSv.getParent();
    if (parent != null) {
        parent.requestDisallowInterceptTouchEvent(true);
    }
    // Add this task to the set of tasks we are deleting
    mSv.addIgnoreTask(tv.getTask());
    // Determine if we are animating the other tasks while dismissing this task
    mCurrentTasks = new ArrayList<Task>(mSv.getStack().getStackTasks());
    MutableBoolean isFrontMostTask = new MutableBoolean(false);
    Task anchorTask = mSv.findAnchorTask(mCurrentTasks, isFrontMostTask);
    TaskStackLayoutAlgorithm layoutAlgorithm = mSv.getStackAlgorithm();
    TaskStackViewScroller stackScroller = mSv.getScroller();
    if (anchorTask != null) {
        // Get the current set of task transforms
        mSv.getCurrentTaskTransforms(mCurrentTasks, mCurrentTaskTransforms);
        // Get the stack scroll of the task to anchor to (since we are removing something, the
        // front most task will be our anchor task)
        float prevAnchorTaskScroll = 0;
        boolean pullStackForward = mCurrentTasks.size() > 0;
        if (pullStackForward) {
            prevAnchorTaskScroll = layoutAlgorithm.getStackScrollForTask(anchorTask);
        }
        // Calculate where the views would be without the deleting tasks
        mSv.updateLayoutAlgorithm(false);
        float newStackScroll = stackScroller.getStackScroll();
        if (isFrontMostTask.value) {
            // Bound the stack scroll to pull tasks forward if necessary
            newStackScroll = stackScroller.getBoundedStackScroll(newStackScroll);
        } else if (pullStackForward) {
            // Otherwise, offset the scroll by the movement of the anchor task
            float anchorTaskScroll = layoutAlgorithm.getStackScrollForTaskIgnoreOverrides(anchorTask);
            float stackScrollOffset = (anchorTaskScroll - prevAnchorTaskScroll);
            if (layoutAlgorithm.getFocusState() != TaskStackLayoutAlgorithm.STATE_FOCUSED) {
                // If we are focused, we don't want the front task to move, but otherwise, we
                // allow the back task to move up, and the front task to move back
                stackScrollOffset *= 0.75f;
            }
            newStackScroll = stackScroller.getBoundedStackScroll(stackScroller.getStackScroll() + stackScrollOffset);
        }
        // Pick up the newly visible views, not including the deleting tasks
        mSv.bindVisibleTaskViews(newStackScroll, true);
        // Get the final set of task transforms (with task removed)
        mSv.getLayoutTaskTransforms(newStackScroll, TaskStackLayoutAlgorithm.STATE_UNFOCUSED, mCurrentTasks, true, /* ignoreTaskOverrides */
        mFinalTaskTransforms);
        // Set the target to scroll towards upon dismissal
        mTargetStackScroll = newStackScroll;
    /*
             * Post condition: All views that will be visible as a part of the gesture are retrieved
             *                 and at their initial positions.  The stack is still at the current
             *                 scroll, but the layout is updated without the task currently being
             *                 dismissed.  The final layout is in the unfocused stack state, which
             *                 will be applied when the current task is dismissed.
             */
    }
}
Also used : Task(com.android.systemui.recents.model.Task) ViewParent(android.view.ViewParent) MutableBoolean(android.util.MutableBoolean)

Example 13 with Task

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

the class TaskStackAnimationHelper method startExitToHomeAnimation.

/**
     * Starts an in-app animation to hide all the task views so that we can transition back home.
     */
public void startExitToHomeAnimation(boolean animated, ReferenceCountedTrigger postAnimationTrigger) {
    TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
    TaskStack stack = mStackView.getStack();
    // Break early if there are no tasks
    if (stack.getTaskCount() == 0) {
        return;
    }
    int offscreenYOffset = stackLayout.mStackRect.height();
    // Create the animations for each of the tasks
    List<TaskView> taskViews = mStackView.getTaskViews();
    int taskViewCount = taskViews.size();
    for (int i = 0; i < taskViewCount; i++) {
        int taskIndexFromFront = taskViewCount - i - 1;
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (mStackView.isIgnoredTask(task)) {
            continue;
        }
        // Animate the tasks down
        AnimationProps taskAnimation;
        if (animated) {
            int delay = Math.min(ENTER_EXIT_NUM_ANIMATING_TASKS, taskIndexFromFront) * DOUBLE_FRAME_OFFSET_MS;
            taskAnimation = new AnimationProps().setStartDelay(AnimationProps.BOUNDS, delay).setDuration(AnimationProps.BOUNDS, EXIT_TO_HOME_TRANSLATION_DURATION).setInterpolator(AnimationProps.BOUNDS, EXIT_TO_HOME_TRANSLATION_INTERPOLATOR).setListener(postAnimationTrigger.decrementOnAnimationEnd());
            postAnimationTrigger.increment();
        } else {
            taskAnimation = AnimationProps.IMMEDIATE;
        }
        mTmpTransform.fillIn(tv);
        mTmpTransform.rect.offset(0, offscreenYOffset);
        mStackView.updateTaskViewToTransform(tv, mTmpTransform, taskAnimation);
    }
}
Also used : TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task)

Example 14 with Task

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

the class TaskStackAnimationHelper method startScrollToFocusedTaskAnimation.

/**
     * Starts the animation to focus the next {@link TaskView} when paging through recents.
     *
     * @return whether or not this will trigger a scroll in the stack
     */
public boolean startScrollToFocusedTaskAnimation(Task newFocusedTask, boolean requestViewFocus) {
    TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
    TaskStackViewScroller stackScroller = mStackView.getScroller();
    TaskStack stack = mStackView.getStack();
    final float curScroll = stackScroller.getStackScroll();
    final float newScroll = stackScroller.getBoundedStackScroll(stackLayout.getStackScrollForTask(newFocusedTask));
    boolean willScrollToFront = newScroll > curScroll;
    boolean willScroll = Float.compare(newScroll, curScroll) != 0;
    // Get the current set of task transforms
    int taskViewCount = mStackView.getTaskViews().size();
    ArrayList<Task> stackTasks = stack.getStackTasks();
    mStackView.getCurrentTaskTransforms(stackTasks, mTmpCurrentTaskTransforms);
    // Pick up the newly visible views after the scroll
    mStackView.bindVisibleTaskViews(newScroll);
    // Update the internal state
    stackLayout.setFocusState(TaskStackLayoutAlgorithm.STATE_FOCUSED);
    stackScroller.setStackScroll(newScroll, null);
    mStackView.cancelDeferredTaskViewLayoutAnimation();
    // Get the final set of task transforms
    mStackView.getLayoutTaskTransforms(newScroll, stackLayout.getFocusState(), stackTasks, true, /* ignoreTaskOverrides */
    mTmpFinalTaskTransforms);
    // Focus the task view
    TaskView newFocusedTaskView = mStackView.getChildViewForTask(newFocusedTask);
    if (newFocusedTaskView == null) {
        // Log the error if we have no task view, and skip the animation
        Log.e("TaskStackAnimationHelper", "b/27389156 null-task-view prebind:" + taskViewCount + " postbind:" + mStackView.getTaskViews().size() + " prescroll:" + curScroll + " postscroll: " + newScroll);
        return false;
    }
    newFocusedTaskView.setFocusedState(true, requestViewFocus);
    // Setup the end listener to return all the hidden views to the view pool after the
    // focus animation
    ReferenceCountedTrigger postAnimTrigger = new ReferenceCountedTrigger();
    postAnimTrigger.addLastDecrementRunnable(new Runnable() {

        @Override
        public void run() {
            mStackView.bindVisibleTaskViews(newScroll);
        }
    });
    List<TaskView> taskViews = mStackView.getTaskViews();
    taskViewCount = taskViews.size();
    int newFocusTaskViewIndex = taskViews.indexOf(newFocusedTaskView);
    for (int i = 0; i < taskViewCount; i++) {
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (mStackView.isIgnoredTask(task)) {
            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;
        Interpolator interpolator;
        if (willScrollToFront) {
            duration = calculateStaggeredAnimDuration(i);
            interpolator = FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR;
        } else {
            if (i < newFocusTaskViewIndex) {
                duration = 150 + ((newFocusTaskViewIndex - i - 1) * 50);
                interpolator = FOCUS_BEHIND_NEXT_TASK_INTERPOLATOR;
            } else if (i > newFocusTaskViewIndex) {
                duration = Math.max(100, 150 - ((i - newFocusTaskViewIndex - 1) * 50));
                interpolator = FOCUS_IN_FRONT_NEXT_TASK_INTERPOLATOR;
            } else {
                duration = 200;
                interpolator = FOCUS_NEXT_TASK_INTERPOLATOR;
            }
        }
        AnimationProps anim = new AnimationProps().setDuration(AnimationProps.BOUNDS, duration).setInterpolator(AnimationProps.BOUNDS, interpolator).setListener(postAnimTrigger.decrementOnAnimationEnd());
        postAnimTrigger.increment();
        mStackView.updateTaskViewToTransform(tv, toTransform, anim);
    }
    return willScroll;
}
Also used : Task(com.android.systemui.recents.model.Task) TaskStack(com.android.systemui.recents.model.TaskStack) ReferenceCountedTrigger(com.android.systemui.recents.misc.ReferenceCountedTrigger) TimeInterpolator(android.animation.TimeInterpolator) PathInterpolator(android.view.animation.PathInterpolator) Interpolator(android.view.animation.Interpolator)

Example 15 with Task

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

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)

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