mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 02:38:20 +00:00
Merge "Fix hotseat border space crash GSI" into udc-qpr-dev
This commit is contained in:
@@ -1134,10 +1134,11 @@ public class DeviceProfile {
|
||||
* This method calculates the space between the icons to achieve a certain width.
|
||||
*/
|
||||
private int calculateHotseatBorderSpace(float hotseatWidthPx, int numExtraBorder) {
|
||||
int numBorders = (numShownHotseatIcons - 1 + numExtraBorder);
|
||||
if (numBorders <= 0) return 0;
|
||||
|
||||
float hotseatIconsTotalPx = iconSizePx * numShownHotseatIcons;
|
||||
int hotseatBorderSpacePx =
|
||||
(int) (hotseatWidthPx - hotseatIconsTotalPx)
|
||||
/ (numShownHotseatIcons - 1 + numExtraBorder);
|
||||
int hotseatBorderSpacePx = (int) (hotseatWidthPx - hotseatIconsTotalPx) / numBorders;
|
||||
return Math.min(hotseatBorderSpacePx, mMaxHotseatIconSpacePx);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,4 +158,25 @@ class HotseatWidthCalculationTest : FakeInvariantDeviceProfileTest() {
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1095)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun border_space_should_be_zero_when_numHotseatIcons_is_smallerOrEqual_1() {
|
||||
initializeVarsForTablet(isGestureMode = false)
|
||||
windowBounds = WindowBounds(Rect(0, 0, 1800, 2560), Rect(0, 104, 0, 0))
|
||||
|
||||
val numShownHotseatIcons = listOf(-1, 0, 1)
|
||||
for (numHotseatIcons in numShownHotseatIcons) {
|
||||
inv?.numShownHotseatIcons = numHotseatIcons
|
||||
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(numHotseatIcons)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(0)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(177)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(177)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1445)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user