Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee2e28fa authored by Tony Wickham's avatar Tony Wickham Committed by Alex Chau
Browse files

Allow clipping individual direction of TaskView

- Only clip the nav bar (taskbar), and always do that in tablets regardless of whether taskbar is stashed, so TaskView always have the same ratio (mocks: https://docs.google.com/presentation/d/1_3zQak_C9FzDPCcIdYagfUit4QyqfdRxetkim3dI9rY/edit#slide=id.ge211eb96a5_5_8)
- When taskbar is present, don't use full thumbnail to avoid TaskView resizing in fullscreen: http://dr/file/d/18C8DSygPBU1gkmMQPPIIa2NqQESFurxW/view?resourcekey=0-8W79f31gstzI_1ZPpHulBQ
- When taskbar is stashed, we still need full thumbnail to gradually crop out the taskbar in overview

Test: Open Chrome, swipe up and ensure status bar inset stays in overview but taskbar stays clipped out from the onset.
Bug: 190681228
Change-Id: I9d563572f2e6800e90d567c2bfae4528a126f24e
parent 2683bd77
Loading
Loading
Loading
Loading
+25 −9
Original line number Diff line number Diff line
@@ -290,19 +290,35 @@ public abstract class BaseActivityInterface<STATE_TYPE extends BaseState<STATE_T
    public static void getTaskDimension(Context context, DeviceProfile dp, PointF out) {
        if (dp.isMultiWindowMode) {
            WindowBounds bounds = SplitScreenBounds.INSTANCE.getSecondaryWindowBounds(context);
            if (TaskView.clipStatusAndNavBars(dp)) {
            out.x = bounds.availableSize.x;
            out.y = bounds.availableSize.y;
            } else {
                out.x = bounds.availableSize.x + bounds.insets.left + bounds.insets.right;
                out.y = bounds.availableSize.y + bounds.insets.top + bounds.insets.bottom;
            if (!TaskView.clipLeft(dp)) {
                out.x += bounds.insets.left;
            }
            if (!TaskView.clipRight(dp)) {
                out.x += bounds.insets.right;
            }
            if (!TaskView.clipTop(dp)) {
                out.y += bounds.insets.top;
            }
            if (!TaskView.clipBottom(dp)) {
                out.y += bounds.insets.bottom;
            }
        } else if (TaskView.clipStatusAndNavBars(dp)) {
            out.x = dp.availableWidthPx;
            out.y = dp.availableHeightPx;
        } else {
            out.x = dp.widthPx;
            out.y = dp.heightPx;
            if (TaskView.clipLeft(dp)) {
                out.x -= dp.getInsets().left;
            }
            if (TaskView.clipRight(dp)) {
                out.x -= dp.getInsets().right;
            }
            if (TaskView.clipTop(dp)) {
                out.y -= dp.getInsets().top;
            }
            if (TaskView.clipBottom(dp)) {
                out.y -= Math.max(dp.getInsets().bottom, dp.taskbarSize);
            }
        }
    }

+11 −3
Original line number Diff line number Diff line
@@ -396,9 +396,17 @@ public class RecentsOrientedState implements
        Rect insets = dp.getInsets();
        float fullWidth = dp.widthPx;
        float fullHeight = dp.heightPx;
        if (TaskView.clipStatusAndNavBars(dp)) {
            fullWidth -= insets.left + insets.right;
            fullHeight -= insets.top + insets.bottom;
        if (TaskView.clipLeft(dp)) {
            fullWidth -= insets.left;
        }
        if (TaskView.clipRight(dp)) {
            fullWidth -= insets.right;
        }
        if (TaskView.clipTop(dp)) {
            fullHeight -= insets.top;
        }
        if (TaskView.clipBottom(dp)) {
            fullHeight -= insets.bottom;
        }

        getTaskDimension(mContext, dp, outPivot);
+21 −11
Original line number Diff line number Diff line
@@ -211,10 +211,6 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
            return Insets.NONE;
        }

        if (!TaskView.clipStatusAndNavBars(mActivity.getDeviceProfile())) {
            return Insets.NONE;
        }

        RectF bitmapRect = new RectF(
                0, 0,
                mThumbnailData.thumbnail.getWidth(), mThumbnailData.thumbnail.getHeight());
@@ -228,11 +224,14 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc
        RectF boundsInBitmapSpace = new RectF();
        boundsToBitmapSpace.mapRect(boundsInBitmapSpace, viewRect);

        return Insets.of(
            Math.round(boundsInBitmapSpace.left),
            Math.round(boundsInBitmapSpace.top),
            Math.round(bitmapRect.right - boundsInBitmapSpace.right),
            Math.round(bitmapRect.bottom - boundsInBitmapSpace.bottom));
        DeviceProfile dp = mActivity.getDeviceProfile();
        int leftInset = TaskView.clipLeft(dp) ? Math.round(boundsInBitmapSpace.left) : 0;
        int topInset = TaskView.clipTop(dp) ? Math.round(boundsInBitmapSpace.top) : 0;
        int rightInset = TaskView.clipRight(dp) ? Math.round(
                bitmapRect.right - boundsInBitmapSpace.right) : 0;
        int bottomInset = TaskView.clipBottom(dp)
                ? Math.round(bitmapRect.bottom - boundsInBitmapSpace.bottom) : 0;
        return Insets.of(leftInset, topInset, rightInset, bottomInset);
    }


@@ -440,8 +439,19 @@ public class TaskThumbnailView extends View implements PluginListener<OverviewSc

            int thumbnailRotation = thumbnailData.rotation;
            int deltaRotate = getRotationDelta(currentRotation, thumbnailRotation);
            RectF thumbnailClipHint = TaskView.clipStatusAndNavBars(dp)
                    ? new RectF(thumbnailData.insets) : new RectF();
            RectF thumbnailClipHint = new RectF();
            if (TaskView.clipLeft(dp)) {
                thumbnailClipHint.left = thumbnailData.insets.left;
            }
            if (TaskView.clipRight(dp)) {
                thumbnailClipHint.right = thumbnailData.insets.right;
            }
            if (TaskView.clipTop(dp)) {
                thumbnailClipHint.top = thumbnailData.insets.top;
            }
            if (TaskView.clipBottom(dp)) {
                thumbnailClipHint.bottom = thumbnailData.insets.bottom;
            }

            float scale = thumbnailData.scale;
            final float thumbnailScale;
+26 −6
Original line number Diff line number Diff line
@@ -146,19 +146,39 @@ public class TaskView extends FrameLayout implements Reusable {
    public static final float MAX_PAGE_SCRIM_ALPHA = 0.4f;

    /**
     * Should the TaskView display clip off the status and navigation bars in recents. When this
     * is false the overview shows the whole screen scaled down instead.
     * Should the TaskView display clip off the left inset in RecentsView.
     */
    public static boolean clipStatusAndNavBars(DeviceProfile deviceProfile) {
        return deviceProfile.isTaskbarPresentInApps;
    public static boolean clipLeft(DeviceProfile deviceProfile) {
        return false;
    }

    /**
     * Should the TaskView display clip off the top inset in RecentsView.
     */
    public static boolean clipTop(DeviceProfile deviceProfile) {
        return false;
    }

    /**
     * Should the TaskView display clip off the right inset in RecentsView.
     */
    public static boolean clipRight(DeviceProfile deviceProfile) {
        return false;
    }

    /**
     * Should the TaskView display clip off the bottom inset in RecentsView.
     */
    public static boolean clipBottom(DeviceProfile deviceProfile) {
        return deviceProfile.isTablet;
    }

    /**
     * Should the TaskView scale down to fit whole thumbnail in fullscreen.
     */
    public static boolean useFullThumbnail(DeviceProfile deviceProfile) {
        return deviceProfile.isTaskbarPresentInApps;
    };
        return deviceProfile.isTablet && !deviceProfile.isTaskbarPresentInApps;
    }

    private static final float EDGE_SCALE_DOWN_FACTOR_CAROUSEL = 0.03f;
    private static final float EDGE_SCALE_DOWN_FACTOR_GRID = 0.00f;