Search in sources :

Example 26 with TaskStack

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

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

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

the class RecentsActivity method onMultiWindowModeChanged.

@Override
public void onMultiWindowModeChanged(boolean isInMultiWindowMode) {
    super.onMultiWindowModeChanged(isInMultiWindowMode);
    // Reload the task stack completely
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
    loader.preloadTasks(loadPlan, -1, /* runningTaskId */
    false);
    RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
    loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
    loadOpts.numVisibleTaskThumbnails = launchState.launchedNumVisibleThumbnails;
    loader.loadTasks(this, loadPlan, loadOpts);
    TaskStack stack = loadPlan.getTaskStack();
    int numStackTasks = stack.getStackTaskCount();
    boolean showDeferredAnimation = numStackTasks > 0;
    EventBus.getDefault().send(new ConfigurationChangedEvent(true, /* fromMultiWindow */
    false, /* fromDeviceOrientationChange */
    false, /* fromDisplayDensityChange */
    numStackTasks > 0));
    EventBus.getDefault().send(new MultiWindowStateChangedEvent(isInMultiWindowMode, showDeferredAnimation, stack));
}
Also used : ActivityOptions(android.app.ActivityOptions) ConfigurationChangedEvent(com.android.systemui.recents.events.activity.ConfigurationChangedEvent) TaskStack(com.android.systemui.recents.model.TaskStack) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) MultiWindowStateChangedEvent(com.android.systemui.recents.events.activity.MultiWindowStateChangedEvent)

Example 28 with TaskStack

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

the class TaskViewFocusFrame method onGlobalFocusChanged.

@Override
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
    if (!mSv.useGridLayout()) {
        return;
    }
    if (newFocus == null) {
        // We're going to touch mode, unset the focus.
        moveGridTaskViewFocus(null);
        return;
    }
    if (oldFocus == null) {
        // We're returning from touch mode, set the focus to the previously focused task.
        final TaskStack stack = mSv.getStack();
        final int taskCount = stack.getTaskCount();
        final int k = stack.indexOfStackTask(mSv.getFocusedTask());
        final int taskIndexToFocus = k == -1 ? (taskCount - 1) : (k % taskCount);
        mSv.setFocusedTask(taskIndexToFocus, false, true);
    }
}
Also used : TaskStack(com.android.systemui.recents.model.TaskStack)

Example 29 with TaskStack

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

the class RecentsImpl method preloadRecents.

public void preloadRecents() {
    // Preload only the raw task list into a new load plan (which will be consumed by the
    // RecentsActivity) only if there is a task to animate to.
    SystemServicesProxy ssp = Recents.getSystemServices();
    MutableBoolean isHomeStackVisible = new MutableBoolean(true);
    if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
        ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
        RecentsTaskLoader loader = Recents.getTaskLoader();
        sInstanceLoadPlan = loader.createLoadPlan(mContext);
        sInstanceLoadPlan.preloadRawTasks(!isHomeStackVisible.value);
        loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible.value);
        TaskStack stack = sInstanceLoadPlan.getTaskStack();
        if (stack.getTaskCount() > 0) {
            // Only preload the icon (but not the thumbnail since it may not have been taken for
            // the pausing activity)
            preloadIcon(runningTask.id);
            // At this point, we don't know anything about the stack state.  So only calculate
            // the dimensions of the thumbnail that we need for the transition into Recents, but
            // do not draw it until we construct the activity options when we start Recents
            updateHeaderBarLayout(stack, null);
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) MutableBoolean(android.util.MutableBoolean) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) ActivityManager(android.app.ActivityManager)

Example 30 with TaskStack

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

the class RecentsImpl method showNextTask.

/**
     * Transitions to the next recent task in the stack.
     */
public void showNextTask() {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    TaskStack focusedStack = plan.getTaskStack();
    // Return early if there are no tasks in the focused stack
    if (focusedStack == null || focusedStack.getTaskCount() == 0)
        return;
    // Return early if there is no running task
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    if (runningTask == null)
        return;
    // Find the task in the recents list
    boolean isRunningTaskInHomeStack = SystemServicesProxy.isHomeStack(runningTask.stackId);
    ArrayList<Task> tasks = focusedStack.getStackTasks();
    Task toTask = null;
    ActivityOptions launchOpts = null;
    int taskCount = tasks.size();
    for (int i = taskCount - 1; i >= 1; i--) {
        Task task = tasks.get(i);
        if (isRunningTaskInHomeStack) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_fast_toggle_app_home_exit);
            break;
        } else if (task.key.id == runningTask.id) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
            break;
        }
    }
    // Return early if there is no next task
    if (toTask == null) {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
        return;
    }
    // Launch the task
    ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) ActivityManager(android.app.ActivityManager) ActivityOptions(android.app.ActivityOptions)

Aggregations

TaskStack (com.android.systemui.recents.model.TaskStack)80 Task (com.android.systemui.recents.model.Task)56 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)40 ActivityOptions (android.app.ActivityOptions)35 RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)25 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)20 ActivityManager (android.app.ActivityManager)15 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)15 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)15 Resources (android.content.res.Resources)10 Rect (android.graphics.Rect)10 ArrayList (java.util.ArrayList)10 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 TimeInterpolator (android.animation.TimeInterpolator)5 ValueAnimator (android.animation.ValueAnimator)5 MutableBoolean (android.util.MutableBoolean)5 AppTransitionAnimationSpec (android.view.AppTransitionAnimationSpec)5 Interpolator (android.view.animation.Interpolator)5 PathInterpolator (android.view.animation.PathInterpolator)5