mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 23:36:47 +00:00
Fix workspace and hotseat paddings for responsive grid in landscape
Add paddings for workspace and hotseat when vertical bar is enabled. Fix: 294033018 Flag: ENABLE_RESPONSIVE_WORKSPACE Test: DeviceProfileDumpTest Test: DeviceProfileAlternativeGridDumpTest Test: DeviceProfileResponsiveDumpTest Test: DeviceProfileResponsiveAlternativeDisplaysDumpTest Change-Id: I7358d2eb7b7c53b436756c21bd81d4746ea01801
This commit is contained in:
@@ -618,6 +618,10 @@ public class DeviceProfile {
|
||||
// Hotseat and QSB width depends on updated cellSize and workspace padding
|
||||
recalculateHotseatWidthAndBorderSpace();
|
||||
|
||||
if (mIsResponsiveGrid && isVerticalBarLayout()) {
|
||||
hotseatBorderSpace = cellLayoutBorderSpacePx.y;
|
||||
}
|
||||
|
||||
// AllApps height calculation depends on updated cellSize
|
||||
if (isTablet) {
|
||||
int collapseHandleHeight =
|
||||
@@ -717,7 +721,7 @@ public class DeviceProfile {
|
||||
/** Updates hotseatCellHeightPx and hotseatBarSizePx */
|
||||
private void updateHotseatSizes(int hotseatIconSizePx) {
|
||||
// Ensure there is enough space for folder icons, which have a slightly larger radius.
|
||||
hotseatCellHeightPx = (int) Math.ceil(hotseatIconSizePx * ICON_OVERLAP_FACTOR);
|
||||
hotseatCellHeightPx = getIconSizeWithOverlap(hotseatIconSizePx);
|
||||
|
||||
if (isVerticalBarLayout()) {
|
||||
hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
|
||||
@@ -783,7 +787,6 @@ public class DeviceProfile {
|
||||
hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidthPx,
|
||||
(isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1);
|
||||
} while (hotseatBorderSpace < mMinHotseatIconSpacePx && numShownHotseatIcons > 1);
|
||||
|
||||
}
|
||||
|
||||
private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
|
||||
@@ -866,11 +869,24 @@ public class DeviceProfile {
|
||||
float workspaceCellPaddingY = getCellSize().y - iconSizePx - iconDrawablePaddingPx
|
||||
- iconTextHeight;
|
||||
|
||||
if (mIsResponsiveGrid) {
|
||||
// Hide text only if doesn't fit inside the cell for responsive grid
|
||||
if (workspaceCellPaddingY < 0) {
|
||||
iconTextSizePx = 0;
|
||||
iconDrawablePaddingPx = 0;
|
||||
int iconSizeWithOverlap = getIconSizeWithOverlap(iconSizePx);
|
||||
cellYPaddingPx = Math.max(0, getCellSize().y - iconSizeWithOverlap) / 2;
|
||||
autoResizeAllAppsCells();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// We want enough space so that the text is closer to its corresponding icon.
|
||||
if (workspaceCellPaddingY < iconTextHeight) {
|
||||
iconTextSizePx = 0;
|
||||
iconDrawablePaddingPx = 0;
|
||||
cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR);
|
||||
cellHeightPx = getIconSizeWithOverlap(iconSizePx);
|
||||
autoResizeAllAppsCells();
|
||||
}
|
||||
}
|
||||
@@ -950,6 +966,10 @@ public class DeviceProfile {
|
||||
return Math.max(0, drawablePadding - iconSizeDiff / 2);
|
||||
}
|
||||
|
||||
private int getIconSizeWithOverlap(int iconSize) {
|
||||
return (int) Math.ceil(iconSize * ICON_OVERLAP_FACTOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updating the iconSize affects many aspects of the launcher layout, such as: iconSizePx,
|
||||
* iconTextSizePx, iconDrawablePaddingPx, cellWidth/Height, allApps* variants,
|
||||
@@ -1052,7 +1072,7 @@ public class DeviceProfile {
|
||||
} else {
|
||||
iconDrawablePaddingPx = (int) (getNormalizedIconDrawablePadding() * iconScale);
|
||||
cellWidthPx = iconSizePx + iconDrawablePaddingPx;
|
||||
cellHeightPx = (int) Math.ceil(iconSizePx * ICON_OVERLAP_FACTOR)
|
||||
cellHeightPx = getIconSizeWithOverlap(iconSizePx)
|
||||
+ iconDrawablePaddingPx
|
||||
+ Utilities.calculateTextHeight(iconTextSizePx);
|
||||
int cellPaddingY = (getCellSize().y - cellHeightPx) / 2;
|
||||
@@ -1107,7 +1127,6 @@ public class DeviceProfile {
|
||||
return Math.min(hotseatBorderSpacePx, mMaxHotseatIconSpacePx);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the iconSize for allApps* variants.
|
||||
*/
|
||||
@@ -1455,14 +1474,26 @@ public class DeviceProfile {
|
||||
private void updateWorkspacePadding() {
|
||||
Rect padding = workspacePadding;
|
||||
if (isVerticalBarLayout()) {
|
||||
padding.top = 0;
|
||||
padding.bottom = edgeMarginPx;
|
||||
if (isSeascape()) {
|
||||
padding.left = hotseatBarSizePx;
|
||||
padding.right = hotseatBarSidePaddingStartPx;
|
||||
if (mIsResponsiveGrid) {
|
||||
padding.top = mResponsiveHeightSpec.getStartPaddingPx();
|
||||
padding.bottom = mResponsiveHeightSpec.getEndPaddingPx();
|
||||
if (isSeascape()) {
|
||||
padding.left = hotseatBarSizePx + mResponsiveWidthSpec.getEndPaddingPx();
|
||||
padding.right = mResponsiveWidthSpec.getStartPaddingPx();
|
||||
} else {
|
||||
padding.left = mResponsiveWidthSpec.getStartPaddingPx();
|
||||
padding.right = hotseatBarSizePx + mResponsiveWidthSpec.getEndPaddingPx();
|
||||
}
|
||||
} else {
|
||||
padding.left = hotseatBarSidePaddingStartPx;
|
||||
padding.right = hotseatBarSizePx;
|
||||
padding.top = 0;
|
||||
padding.bottom = edgeMarginPx;
|
||||
if (isSeascape()) {
|
||||
padding.left = hotseatBarSizePx;
|
||||
padding.right = hotseatBarSidePaddingStartPx;
|
||||
} else {
|
||||
padding.left = hotseatBarSidePaddingStartPx;
|
||||
padding.right = hotseatBarSizePx;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Pad the bottom of the workspace with hotseat bar
|
||||
@@ -1505,7 +1536,9 @@ public class DeviceProfile {
|
||||
// in vertical bar layout.
|
||||
// Workspace icons are moved up by a small factor. The variable diffOverlapFactor
|
||||
// is set to account for that difference.
|
||||
float diffOverlapFactor = iconSizePx * (ICON_OVERLAP_FACTOR - 1) / 2;
|
||||
float diffOverlapFactor = mIsResponsiveGrid ? 0
|
||||
: iconSizePx * (ICON_OVERLAP_FACTOR - 1) / 2;
|
||||
|
||||
int paddingTop = Math.max((int) (mInsets.top + cellLayoutPaddingPx.top
|
||||
- diffOverlapFactor), 0);
|
||||
int paddingBottom = Math.max((int) (mInsets.bottom + cellLayoutPaddingPx.bottom
|
||||
|
||||
@@ -158,41 +158,55 @@ abstract class AbstractDeviceProfileTest {
|
||||
}
|
||||
|
||||
protected fun initializeVarsForTwoPanel(
|
||||
deviceTabletSpec: DeviceSpec,
|
||||
deviceSpec: DeviceSpec,
|
||||
deviceSpecUnfolded: DeviceSpec,
|
||||
deviceSpecFolded: DeviceSpec,
|
||||
isLandscape: Boolean = false,
|
||||
isGestureMode: Boolean = true
|
||||
isGestureMode: Boolean = true,
|
||||
isFolded: Boolean = false
|
||||
) {
|
||||
val (tabletNaturalX, tabletNaturalY) = deviceTabletSpec.naturalSize
|
||||
val tabletWindowsBounds =
|
||||
tabletWindowsBounds(deviceTabletSpec, tabletNaturalX, tabletNaturalY)
|
||||
val tabletDisplayInfo =
|
||||
val (unfoldedNaturalX, unfoldedNaturalY) = deviceSpecUnfolded.naturalSize
|
||||
val unfoldedWindowsBounds =
|
||||
tabletWindowsBounds(deviceSpecUnfolded, unfoldedNaturalX, unfoldedNaturalY)
|
||||
val unfoldedDisplayInfo =
|
||||
CachedDisplayInfo(
|
||||
Point(tabletNaturalX, tabletNaturalY),
|
||||
Point(unfoldedNaturalX, unfoldedNaturalY),
|
||||
Surface.ROTATION_0,
|
||||
Rect(0, 0, 0, 0)
|
||||
)
|
||||
|
||||
val (phoneNaturalX, phoneNaturalY) = deviceSpec.naturalSize
|
||||
val phoneWindowsBounds =
|
||||
phoneWindowsBounds(deviceSpec, isGestureMode, phoneNaturalX, phoneNaturalY)
|
||||
val phoneDisplayInfo =
|
||||
val (foldedNaturalX, foldedNaturalY) = deviceSpecFolded.naturalSize
|
||||
val foldedWindowsBounds =
|
||||
phoneWindowsBounds(deviceSpecFolded, isGestureMode, foldedNaturalX, foldedNaturalY)
|
||||
val foldedDisplayInfo =
|
||||
CachedDisplayInfo(
|
||||
Point(phoneNaturalX, phoneNaturalY),
|
||||
Point(foldedNaturalX, foldedNaturalY),
|
||||
Surface.ROTATION_0,
|
||||
Rect(0, 0, 0, 0)
|
||||
)
|
||||
|
||||
val perDisplayBoundsCache =
|
||||
mapOf(tabletDisplayInfo to tabletWindowsBounds, phoneDisplayInfo to phoneWindowsBounds)
|
||||
mapOf(
|
||||
unfoldedDisplayInfo to unfoldedWindowsBounds,
|
||||
foldedDisplayInfo to foldedWindowsBounds
|
||||
)
|
||||
|
||||
initializeCommonVars(
|
||||
perDisplayBoundsCache,
|
||||
tabletDisplayInfo,
|
||||
rotation = if (isLandscape) Surface.ROTATION_0 else Surface.ROTATION_90,
|
||||
isGestureMode,
|
||||
densityDpi = deviceTabletSpec.densityDpi
|
||||
)
|
||||
if (isFolded) {
|
||||
initializeCommonVars(
|
||||
perDisplayBoundsCache = perDisplayBoundsCache,
|
||||
displayInfo = foldedDisplayInfo,
|
||||
rotation = if (isLandscape) Surface.ROTATION_90 else Surface.ROTATION_0,
|
||||
isGestureMode = isGestureMode,
|
||||
densityDpi = deviceSpecFolded.densityDpi
|
||||
)
|
||||
} else {
|
||||
initializeCommonVars(
|
||||
perDisplayBoundsCache = perDisplayBoundsCache,
|
||||
displayInfo = unfoldedDisplayInfo,
|
||||
rotation = if (isLandscape) Surface.ROTATION_0 else Surface.ROTATION_90,
|
||||
isGestureMode = isGestureMode,
|
||||
densityDpi = deviceSpecUnfolded.densityDpi
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun phoneWindowsBounds(
|
||||
|
||||
Reference in New Issue
Block a user