Search in sources :

Example 66 with Task

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

the class TaskStackView method computeVisibleTaskTransforms.

/**
     * Computes the task transforms at the current stack scroll for all visible tasks. If a valid
     * target stack scroll is provided (ie. is different than {@param curStackScroll}), then the
     * visible range includes all tasks at the target stack scroll. This is useful for ensure that
     * all views necessary for a transition or animation will be visible at the start.
     *
     * This call ignores freeform tasks.
     *
     * @param taskTransforms The set of task view transforms to reuse, this list will be sized to
     *                       match the size of {@param tasks}
     * @param tasks The set of tasks for which to generate transforms
     * @param curStackScroll The current stack scroll
     * @param targetStackScroll The stack scroll that we anticipate we are going to be scrolling to.
     *                          The range of the union of the visible views at the current and
     *                          target stack scrolls will be returned.
     * @param ignoreTasksSet The set of tasks to skip for purposes of calculaing the visible range.
     *                       Transforms will still be calculated for the ignore tasks.
     * @return the front and back most visible task indices (there may be non visible tasks in
     *         between this range)
     */
int[] computeVisibleTaskTransforms(ArrayList<TaskViewTransform> taskTransforms, ArrayList<Task> tasks, float curStackScroll, float targetStackScroll, ArraySet<Task.TaskKey> ignoreTasksSet, boolean ignoreTaskOverrides) {
    int taskCount = tasks.size();
    int[] visibleTaskRange = mTmpIntPair;
    visibleTaskRange[0] = -1;
    visibleTaskRange[1] = -1;
    boolean useTargetStackScroll = Float.compare(curStackScroll, targetStackScroll) != 0;
    // We can reuse the task transforms where possible to reduce object allocation
    Utilities.matchTaskListSize(tasks, taskTransforms);
    // Update the stack transforms
    TaskViewTransform frontTransform = null;
    TaskViewTransform frontTransformAtTarget = null;
    TaskViewTransform transform = null;
    TaskViewTransform transformAtTarget = null;
    for (int i = taskCount - 1; i >= 0; i--) {
        Task task = tasks.get(i);
        // Calculate the current and (if necessary) the target transform for the task
        transform = mLayoutAlgorithm.getStackTransform(task, curStackScroll, taskTransforms.get(i), frontTransform, ignoreTaskOverrides);
        if (useTargetStackScroll && !transform.visible) {
            // If we have a target stack scroll and the task is not currently visible, then we
            // just update the transform at the new scroll
            // TODO: Optimize this
            transformAtTarget = mLayoutAlgorithm.getStackTransform(task, targetStackScroll, new TaskViewTransform(), frontTransformAtTarget);
            if (transformAtTarget.visible) {
                transform.copyFrom(transformAtTarget);
            }
        }
        // visible stack indices
        if (ignoreTasksSet.contains(task.key)) {
            continue;
        }
        // the visible stack indices
        if (task.isFreeformTask()) {
            continue;
        }
        frontTransform = transform;
        frontTransformAtTarget = transformAtTarget;
        if (transform.visible) {
            if (visibleTaskRange[0] < 0) {
                visibleTaskRange[0] = i;
            }
            visibleTaskRange[1] = i;
        }
    }
    return visibleTaskRange;
}
Also used : Task(com.android.systemui.recents.model.Task)

Example 67 with Task

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

the class TaskStackView method getFrontMostTaskView.

/**
     * Returns the front most task view.
     *
     * @param stackTasksOnly if set, will return the front most task view in the stack (by default
     *                       the front most task view will be freeform since they are placed above
     *                       stack tasks)
     */
private TaskView getFrontMostTaskView(boolean stackTasksOnly) {
    List<TaskView> taskViews = getTaskViews();
    int taskViewCount = taskViews.size();
    for (int i = taskViewCount - 1; i >= 0; i--) {
        TaskView tv = taskViews.get(i);
        Task task = tv.getTask();
        if (stackTasksOnly && task.isFreeformTask()) {
            continue;
        }
        return tv;
    }
    return null;
}
Also used : GridTaskView(com.android.systemui.recents.views.grid.GridTaskView) Task(com.android.systemui.recents.model.Task)

