Merge "Add more extra space to hotseat for taller devices." into sc-dev am: 0c7153bbdf
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/15363650 Change-Id: I22dce6692e5e284c5c12e21f1d179ce23ad870d3
This commit is contained in:
@@ -90,6 +90,7 @@ public class DeviceProfile {
|
|||||||
private static final float MAX_HORIZONTAL_PADDING_PERCENT = 0.14f;
|
private static final float MAX_HORIZONTAL_PADDING_PERCENT = 0.14f;
|
||||||
|
|
||||||
private static final float TALL_DEVICE_ASPECT_RATIO_THRESHOLD = 2.0f;
|
private static final float TALL_DEVICE_ASPECT_RATIO_THRESHOLD = 2.0f;
|
||||||
|
private static final float TALLER_DEVICE_ASPECT_RATIO_THRESHOLD = 2.15f;
|
||||||
|
|
||||||
// To evenly space the icons, increase the left/right margins for tablets in portrait mode.
|
// To evenly space the icons, increase the left/right margins for tablets in portrait mode.
|
||||||
private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4;
|
private static final int PORTRAIT_TABLET_LEFT_RIGHT_PADDING_MULTIPLIER = 4;
|
||||||
@@ -149,12 +150,13 @@ public class DeviceProfile {
|
|||||||
public int folderChildDrawablePaddingPx;
|
public int folderChildDrawablePaddingPx;
|
||||||
|
|
||||||
// Hotseat
|
// Hotseat
|
||||||
|
public int hotseatBarSizeExtraSpacePx;
|
||||||
public final int numShownHotseatIcons;
|
public final int numShownHotseatIcons;
|
||||||
public int hotseatCellHeightPx;
|
public int hotseatCellHeightPx;
|
||||||
private final int hotseatExtraVerticalSize;
|
private final int hotseatExtraVerticalSize;
|
||||||
// In portrait: size = height, in landscape: size = width
|
// In portrait: size = height, in landscape: size = width
|
||||||
public int hotseatBarSizePx;
|
public int hotseatBarSizePx;
|
||||||
public final int hotseatBarTopPaddingPx;
|
public int hotseatBarTopPaddingPx;
|
||||||
public final int hotseatBarBottomPaddingPx;
|
public final int hotseatBarBottomPaddingPx;
|
||||||
// Start is the side next to the nav bar, end is the side next to the workspace
|
// Start is the side next to the nav bar, end is the side next to the workspace
|
||||||
public final int hotseatBarSidePaddingStartPx;
|
public final int hotseatBarSidePaddingStartPx;
|
||||||
@@ -323,6 +325,7 @@ public class DeviceProfile {
|
|||||||
isTwoPanels ? inv.numDatabaseHotseatIcons : inv.numShownHotseatIcons;
|
isTwoPanels ? inv.numDatabaseHotseatIcons : inv.numShownHotseatIcons;
|
||||||
numShownAllAppsColumns =
|
numShownAllAppsColumns =
|
||||||
isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;
|
isTwoPanels ? inv.numDatabaseAllAppsColumns : inv.numAllAppsColumns;
|
||||||
|
hotseatBarSizeExtraSpacePx = 0;
|
||||||
hotseatBarTopPaddingPx =
|
hotseatBarTopPaddingPx =
|
||||||
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
|
res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding);
|
||||||
hotseatBarBottomPaddingPx = (isTallDevice ? 0
|
hotseatBarBottomPaddingPx = (isTallDevice ? 0
|
||||||
@@ -353,6 +356,7 @@ public class DeviceProfile {
|
|||||||
|
|
||||||
// Calculate all of the remaining variables.
|
// Calculate all of the remaining variables.
|
||||||
extraSpace = updateAvailableDimensions(res);
|
extraSpace = updateAvailableDimensions(res);
|
||||||
|
|
||||||
// Now that we have all of the variables calculated, we can tune certain sizes.
|
// Now that we have all of the variables calculated, we can tune certain sizes.
|
||||||
if (isScalableGrid && inv.devicePaddings != null) {
|
if (isScalableGrid && inv.devicePaddings != null) {
|
||||||
// Paddings were created assuming no scaling, so we first unscale the extra space.
|
// Paddings were created assuming no scaling, so we first unscale the extra space.
|
||||||
@@ -372,12 +376,25 @@ public class DeviceProfile {
|
|||||||
qsbBottomMarginPx = Math.round(qsbBottomMarginOriginalPx * cellScaleToFit);
|
qsbBottomMarginPx = Math.round(qsbBottomMarginOriginalPx * cellScaleToFit);
|
||||||
} else if (!isVerticalBarLayout() && isPhone && isTallDevice) {
|
} else if (!isVerticalBarLayout() && isPhone && isTallDevice) {
|
||||||
// We increase the hotseat size when there is extra space.
|
// We increase the hotseat size when there is extra space.
|
||||||
// ie. For a display with a large aspect ratio, we can keep the icons on the workspace
|
|
||||||
// in portrait mode closer together by adding more height to the hotseat.
|
if (Float.compare(aspectRatio, TALLER_DEVICE_ASPECT_RATIO_THRESHOLD) >= 0) {
|
||||||
// Note: This calculation was created after noticing a pattern in the design spec.
|
// For taller devices, we will take a third of the extra space from each row,
|
||||||
int extraSpace = getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2
|
// and add it to the space above and below the hotseat.
|
||||||
- workspacePageIndicatorHeight;
|
int extraSpace = ((getCellSize().y - iconSizePx - iconDrawablePaddingPx * 2)
|
||||||
hotseatBarSizePx += extraSpace;
|
* inv.numRows) / 3;
|
||||||
|
|
||||||
|
int halfExtraSpace = extraSpace / 2;
|
||||||
|
hotseatBarTopPaddingPx += halfExtraSpace;
|
||||||
|
hotseatBarSizeExtraSpacePx = halfExtraSpace;
|
||||||
|
} else {
|
||||||
|
// ie. For a display with a large aspect ratio, we can keep the icons on the
|
||||||
|
// workspace in portrait mode closer together by adding more height to the hotseat.
|
||||||
|
// Note: This calculation was created after noticing a pattern in the design spec.
|
||||||
|
hotseatBarSizeExtraSpacePx = getCellSize().y - iconSizePx
|
||||||
|
- iconDrawablePaddingPx * 2 - workspacePageIndicatorHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateHotseatIconSize(iconSizePx);
|
||||||
|
|
||||||
// Recalculate the available dimensions using the new hotseat size.
|
// Recalculate the available dimensions using the new hotseat size.
|
||||||
updateAvailableDimensions(res);
|
updateAvailableDimensions(res);
|
||||||
@@ -402,7 +419,8 @@ public class DeviceProfile {
|
|||||||
+ hotseatBarSidePaddingEndPx;
|
+ hotseatBarSidePaddingEndPx;
|
||||||
} else {
|
} else {
|
||||||
hotseatBarSizePx = hotseatIconSizePx + hotseatBarTopPaddingPx
|
hotseatBarSizePx = hotseatIconSizePx + hotseatBarTopPaddingPx
|
||||||
+ hotseatBarBottomPaddingPx + (isScalableGrid ? 0 : hotseatExtraVerticalSize);
|
+ hotseatBarBottomPaddingPx + (isScalableGrid ? 0 : hotseatExtraVerticalSize)
|
||||||
|
+ hotseatBarSizeExtraSpacePx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user