Search in sources :

Example 26 with Task

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

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

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

the class RecentsView method launchPreviousTask.

/** Launches the task that recents was launched from if possible */
public boolean launchPreviousTask() {
    if (mTaskStackView != null) {
        Task task = getStack().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 : Task(com.android.systemui.recents.model.Task) LaunchTaskEvent(com.android.systemui.recents.events.activity.LaunchTaskEvent)

Example 28 with Task

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

the class TaskStackLayoutAlgorithm method update.

/**
     * Computes the minimum and maximum scroll progress values and the progress values for each task
     * in the stack.
     */
void update(TaskStack stack, ArraySet<Task.TaskKey> ignoreTasksSet) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
    // Clear the progress map
    mTaskIndexMap.clear();
    // Return early if we have no tasks
    ArrayList<Task> tasks = stack.getStackTasks();
    if (tasks.isEmpty()) {
        mFrontMostTaskP = 0;
        mMinScrollP = mMaxScrollP = mInitialScrollP = 0;
        mNumStackTasks = mNumFreeformTasks = 0;
        return;
    }
    // Filter the set of freeform and stack tasks
    ArrayList<Task> freeformTasks = new ArrayList<>();
    ArrayList<Task> stackTasks = new ArrayList<>();
    for (int i = 0; i < tasks.size(); i++) {
        Task task = tasks.get(i);
        if (ignoreTasksSet.contains(task.key)) {
            continue;
        }
        if (task.isFreeformTask()) {
            freeformTasks.add(task);
        } else {
            stackTasks.add(task);
        }
    }
    mNumStackTasks = stackTasks.size();
    mNumFreeformTasks = freeformTasks.size();
    // Put each of the tasks in the progress map at a fixed index (does not need to actually
    // map to a scroll position, just by index)
    int taskCount = stackTasks.size();
    for (int i = 0; i < taskCount; i++) {
        Task task = stackTasks.get(i);
        mTaskIndexMap.put(task.key.id, i);
    }
    // Update the freeform tasks
    if (!freeformTasks.isEmpty()) {
        mFreeformLayoutAlgorithm.update(freeformTasks, this);
    }
    // Calculate the min/max/initial scroll
    Task launchTask = stack.getLaunchTarget();
    int launchTaskIndex = launchTask != null ? stack.indexOfStackTask(launchTask) : mNumStackTasks - 1;
    if (getInitialFocusState() == STATE_FOCUSED) {
        int maxBottomOffset = mStackBottomOffset + mTaskRect.height();
        float maxBottomNormX = getNormalizedXFromFocusedY(maxBottomOffset, FROM_BOTTOM);
        mFocusedRange.offset(0f);
        mMinScrollP = 0;
        mMaxScrollP = Math.max(mMinScrollP, (mNumStackTasks - 1) - Math.max(0, mFocusedRange.getAbsoluteX(maxBottomNormX)));
        if (launchState.launchedFromHome) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else {
            mInitialScrollP = Utilities.clamp(launchTaskIndex - 1, mMinScrollP, mMaxScrollP);
        }
    } else if (!ssp.hasFreeformWorkspaceSupport() && mNumStackTasks == 1) {
        // If there is one stack task, ignore the min/max/initial scroll positions
        mMinScrollP = 0;
        mMaxScrollP = 0;
        mInitialScrollP = 0;
    } else {
        // Set the max scroll to be the point where the front most task is visible with the
        // stack bottom offset
        int maxBottomOffset = mStackBottomOffset + mTaskRect.height();
        float maxBottomNormX = getNormalizedXFromUnfocusedY(maxBottomOffset, FROM_BOTTOM);
        mUnfocusedRange.offset(0f);
        mMinScrollP = 0;
        mMaxScrollP = Math.max(mMinScrollP, (mNumStackTasks - 1) - Math.max(0, mUnfocusedRange.getAbsoluteX(maxBottomNormX)));
        boolean scrollToFront = launchState.launchedFromHome || launchState.launchedViaDockGesture;
        if (launchState.launchedFromBlacklistedApp) {
            mInitialScrollP = mMaxScrollP;
        } else if (launchState.launchedWithAltTab) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else if (scrollToFront) {
            mInitialScrollP = Utilities.clamp(launchTaskIndex, mMinScrollP, mMaxScrollP);
        } else {
            // We are overriding the initial two task positions, so set the initial scroll
            // position to match the second task (aka focused task) position
            float initialTopNormX = getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP);
            mInitialScrollP = Math.max(mMinScrollP, Math.min(mMaxScrollP, (mNumStackTasks - 2)) - Math.max(0, mUnfocusedRange.getAbsoluteX(initialTopNormX)));
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Task(com.android.systemui.recents.model.Task) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) ArrayList(java.util.ArrayList)

Example 29 with Task

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

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)

Example 30 with Task

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

the class TaskStackHorizontalViewAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Task task = mTaskList.get(position);
    // Retrives from caches, loading only if necessary
    Recents.getTaskLoader().loadTaskData(task);
    holder.init(task);
}
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