Example 68 with Task

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

the class TaskStackView method setFocusedTask.

/**
     * Sets the focused task to the provided (bounded focusTaskIndex).
     *
     * @return whether or not the stack will scroll as a part of this focus change
     */
public boolean setFocusedTask(int focusTaskIndex, boolean scrollToTask, boolean requestViewFocus, int timerIndicatorDuration) {
    // Find the next task to focus
    int newFocusedTaskIndex = mStack.getTaskCount() > 0 ? Utilities.clamp(focusTaskIndex, 0, mStack.getTaskCount() - 1) : -1;
    final Task newFocusedTask = (newFocusedTaskIndex != -1) ? mStack.getStackTasks().get(newFocusedTaskIndex) : null;
    // Reset the last focused task state if changed
    if (mFocusedTask != null) {
        // Cancel the timer indicator, if applicable
        if (timerIndicatorDuration > 0) {
            final TaskView tv = getChildViewForTask(mFocusedTask);
            if (tv != null) {
                tv.getHeaderView().cancelFocusTimerIndicator();
            }
        }
        resetFocusedTask(mFocusedTask);
    }
    boolean willScroll = false;
    mFocusedTask = newFocusedTask;
    if (newFocusedTask != null) {
        // Start the timer indicator, if applicable
        if (timerIndicatorDuration > 0) {
            final TaskView tv = getChildViewForTask(mFocusedTask);
            if (tv != null) {
                tv.getHeaderView().startFocusTimerIndicator(timerIndicatorDuration);
            } else {
                // The view is null; set a flag for later
                mStartTimerIndicatorDuration = timerIndicatorDuration;
            }
        }
        if (scrollToTask) {
            // Cancel any running enter animations at this point when we scroll or change focus
            if (!mEnterAnimationComplete) {
                cancelAllTaskViewAnimations();
            }
            mLayoutAlgorithm.clearUnfocusedTaskOverrides();
            willScroll = mAnimationHelper.startScrollToFocusedTaskAnimation(newFocusedTask, requestViewFocus);
        } else {
            // Focus the task view
            TaskView newFocusedTaskView = getChildViewForTask(newFocusedTask);
            if (newFocusedTaskView != null) {
                newFocusedTaskView.setFocusedState(true, requestViewFocus);
            }
        }
        // Any time a task view gets the focus, we move the focus frame around it.
        if (mTaskViewFocusFrame != null) {
            mTaskViewFocusFrame.moveGridTaskViewFocus(getChildViewForTask(newFocusedTask));
        }
    }
    return willScroll;
}
Also used : Task(com.android.systemui.recents.model.Task) GridTaskView(com.android.systemui.recents.views.grid.GridTaskView)

Example 69 with Task

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

the class TaskStackView method getLockedTaskCount.

public int getLockedTaskCount() {
    int count = 0;
    ArrayList<Task> mTasks = mStack.getStackTasks();
    for (Task mTask : mTasks) {
        if (mTask.isLockedTask) {
            count++;
        }
    }
    return count;
}
Also used : Task(com.android.systemui.recents.model.Task)

Example 70 with Task

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

the class TaskStackView method performAccessibilityAction.

@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
    if (super.performAccessibilityAction(action, arguments)) {
        return true;
    }
    Task focusedTask = getAccessibilityFocusedTask();
    int taskIndex = mStack.indexOfStackTask(focusedTask);
    if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
        switch(action) {
            case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
                {
                    setFocusedTask(taskIndex + 1, true, /* scrollToTask */
                    true, /* requestViewFocus */
                    0);
                    return true;
                }
            case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
                {
                    setFocusedTask(taskIndex - 1, true, /* scrollToTask */
                    true, /* requestViewFocus */
                    0);
                    return true;
                }
        }
    }
    return false;
}
Also used : Task(com.android.systemui.recents.model.Task)

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