use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackView method computeVisibleTaskTransforms.
/**
* Computes the task transforms at the current stack scroll for all visible tasks. If a valid
* target stack scroll is provided (ie. is different than {@param curStackScroll}), then the
* visible range includes all tasks at the target stack scroll. This is useful for ensure that
* all views necessary for a transition or animation will be visible at the start.
*
* This call ignores freeform tasks.
*
* @param taskTransforms The set of task view transforms to reuse, this list will be sized to
* match the size of {@param tasks}
* @param tasks The set of tasks for which to generate transforms
* @param curStackScroll The current stack scroll
* @param targetStackScroll The stack scroll that we anticipate we are going to be scrolling to.
* The range of the union of the visible views at the current and
* target stack scrolls will be returned.
* @param ignoreTasksSet The set of tasks to skip for purposes of calculaing the visible range.
* Transforms will still be calculated for the ignore tasks.
* @return the front and back most visible task indices (there may be non visible tasks in
* between this range)
*/
int[] computeVisibleTaskTransforms(ArrayList<TaskViewTransform> taskTransforms, ArrayList<Task> tasks, float curStackScroll, float targetStackScroll, ArraySet<Task.TaskKey> ignoreTasksSet, boolean ignoreTaskOverrides) {
int taskCount = tasks.size();
int[] visibleTaskRange = mTmpIntPair;
visibleTaskRange[0] = -1;
visibleTaskRange[1] = -1;
boolean useTargetStackScroll = Float.compare(curStackScroll, targetStackScroll) != 0;
// We can reuse the task transforms where possible to reduce object allocation
Utilities.matchTaskListSize(tasks, taskTransforms);
// Update the stack transforms
TaskViewTransform frontTransform = null;
TaskViewTransform frontTransformAtTarget = null;
TaskViewTransform transform = null;
TaskViewTransform transformAtTarget = null;
for (int i = taskCount - 1; i >= 0; i--) {
Task task = tasks.get(i);
// Calculate the current and (if necessary) the target transform for the task
transform = mLayoutAlgorithm.getStackTransform(task, curStackScroll, taskTransforms.get(i), frontTransform, ignoreTaskOverrides);
if (useTargetStackScroll && !transform.visible) {
// If we have a target stack scroll and the task is not currently visible, then we
// just update the transform at the new scroll
// TODO: Optimize this
transformAtTarget = mLayoutAlgorithm.getStackTransform(task, targetStackScroll, new TaskViewTransform(), frontTransformAtTarget);
if (transformAtTarget.visible) {
transform.copyFrom(transformAtTarget);
}
}
// visible stack indices
if (ignoreTasksSet.contains(task.key)) {
continue;
}
// the visible stack indices
if (task.isFreeformTask()) {
continue;
}
frontTransform = transform;
frontTransformAtTarget = transformAtTarget;
if (transform.visible) {
if (visibleTaskRange[0] < 0) {
visibleTaskRange[0] = i;
}
visibleTaskRange[1] = i;
}
}
return visibleTaskRange;
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackView method getFrontMostTaskView.
/**
* Returns the front most task view.
*
* @param stackTasksOnly if set, will return the front most task view in the stack (by default
* the front most task view will be freeform since they are placed above
* stack tasks)
*/
private TaskView getFrontMostTaskView(boolean stackTasksOnly) {
List<TaskView> taskViews = getTaskViews();
int taskViewCount = taskViews.size();
for (int i = taskViewCount - 1; i >= 0; i--) {
TaskView tv = taskViews.get(i);
Task task = tv.getTask();
if (stackTasksOnly && task.isFreeformTask()) {
continue;
}
return tv;
}
return null;
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackView method setFocusedTask.
/**
* Sets the focused task to the provided (bounded focusTaskIndex).
*
* @return whether or not the stack will scroll as a part of this focus change
*/
public boolean setFocusedTask(int focusTaskIndex, boolean scrollToTask, boolean requestViewFocus, int timerIndicatorDuration) {
// Find the next task to focus
int newFocusedTaskIndex = mStack.getTaskCount() > 0 ? Utilities.clamp(focusTaskIndex, 0, mStack.getTaskCount() - 1) : -1;
final Task newFocusedTask = (newFocusedTaskIndex != -1) ? mStack.getStackTasks().get(newFocusedTaskIndex) : null;
// Reset the last focused task state if changed
if (mFocusedTask != null) {
// Cancel the timer indicator, if applicable
if (timerIndicatorDuration > 0) {
final TaskView tv = getChildViewForTask(mFocusedTask);
if (tv != null) {
tv.getHeaderView().cancelFocusTimerIndicator();
}
}
resetFocusedTask(mFocusedTask);
}
boolean willScroll = false;
mFocusedTask = newFocusedTask;
if (newFocusedTask != null) {
// Start the timer indicator, if applicable
if (timerIndicatorDuration > 0) {
final TaskView tv = getChildViewForTask(mFocusedTask);
if (tv != null) {
tv.getHeaderView().startFocusTimerIndicator(timerIndicatorDuration);
} else {
// The view is null; set a flag for later
mStartTimerIndicatorDuration = timerIndicatorDuration;
}
}
if (scrollToTask) {
// Cancel any running enter animations at this point when we scroll or change focus
if (!mEnterAnimationComplete) {
cancelAllTaskViewAnimations();
}
mLayoutAlgorithm.clearUnfocusedTaskOverrides();
willScroll = mAnimationHelper.startScrollToFocusedTaskAnimation(newFocusedTask, requestViewFocus);
} else {
// Focus the task view
TaskView newFocusedTaskView = getChildViewForTask(newFocusedTask);
if (newFocusedTaskView != null) {
newFocusedTaskView.setFocusedState(true, requestViewFocus);
}
}
// Any time a task view gets the focus, we move the focus frame around it.
if (mTaskViewFocusFrame != null) {
mTaskViewFocusFrame.moveGridTaskViewFocus(getChildViewForTask(newFocusedTask));
}
}
return willScroll;
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackView method getLockedTaskCount.
public int getLockedTaskCount() {
int count = 0;
ArrayList<Task> mTasks = mStack.getStackTasks();
for (Task mTask : mTasks) {
if (mTask.isLockedTask) {
count++;
}
}
return count;
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by crdroidandroid.
the class TaskStackView method performAccessibilityAction.
@Override
public boolean performAccessibilityAction(int action, Bundle arguments) {
if (super.performAccessibilityAction(action, arguments)) {
return true;
}
Task focusedTask = getAccessibilityFocusedTask();
int taskIndex = mStack.indexOfStackTask(focusedTask);
if (0 <= taskIndex && taskIndex < mStack.getTaskCount()) {
switch(action) {
case AccessibilityNodeInfo.ACTION_SCROLL_FORWARD:
{
setFocusedTask(taskIndex + 1, true, /* scrollToTask */
true, /* requestViewFocus */
0);
return true;
}
case AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD:
{
setFocusedTask(taskIndex - 1, true, /* scrollToTask */
true, /* requestViewFocus */
0);
return true;
}
}
}
return false;
}
Aggregations