Search in sources :

Example 1 with TaskGridLayoutAlgorithm

use of com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm in project android_frameworks_base by DirtyUnicorns.

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 2 with TaskGridLayoutAlgorithm

use of com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm in project android_frameworks_base by ResurrectionRemix.

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 3 with TaskGridLayoutAlgorithm

use of com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm in project android_frameworks_base by crdroidandroid.

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 4 with TaskGridLayoutAlgorithm

use of com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm 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)

Aggregations

Rect (android.graphics.Rect)4 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)4 TaskStackLayoutAlgorithm (com.android.systemui.recents.views.TaskStackLayoutAlgorithm)4 TaskViewTransform (com.android.systemui.recents.views.TaskViewTransform)4 TaskGridLayoutAlgorithm (com.android.systemui.recents.views.grid.TaskGridLayoutAlgorithm)4