Search in sources :

Example 11 with TaskViewTransform

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);
            }
        }
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) Rect(android.graphics.Rect) TaskGridLayoutAlgorithm(com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm) TaskViewTransform(com.android.systemui.recents.views.TaskViewTransform) TaskStackLayoutAlgorithm(com.android.systemui.recents.views.TaskStackLayoutAlgorithm)

Example 12 with TaskViewTransform

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();
    }
}
Also used : TaskStackViewScroller(com.android.systemui.recents.views.TaskStackViewScroller) Task(com.android.systemui.recents.model.Task) Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) TaskViewTransform(com.android.systemui.recents.views.TaskViewTransform) TaskStackLayoutAlgorithm(com.android.systemui.recents.views.TaskStackLayoutAlgorithm)

Example 13 with TaskViewTransform

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();
    }
}
Also used : TaskViewTransform(com.android.systemui.recents.views.TaskViewTransform)

Example 14 with TaskViewTransform

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();
    }
}
Also used : TaskStackViewScroller(com.android.systemui.recents.views.TaskStackViewScroller) Task(com.android.systemui.recents.model.Task) Rect(android.graphics.Rect) ArrayList(java.util.ArrayList) RectF(android.graphics.RectF) Bitmap(android.graphics.Bitmap) AppTransitionAnimationSpec(android.view.AppTransitionAnimationSpec) TaskViewTransform(com.android.systemui.recents.views.TaskViewTransform) TaskStackLayoutAlgorithm(com.android.systemui.recents.views.TaskStackLayoutAlgorithm)

Aggregations

TaskViewTransform (com.android.systemui.recents.views.TaskViewTransform)14 Rect (android.graphics.Rect)9 TaskStackLayoutAlgorithm (com.android.systemui.recents.views.TaskStackLayoutAlgorithm)9 Bitmap (android.graphics.Bitmap)5 RectF (android.graphics.RectF)5 AppTransitionAnimationSpec (android.view.AppTransitionAnimationSpec)5 Task (com.android.systemui.recents.model.Task)5 TaskStackViewScroller (com.android.systemui.recents.views.TaskStackViewScroller)5 ArrayList (java.util.ArrayList)5 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)4 TaskGridLayoutAlgorithm (com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm)4