Search in sources :

Example 6 with Task

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

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 7 with Task

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

the class RecentsTvActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    mPipRecentsOverlayManager.onRecentsResumed();
    // Update the recent tasks
    updateRecentsTasks();
    // If this is a new instance from a configuration change, then we have to manually trigger
    // the enter animation state, or if recents was relaunched by AM, without going through
    // the normal mechanisms
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    boolean wasLaunchedByAm = !launchState.launchedFromHome && !launchState.launchedFromApp;
    if (wasLaunchedByAm) {
        EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
    }
    // Notify that recents is now visible
    SystemServicesProxy ssp = Recents.getSystemServices();
    EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, true));
    if (mTaskStackHorizontalGridView.getStack().getTaskCount() > 1 && !mLaunchedFromHome) {
        // If there are 2 or more tasks, and we are not launching from home
        // set the selected position to the 2nd task to allow for faster app switching
        mTaskStackHorizontalGridView.setSelectedPosition(1);
    } else {
        mTaskStackHorizontalGridView.setSelectedPosition(0);
    }
    mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
    View dismissPlaceholder = findViewById(R.id.dismiss_placeholder);
    mTalkBackEnabled = ssp.isTouchExplorationEnabled();
    if (mTalkBackEnabled) {
        dismissPlaceholder.setAccessibilityTraversalBefore(R.id.task_list);
        dismissPlaceholder.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
        mTaskStackHorizontalGridView.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
        mTaskStackHorizontalGridView.setAccessibilityTraversalBefore(R.id.pip);
        dismissPlaceholder.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                mTaskStackHorizontalGridView.requestFocus();
                mTaskStackHorizontalGridView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
                Task focusedTask = mTaskStackHorizontalGridView.getFocusedTask();
                if (focusedTask != null) {
                    mTaskStackViewAdapter.removeTask(focusedTask);
                    EventBus.getDefault().send(new DeleteTaskDataEvent(focusedTask));
                }
            }
        });
    }
    // Initialize PIP UI
    if (mPipManager.isPipShown()) {
        if (mTalkBackEnabled) {
            // If talkback is on, use the mPipView to handle focus changes
            // between recents row and PIP controls.
            mPipView.setVisibility(View.VISIBLE);
        } else {
            mPipView.setVisibility(View.GONE);
        }
        // When PIP view has focus, recents overlay view will takes the focus
        // as if it's the part of the Recents UI.
        mPipRecentsOverlayManager.requestFocus(mTaskStackViewAdapter.getItemCount() > 0);
    } else {
        mPipView.setVisibility(View.GONE);
        mPipRecentsOverlayManager.removePipRecentsOverlayView();
    }
}
Also used : EnterRecentsWindowAnimationCompletedEvent(com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent) SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) RecentsVisibilityChangedEvent(com.android.systemui.recents.events.component.RecentsVisibilityChangedEvent) DeleteTaskDataEvent(com.android.systemui.recents.events.ui.DeleteTaskDataEvent) RecentsTvView(com.android.systemui.recents.tv.views.RecentsTvView) TaskCardView(com.android.systemui.recents.tv.views.TaskCardView) TaskStackHorizontalGridView(com.android.systemui.recents.tv.views.TaskStackHorizontalGridView) View(android.view.View)

Example 8 with Task

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

the class RecentsTvView method launchTaskFomRecents.

/**
     * Launch the given task from recents with animation. If the task is not focused, this will
     * attempt to scroll to focus the task before launching.
     * @param task
     */
private void launchTaskFomRecents(final Task task, boolean animate) {
    if (!animate) {
        SystemServicesProxy ssp = Recents.getSystemServices();
        ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
        return;
    }
    mTaskStackHorizontalView.requestFocus();
    Task focusedTask = mTaskStackHorizontalView.getFocusedTask();
    if (focusedTask != null && task != focusedTask) {
        if (mScrollListener != null) {
            mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
        }
        mScrollListener = new OnScrollListener() {

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                    TaskCardView cardView = mTaskStackHorizontalView.getChildViewForTask(task);
                    if (cardView != null) {
                        mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, cardView, null, INVALID_STACK_ID);
                    } else {
                        // This should not happen normally. If this happens then the data in
                        // the grid view was altered during the scroll. Log error and launch
                        // task with no animation.
                        Log.e(TAG, "Card view for task : " + task + ", returned null.");
                        SystemServicesProxy ssp = Recents.getSystemServices();
                        ssp.startActivityFromRecents(getContext(), task.key, task.title, null);
                    }
                    mTaskStackHorizontalView.removeOnScrollListener(mScrollListener);
                }
            }
        };
        mTaskStackHorizontalView.addOnScrollListener(mScrollListener);
        mTaskStackHorizontalView.setSelectedPositionSmooth(((TaskStackHorizontalViewAdapter) mTaskStackHorizontalView.getAdapter()).getPositionOfTask(task));
    } else {
        mTransitionHelper.launchTaskFromRecents(mStack, task, mTaskStackHorizontalView, mTaskStackHorizontalView.getChildViewForTask(task), null, INVALID_STACK_ID);
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) OnScrollListener(android.support.v7.widget.RecyclerView.OnScrollListener) RecyclerView(android.support.v7.widget.RecyclerView)

