use of com.android.systemui.recents.views.TaskViewTransform in project android_frameworks_base by AOSPA.
the class RecentsImpl method updateHeaderBarLayout.
/**
* Prepares the header bar layout for the next transition, if the task view bounds has changed
* since the last call, it will attempt to re-measure and layout the header bar to the new size.
*
* @param stack the stack to initialize the stack layout with
* @param windowRectOverride the rectangle to use when calculating the stack state which can
* be different from the current window rect if recents is resizing
* while being launched
*/
private void updateHeaderBarLayout(TaskStack stack, Rect windowRectOverride) {
SystemServicesProxy ssp = Recents.getSystemServices();
Rect displayRect = ssp.getDisplayRect();
Rect systemInsets = new Rect();
ssp.getStableInsets(systemInsets);
Rect windowRect = windowRectOverride != null ? new Rect(windowRectOverride) : ssp.getWindowRect();
// them identical.
if (ssp.hasDockedTask()) {
windowRect.bottom -= systemInsets.bottom;
systemInsets.bottom = 0;
}
calculateWindowStableInsets(systemInsets, windowRect);
windowRect.offsetTo(0, 0);
TaskStackLayoutAlgorithm stackLayout = mDummyStackView.getStackAlgorithm();
// Rebind the header bar and draw it for the transition
stackLayout.setSystemInsets(systemInsets);
if (stack != null) {
stackLayout.getTaskStackBounds(displayRect, windowRect, systemInsets.top, systemInsets.left, systemInsets.right, mTaskStackBounds);
stackLayout.reset();
stackLayout.initialize(displayRect, windowRect, mTaskStackBounds, TaskStackLayoutAlgorithm.StackState.getStackStateForStack(stack));
mDummyStackView.setTasks(stack, false);
// Get the width of a task view so that we know how wide to draw the header bar.
int taskViewWidth = 0;
if (mDummyStackView.useGridLayout()) {
TaskGridLayoutAlgorithm gridLayout = mDummyStackView.getGridAlgorithm();
gridLayout.initialize(windowRect);
taskViewWidth = (int) gridLayout.getTransform(0, /* taskIndex */
stack.getTaskCount(), new TaskViewTransform(), stackLayout).rect.width();
} else {
Rect taskViewBounds = stackLayout.getUntransformedTaskViewBounds();
if (!taskViewBounds.isEmpty()) {
taskViewWidth = taskViewBounds.width();
}
}
if (taskViewWidth > 0) {
synchronized (mHeaderBarLock) {
if (mHeaderBar.getMeasuredWidth() != taskViewWidth || mHeaderBar.getMeasuredHeight() != mTaskBarHeight) {
if (mDummyStackView.useGridLayout()) {
mHeaderBar.setShouldDarkenBackgroundColor(true);
mHeaderBar.setNoUserInteractionState();
}
mHeaderBar.forceLayout();
mHeaderBar.measure(MeasureSpec.makeMeasureSpec(taskViewWidth, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(mTaskBarHeight, MeasureSpec.EXACTLY));
}
mHeaderBar.layout(0, 0, taskViewWidth, mTaskBarHeight);
}
// Update the transition bitmap to match the new header bar height
if (mThumbTransitionBitmapCache == null || (mThumbTransitionBitmapCache.getWidth() != taskViewWidth) || (mThumbTransitionBitmapCache.getHeight() != mTaskBarHeight)) {
mThumbTransitionBitmapCache = Bitmap.createBitmap(taskViewWidth, mTaskBarHeight, Bitmap.Config.ARGB_8888);
}
}
}
}
use of com.android.systemui.recents.views.TaskViewTransform in project android_frameworks_base by AOSPA.
the class RecentsImpl method getThumbnailTransitionActivityOptions.
/**
* Creates the activity options for an app->recents transition.
*/
private ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo runningTask, TaskStackView stackView, Rect windowOverrideRect) {
if (runningTask != null && runningTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>();
ArrayList<Task> tasks = stackView.getStack().getStackTasks();
TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
TaskStackViewScroller stackScroller = stackView.getScroller();
stackView.updateLayoutAlgorithm(true);
stackView.updateToInitialState();
for (int i = tasks.size() - 1; i >= 0; i--) {
Task task = tasks.get(i);
if (task.isFreeformTask()) {
mTmpTransform = stackLayout.getStackTransformScreenCoordinates(task, stackScroller.getStackScroll(), mTmpTransform, null, windowOverrideRect);
Bitmap thumbnail = drawThumbnailTransitionBitmap(task, mTmpTransform, mThumbTransitionBitmapCache);
Rect toTaskRect = new Rect();
mTmpTransform.rect.round(toTaskRect);
specs.add(new AppTransitionAnimationSpec(task.key.id, thumbnail, toTaskRect));
}
}
AppTransitionAnimationSpec[] specsArray = new AppTransitionAnimationSpec[specs.size()];
specs.toArray(specsArray);
return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, specsArray, mHandler, null, this);
} else {
// Update the destination rect
Task toTask = new Task();
TaskViewTransform toTransform = getThumbnailTransitionTransform(stackView, toTask, windowOverrideRect);
Bitmap thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform, mThumbTransitionBitmapCache);
if (thumbnail != null) {
RectF toTaskRect = toTransform.rect;
return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, thumbnail, (int) toTaskRect.left, (int) toTaskRect.top, (int) toTaskRect.width(), (int) toTaskRect.height(), mHandler, null);
}
// If both the screenshot and thumbnail fails, then just fall back to the default transition
return getUnknownTransitionActivityOptions();
}
}
use of com.android.systemui.recents.views.TaskViewTransform in project android_frameworks_base by AOSPA.
the class Utilities method matchTaskListSize.
/**
* Updates {@param transforms} to be the same size as {@param tasks}.
*/
public static void matchTaskListSize(List<Task> tasks, List<TaskViewTransform> transforms) {
// We can reuse the task transforms where possible to reduce object allocation
int taskTransformCount = transforms.size();
int taskCount = tasks.size();
if (taskTransformCount < taskCount) {
// If there are less transforms than tasks, then add as many transforms as necessary
for (int i = taskTransformCount; i < taskCount; i++) {
transforms.add(new TaskViewTransform());
}
} else if (taskTransformCount > taskCount) {
// If there are more transforms than tasks, then just subset the transform list
transforms.subList(taskCount, taskTransformCount).clear();
}
}
use of com.android.systemui.recents.views.TaskViewTransform in project android_frameworks_base by crdroidandroid.
the class RecentsImpl method getThumbnailTransitionActivityOptions.
/**
* Creates the activity options for an app->recents transition.
*/
private ActivityOptions getThumbnailTransitionActivityOptions(ActivityManager.RunningTaskInfo runningTask, TaskStackView stackView, Rect windowOverrideRect) {
if (runningTask != null && runningTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>();
ArrayList<Task> tasks = stackView.getStack().getStackTasks();
TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
TaskStackViewScroller stackScroller = stackView.getScroller();
stackView.updateLayoutAlgorithm(true);
stackView.updateToInitialState();
for (int i = tasks.size() - 1; i >= 0; i--) {
Task task = tasks.get(i);
if (task.isFreeformTask()) {
mTmpTransform = stackLayout.getStackTransformScreenCoordinates(task, stackScroller.getStackScroll(), mTmpTransform, null, windowOverrideRect);
Bitmap thumbnail = drawThumbnailTransitionBitmap(task, mTmpTransform, mThumbTransitionBitmapCache);
Rect toTaskRect = new Rect();
mTmpTransform.rect.round(toTaskRect);
specs.add(new AppTransitionAnimationSpec(task.key.id, thumbnail, toTaskRect));
}
}
AppTransitionAnimationSpec[] specsArray = new AppTransitionAnimationSpec[specs.size()];
specs.toArray(specsArray);
return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, specsArray, mHandler, null, this);
} else {
// Update the destination rect
Task toTask = new Task();
TaskViewTransform toTransform = getThumbnailTransitionTransform(stackView, toTask, windowOverrideRect);
Bitmap thumbnail = drawThumbnailTransitionBitmap(toTask, toTransform, mThumbTransitionBitmapCache);
if (thumbnail != null) {
RectF toTaskRect = toTransform.rect;
return ActivityOptions.makeThumbnailAspectScaleDownAnimation(mDummyStackView, thumbnail, (int) toTaskRect.left, (int) toTaskRect.top, (int) toTaskRect.width(), (int) toTaskRect.height(), mHandler, null);
}
// If both the screenshot and thumbnail fails, then just fall back to the default transition
return getUnknownTransitionActivityOptions();
}
}
Aggregations