mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 10:48:19 +00:00
Merge "Don't scale iconSize and textSize in non-default display size" into tm-qpr-dev
This commit is contained in:
@@ -63,13 +63,13 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(558)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(4)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(76)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(50)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(122)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(112)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(558)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1058)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1080)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,13 +84,13 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(744)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(83)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(82)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(106)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(744)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1467)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1468)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,13 +109,13 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(705)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(108)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(102)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(631)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(625)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(705)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1227)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1233)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,11 +132,11 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(36)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(884)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(854)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(705)
|
||||
|
||||
assertThat(dp.isQsbInline).isTrue()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(559)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(531)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,9 +152,9 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(705)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(5)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(56)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(43)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(801)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(782)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(705)
|
||||
|
||||
assertThat(dp.isQsbInline).isTrue()
|
||||
|
||||
@@ -867,8 +867,8 @@ public class DeviceProfile {
|
||||
float invIconSizeDp = inv.iconSize[mTypeIndex];
|
||||
float invIconTextSizeSp = inv.iconTextSize[mTypeIndex];
|
||||
|
||||
iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics, iconScale));
|
||||
iconTextSizePx = (int) (pxFromSp(invIconTextSizeSp, mMetrics) * iconScale);
|
||||
iconSizePx = Math.max(1, pxFromDp(invIconSizeDp, mMetrics));
|
||||
iconTextSizePx = pxFromSp(invIconTextSizeSp, mMetrics);
|
||||
iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * iconScale);
|
||||
|
||||
cellLayoutBorderSpacePx = getCellLayoutBorderSpace(inv, scale);
|
||||
@@ -876,8 +876,46 @@ public class DeviceProfile {
|
||||
if (isScalableGrid) {
|
||||
cellWidthPx = pxFromDp(inv.minCellSize[mTypeIndex].x, mMetrics, scale);
|
||||
cellHeightPx = pxFromDp(inv.minCellSize[mTypeIndex].y, mMetrics, scale);
|
||||
int cellContentHeight = iconSizePx + iconDrawablePaddingPx
|
||||
+ Utilities.calculateTextHeight(iconTextSizePx);
|
||||
|
||||
if (cellWidthPx < iconSizePx) {
|
||||
// If cellWidth no longer fit iconSize, reduce borderSpace to make cellWidth bigger.
|
||||
int numColumns = getPanelCount() * inv.numColumns;
|
||||
int numBorders = numColumns - 1;
|
||||
int extraWidthRequired = (iconSizePx - cellWidthPx) * numColumns;
|
||||
if (cellLayoutBorderSpacePx.x * numBorders >= extraWidthRequired) {
|
||||
cellWidthPx = iconSizePx;
|
||||
cellLayoutBorderSpacePx.x -= extraWidthRequired / numBorders;
|
||||
} else {
|
||||
// If it still doesn't fit, set borderSpace to 0 and distribute the space for
|
||||
// cellWidth, and reduce iconSize.
|
||||
cellWidthPx = (cellWidthPx * numColumns
|
||||
+ cellLayoutBorderSpacePx.x * numBorders) / numColumns;
|
||||
iconSizePx = Math.min(iconSizePx, cellWidthPx);
|
||||
cellLayoutBorderSpacePx.x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int cellTextAndPaddingHeight =
|
||||
iconDrawablePaddingPx + Utilities.calculateTextHeight(iconTextSizePx);
|
||||
int cellContentHeight = iconSizePx + cellTextAndPaddingHeight;
|
||||
if (cellHeightPx < cellContentHeight) {
|
||||
// If cellHeight no longer fit iconSize, reduce borderSpace to make cellHeight
|
||||
// bigger.
|
||||
int numBorders = inv.numRows - 1;
|
||||
int extraHeightRequired = (cellContentHeight - cellHeightPx) * inv.numRows;
|
||||
if (cellLayoutBorderSpacePx.y * numBorders >= extraHeightRequired) {
|
||||
cellHeightPx = cellContentHeight;
|
||||
cellLayoutBorderSpacePx.y -= extraHeightRequired / numBorders;
|
||||
} else {
|
||||
// If it still doesn't fit, set borderSpace to 0 and distribute the space for
|
||||
// cellHeight, and reduce iconSize.
|
||||
cellHeightPx = (cellHeightPx * inv.numRows
|
||||
+ cellLayoutBorderSpacePx.y * numBorders) / inv.numRows;
|
||||
iconSizePx = Math.min(iconSizePx, cellHeightPx - cellTextAndPaddingHeight);
|
||||
cellLayoutBorderSpacePx.y = 0;
|
||||
}
|
||||
cellContentHeight = iconSizePx + cellTextAndPaddingHeight;
|
||||
}
|
||||
cellYPaddingPx = Math.max(0, cellHeightPx - cellContentHeight) / 2;
|
||||
desiredWorkspaceHorizontalMarginPx =
|
||||
(int) (desiredWorkspaceHorizontalMarginOriginalPx * scale);
|
||||
@@ -929,17 +967,41 @@ public class DeviceProfile {
|
||||
pxFromDp(inv.allAppsBorderSpaces[mTypeIndex].y, mMetrics, scale));
|
||||
// AllApps cells don't have real space between cells,
|
||||
// so we add the border space to the cell height
|
||||
allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics, scale)
|
||||
allAppsCellHeightPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].y, mMetrics)
|
||||
+ allAppsBorderSpacePx.y;
|
||||
// but width is just the cell,
|
||||
// the border is added in #updateAllAppsContainerWidth
|
||||
if (isScalableGrid) {
|
||||
allAppsIconSizePx =
|
||||
pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics, scale);
|
||||
allAppsIconTextSizePx =
|
||||
pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics, scale);
|
||||
allAppsIconSizePx = pxFromDp(inv.allAppsIconSize[mTypeIndex], mMetrics);
|
||||
allAppsIconTextSizePx = pxFromSp(inv.allAppsIconTextSize[mTypeIndex], mMetrics);
|
||||
allAppsIconDrawablePaddingPx = iconDrawablePaddingOriginalPx;
|
||||
allAppsCellWidthPx = pxFromDp(inv.allAppsCellSize[mTypeIndex].x, mMetrics, scale);
|
||||
|
||||
if (allAppsCellWidthPx < allAppsIconSizePx) {
|
||||
// If allAppsCellWidth no longer fit allAppsIconSize, reduce allAppsBorderSpace to
|
||||
// make allAppsCellWidth bigger.
|
||||
int numBorders = inv.numAllAppsColumns - 1;
|
||||
int extraWidthRequired =
|
||||
(allAppsIconSizePx - allAppsCellWidthPx) * inv.numAllAppsColumns;
|
||||
if (allAppsBorderSpacePx.x * numBorders >= extraWidthRequired) {
|
||||
allAppsCellWidthPx = allAppsIconSizePx;
|
||||
allAppsBorderSpacePx.x -= extraWidthRequired / numBorders;
|
||||
} else {
|
||||
// If it still doesn't fit, set allAppsBorderSpace to 0 and distribute the space
|
||||
// for allAppsCellWidth, and reduce allAppsIconSize.
|
||||
allAppsCellWidthPx = (allAppsCellWidthPx * inv.numAllAppsColumns
|
||||
+ allAppsBorderSpacePx.x * numBorders) / inv.numAllAppsColumns;
|
||||
allAppsIconSizePx = Math.min(allAppsIconSizePx, allAppsCellWidthPx);
|
||||
allAppsBorderSpacePx.x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
int cellContentHeight = allAppsIconSizePx
|
||||
+ Utilities.calculateTextHeight(allAppsIconTextSizePx) + allAppsBorderSpacePx.y;
|
||||
if (allAppsCellHeightPx < cellContentHeight) {
|
||||
// Increase allAppsCellHeight to fit its content.
|
||||
allAppsCellHeightPx = cellContentHeight;
|
||||
}
|
||||
} else {
|
||||
float invIconSizeDp = inv.allAppsIconSize[mTypeIndex];
|
||||
float invIconTextSizeSp = inv.allAppsIconTextSize[mTypeIndex];
|
||||
|
||||
@@ -63,13 +63,13 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(0)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(94)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(72)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(121)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(121)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(110)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(110)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1058)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1080)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,13 +84,13 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(0)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(105)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(104)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(370)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(370)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1467)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1468)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,13 +130,13 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(0)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(96)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(91)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(643)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(643)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(640)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(640)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1174)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1179)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,12 +152,12 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(0)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(89)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(75)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(589)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(589)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(582)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(582)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1081)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1095)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user