use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.
the class RecentsImpl method getThumbnailTransitionTransform.
/**
* Returns the transition rect for the given task id.
*/
private TaskViewTransform getThumbnailTransitionTransform(TaskStackView stackView, Task runningTaskOut, Rect windowOverrideRect) {
// Find the running task in the TaskStack
TaskStack stack = stackView.getStack();
Task launchTask = stack.getLaunchTarget();
if (launchTask != null) {
runningTaskOut.copyFrom(launchTask);
} else {
// If no task is specified or we can not find the task just use the front most one
launchTask = stack.getStackFrontMostTask(true);
runningTaskOut.copyFrom(launchTask);
}
// Get the transform for the running task
stackView.updateLayoutAlgorithm(true);
stackView.updateToInitialState();
stackView.getStackAlgorithm().getStackTransformScreenCoordinates(launchTask, stackView.getScroller().getStackScroll(), mTmpTransform, null, windowOverrideRect);
return mTmpTransform;
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.
the class TaskStackLayoutAlgorithm method addUnfocusedTaskOverride.
/**
* Adds and override task progress for the given task when transitioning from focused to
* unfocused state.
*/
public void addUnfocusedTaskOverride(TaskView taskView, float stackScroll) {
mFocusedRange.offset(stackScroll);
mUnfocusedRange.offset(stackScroll);
Task task = taskView.getTask();
int top = taskView.getTop() - mTaskRect.top;
float focusedRangeX = getNormalizedXFromFocusedY(top, FROM_TOP);
float unfocusedRangeX = getNormalizedXFromUnfocusedY(top, FROM_TOP);
float unfocusedTaskProgress = stackScroll + mUnfocusedRange.getAbsoluteX(unfocusedRangeX);
if (Float.compare(focusedRangeX, unfocusedRangeX) != 0) {
mTaskIndexOverrideMap.put(task.key.id, unfocusedTaskProgress);
}
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.
the class TaskStackAnimationHelper method prepareForEnterAnimation.
/**
* Prepares the stack views and puts them in their initial animation state while visible, before
* the in-app enter animations start (after the window-transition completes).
*/
public void prepareForEnterAnimation() {
RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState();
Resources res = mStackView.getResources();
Resources appResources = mStackView.getContext().getApplicationContext().getResources();
TaskStackLayoutAlgorithm stackLayout = mStackView.getStackAlgorithm();
TaskStackViewScroller stackScroller = mStackView.getScroller();
TaskStack stack = mStackView.getStack();
Task launchTargetTask = stack.getLaunchTarget();
// Break early if there are no tasks
if (stack.getTaskCount() == 0) {
return;
}
int offscreenYOffset = stackLayout.mStackRect.height();
int taskViewAffiliateGroupEnterOffset = res.getDimensionPixelSize(R.dimen.recents_task_stack_animation_affiliate_enter_offset);
int launchedWhileDockingOffset = res.getDimensionPixelSize(R.dimen.recents_task_stack_animation_launched_while_docking_offset);
boolean isLandscape = appResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
// Prepare each of the task views for their enter animation from front to back
List<TaskView> taskViews = mStackView.getTaskViews();
for (int i = taskViews.size() - 1; i >= 0; i--) {
TaskView tv = taskViews.get(i);
Task task = tv.getTask();
boolean currentTaskOccludesLaunchTarget = launchTargetTask != null && launchTargetTask.group != null && launchTargetTask.group.isTaskAboveTask(task, launchTargetTask);
boolean hideTask = launchTargetTask != null && launchTargetTask.isFreeformTask() && task.isFreeformTask();
// Get the current transform for the task, which will be used to position it offscreen
stackLayout.getStackTransform(task, stackScroller.getStackScroll(), mTmpTransform, null);
if (hideTask) {
tv.setVisibility(View.INVISIBLE);
} else if (launchState.launchedFromApp && !launchState.launchedViaDockGesture) {
if (task.isLaunchTarget) {
tv.onPrepareLaunchTargetForEnterAnimation();
} else if (currentTaskOccludesLaunchTarget) {
// Move the task view slightly lower so we can animate it in
mTmpTransform.rect.offset(0, taskViewAffiliateGroupEnterOffset);
mTmpTransform.alpha = 0f;
mStackView.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
tv.setClipViewInStack(false);
}
} else if (launchState.launchedFromHome) {
// Move the task view off screen (below) so we can animate it in
mTmpTransform.rect.offset(0, offscreenYOffset);
mTmpTransform.alpha = 0f;
mStackView.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
} else if (launchState.launchedViaDockGesture) {
int offset = isLandscape ? launchedWhileDockingOffset : (int) (offscreenYOffset * 0.9f);
mTmpTransform.rect.offset(0, offset);
mTmpTransform.alpha = 0f;
mStackView.updateTaskViewToTransform(tv, mTmpTransform, AnimationProps.IMMEDIATE);
}
}
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.
the class TaskStackLayoutAlgorithm method setTaskOverridesForInitialState.
/**
* Creates task overrides to ensure the initial stack layout if necessary.
*/
public void setTaskOverridesForInitialState(TaskStack stack, boolean ignoreScrollToFront) {
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
mTaskIndexOverrideMap.clear();
boolean scrollToFront = launchState.launchedFromHome || launchState.launchedFromBlacklistedApp || launchState.launchedViaDockGesture;
if (getInitialFocusState() == STATE_UNFOCUSED && mNumStackTasks > 1) {
if (ignoreScrollToFront || (!launchState.launchedWithAltTab && !scrollToFront)) {
// Set the initial scroll to the predefined state (which differs from the stack)
float[] initialNormX = null;
float minBottomTaskNormX = getNormalizedXFromUnfocusedY(mSystemInsets.bottom + mInitialBottomOffset, FROM_BOTTOM);
float maxBottomTaskNormX = getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight + mTaskRect.height() - mMinMargin, FROM_TOP);
if (mNumStackTasks <= 2) {
// For small stacks, position the tasks so that they are top aligned to under
// the action button, but ensure that it is at least a certain offset from the
// bottom of the stack
initialNormX = new float[] { Math.min(maxBottomTaskNormX, minBottomTaskNormX), getNormalizedXFromUnfocusedY(mFocusedTopPeekHeight, FROM_TOP) };
} else {
initialNormX = new float[] { minBottomTaskNormX, getNormalizedXFromUnfocusedY(mInitialTopOffset, FROM_TOP) };
}
mUnfocusedRange.offset(0f);
List<Task> tasks = stack.getStackTasks();
int taskCount = tasks.size();
for (int i = taskCount - 1; i >= 0; i--) {
int indexFromFront = taskCount - i - 1;
if (indexFromFront >= initialNormX.length) {
break;
}
float newTaskProgress = mInitialScrollP + mUnfocusedRange.getAbsoluteX(initialNormX[indexFromFront]);
mTaskIndexOverrideMap.put(tasks.get(i).key.id, newTaskProgress);
}
}
}
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by AOSPA.
the class TaskStackView method onBusEvent.
public final void onBusEvent(LaunchNextTaskRequestEvent event) {
if (mAwaitingFirstLayout) {
mLaunchNextAfterFirstMeasure = true;
return;
}
final Task launchTask = mStack.getNextLaunchTarget();
if (launchTask != null) {
launchTask(launchTask);
MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_LAUNCH_PREVIOUS_TASK, launchTask.key.getComponent().toString());
} else if (mStack.getTaskCount() == 0) {
// If there are no tasks, then just hide recents back to home.
EventBus.getDefault().send(new HideRecentsEvent(false, true));
}
}
Aggregations