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

Commit 803fe9da authored by Jonathan Miranda's avatar Jonathan Miranda
Browse files

Manually compute all apps cell height in multi-window mode. am: 1091e538 am: bf6bbe9a

Change-Id: Ief2d499040d8d8eb7dfac8eca8faadb6022078a1
parents a9c8c4ad bf6bbe9a
Loading
Loading
Loading
Loading
+20 −11
Original line number Diff line number Diff line
@@ -266,9 +266,7 @@ public class DeviceProfile {
                isLandscape);

        // Hide labels on the workspace.
        profile.iconTextSizePx = 0;
        profile.cellHeightPx = profile.iconSizePx + profile.iconDrawablePaddingPx
                + Utilities.calculateTextHeight(profile.iconTextSizePx);
        profile.adjustToHideWorkspaceLabels();

        // We use these scales to measure and layout the widgets using their full invariant profile
        // sizes and then draw them scaled and centered to fit in their multi-window mode cellspans.
@@ -291,6 +289,24 @@ public class DeviceProfile {
        }
    }

    /**
     * Adjusts the profile so that the labels on the Workspace are hidden.
     * It is important to call this method after the All Apps variables have been set.
     */
    private void adjustToHideWorkspaceLabels() {
        iconTextSizePx = 0;
        iconDrawablePaddingPx = 0;
        cellHeightPx = iconSizePx;

        // In normal cases, All Apps cell height should equal the Workspace cell height.
        // Since we are removing labels from the Workspace, we need to manually compute the
        // All Apps cell height.
        allAppsCellHeightPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx
                + Utilities.calculateTextHeight(allAppsIconTextSizePx)
                // Top and bottom padding is equal to the drawable padding
                + allAppsIconDrawablePaddingPx * 2;
    }

    /**
     * Determine the exact visual footprint of the all apps button, taking into account scaling
     * and internal padding of the drawable.
@@ -329,14 +345,7 @@ public class DeviceProfile {

        if (isVerticalBarLayout()) {
            // Always hide the Workspace text with vertical bar layout.
            iconTextSizePx = 0;
            iconDrawablePaddingPx = 0;

            // Manually compute all apps cell height since workspace cells have less content.
            allAppsCellHeightPx = allAppsIconSizePx + allAppsIconDrawablePaddingPx
                    + Utilities.calculateTextHeight(allAppsIconTextSizePx)
                    // Top and bottom padding is equal to the drawable padding
                    + allAppsIconDrawablePaddingPx * 2;
            adjustToHideWorkspaceLabels();
        }

        cellWidthPx = iconSizePx + iconDrawablePaddingPx;