Merge "Folder cell should match grid cell aspect ratio if isScalableGrid is true." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f072b062a2
@@ -212,7 +212,10 @@ public class CellLayout extends ViewGroup {
|
|||||||
mActivity = ActivityContext.lookupContext(context);
|
mActivity = ActivityContext.lookupContext(context);
|
||||||
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
DeviceProfile deviceProfile = mActivity.getDeviceProfile();
|
||||||
|
|
||||||
mBorderSpacing = deviceProfile.cellLayoutBorderSpacingPx;
|
mBorderSpacing = mContainerType == FOLDER
|
||||||
|
? deviceProfile.folderCellLayoutBorderSpacingPx
|
||||||
|
: deviceProfile.cellLayoutBorderSpacingPx;
|
||||||
|
|
||||||
mCellWidth = mCellHeight = -1;
|
mCellWidth = mCellHeight = -1;
|
||||||
mFixedCellWidth = mFixedCellHeight = -1;
|
mFixedCellWidth = mFixedCellHeight = -1;
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ public class DeviceProfile {
|
|||||||
public int folderIconOffsetYPx;
|
public int folderIconOffsetYPx;
|
||||||
|
|
||||||
// Folder content
|
// Folder content
|
||||||
|
public int folderCellLayoutBorderSpacingPx;
|
||||||
public int folderContentPaddingLeftRight;
|
public int folderContentPaddingLeftRight;
|
||||||
public int folderContentPaddingTop;
|
public int folderContentPaddingTop;
|
||||||
|
|
||||||
@@ -254,6 +255,7 @@ public class DeviceProfile {
|
|||||||
|
|
||||||
setCellLayoutBorderSpacing(pxFromDp(inv.borderSpacing, mInfo.metrics, 1f));
|
setCellLayoutBorderSpacing(pxFromDp(inv.borderSpacing, mInfo.metrics, 1f));
|
||||||
cellLayoutBorderSpacingOriginalPx = cellLayoutBorderSpacingPx;
|
cellLayoutBorderSpacingOriginalPx = cellLayoutBorderSpacingPx;
|
||||||
|
folderCellLayoutBorderSpacingPx = cellLayoutBorderSpacingPx;
|
||||||
|
|
||||||
int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet
|
int cellLayoutPaddingLeftRightMultiplier = !isVerticalBarLayout() && isTablet
|
||||||
? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;
|
? PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER : 1;
|
||||||
@@ -352,13 +354,7 @@ public class DeviceProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setCellLayoutBorderSpacing(int borderSpacing) {
|
private void setCellLayoutBorderSpacing(int borderSpacing) {
|
||||||
if (isScalableGrid) {
|
cellLayoutBorderSpacingPx = isScalableGrid ? borderSpacing : 0;
|
||||||
cellLayoutBorderSpacingPx = borderSpacing;
|
|
||||||
folderContentPaddingLeftRight = borderSpacing;
|
|
||||||
folderContentPaddingTop = borderSpacing;
|
|
||||||
} else {
|
|
||||||
cellLayoutBorderSpacingPx = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -587,14 +583,14 @@ public class DeviceProfile {
|
|||||||
|
|
||||||
// Check if the icons fit within the available height.
|
// Check if the icons fit within the available height.
|
||||||
float contentUsedHeight = folderCellHeightPx * inv.numFolderRows
|
float contentUsedHeight = folderCellHeightPx * inv.numFolderRows
|
||||||
+ ((inv.numFolderRows - 1) * cellLayoutBorderSpacingPx);
|
+ ((inv.numFolderRows - 1) * folderCellLayoutBorderSpacingPx);
|
||||||
int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y - folderBottomPanelSize
|
int contentMaxHeight = availableHeightPx - totalWorkspacePadding.y - folderBottomPanelSize
|
||||||
- folderMargin - folderContentPaddingTop;
|
- folderMargin - folderContentPaddingTop;
|
||||||
float scaleY = contentMaxHeight / contentUsedHeight;
|
float scaleY = contentMaxHeight / contentUsedHeight;
|
||||||
|
|
||||||
// Check if the icons fit within the available width.
|
// Check if the icons fit within the available width.
|
||||||
float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns
|
float contentUsedWidth = folderCellWidthPx * inv.numFolderColumns
|
||||||
+ ((inv.numFolderColumns - 1) * cellLayoutBorderSpacingPx);
|
+ ((inv.numFolderColumns - 1) * folderCellLayoutBorderSpacingPx);
|
||||||
int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x - folderMargin
|
int contentMaxWidth = availableWidthPx - totalWorkspacePadding.x - folderMargin
|
||||||
- folderContentPaddingLeftRight * 2;
|
- folderContentPaddingLeftRight * 2;
|
||||||
float scaleX = contentMaxWidth / contentUsedWidth;
|
float scaleX = contentMaxWidth / contentUsedWidth;
|
||||||
@@ -612,11 +608,25 @@ public class DeviceProfile {
|
|||||||
folderLabelTextSizePx = (int) (folderChildTextSizePx * folderLabelTextScale);
|
folderLabelTextSizePx = (int) (folderChildTextSizePx * folderLabelTextScale);
|
||||||
|
|
||||||
int textHeight = Utilities.calculateTextHeight(folderChildTextSizePx);
|
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;
|
if (isScalableGrid) {
|
||||||
folderCellHeightPx = folderChildIconSizePx + 2 * cellPaddingY + textHeight;
|
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,
|
folderChildDrawablePaddingPx = Math.max(0,
|
||||||
(folderCellHeightPx - folderChildIconSizePx - textHeight) / 3);
|
(folderCellHeightPx - folderChildIconSizePx - textHeight) / 3);
|
||||||
}
|
}
|
||||||
@@ -868,6 +878,8 @@ public class DeviceProfile {
|
|||||||
writer.println(prefix + pxToDpStr("folderChildTextSizePx", folderChildTextSizePx));
|
writer.println(prefix + pxToDpStr("folderChildTextSizePx", folderChildTextSizePx));
|
||||||
writer.println(prefix + pxToDpStr("folderChildDrawablePaddingPx",
|
writer.println(prefix + pxToDpStr("folderChildDrawablePaddingPx",
|
||||||
folderChildDrawablePaddingPx));
|
folderChildDrawablePaddingPx));
|
||||||
|
writer.println(prefix + pxToDpStr("folderCellLayoutBorderSpacingPx",
|
||||||
|
folderCellLayoutBorderSpacingPx));
|
||||||
|
|
||||||
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacingPx",
|
writer.println(prefix + pxToDpStr("cellLayoutBorderSpacingPx",
|
||||||
cellLayoutBorderSpacingPx));
|
cellLayoutBorderSpacingPx));
|
||||||
|
|||||||
Reference in New Issue
Block a user