Example 9 with Task

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

the class TaskStackView method setRelativeFocusedTask.

/**
     * Sets the focused task relative to the currently focused task.
     *
     * @param forward whether to go to the next task in the stack (along the curve) or the previous
     * @param stackTasksOnly if set, will ensure that the traversal only goes along stack tasks, and
     *                       if the currently focused task is not a stack task, will set the focus
     *                       to the first visible stack task
     * @param animated determines whether to actually draw the highlight along with the change in
     *                            focus.
     * @param cancelWindowAnimations if set, will attempt to cancel window animations if a scroll
     *                               happens.
     * @param timerIndicatorDuration the duration to initialize the auto-advance timer indicator
     */
public void setRelativeFocusedTask(boolean forward, boolean stackTasksOnly, boolean animated, boolean cancelWindowAnimations, int timerIndicatorDuration) {
    Task focusedTask = getFocusedTask();
    int newIndex = mStack.indexOfStackTask(focusedTask);
    if (focusedTask != null) {
        if (stackTasksOnly) {
            List<Task> tasks = mStack.getStackTasks();
            if (focusedTask.isFreeformTask()) {
                // Try and focus the front most stack task
                TaskView tv = getFrontMostTaskView(stackTasksOnly);
                if (tv != null) {
                    newIndex = mStack.indexOfStackTask(tv.getTask());
                }
            } else {
                // Try the next task if it is a stack task
                int tmpNewIndex = newIndex + (forward ? -1 : 1);
                if (0 <= tmpNewIndex && tmpNewIndex < tasks.size()) {
                    Task t = tasks.get(tmpNewIndex);
                    if (!t.isFreeformTask()) {
                        newIndex = tmpNewIndex;
                    }
                }
            }
        } else {
            // No restrictions, lets just move to the new task (looping forward/backwards if
            // necessary)
            int taskCount = mStack.getTaskCount();
            newIndex = (newIndex + (forward ? -1 : 1) + taskCount) % taskCount;
        }
    } else {
        // We don't have a focused task
        float stackScroll = mStackScroller.getStackScroll();
        ArrayList<Task> tasks = mStack.getStackTasks();
        int taskCount = tasks.size();
        if (forward) {
            // Walk backwards and focus the next task smaller than the current stack scroll
            for (newIndex = taskCount - 1; newIndex >= 0; newIndex--) {
                float taskP = mLayoutAlgorithm.getStackScrollForTask(tasks.get(newIndex));
                if (Float.compare(taskP, stackScroll) <= 0) {
                    break;
                }
            }
        } else {
            // Walk forwards and focus the next task larger than the current stack scroll
            for (newIndex = 0; newIndex < taskCount; newIndex++) {
                float taskP = mLayoutAlgorithm.getStackScrollForTask(tasks.get(newIndex));
                if (Float.compare(taskP, stackScroll) >= 0) {
                    break;
                }
            }
        }
    }
    if (newIndex != -1) {
        boolean willScroll = setFocusedTask(newIndex, true, /* scrollToTask */
        true, /* requestViewFocus */
        timerIndicatorDuration);
        if (willScroll && cancelWindowAnimations) {
            // As we iterate to the next/previous task, cancel any current/lagging window
            // transition animations
            EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null));
        }
    }
}
Also used : Task(com.android.systemui.recents.model.Task) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent)

Example 10 with Task

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

the class TaskStackView method onInitializeAccessibilityNodeInfo.

@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    List<TaskView> taskViews = getTaskViews();
    int taskViewCount = taskViews.size();
    if (taskViewCount > 1) {
        // Find the accessibility focused task
        Task focusedTask = getAccessibilityFocusedTask();
        info.setScrollable(true);
        int focusedTaskIndex = mStack.indexOfStackTask(focusedTask);
        if (focusedTaskIndex > 0) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
        }
        if (0 <= focusedTaskIndex && focusedTaskIndex < mStack.getTaskCount() - 1) {
            info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
        }
    }
}
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