mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Align QSB with hotseat and workspace icons
The QSB was a bit wider becuase icons visible size is a bit smaller than their actual size due to b/235886078 so we add a workaround to adjust QSB size based on the visible icon size Bug: 281587788 Test: atest HomeScreenImageTest Flag: NONE Change-Id: I593ca2d588f08b830be0b2ac389c747b6f558b91
This commit is contained in:
@@ -47,7 +47,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(580)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1445)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1435)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(550)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1080)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1070)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(759)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1468)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1455)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(1040)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1233)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1223)
|
||||
}
|
||||
|
||||
/** This is a case when after setting the hotseat, the QSB width needs to be changed to fit */
|
||||
|
||||
@@ -789,14 +789,16 @@ public class DeviceProfile {
|
||||
* width of the hotseat.
|
||||
*/
|
||||
private int calculateQsbWidth(int hotseatBorderSpace) {
|
||||
int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx);
|
||||
if (isQsbInline) {
|
||||
int columns = getPanelCount() * inv.numColumns;
|
||||
return getIconToIconWidthForColumns(columns)
|
||||
- iconSizePx * numShownHotseatIcons
|
||||
- hotseatBorderSpace * numShownHotseatIcons;
|
||||
- hotseatBorderSpace * numShownHotseatIcons
|
||||
- iconExtraSpacePx;
|
||||
} else {
|
||||
int columns = inv.hotseatColumnSpan[mTypeIndex];
|
||||
return getIconToIconWidthForColumns(columns);
|
||||
return getIconToIconWidthForColumns(columns) - iconExtraSpacePx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1074,11 +1076,8 @@ public class DeviceProfile {
|
||||
}
|
||||
|
||||
private int getNormalizedIconDrawablePadding(int iconSizePx, int iconDrawablePadding) {
|
||||
// TODO(b/235886078): workaround needed because of this bug
|
||||
// Icons are 10% larger on XML than their visual size,
|
||||
// so remove that extra space to get labels closer to the correct padding
|
||||
int iconVisibleSizePx = Math.round(ICON_VISIBLE_AREA_FACTOR * iconSizePx);
|
||||
return Math.max(0, iconDrawablePadding - ((iconSizePx - iconVisibleSizePx) / 2));
|
||||
return Math.max(0, iconDrawablePadding
|
||||
- ((iconSizePx - getIconVisibleSizePx(iconSizePx)) / 2));
|
||||
}
|
||||
|
||||
private int getNormalizedIconDrawablePadding() {
|
||||
@@ -1091,8 +1090,7 @@ public class DeviceProfile {
|
||||
// so remove that extra space to get labels closer to the correct padding
|
||||
int drawablePadding = (folderCellHeightPx - folderChildIconSizePx - textHeight) / 3;
|
||||
|
||||
int iconVisibleSizePx = Math.round(ICON_VISIBLE_AREA_FACTOR * folderChildIconSizePx);
|
||||
int iconSizeDiff = folderChildIconSizePx - iconVisibleSizePx;
|
||||
int iconSizeDiff = folderChildIconSizePx - getIconVisibleSizePx(folderChildIconSizePx);
|
||||
return Math.max(0, drawablePadding - iconSizeDiff / 2);
|
||||
}
|
||||
|
||||
@@ -1788,7 +1786,8 @@ public class DeviceProfile {
|
||||
}
|
||||
|
||||
} else if (mIsScalableGrid) {
|
||||
int sideSpacing = (availableWidthPx - hotseatQsbWidth) / 2;
|
||||
int iconExtraSpacePx = iconSizePx - getIconVisibleSizePx(iconSizePx);
|
||||
int sideSpacing = (availableWidthPx - (hotseatQsbWidth + iconExtraSpacePx)) / 2;
|
||||
hotseatBarPadding.set(sideSpacing,
|
||||
0,
|
||||
sideSpacing,
|
||||
@@ -1827,13 +1826,24 @@ public class DeviceProfile {
|
||||
availableWidthPx - allAppsSpacing,
|
||||
0 /* borderSpace */,
|
||||
numShownAllAppsColumns);
|
||||
int iconVisibleSize = Math.round(ICON_VISIBLE_AREA_FACTOR * allAppsIconSizePx);
|
||||
int iconAlignmentMargin = (cellWidth - iconVisibleSize) / 2;
|
||||
int iconAlignmentMargin = (cellWidth - getIconVisibleSizePx(allAppsIconSizePx)) / 2;
|
||||
|
||||
return (Utilities.isRtl(context.getResources()) ? allAppsPadding.right
|
||||
: allAppsPadding.left) + iconAlignmentMargin;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO(b/235886078): workaround needed because of this bug
|
||||
* Icons are 10% larger on XML than their visual size, so remove that extra space to get
|
||||
* some dimensions correct.
|
||||
*
|
||||
* When this bug is resolved this method will no longer be needed and we would be able to
|
||||
* replace all instances where this method is called with iconSizePx.
|
||||
*/
|
||||
private int getIconVisibleSizePx(int iconSizePx) {
|
||||
return Math.round(ICON_VISIBLE_AREA_FACTOR * iconSizePx);
|
||||
}
|
||||
|
||||
private int getAdditionalQsbSpace() {
|
||||
return isQsbInline ? hotseatQsbWidth + hotseatBorderSpace : 0;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ DeviceProfile:
|
||||
numShownHotseatIcons: 6
|
||||
hotseatBorderSpace: 100.0px (50.0dp)
|
||||
isQsbInline: false
|
||||
hotseatQsbWidth: 1224.0px (612.0dp)
|
||||
hotseatQsbWidth: 1214.0px (607.0dp)
|
||||
isTaskbarPresent:false
|
||||
isTaskbarPresentInApps:true
|
||||
taskbarHeight: 0.0px (0.0dp)
|
||||
|
||||
@@ -87,7 +87,7 @@ DeviceProfile:
|
||||
numShownHotseatIcons: 6
|
||||
hotseatBorderSpace: 100.0px (50.0dp)
|
||||
isQsbInline: false
|
||||
hotseatQsbWidth: 1224.0px (612.0dp)
|
||||
hotseatQsbWidth: 1214.0px (607.0dp)
|
||||
isTaskbarPresent:false
|
||||
isTaskbarPresentInApps:true
|
||||
taskbarHeight: 0.0px (0.0dp)
|
||||
|
||||
@@ -87,7 +87,7 @@ DeviceProfile:
|
||||
numShownHotseatIcons: 6
|
||||
hotseatBorderSpace: 116.0px (58.0dp)
|
||||
isQsbInline: false
|
||||
hotseatQsbWidth: 1300.0px (650.0dp)
|
||||
hotseatQsbWidth: 1290.0px (645.0dp)
|
||||
isTaskbarPresent:false
|
||||
isTaskbarPresentInApps:true
|
||||
taskbarHeight: 0.0px (0.0dp)
|
||||
|
||||
@@ -87,7 +87,7 @@ DeviceProfile:
|
||||
numShownHotseatIcons: 6
|
||||
hotseatBorderSpace: 116.0px (58.0dp)
|
||||
isQsbInline: false
|
||||
hotseatQsbWidth: 1300.0px (650.0dp)
|
||||
hotseatQsbWidth: 1290.0px (645.0dp)
|
||||
isTaskbarPresent:false
|
||||
isTaskbarPresentInApps:true
|
||||
taskbarHeight: 0.0px (0.0dp)
|
||||
|
||||
@@ -47,7 +47,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(177)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1445)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1435)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(110)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1080)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1070)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,7 +90,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(370)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1468)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1455)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(668)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1224)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1214)
|
||||
}
|
||||
|
||||
/** This is a case when after setting the hotseat, the QSB width needs to be changed to fit */
|
||||
@@ -134,7 +134,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(640)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1179)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1169)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +156,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(582)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1095)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1085)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -176,7 +176,7 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(177)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(177)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1445)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1435)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user