Search in sources :

Example 56 with Task

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

the class TaskStackView method onBusEvent.

public final void onBusEvent(LaunchNextTaskRequestEvent event) {
    if (mAwaitingFirstLayout) {
        mLaunchNextAfterFirstMeasure = true;
        return;
    }
    final Task launchTask = mStack.getNextLaunchTarget();
    if (launchTask != null) {
        launchTask(launchTask);
        MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_LAUNCH_PREVIOUS_TASK, launchTask.key.getComponent().toString());
    } else if (mStack.getTaskCount() == 0) {
        // If there are no tasks, then just hide recents back to home.
        EventBus.getDefault().send(new HideRecentsEvent(false, true));
    }
}
Also used : Task(com.android.systemui.recents.model.Task) HideRecentsEvent(com.android.systemui.recents.events.activity.HideRecentsEvent)

Example 57 with Task

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

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

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

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

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

the class RecentsTransitionHelper method composeAnimationSpecs.

/**
     * Composes the animation specs for all the tasks in the target stack.
     */
private List<AppTransitionAnimationSpec> composeAnimationSpecs(final Task task, final TaskStackView stackView, final int destinationStack) {
    // Ensure we have a valid target stack id
    final int targetStackId = destinationStack != INVALID_STACK_ID ? destinationStack : task.key.stackId;
    if (!StackId.useAnimationSpecForAppTransition(targetStackId)) {
        return null;
    }
    // Calculate the offscreen task rect (for tasks that are not backed by views)
    TaskView taskView = stackView.getChildViewForTask(task);
    TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
    Rect offscreenTaskRect = new Rect();
    stackLayout.getFrontOfStackTransform().rect.round(offscreenTaskRect);
    // If this is a full screen stack, the transition will be towards the single, full screen
    // task. We only need the transition spec for this task.
    List<AppTransitionAnimationSpec> specs = new ArrayList<>();
    // check for INVALID_STACK_ID
    if (targetStackId == FULLSCREEN_WORKSPACE_STACK_ID || targetStackId == DOCKED_STACK_ID || targetStackId == INVALID_STACK_ID) {
        if (taskView == null) {
            specs.add(composeOffscreenAnimationSpec(task, offscreenTaskRect));
        } else {
            mTmpTransform.fillIn(taskView);
            stackLayout.transformToScreenCoordinates(mTmpTransform, null);
            AppTransitionAnimationSpec spec = composeAnimationSpec(stackView, taskView, mTmpTransform, true);
            if (spec != null) {
                specs.add(spec);
            }
        }
        return specs;
    }
    // Otherwise, for freeform tasks, create a new animation spec for each task we have to
    // launch
    TaskStack stack = stackView.getStack();
    ArrayList<Task> tasks = stack.getStackTasks();
    int taskCount = tasks.size();
    for (int i = taskCount - 1; i >= 0; i--) {
        Task t = tasks.get(i);
        if (t.isFreeformTask() || targetStackId == FREEFORM_WORKSPACE_STACK_ID) {
            TaskView tv = stackView.getChildViewForTask(t);
            if (tv == null) {
                // TODO: Create a different animation task rect for this case (though it should
                //       never happen)
                specs.add(composeOffscreenAnimationSpec(t, offscreenTaskRect));
            } else {
                mTmpTransform.fillIn(taskView);
                stackLayout.transformToScreenCoordinates(mTmpTransform, null);
                AppTransitionAnimationSpec spec = composeAnimationSpec(stackView, tv, mTmpTransform, true);
                if (spec != null) {
                    specs.add(spec);
                }
            }
        }
    }
    return specs;
}
Also used : Rect(android.graphics.Rect) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) ArrayList(java.util.ArrayList)

Example 60 with Task

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

the class RecentsTvActivity method updateRecentsTasks.

private void updateRecentsTasks() {
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = RecentsImpl.consumeInstanceLoadPlan();
    if (plan == null) {
        plan = loader.createLoadPlan(this);
    }
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    if (!plan.hasTasks()) {
        loader.preloadTasks(plan, -1, !launchState.launchedFromHome);
    }
    int numVisibleTasks = TaskCardView.getNumberOfVisibleTasks(getApplicationContext());
    mLaunchedFromHome = launchState.launchedFromHome;
    TaskStack stack = plan.getTaskStack();
    RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
    loadOpts.runningTaskId = launchState.launchedToTaskId;
    loadOpts.numVisibleTasks = numVisibleTasks;
    loadOpts.numVisibleTaskThumbnails = numVisibleTasks;
    loader.loadTasks(this, plan, loadOpts);
    List stackTasks = stack.getStackTasks();
    Collections.reverse(stackTasks);
    if (mTaskStackViewAdapter == null) {
        mTaskStackViewAdapter = new TaskStackHorizontalViewAdapter(stackTasks);
        mTaskStackHorizontalGridView = mRecentsView.setTaskStackViewAdapter(mTaskStackViewAdapter);
        mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(getApplicationContext(), mTaskStackHorizontalGridView);
    } else {
        mTaskStackViewAdapter.setNewStackTasks(stackTasks);
    }
    mRecentsView.init(stack);
    if (launchState.launchedToTaskId != -1) {
        ArrayList<Task> tasks = stack.getStackTasks();
        int taskCount = tasks.size();
        for (int i = 0; i < taskCount; i++) {
            Task t = tasks.get(i);
            if (t.key.id == launchState.launchedToTaskId) {
                t.isLaunchTarget = true;
                break;
            }
        }
    }
}
Also used : ActivityOptions(android.app.ActivityOptions) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) HomeRecentsEnterExitAnimationHolder(com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder) TaskStack(com.android.systemui.recents.model.TaskStack) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) TaskStackHorizontalViewAdapter(com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter) ArrayList(java.util.ArrayList) List(java.util.List)

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