Add new attribute to hotseat specs

Edge padding is used as the space between hotseat and the edge of the screen. In most cases it is used in a height spec, but for vertical bar, i.e. when a handheld is in landscape, it is used a width spec.

Fix: 292204436
Test: CalculatedHotseatSpecTest
Test: HotseatSpecsTest
Test: DeviceProfileResponsiveAlternativeDisplaysDumpTest
Test: DeviceProfileResponsiveDumpTest
Flag: ENABLE_RESPONSIVE_WORKSPACE
Change-Id: Ib75ffcdd33925ee9ef156dcb70eefd133c9b458b
This commit is contained in:
Thales Lima committed 2023-09-05 16:31:06 +01:00
1 parent 53b19f1b6a
commit 8e11d531e8
3 files changed
+82 -48

No files matched your search

+55 -42
View File
@@ -205,9 +205,11 @@ public class DeviceProfile {
public int hotseatBarEndOffset;
public int hotseatQsbSpace;
public int springLoadedHotseatBarTopMarginPx;
// Start is the side next to the nav bar, end is the side next to the workspace
public final int hotseatBarSidePaddingStartPx;
public final int hotseatBarSidePaddingEndPx;
// These 2 values are only used for isVerticalBar
// Padding between edge of screen and hotseat
public final int mHotseatBarEdgePaddingPx;
// Space between hotseat and workspace (not used in responsive)
public final int mHotseatBarWorkspaceSpacePx;
public int hotseatQsbWidth; // only used when isQsbInline
public final int hotseatQsbHeight;
public final int hotseatQsbVisualHeight;
@@ -497,46 +499,56 @@ public class DeviceProfile {
numShownAllAppsColumns =
isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;
int hotseatBarBottomSpace = pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics);
int hotseatBarBottomSpace;
int minQsbMargin = res.getDimensionPixelSize(R.dimen.min_qsb_margin);
if (mIsResponsiveGrid) {
HotseatSpecs hotseatSpecs =
HotseatSpecs.create(new ResourceHelper(context,
isTwoPanels ? inv.hotseatSpecsTwoPanelId : inv.hotseatSpecsId));
mResponsiveHotseatSpec = hotseatSpecs.getCalculatedHeightSpec(heightPx);
mResponsiveHotseatSpec =
isVerticalBarLayout() ? hotseatSpecs.getCalculatedWidthSpec(widthPx)
: hotseatSpecs.getCalculatedHeightSpec(heightPx);
hotseatQsbSpace = mResponsiveHotseatSpec.getHotseatQsbSpace();
hotseatBarBottomSpace =
isVerticalBarLayout() ? 0 : mResponsiveHotseatSpec.getEdgePadding();
mHotseatBarEdgePaddingPx =
isVerticalBarLayout() ? mResponsiveHotseatSpec.getEdgePadding() : 0;
mHotseatBarWorkspaceSpacePx = 0;
} else {
hotseatQsbSpace = pxFromDp(inv.hotseatQsbSpace[mTypeIndex], mMetrics);
hotseatBarBottomSpace = pxFromDp(inv.hotseatBarBottomSpace[mTypeIndex], mMetrics);
mHotseatBarEdgePaddingPx =
isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
mHotseatBarWorkspaceSpacePx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
}
// Have a little space between the inset and the QSB
if (mInsets.bottom + minQsbMargin > hotseatBarBottomSpace) {
int availableSpace = hotseatQsbSpace - (mInsets.bottom - hotseatBarBottomSpace);
if (!isVerticalBarLayout()) {
// Have a little space between the inset and the QSB
if (mInsets.bottom + minQsbMargin > hotseatBarBottomSpace) {
int availableSpace = hotseatQsbSpace - (mInsets.bottom - hotseatBarBottomSpace);
// Only change the spaces if there is space
if (availableSpace > 0) {
// Make sure there is enough space between hotseat/QSB and QSB/navBar
if (availableSpace < minQsbMargin * 2) {
minQsbMargin = availableSpace / 2;
hotseatQsbSpace = minQsbMargin;
} else {
hotseatQsbSpace -= minQsbMargin;
// Only change the spaces if there is space
if (availableSpace > 0) {
// Make sure there is enough space between hotseat/QSB and QSB/navBar
if (availableSpace < minQsbMargin * 2) {
minQsbMargin = availableSpace / 2;
hotseatQsbSpace = minQsbMargin;
} else {
hotseatQsbSpace -= minQsbMargin;
}
}
}
hotseatBarBottomSpacePx = mInsets.bottom + minQsbMargin;
hotseatBarBottomSpacePx = mInsets.bottom + minQsbMargin;
} else {
hotseatBarBottomSpacePx = hotseatBarBottomSpace;
} else {
hotseatBarBottomSpacePx = hotseatBarBottomSpace;
}
}
springLoadedHotseatBarTopMarginPx = res.getDimensionPixelSize(
R.dimen.spring_loaded_hotseat_top_margin);
hotseatBarSidePaddingEndPx =
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_side_padding);
// Add a bit of space between nav bar and hotseat in vertical bar layout.
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
updateHotseatSizes(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
updateHotseatSizes(pxFromDp(inv.iconSize[mTypeIndex], mMetrics));
if (areNavButtonsInline && !isPhone) {
inlineNavButtonsEndSpacingPx =
res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing);
@@ -562,10 +574,9 @@ public class DeviceProfile {
int availableResponsiveWidth =
availableWidthPx - (isVerticalBarLayout() ? hotseatBarSizePx : 0);
int numColumns = getPanelCount() * inv.numColumns;
// don't use availableHeightPx because it subtracts bottom padding,
// but the workspace go behind it
int availableResponsiveHeight =
heightPx - mInsets.top - (isVerticalBarLayout() ? 0 : hotseatBarSizePx);
// don't use availableHeightPx because it subtracts mInsets.bottom
int availableResponsiveHeight = heightPx - mInsets.top
- (isVerticalBarLayout() ? 0 : hotseatBarSizePx);
mResponsiveWidthSpec = workspaceSpecs.getCalculatedWidthSpec(numColumns,
availableResponsiveWidth);
mResponsiveHeightSpec = workspaceSpecs.getCalculatedHeightSpec(inv.numRows,
@@ -738,8 +749,8 @@ public class DeviceProfile {
hotseatCellHeightPx = getIconSizeWithOverlap(hotseatIconSizePx);
if (isVerticalBarLayout()) {
hotseatBarSizePx = hotseatIconSizePx + hotseatBarSidePaddingStartPx
+ hotseatBarSidePaddingEndPx;
hotseatBarSizePx = hotseatIconSizePx + mHotseatBarEdgePaddingPx
+ mHotseatBarWorkspaceSpacePx;
} else if (isQsbInline) {
hotseatBarSizePx = Math.max(hotseatIconSizePx, hotseatQsbVisualHeight)
+ hotseatBarBottomSpacePx;
@@ -1007,6 +1018,7 @@ public class DeviceProfile {
iconSizePx = mIconSizeSteps.getIconSmallerThan(cellWidthPx);
}
// TODO(b/296400197): isVerticalBar shouldn't show labels anymore
iconDrawablePaddingPx = getNormalizedIconDrawablePadding();
int iconTextHeight = Utilities.calculateTextHeight(iconTextSizePx);
int cellContentHeight = iconSizePx + iconDrawablePaddingPx + iconTextHeight;
@@ -1491,7 +1503,8 @@ public class DeviceProfile {
if (isVerticalBarLayout()) {
if (mIsResponsiveGrid) {
padding.top = mResponsiveHeightSpec.getStartPaddingPx();
padding.bottom = mResponsiveHeightSpec.getEndPaddingPx();
padding.bottom = Math.max(0,
mResponsiveHeightSpec.getEndPaddingPx() - mInsets.bottom);
if (isSeascape()) {
padding.left = hotseatBarSizePx + mResponsiveWidthSpec.getEndPaddingPx();
padding.right = mResponsiveWidthSpec.getStartPaddingPx();
@@ -1504,9 +1517,9 @@ public class DeviceProfile {
padding.bottom = edgeMarginPx;
if (isSeascape()) {
padding.left = hotseatBarSizePx;
padding.right = hotseatBarSidePaddingStartPx;
padding.right = mHotseatBarEdgePaddingPx;
} else {
padding.left = hotseatBarSidePaddingStartPx;
padding.left = mHotseatBarEdgePaddingPx;
padding.right = hotseatBarSizePx;
}
}
@@ -1560,11 +1573,11 @@ public class DeviceProfile {
+ diffOverlapFactor), 0);
if (isSeascape()) {
hotseatBarPadding.set(mInsets.left + hotseatBarSidePaddingStartPx, paddingTop,
hotseatBarSidePaddingEndPx, paddingBottom);
hotseatBarPadding.set(mInsets.left + mHotseatBarEdgePaddingPx, paddingTop,
mHotseatBarWorkspaceSpacePx, paddingBottom);
} else {
hotseatBarPadding.set(hotseatBarSidePaddingEndPx, paddingTop,
mInsets.right + hotseatBarSidePaddingStartPx, paddingBottom);
hotseatBarPadding.set(mHotseatBarWorkspaceSpacePx, paddingTop,
mInsets.right + mHotseatBarEdgePaddingPx, paddingBottom);
}
} else if (isTaskbarPresent) {
// Center the QSB vertically with hotseat
@@ -1910,10 +1923,10 @@ public class DeviceProfile {
writer.println(prefix + "\tinv.hotseatColumnSpan: " + inv.hotseatColumnSpan[mTypeIndex]);
writer.println(prefix + pxToDpStr("hotseatCellHeightPx", hotseatCellHeightPx));
writer.println(prefix + pxToDpStr("hotseatBarBottomSpacePx", hotseatBarBottomSpacePx));
writer.println(prefix + pxToDpStr("hotseatBarSidePaddingStartPx",
hotseatBarSidePaddingStartPx));
writer.println(prefix + pxToDpStr("hotseatBarSidePaddingEndPx",
hotseatBarSidePaddingEndPx));
writer.println(prefix + pxToDpStr("mHotseatBarEdgePaddingPx",
mHotseatBarEdgePaddingPx));
writer.println(prefix + pxToDpStr("mHotseatBarWorkspaceSpacePx",
mHotseatBarWorkspaceSpacePx));
writer.println(prefix + pxToDpStr("hotseatBarEndOffset", hotseatBarEndOffset));
writer.println(prefix + pxToDpStr("hotseatQsbSpace", hotseatQsbSpace));
writer.println(prefix + pxToDpStr("hotseatQsbHeight", hotseatQsbHeight));