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));
}
}
}
use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by crdroidandroid.
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));
}
}
}
use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by AOSPA.
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);
}
use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by AOSPA.
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));
}
}
}
use of com.android.systemui.recents.events.activity.CancelEnterRecentsWindowAnimationEvent in project android_frameworks_base by crdroidandroid.
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);
}
Aggregations