Search in sources :

Example 1 with CancelEnterRecentsWindowAnimationEvent

use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by ResurrectionRemix.

the class RecentsTransitionHelper method launchTaskFromRecents.

/**
     * Launches the specified {@link Task}.
     */
public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task, final TaskStackView stackView, final TaskView taskView, final boolean screenPinningRequested, final Rect bounds, final int destinationStack) {
    final ActivityOptions opts = ActivityOptions.makeBasic();
    if (bounds != null) {
        opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
    }
    final ActivityOptions.OnAnimationStartedListener animStartedListener;
    final IAppTransitionAnimationSpecsFuture transitionFuture;
    if (taskView != null) {
        transitionFuture = getAppTransitionFuture(new AnimationSpecComposer() {

            @Override
            public List<AppTransitionAnimationSpec> composeSpecs() {
                return composeAnimationSpecs(task, stackView, destinationStack);
            }
        });
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
                if (screenPinningRequested) {
                    // Request screen pinning after the animation runs
                    mStartScreenPinningRunnable.taskId = task.key.id;
                    mHandler.postDelayed(mStartScreenPinningRunnable, 350);
                }
            }
        };
    } else {
        // This is only the case if the task is not on screen (scrolled offscreen for example)
        transitionFuture = null;
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
            }
        };
    }
    if (taskView == null) {
        // If there is no task view, then we do not need to worry about animating out occluding
        // task views, and we can launch immediately
        startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
    } else {
        LaunchTaskStartedEvent launchStartedEvent = new LaunchTaskStartedEvent(taskView, screenPinningRequested);
        if (task.group != null && !task.group.isFrontMostTask(task)) {
            launchStartedEvent.addPostAnimationCallback(new Runnable() {

                @Override
                public void run() {
                    startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
                }
            });
            EventBus.getDefault().send(launchStartedEvent);
        } else {
            EventBus.getDefault().send(launchStartedEvent);
            startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
        }
    }
    Recents.getSystemServices().sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
}
Also used : OnAnimationStartedListener(android.app.ActivityOptions.OnAnimationStartedListener) IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) LaunchTaskStartedEvent(com.android.systemui.recents.events.activity.LaunchTaskStartedEvent) ExitRecentsWindowFirstAnimationFrameEvent(com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent) ActivityOptions(android.app.ActivityOptions)

Example 2 with CancelEnterRecentsWindowAnimationEvent

use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by ResurrectionRemix.

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 (useGridLayout()) {
            // For the grid layout, we directly set focus to the most recently used task
            // no matter we're moving forwards or backwards.
            newIndex = taskCount - 1;
        } else {
            // stack scroll.
            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) GridTaskView(com.android.systemui.recents.views.grid.GridTaskView) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent)

Example 3 with CancelEnterRecentsWindowAnimationEvent

use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by DirtyUnicorns.

the class RecentsTransitionHelper method launchTaskFromRecents.

/**
     * Launches the specified {@link Task}.
     */
public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task, final TaskStackView stackView, final TaskView taskView, final boolean screenPinningRequested, final Rect bounds, final int destinationStack) {
    final ActivityOptions opts = ActivityOptions.makeBasic();
    if (bounds != null) {
        opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
    }
    final ActivityOptions.OnAnimationStartedListener animStartedListener;
    final IAppTransitionAnimationSpecsFuture transitionFuture;
    if (taskView != null) {
        transitionFuture = getAppTransitionFuture(new AnimationSpecComposer() {

            @Override
            public List<AppTransitionAnimationSpec> composeSpecs() {
                return composeAnimationSpecs(task, stackView, destinationStack);
            }
        });
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
                if (screenPinningRequested) {
                    // Request screen pinning after the animation runs
                    mStartScreenPinningRunnable.taskId = task.key.id;
                    mHandler.postDelayed(mStartScreenPinningRunnable, 350);
                }
            }
        };
    } else {
        // This is only the case if the task is not on screen (scrolled offscreen for example)
        transitionFuture = null;
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
            }
        };
    }
    if (taskView == null) {
        // If there is no task view, then we do not need to worry about animating out occluding
        // task views, and we can launch immediately
        startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
    } else {
        LaunchTaskStartedEvent launchStartedEvent = new LaunchTaskStartedEvent(taskView, screenPinningRequested);
        if (task.group != null && !task.group.isFrontMostTask(task)) {
            launchStartedEvent.addPostAnimationCallback(new Runnable() {

                @Override
                public void run() {
                    startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
                }
            });
            EventBus.getDefault().send(launchStartedEvent);
        } else {
            EventBus.getDefault().send(launchStartedEvent);
            startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
        }
    }
    Recents.getSystemServices().sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
}
Also used : OnAnimationStartedListener(android.app.ActivityOptions.OnAnimationStartedListener) IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) LaunchTaskStartedEvent(com.android.systemui.recents.events.activity.LaunchTaskStartedEvent) ExitRecentsWindowFirstAnimationFrameEvent(com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent) ActivityOptions(android.app.ActivityOptions)

