Merge "launcher: create paddings for foldables" into sc-v2-dev

This commit is contained in:
Thales Lima
2021-09-30 09:19:22 +00:00
committed by Android (Google) Code Review
4 changed files with 25 additions and 38 deletions
+10 -28
View File
@@ -296,10 +296,7 @@ public class DeviceProfile {
: res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_layout_padding);
if (isTwoPanels) {
cellLayoutPaddingLeftRightPx = res.getDimensionPixelSize(
isLandscape
? R.dimen.two_panels_home_side_padding_landscape
: R.dimen.two_panels_home_side_padding_portrait);
cellLayoutPaddingLeftRightPx = 0;
cellLayoutBottomPaddingPx = 0;
} else if (isLandscape) {
cellLayoutPaddingLeftRightPx = 0;
@@ -817,7 +814,9 @@ public class DeviceProfile {
Point padding = getTotalWorkspacePadding();
int numColumns = isTwoPanels ? inv.numColumns * 2 : inv.numColumns;
int screenWidthPx = availableWidthPx - padding.x - 2 * cellLayoutPaddingLeftRightPx;
int cellLayoutTotalPadding =
isTwoPanels ? 4 * cellLayoutPaddingLeftRightPx : 2 * cellLayoutPaddingLeftRightPx;
int screenWidthPx = availableWidthPx - padding.x - cellLayoutTotalPadding;
result.x = calculateCellWidth(screenWidthPx, cellLayoutBorderSpacingPx, numColumns);
result.y = calculateCellHeight(availableHeightPx - padding.y
- cellLayoutBottomPaddingPx, cellLayoutBorderSpacingPx, inv.numRows);
@@ -847,33 +846,15 @@ public class DeviceProfile {
padding.right = hotseatBarSizePx;
}
} else {
// Pad the bottom of the workspace with search/hotseat bar sizes
int hotseatTop = hotseatBarSizePx;
int paddingBottom = hotseatTop + workspacePageIndicatorHeight
+ workspaceBottomPadding - mWorkspacePageIndicatorOverlapWorkspace;
if (isTablet) {
// Pad the left and right of the workspace to ensure consistent spacing
// between all icons
// The amount of screen space available for left/right padding.
int availablePaddingX = Math.max(0, widthPx - ((inv.numColumns * cellWidthPx) +
((inv.numColumns - 1) * cellWidthPx)));
availablePaddingX = (int) Math.min(availablePaddingX,
widthPx * MAX_HORIZONTAL_PADDING_PERCENT);
int hotseatVerticalPadding = hotseatBarTopPaddingPx + hotseatBarBottomPaddingPx;
int availablePaddingY = Math.max(0, heightPx - edgeMarginPx - paddingBottom
- (2 * inv.numRows * cellHeightPx) - hotseatVerticalPadding);
padding.set(availablePaddingX / 2, edgeMarginPx + availablePaddingY / 2,
availablePaddingX / 2, paddingBottom + availablePaddingY / 2);
if (isTwoPanels) {
padding.set(0, padding.top, 0, padding.bottom);
}
} else {
// Pad the top and bottom of the workspace with search/hotseat bar sizes
padding.set(desiredWorkspaceLeftRightMarginPx,
workspaceTopPadding + (isScalableGrid ? 0 : edgeMarginPx),
desiredWorkspaceLeftRightMarginPx,
paddingBottom);
}
padding.set(desiredWorkspaceLeftRightMarginPx,
(isScalableGrid ? workspaceTopPadding : edgeMarginPx),
desiredWorkspaceLeftRightMarginPx,
paddingBottom);
}
}
@@ -1132,6 +1113,7 @@ public class DeviceProfile {
writer.println(prefix + pxToDpStr("iconScale", iconScale));
writer.println(prefix + pxToDpStr("cellScaleToFit ", cellScaleToFit));
writer.println(prefix + pxToDpStr("extraSpace", extraSpace));
writer.println(prefix + pxToDpStr("unscaled extraSpace", extraSpace / iconScale));
if (inv.devicePaddings != null) {
int unscaledExtraSpace = (int) (extraSpace / iconScale);
+4 -1
View File
@@ -638,7 +638,10 @@ public abstract class PagedView<T extends View & PageIndicator> extends ViewGrou
}
private int getPageWidthSize(int widthSize) {
return (widthSize - mInsets.left - mInsets.right) / getPanelCount();
// It's necessary to add the padding back because it is remove when measuring children,
// like when MeasureSpec.getSize in CellLayout.
return (widthSize - mInsets.left - mInsets.right - getPaddingLeft() - getPaddingRight())
/ getPanelCount() + getPaddingLeft() + getPaddingRight();
}
@Override
+5 -6
View File
@@ -342,16 +342,15 @@ public class Workspace extends PagedView<WorkspacePageIndicator>
for (int i = 0; i < numberOfScreens; i++) {
int paddingLeft = paddingLeftRight;
int paddingRight = paddingLeftRight;
// Add missing cellLayout border in-between panels.
if (panelCount > 1) {
if (i % panelCount == leftPanelModulus) {
paddingLeft = paddingLeftRight;
paddingRight = grid.cellLayoutBorderSpacingPx / 2;
paddingRight += grid.cellLayoutBorderSpacingPx / 2;
} else if (i % panelCount == rightPanelModulus) { // right side panel
paddingLeft = grid.cellLayoutBorderSpacingPx / 2;
paddingRight = paddingLeftRight;
paddingLeft += grid.cellLayoutBorderSpacingPx / 2;
} else { // middle panel
paddingLeft = grid.cellLayoutBorderSpacingPx / 2;
paddingRight = grid.cellLayoutBorderSpacingPx / 2;
paddingLeft += grid.cellLayoutBorderSpacingPx / 2;
paddingRight += grid.cellLayoutBorderSpacingPx / 2;
}
}
// SparseArrayMap doesn't keep the order
@@ -230,16 +230,19 @@ public class LauncherPreviewRenderer extends ContextWrapper
CellLayout firstScreen = mRootView.findViewById(R.id.workspace);
firstScreen.setPadding(mDp.workspacePadding.left + mDp.cellLayoutPaddingLeftRightPx,
mDp.workspacePadding.top,
mDp.workspacePadding.right + mDp.cellLayoutBorderSpacingPx / 2,
(mDp.isTwoPanels ? mDp.cellLayoutBorderSpacingPx / 2 : mDp.workspacePadding.right)
+ mDp.cellLayoutPaddingLeftRightPx,
mDp.workspacePadding.bottom);
mWorkspaceScreens.put(FIRST_SCREEN_ID, firstScreen);
if (mDp.isTwoPanels) {
CellLayout rightPanel = mRootView.findViewById(R.id.workspace_right);
rightPanel.setPadding(mDp.workspacePadding.left + mDp.cellLayoutBorderSpacingPx / 2,
rightPanel.setPadding(
mDp.cellLayoutBorderSpacingPx / 2 + mDp.cellLayoutPaddingLeftRightPx,
mDp.workspacePadding.top,
mDp.workspacePadding.right + mDp.cellLayoutPaddingLeftRightPx,
mDp.workspacePadding.bottom);
mDp.workspacePadding.bottom
);
mWorkspaceScreens.put(Workspace.SECOND_SCREEN_ID, rightPanel);
}