Merge "Folder cell should match grid cell aspect ratio if isScalableGrid is true." into sc-dev

This commit is contained in:
Jonathan Miranda
2021-03-31 19:15:30 +00:00
committed by Android (Google) Code Review
2 changed files with 29 additions and 14 deletions

View File

@@ -123,6 +123,7 @@ public class DeviceProfile {
public int folderIconOffsetYPx;
// Folder content
public int folderCellLayoutBorderSpacingPx;
public int folderContentPaddingLeftRight;
public int folderContentPaddingTop;
@@ -254,6 +255,7 @@ public class DeviceProfile {
setCellLayoutBorderSpacing(pxFromDp(inv.borderSpacing, mInfo.metrics, 1f));
cellLayoutBorderSpacingOriginalPx = cellLayoutBorderSpacingPx;
folderCellLayoutBorderSpacingPx = cellLayoutBorderSpacingPx;
int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet
? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;
@@ -352,13 +354,7 @@ public class DeviceProfile {
}
private void setCellLayoutBorderSpacing(int borderSpacing) {
if (isScalableGrid) {
cellLayoutBorderSpacingPx = borderSpacing;
folderContentPaddingLeftRight = borderSpacing;
folderContentPaddingTop = borderSpacing;
} else {
cellLayoutBorderSpacingPx = 0;
}
cellLayoutBorderSpacingPx = isScalableGrid ? borderSpacing : 0;
}
/**
@@ -587,14 +583,14 @@ public class DeviceProfile {
// Check if the icons fit within the available height.
float contentUsedHeight = folderCellHeightPx * inv.numFolderRows
+ ((inv.numFolderRows - 1) * cellLayoutBorderSpacingPx);
+ ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacingPx);
int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y - folderBottomPanelSize
- folderMargin - folderContentPaddingTop;
float scaleY = contentMaxHeight / contentUsedHeight;
// Check if the icons fit within the available width.
float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns
+ ((inv.numFolderColumns - 1) * cellLayoutBorderSpacingPx);
+ ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacingPx);
int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x - folderMargin
- folderContentPaddingLeftRight * 2;
float scaleX = contentMaxWidth / contentUsedWidth;
@@ -612,11 +608,25 @@ public class DeviceProfile {
folderLabelTextSizePx = (int) (folderChildTextSizePx * folderLabelTextScale);
int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
int cellPaddingX = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_x_padding) * scale);
int cellPaddingY = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_y_padding) * scale);
folderCellWidthPx = folderChildIconSizePx + 2 * cellPaddingX;
folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight;
if (isScalableGrid) {
folderCellWidthPx = (int) (cellWidthPx * scale);
folderCellHeightPx = (int) (cellHeightPx * scale);
int borderSpacing = (int) (cellLayoutBorderSpacingOriginalPx * scale);
folderCellLayoutBorderSpacingPx = borderSpacing;
folderContentPaddingLeftRight = borderSpacing;
folderContentPaddingTop = borderSpacing;
} else {
int cellPaddingX = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_x_padding)
* scale);
int cellPaddingY = (int) (res.getDimensionPixelSize(R.dimen.folder_cell_y_padding)
* scale);
folderCellWidthPx = folderChildIconSizePx + 2 * cellPaddingX;
folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight;
}
folderChildDrawablePaddingPx = Math.max(0,
(folderCellHeightPx - folderChildIconSizePx - textHeight) / 3);
}
@@ -868,6 +878,8 @@ public class DeviceProfile {
writer.println(prefix + pxToDpStr("folderChildTextSizePx", folderChildTextSizePx));
writer.println(prefix + pxToDpStr("folderChildDrawablePaddingPx",
folderChildDrawablePaddingPx));
writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacingPx",
folderCellLayoutBorderSpacingPx));
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacingPx",
cellLayoutBorderSpacingPx));