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

Commit 0d284852 authored by Jon Miranda's avatar Jon Miranda
Browse files

Fix bug where icons in hotseat were clipped when display size is Small.

Simplify calculations to ensure the hotseat sizes are always accurate.

Bug: 186556930
Test: changed display setting from small to largest on different grid
      sizes (5x5, 4x4, 4x5, 3x3, 2x2)

Change-Id: I97580c50a9d821577eb63335950d5695d9bf035d
parent 61bc5c6c
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -149,10 +149,11 @@ public class DeviceProfile {
    // Hotseat
    public final int numShownHotseatIcons;
    public int hotseatCellHeightPx;
    private final int hotseatExtraVerticalSize;
    // In portrait: size = height, in landscape: size = width
    public int hotseatBarSizePx;
    public final int hotseatBarTopPaddingPx;
    public int hotseatBarBottomPaddingPx;
    public final int hotseatBarBottomPaddingPx;
    // Start is the side next to the nav bar, end is the side next to the workspace
    public final int hotseatBarSidePaddingStartPx;
    public final int hotseatBarSidePaddingEndPx;
@@ -326,13 +327,9 @@ public class DeviceProfile {
                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
        // Add a bit of space between nav bar and hotseat in vertical bar layout.
        hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
        int hotseatExtraVerticalSize =
        hotseatExtraVerticalSize =
                res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_extra_vertical_size);
        hotseatBarSizePx = pxFromDp(inv.iconSize, mMetrics, 1f)
                + (isVerticalBarLayout()
                ? (hotseatBarSidePaddingStartPx + hotseatBarSidePaddingEndPx)
                : (hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx
                        + (isScalableGrid ? 0 : hotseatExtraVerticalSize)));
        updateHotseatIconSize(pxFromDp(inv.iconSize, mMetrics, 1f));

        overviewTaskMarginPx = res.getDimensionPixelSize(R.dimen.overview_task_margin);
        overviewTaskIconSizePx =
@@ -362,7 +359,6 @@ public class DeviceProfile {
            extraHotseatBottomPadding = Math.round(paddingHotseatBottom * iconScale);

            hotseatBarSizePx += extraHotseatBottomPadding;
            hotseatBarBottomPaddingPx += extraHotseatBottomPadding;
        } else if (!isVerticalBarLayout() && isPhone && isTallDevice) {
            // We increase the hotseat size when there is extra space.
            // ie. For a display with a large aspect ratio, we can keep the icons on the workspace
@@ -371,7 +367,6 @@ public class DeviceProfile {
            int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2
                    - workspacePageIndicatorHeight;
            hotseatBarSizePx += extraSpace;
            hotseatBarBottomPaddingPx += extraSpace;

            // Recalculate the available dimensions using the new hotseat size.
            updateAvailableDimensions(res);
@@ -388,6 +383,17 @@ public class DeviceProfile {
                new DotRenderer(allAppsIconSizePx, dotPath, DEFAULT_DOT_SIZE);
    }

    private void updateHotseatIconSize(int hotseatIconSizePx) {
        hotseatCellHeightPx = hotseatIconSizePx;
        if (isVerticalBarLayout()) {
            hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
                    + hotseatBarSidePaddingEndPx;
        } else {
            hotseatBarSizePx = hotseatIconSizePx + hotseatBarTopPaddingPx
                    + hotseatBarBottomPaddingPx + (isScalableGrid ? 0 : hotseatExtraVerticalSize);
        }
    }

    private void setCellLayoutBorderSpacing(int borderSpacing) {
        cellLayoutBorderSpacingPx = isScalableGrid ? borderSpacing : 0;
    }
@@ -573,11 +579,7 @@ public class DeviceProfile {
        }

        // Hotseat
        if (isVerticalLayout) {
            hotseatBarSizePx = iconSizePx + hotseatBarSidePaddingStartPx
                    + hotseatBarSidePaddingEndPx;
        }
        hotseatCellHeightPx = iconSizePx;
        updateHotseatIconSize(iconSizePx);

        if (!isVerticalLayout) {
            int expectedWorkspaceHeight = availableHeightPx - hotseatBarSizePx
@@ -763,7 +765,8 @@ public class DeviceProfile {
                    hotseatBarTopPaddingPx,
                    hotseatAdjustment + workspacePadding.right + cellLayoutPaddingLeftRightPx
                            + mInsets.right,
                    hotseatBarBottomPaddingPx + mInsets.bottom + cellLayoutBottomPaddingPx);
                    hotseatBarSizePx - hotseatCellHeightPx - hotseatBarTopPaddingPx
                            + cellLayoutBottomPaddingPx + mInsets.bottom);
        }
        return mHotseatPadding;
    }