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

Commit 06f36e85 authored by Alex Chau's avatar Alex Chau
Browse files

Reduce icon/text simultaneously when cellHeight is not enough for largest display size

- Follow-up of http://ag/20691430
- Reduce iconDrawablePaddingPx to further recover space
- Then proportional reduce both iconSizePx and iconTextSizePx
- This will result in larger icon/text size in px when going from larger to largest for most devices
- For extremely large desnity (> largest for most devices), iconSizePx/iconTextSizePx will inevitably reduce due to smaller availalbe space

Fix: 264149604
Test: test different density between larger and largest, check that icon/text size continues to grow in px
Change-Id: I1633566b9372acf1393c7e997598cb3e46c4a507
parent d96be3eb
Loading
Loading
Loading
Loading
+15 −3
Original line number Original line Diff line number Diff line
@@ -910,12 +910,24 @@ public class DeviceProfile {
                    cellHeightPx = cellContentHeight;
                    cellHeightPx = cellContentHeight;
                    cellLayoutBorderSpacePx.y -= extraHeightRequired / numBorders;
                    cellLayoutBorderSpacePx.y -= extraHeightRequired / numBorders;
                } else {
                } else {
                    // If it still doesn't fit, set borderSpace to 0 and distribute the space for
                    // If it still doesn't fit, set borderSpace to 0 to recover space.
                    // cellHeight, and reduce iconSize.
                    cellHeightPx = (cellHeightPx * inv.numRows
                    cellHeightPx = (cellHeightPx * inv.numRows
                            + cellLayoutBorderSpacePx.y * numBorders) / inv.numRows;
                            + cellLayoutBorderSpacePx.y * numBorders) / inv.numRows;
                    iconSizePx = Math.min(iconSizePx, cellHeightPx - cellTextAndPaddingHeight);
                    cellLayoutBorderSpacePx.y = 0;
                    cellLayoutBorderSpacePx.y = 0;
                    // Reduce iconDrawablePaddingPx to make cellContentHeight smaller.
                    int cellContentWithoutPadding = cellContentHeight - iconDrawablePaddingPx;
                    if (cellContentWithoutPadding <= cellHeightPx) {
                        iconDrawablePaddingPx = cellContentHeight - cellHeightPx;
                    } else {
                        // If it still doesn't fit, set iconDrawablePaddingPx to 0 to recover space,
                        // then proportional reduce iconSizePx and iconTextSizePx to fit.
                        iconDrawablePaddingPx = 0;
                        float ratio = cellHeightPx / (float) cellContentWithoutPadding;
                        iconSizePx = (int) (iconSizePx * ratio);
                        iconTextSizePx = (int) (iconTextSizePx * ratio);
                    }
                    cellTextAndPaddingHeight =
                            iconDrawablePaddingPx + Utilities.calculateTextHeight(iconTextSizePx);
                }
                }
                cellContentHeight = iconSizePx + cellTextAndPaddingHeight;
                cellContentHeight = iconSizePx + cellTextAndPaddingHeight;
            }
            }