use of com.android.systemui.recents.model.Task 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.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackView method onInitializeAccessibilityNodeInfo.
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(info);
List<TaskView> taskViews = getTaskViews();
int taskViewCount = taskViews.size();
if (taskViewCount > 1) {
// Find the accessibility focused task
Task focusedTask = getAccessibilityFocusedTask();
info.setScrollable(true);
int focusedTaskIndex = mStack.indexOfStackTask(focusedTask);
if (focusedTaskIndex > 0) {
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD);
}
if (0 <= focusedTaskIndex && focusedTaskIndex < mStack.getTaskCount() - 1) {
info.addAction(AccessibilityNodeInfo.ACTION_SCROLL_FORWARD);
}
}
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackViewTouchHandler method updateTaskViewTransforms.
/**
* Interpolates the non-deleting tasks to their final transforms from their current transforms.
*/
private void updateTaskViewTransforms(float dismissFraction) {
List<TaskView> taskViews = mSv.getTaskViews();
int taskViewCount = taskViews.size();
for (int i = 0; i < taskViewCount; i++) {
TaskView tv = taskViews.get(i);
Task task = tv.getTask();
if (mSv.isIgnoredTask(task)) {
continue;
}
int taskIndex = mCurrentTasks.indexOf(task);
if (taskIndex == -1) {
// just ignore it
continue;
}
TaskViewTransform fromTransform = mCurrentTaskTransforms.get(taskIndex);
TaskViewTransform toTransform = mFinalTaskTransforms.get(taskIndex);
mTmpTransform.copyFrom(fromTransform);
// We only really need to interpolate the bounds, progress and translation
mTmpTransform.rect.set(Utilities.RECTF_EVALUATOR.evaluate(dismissFraction, fromTransform.rect, toTransform.rect));
mTmpTransform.dimAlpha = fromTransform.dimAlpha + (toTransform.dimAlpha - fromTransform.dimAlpha) * dismissFraction;
mTmpTransform.viewOutlineAlpha = fromTransform.viewOutlineAlpha + (toTransform.viewOutlineAlpha - fromTransform.viewOutlineAlpha) * dismissFraction;
mTmpTransform.translationZ = fromTransform.translationZ + (toTransform.translationZ - fromTransform.translationZ) * dismissFraction;
mSv.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
}
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackViewTouchHandler method canChildBeDismissed.
@Override
public boolean canChildBeDismissed(View v) {
// Disallow dismissing an already dismissed task
TaskView tv = (TaskView) v;
Task task = tv.getTask();
return !mSwipeHelperAnimations.containsKey(v) && (mSv.getStack().indexOfStackTask(task) != -1);
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackView method onBusEvent.
public final void onBusEvent(LaunchMostRecentTaskRequestEvent event) {
if (mStack.getTaskCount() > 0) {
Task mostRecentTask = mStack.getStackFrontMostTask(true);
launchTask(mostRecentTask);
}
}
Aggregations