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

Commit 3646a1b7 authored by Jordan Silva's avatar Jordan Silva
Browse files

Fix workspace and hotseat paddings for responsive grid in landscape

Add paddings for workspace and hotseat when vertical bar is enabled.

Fix: 294033018
Flag: ENABLE_RESPONSIVE_WORKSPACE
Test: DeviceProfileDumpTest
Test: DeviceProfileAlternativeGridDumpTest
Test: DeviceProfileResponsiveDumpTest
Test: DeviceProfileResponsiveAlternativeDisplaysDumpTest
Change-Id: I7358d2eb7b7c53b436756c21bd81d4746ea01801
parent 08799066
Loading
Loading
Loading
Loading
+46 −13
Original line number Diff line number Diff line
@@ -618,6 +618,10 @@ public class DeviceProfile {
        // Hotseat and QSB width depends on updated cellSize and workspace padding
        recalculateHotseatWidthAndBorderSpace();

        if (mIsResponsiveGrid && isVerticalBarLayout()) {
            hotseatBorderSpace = cellLayoutBorderSpacePx.y;
        }

        // AllApps height calculation depends on updated cellSize
        if (isTablet) {
            int collapseHandleHeight =
@@ -717,7 +721,7 @@ public class DeviceProfile {
    /** Updates hotseatCellHeightPx and hotseatBarSizePx */
    private void updateHotseatSizes(int hotseatIconSizePx) {
        // Ensure there is enough space for folder icons, which have a slightly larger radius.
        hotseatCellHeightPx = (int) Math.ceil(hotseatIconSizePx * ICON_OVERLAP_FACTOR);
        hotseatCellHeightPx = getIconSizeWithOverlap(hotseatIconSizePx);

        if (isVerticalBarLayout()) {
            hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
@@ -783,7 +787,6 @@ public class DeviceProfile {
            hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidthPx,
                    (isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1);
        } while (hotseatBorderSpace < mMinHotseatIconSpacePx && numShownHotseatIcons > 1);

    }

    private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
@@ -866,11 +869,24 @@ public class DeviceProfile {
        float workspaceCellPaddingY = getCellSize().y - iconSizePx - iconDrawablePaddingPx
                - iconTextHeight;

        if (mIsResponsiveGrid) {
            // Hide text only if doesn't fit inside the cell for responsive grid
            if (workspaceCellPaddingY < 0) {
                iconTextSizePx = 0;
                iconDrawablePaddingPx = 0;
                int iconSizeWithOverlap = getIconSizeWithOverlap(iconSizePx);
                cellYPaddingPx = Math.max(0, getCellSize().y - iconSizeWithOverlap) / 2;
                autoResizeAllAppsCells();
            }

            return;
        }

        // We want enough space so that the text is closer to its corresponding icon.
        if (workspaceCellPaddingY < iconTextHeight) {
            iconTextSizePx = 0;
            iconDrawablePaddingPx = 0;
            cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR);
            cellHeightPx = getIconSizeWithOverlap(iconSizePx);
            autoResizeAllAppsCells();
        }
    }
@@ -950,6 +966,10 @@ public class DeviceProfile {
        return Math.max(0, drawablePadding - iconSizeDiff / 2);
    }

    private int getIconSizeWithOverlap(int iconSize) {
        return (int) Math.ceil(iconSize * ICON_OVERLAP_FACTOR);
    }

    /**
     * Updating the iconSize affects many aspects of the launcher layout, such as: iconSizePx,
     * iconTextSizePx, iconDrawablePaddingPx, cellWidth/Height, allApps* variants,
@@ -1052,7 +1072,7 @@ public class DeviceProfile {
        } else {
            iconDrawablePaddingPx = (int) (getNormalizedIconDrawablePadding() * iconScale);
            cellWidthPx = iconSizePx + iconDrawablePaddingPx;
            cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR)
            cellHeightPx = getIconSizeWithOverlap(iconSizePx)
                    + iconDrawablePaddingPx
                    + Utilities.calculateTextHeight(iconTextSizePx);
            int cellPaddingY = (getCellSize().y - cellHeightPx) / 2;
@@ -1107,7 +1127,6 @@ public class DeviceProfile {
        return Math.min(hotseatBorderSpacePx, mMaxHotseatIconSpacePx);
    }


    /**
     * Updates the iconSize for allApps* variants.
     */
@@ -1455,6 +1474,17 @@ public class DeviceProfile {
    private void updateWorkspacePadding() {
        Rect padding = workspacePadding;
        if (isVerticalBarLayout()) {
            if (mIsResponsiveGrid) {
                padding.top = mResponsiveHeightSpec.getStartPaddingPx();
                padding.bottom = mResponsiveHeightSpec.getEndPaddingPx();
                if (isSeascape()) {
                    padding.left = hotseatBarSizePx + mResponsiveWidthSpec.getEndPaddingPx();
                    padding.right = mResponsiveWidthSpec.getStartPaddingPx();
                } else {
                    padding.left = mResponsiveWidthSpec.getStartPaddingPx();
                    padding.right = hotseatBarSizePx + mResponsiveWidthSpec.getEndPaddingPx();
                }
            } else {
                padding.top = 0;
                padding.bottom = edgeMarginPx;
                if (isSeascape()) {
@@ -1464,6 +1494,7 @@ public class DeviceProfile {
                    padding.left = hotseatBarSidePaddingStartPx;
                    padding.right = hotseatBarSizePx;
                }
            }
        } else {
            // Pad the bottom of the workspace with hotseat bar
            // and leave a bit of space in case a widget go all the way down
@@ -1505,7 +1536,9 @@ public class DeviceProfile {
            // in vertical bar layout.
            // Workspace icons are moved up by a small factor. The variable diffOverlapFactor
            // is set to account for that difference.
            float diffOverlapFactor = iconSizePx * (ICON_OVERLAP_FACTOR - 1) / 2;
            float diffOverlapFactor = mIsResponsiveGrid ? 0
                    : iconSizePx * (ICON_OVERLAP_FACTOR - 1) / 2;

            int paddingTop = Math.max((int) (mInsets.top + cellLayoutPaddingPx.top
                    - diffOverlapFactor), 0);
            int paddingBottom = Math.max((int) (mInsets.bottom + cellLayoutPaddingPx.bottom
+35 −21
Original line number Diff line number Diff line
@@ -158,42 +158,56 @@ abstract class AbstractDeviceProfileTest {
    }

    protected fun initializeVarsForTwoPanel(
        deviceTabletSpec: DeviceSpec,
        deviceSpec: DeviceSpec,
        deviceSpecUnfolded: DeviceSpec,
        deviceSpecFolded: DeviceSpec,
        isLandscape: Boolean = false,
        isGestureMode: Boolean = true
        isGestureMode: Boolean = true,
        isFolded: Boolean = false
    ) {
        val (tabletNaturalX, tabletNaturalY) = deviceTabletSpec.naturalSize
        val tabletWindowsBounds =
            tabletWindowsBounds(deviceTabletSpec, tabletNaturalX, tabletNaturalY)
        val tabletDisplayInfo =
        val (unfoldedNaturalX, unfoldedNaturalY) = deviceSpecUnfolded.naturalSize
        val unfoldedWindowsBounds =
            tabletWindowsBounds(deviceSpecUnfolded, unfoldedNaturalX, unfoldedNaturalY)
        val unfoldedDisplayInfo =
            CachedDisplayInfo(
                Point(tabletNaturalX, tabletNaturalY),
                Point(unfoldedNaturalX, unfoldedNaturalY),
                Surface.ROTATION_0,
                Rect(0, 0, 0, 0)
            )

        val (phoneNaturalX, phoneNaturalY) = deviceSpec.naturalSize
        val phoneWindowsBounds =
            phoneWindowsBounds(deviceSpec, isGestureMode, phoneNaturalX, phoneNaturalY)
        val phoneDisplayInfo =
        val (foldedNaturalX, foldedNaturalY) = deviceSpecFolded.naturalSize
        val foldedWindowsBounds =
            phoneWindowsBounds(deviceSpecFolded, isGestureMode, foldedNaturalX, foldedNaturalY)
        val foldedDisplayInfo =
            CachedDisplayInfo(
                Point(phoneNaturalX, phoneNaturalY),
                Point(foldedNaturalX, foldedNaturalY),
                Surface.ROTATION_0,
                Rect(0, 0, 0, 0)
            )

        val perDisplayBoundsCache =
            mapOf(tabletDisplayInfo to tabletWindowsBounds, phoneDisplayInfo to phoneWindowsBounds)
            mapOf(
                unfoldedDisplayInfo to unfoldedWindowsBounds,
                foldedDisplayInfo to foldedWindowsBounds
            )

        if (isFolded) {
            initializeCommonVars(
            perDisplayBoundsCache,
            tabletDisplayInfo,
                perDisplayBoundsCache = perDisplayBoundsCache,
                displayInfo = foldedDisplayInfo,
                rotation = if (isLandscape) Surface.ROTATION_90 else Surface.ROTATION_0,
                isGestureMode = isGestureMode,
                densityDpi = deviceSpecFolded.densityDpi
            )
        } else {
            initializeCommonVars(
                perDisplayBoundsCache = perDisplayBoundsCache,
                displayInfo = unfoldedDisplayInfo,
                rotation = if (isLandscape) Surface.ROTATION_0 else Surface.ROTATION_90,
            isGestureMode,
            densityDpi = deviceTabletSpec.densityDpi
                isGestureMode = isGestureMode,
                densityDpi = deviceSpecUnfolded.densityDpi
            )
        }
    }

    private fun phoneWindowsBounds(
        deviceSpec: DeviceSpec,