Example 4 with CancelEnterRecentsWindowAnimationEvent

use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by DirtyUnicorns.

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 (useGridLayout()) {
            // For the grid layout, we directly set focus to the most recently used task
            // no matter we're moving forwards or backwards.
            newIndex = taskCount - 1;
        } else {
            // stack scroll.
            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) GridTaskView(com.android.systemui.recents.views.grid.GridTaskView) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent)

Example 5 with CancelEnterRecentsWindowAnimationEvent

use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project platform_frameworks_base by android.

the class RecentsTransitionHelper method launchTaskFromRecents.

/**
     * Launches the specified {@link Task}.
     */
public void launchTaskFromRecents(final TaskStack stack, @Nullable final Task task, final TaskStackView stackView, final TaskView taskView, final boolean screenPinningRequested, final Rect bounds, final int destinationStack) {
    final ActivityOptions opts = ActivityOptions.makeBasic();
    if (bounds != null) {
        opts.setLaunchBounds(bounds.isEmpty() ? null : bounds);
    }
    final ActivityOptions.OnAnimationStartedListener animStartedListener;
    final IAppTransitionAnimationSpecsFuture transitionFuture;
    if (taskView != null) {
        transitionFuture = getAppTransitionFuture(new AnimationSpecComposer() {

            @Override
            public List<AppTransitionAnimationSpec> composeSpecs() {
                return composeAnimationSpecs(task, stackView, destinationStack);
            }
        });
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
                if (screenPinningRequested) {
                    // Request screen pinning after the animation runs
                    mStartScreenPinningRunnable.taskId = task.key.id;
                    mHandler.postDelayed(mStartScreenPinningRunnable, 350);
                }
            }
        };
    } else {
        // This is only the case if the task is not on screen (scrolled offscreen for example)
        transitionFuture = null;
        animStartedListener = new ActivityOptions.OnAnimationStartedListener() {

            @Override
            public void onAnimationStarted() {
                // If we are launching into another task, cancel the previous task's
                // window transition
                EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task));
                EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent());
                stackView.cancelAllTaskViewAnimations();
            }
        };
    }
    if (taskView == null) {
        // If there is no task view, then we do not need to worry about animating out occluding
        // task views, and we can launch immediately
        startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
    } else {
        LaunchTaskStartedEvent launchStartedEvent = new LaunchTaskStartedEvent(taskView, screenPinningRequested);
        if (task.group != null && !task.group.isFrontMostTask(task)) {
            launchStartedEvent.addPostAnimationCallback(new Runnable() {

                @Override
                public void run() {
                    startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
                }
            });
            EventBus.getDefault().send(launchStartedEvent);
        } else {
            EventBus.getDefault().send(launchStartedEvent);
            startTaskActivity(stack, task, taskView, opts, transitionFuture, animStartedListener);
        }
    }
    Recents.getSystemServices().sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_HOME_KEY);
}
Also used : OnAnimationStartedListener(android.app.ActivityOptions.OnAnimationStartedListener) IAppTransitionAnimationSpecsFuture(android.view.IAppTransitionAnimationSpecsFuture) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) LaunchTaskStartedEvent(com.android.systemui.recents.events.activity.LaunchTaskStartedEvent) ExitRecentsWindowFirstAnimationFrameEvent(com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent) CancelEnterRecentsWindowAnimationEvent(com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent) ActivityOptions(android.app.ActivityOptions)

Aggregations

CancelEnterRecentsWindowAnimationEvent (com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent)10 ActivityOptions (android.app.ActivityOptions)5 OnAnimationStartedListener (android.app.ActivityOptions.OnAnimationStartedListener)5 AppTransitionAnimationSpec (android.view.AppTransitionAnimationSpec)5 IAppTransitionAnimationSpecsFuture (android.view.IAppTransitionAnimationSpecsFuture)5 ExitRecentsWindowFirstAnimationFrameEvent (com.android.systemui.recents.events.activity.ExitRecentsWindowFirstAnimationFrameEvent)5 LaunchTaskStartedEvent (com.android.systemui.recents.events.activity.LaunchTaskStartedEvent)5 Task (com.android.systemui.recents.model.Task)5 GridTaskView (com.android.systemui.recents.views.grid.GridTaskView)4