mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-28 07:46:55 +00:00
Merge "Polish hotseat and taskbar with 3 buttons" into tm-qpr-dev
This commit is contained in:
@@ -76,10 +76,8 @@
|
||||
<dimen name="gesture_tutorial_taskbar_padding_start_end">218dp</dimen>
|
||||
|
||||
<!-- Taskbar 3 button spacing -->
|
||||
<dimen name="taskbar_button_margin_5_5">94.5dp</dimen>
|
||||
<dimen name="taskbar_button_margin_split">88dp</dimen>
|
||||
<dimen name="taskbar_button_margin_6_5">219.6dp</dimen>
|
||||
<dimen name="taskbar_button_margin_4_5">84dp</dimen>
|
||||
<dimen name="taskbar_button_margin_4_4">79dp</dimen>
|
||||
<dimen name="taskbar_contextual_button_margin">48dp</dimen>
|
||||
<dimen name="taskbar_suw_frame">96dp</dimen>
|
||||
<dimen name="taskbar_suw_insets">24dp</dimen>
|
||||
|
||||
@@ -303,11 +303,9 @@
|
||||
<!-- Taskbar 3 button spacing -->
|
||||
<dimen name="taskbar_button_space_inbetween">24dp</dimen>
|
||||
<dimen name="taskbar_button_space_inbetween_phone">40dp</dimen>
|
||||
<dimen name="taskbar_button_margin_5_5">26dp</dimen>
|
||||
<dimen name="taskbar_button_margin_split">48dp</dimen>
|
||||
<dimen name="taskbar_button_margin_6_5">75dp</dimen>
|
||||
<dimen name="taskbar_button_margin_4_5">47dp</dimen>
|
||||
<dimen name="taskbar_button_margin_4_4">47dp</dimen>
|
||||
<dimen name="taskbar_button_margin_default">47dp</dimen>
|
||||
<dimen name="taskbar_button_margin_default">48dp</dimen>
|
||||
|
||||
<!-- Launcher splash screen -->
|
||||
<!-- Note: keep this value in sync with the WindowManager/Shell dimens.xml -->
|
||||
|
||||
@@ -152,10 +152,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
TaskbarNavButtonController buttonController, ScopedUnfoldTransitionProgressProvider
|
||||
unfoldTransitionProgressProvider) {
|
||||
super(windowContext);
|
||||
mDeviceProfile = launcherDp.copy(this);
|
||||
|
||||
final Resources resources = getResources();
|
||||
|
||||
matchDeviceProfile(launcherDp, getResources());
|
||||
|
||||
mNavMode = DisplayController.getNavigationMode(windowContext);
|
||||
mImeDrawsImeNavBar = getBoolByName(IME_DRAWS_IME_NAV_BAR_RES_NAME, resources, false);
|
||||
mIsSafeModeEnabled = TraceHelper.allowIpcs("isSafeMode",
|
||||
@@ -170,8 +170,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
mIsNavBarKidsMode = settingsCache.getValue(
|
||||
Settings.Secure.getUriFor(Settings.Secure.NAV_BAR_KIDS_MODE), 0);
|
||||
|
||||
updateIconSize(resources);
|
||||
|
||||
// Get display and corners first, as views might use them in constructor.
|
||||
Display display = windowContext.getDisplay();
|
||||
Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
|
||||
@@ -259,8 +257,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
public void updateDeviceProfile(DeviceProfile launcherDp, NavigationMode navMode) {
|
||||
mNavMode = navMode;
|
||||
mControllers.taskbarOverlayController.updateLauncherDeviceProfile(launcherDp);
|
||||
mDeviceProfile = launcherDp.copy(this);
|
||||
updateIconSize(getResources());
|
||||
matchDeviceProfile(launcherDp, getResources());
|
||||
|
||||
AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE);
|
||||
// Reapply fullscreen to take potential new screen size into account.
|
||||
@@ -269,6 +266,21 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
dispatchDeviceProfileChanged();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the original DeviceProfile, match the number of hotseat icons and qsb width and update
|
||||
* the icon size
|
||||
*/
|
||||
private void matchDeviceProfile(DeviceProfile originDeviceProfile, Resources resources) {
|
||||
mDeviceProfile = originDeviceProfile.copy(this);
|
||||
// Taskbar should match the number of icons of hotseat
|
||||
mDeviceProfile.numShownHotseatIcons = originDeviceProfile.numShownHotseatIcons;
|
||||
// Same QSB width to have a smooth animation
|
||||
mDeviceProfile.hotseatQsbWidth = originDeviceProfile.hotseatQsbWidth;
|
||||
// Update the size of the icons
|
||||
updateIconSize(resources);
|
||||
}
|
||||
|
||||
|
||||
private void updateIconSize(Resources resources) {
|
||||
mDeviceProfile.iconSizePx = resources.getDimensionPixelSize(
|
||||
DisplayController.isTransientTaskbar(this)
|
||||
|
||||
@@ -39,12 +39,12 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(558)
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(510)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(69)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(70)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(176)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(558)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(150)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(580)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1445)
|
||||
@@ -61,12 +61,12 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(558)
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(510)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(4)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(50)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(40)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(112)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(558)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(150)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(550)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1080)
|
||||
@@ -82,12 +82,12 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(744)
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(705)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(82)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(54)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(106)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(744)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(231)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(759)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1468)
|
||||
@@ -107,12 +107,12 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(705)
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(660)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(102)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(100)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(625)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(705)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(300)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(1040)
|
||||
|
||||
assertThat(dp.isQsbInline).isFalse()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(1233)
|
||||
@@ -128,15 +128,15 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(705)
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(660)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(6)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(36)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(854)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(705)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(864)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(696)
|
||||
|
||||
assertThat(dp.isQsbInline).isTrue()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(531)
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(528)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -150,12 +150,12 @@ class HotseatWidthCalculationTest : DeviceProfileBaseTest() {
|
||||
val dp = newDP()
|
||||
dp.isTaskbarPresentInApps = true
|
||||
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(705)
|
||||
assertThat(dp.hotseatBarEndOffset).isEqualTo(660)
|
||||
assertThat(dp.numShownHotseatIcons).isEqualTo(5)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(43)
|
||||
assertThat(dp.hotseatBorderSpace).isEqualTo(36)
|
||||
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(782)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(705)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).left).isEqualTo(816)
|
||||
assertThat(dp.getHotseatLayoutPadding(context).right).isEqualTo(700)
|
||||
|
||||
assertThat(dp.isQsbInline).isTrue()
|
||||
assertThat(dp.hotseatQsbWidth).isEqualTo(480)
|
||||
|
||||
@@ -361,6 +361,7 @@
|
||||
<dimen name="qsb_widget_height">0dp</dimen>
|
||||
<dimen name="qsb_shadow_height">0dp</dimen>
|
||||
<dimen name="min_hotseat_icon_space">18dp</dimen>
|
||||
<dimen name="max_hotseat_icon_space">50dp</dimen>
|
||||
<dimen name="min_hotseat_qsb_width">0dp</dimen>
|
||||
<dimen name="taskbar_icon_size">44dp</dimen>
|
||||
<dimen name="transient_taskbar_icon_size">57dp</dimen>
|
||||
@@ -383,10 +384,8 @@
|
||||
<dimen name="taskbar_button_margin_default">0dp</dimen>
|
||||
<dimen name="taskbar_button_space_inbetween">0dp</dimen>
|
||||
<dimen name="taskbar_button_space_inbetween_phone">0dp</dimen>
|
||||
<dimen name="taskbar_button_margin_5_5">0dp</dimen>
|
||||
<dimen name="taskbar_button_margin_split">0dp</dimen>
|
||||
<dimen name="taskbar_button_margin_6_5">0dp</dimen>
|
||||
<dimen name="taskbar_button_margin_4_5">0dp</dimen>
|
||||
<dimen name="taskbar_button_margin_4_4">0dp</dimen>
|
||||
<!-- Taskbar swipe up thresholds threshold -->
|
||||
<dimen name="taskbar_nav_threshold">0dp</dimen>
|
||||
<dimen name="taskbar_app_window_threshold">0dp</dimen>
|
||||
|
||||
@@ -57,8 +57,9 @@
|
||||
launcher:numFolderRows="3"
|
||||
launcher:numFolderColumns="4"
|
||||
launcher:numHotseatIcons="4"
|
||||
launcher:numExtendedHotseatIcons="6"
|
||||
launcher:dbFile="launcher_4_by_4.db"
|
||||
launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_4_4"
|
||||
launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_split"
|
||||
launcher:defaultLayoutId="@xml/default_workspace_4x4"
|
||||
launcher:deviceCategory="phone|multi_display" >
|
||||
|
||||
@@ -121,8 +122,9 @@
|
||||
launcher:numFolderRows="4"
|
||||
launcher:numFolderColumns="4"
|
||||
launcher:numHotseatIcons="5"
|
||||
launcher:numExtendedHotseatIcons="6"
|
||||
launcher:dbFile="launcher.db"
|
||||
launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_5_5"
|
||||
launcher:inlineNavButtonsEndSpacing="@dimen/taskbar_button_margin_split"
|
||||
launcher:defaultLayoutId="@xml/default_workspace_5x5"
|
||||
launcher:deviceCategory="phone|multi_display" >
|
||||
|
||||
|
||||
@@ -188,6 +188,10 @@ public class DeviceProfile {
|
||||
public final int hotseatQsbVisualHeight;
|
||||
private final int hotseatQsbShadowHeight;
|
||||
public int hotseatBorderSpace;
|
||||
private int minHotseatIconSpacePx;
|
||||
private int minHotseatQsbWidthPx;
|
||||
private final int maxHotseatIconSpacePx;
|
||||
private int inlineNavButtonsEndSpacing;
|
||||
|
||||
// Bottom sheets
|
||||
public int bottomSheetTopPadding;
|
||||
@@ -434,7 +438,7 @@ public class DeviceProfile {
|
||||
|| inv.inlineQsb[INDEX_TWO_PANEL_LANDSCAPE]
|
||||
: inv.inlineQsb[INDEX_DEFAULT] || inv.inlineQsb[INDEX_LANDSCAPE])
|
||||
&& hotseatQsbHeight > 0;
|
||||
isQsbInline = inv.inlineQsb[mTypeIndex] && canQsbInline;
|
||||
isQsbInline = isScalableGrid && inv.inlineQsb[mTypeIndex] && canQsbInline;
|
||||
|
||||
areNavButtonsInline = isTaskbarPresent && !isGestureMode;
|
||||
numShownHotseatIcons =
|
||||
@@ -474,17 +478,17 @@ public class DeviceProfile {
|
||||
hotseatBarSidePaddingStartPx = isVerticalBarLayout() ? workspacePageIndicatorHeight : 0;
|
||||
updateHotseatSizes(pxFromDp(inv.iconSize[INDEX_DEFAULT], mMetrics));
|
||||
if (areNavButtonsInline && !isPhone) {
|
||||
inlineNavButtonsEndSpacing = res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing);
|
||||
/*
|
||||
* 3 nav buttons +
|
||||
* Spacing between nav buttons +
|
||||
* Little space at the end for contextual buttons +
|
||||
* Little space between icons and nav buttons
|
||||
* Space at the end for contextual buttons
|
||||
*/
|
||||
hotseatBarEndOffset = 3 * res.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size)
|
||||
+ 2 * res.getDimensionPixelSize(R.dimen.taskbar_button_space_inbetween)
|
||||
+ res.getDimensionPixelSize(inv.inlineNavButtonsEndSpacing)
|
||||
+ res.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing);
|
||||
+ inlineNavButtonsEndSpacing;
|
||||
} else {
|
||||
inlineNavButtonsEndSpacing = 0;
|
||||
hotseatBarEndOffset = 0;
|
||||
}
|
||||
|
||||
@@ -531,8 +535,12 @@ public class DeviceProfile {
|
||||
cellLayoutPadding);
|
||||
updateWorkspacePadding();
|
||||
|
||||
minHotseatIconSpacePx = res.getDimensionPixelSize(R.dimen.min_hotseat_icon_space);
|
||||
minHotseatQsbWidthPx = res.getDimensionPixelSize(R.dimen.min_hotseat_qsb_width);
|
||||
maxHotseatIconSpacePx = areNavButtonsInline
|
||||
? res.getDimensionPixelSize(R.dimen.max_hotseat_icon_space) : Integer.MAX_VALUE;
|
||||
// Hotseat and QSB width depends on updated cellSize and workspace padding
|
||||
recalculateHotseatWidthAndBorderSpace(res);
|
||||
recalculateHotseatWidthAndBorderSpace();
|
||||
|
||||
// AllApps height calculation depends on updated cellSize
|
||||
if (isTablet) {
|
||||
@@ -621,68 +629,57 @@ public class DeviceProfile {
|
||||
}
|
||||
}
|
||||
|
||||
private void recalculateHotseatWidthAndBorderSpace(Resources res) {
|
||||
hotseatBorderSpace = calculateHotseatBorderSpace();
|
||||
/**
|
||||
* Calculates the width of the hotseat, changing spaces between the icons and removing icons if
|
||||
* necessary.
|
||||
*/
|
||||
public void recalculateHotseatWidthAndBorderSpace() {
|
||||
if (!isScalableGrid) return;
|
||||
|
||||
int columns = inv.hotseatColumnSpan[mTypeIndex];
|
||||
float hotseatWidthPx = getIconToIconWidthForColumns(columns);
|
||||
hotseatBorderSpace = calculateHotseatBorderSpace(hotseatWidthPx, /* numExtraBorder= */ 0);
|
||||
hotseatQsbWidth = calculateQsbWidth(hotseatBorderSpace);
|
||||
// Spaces should be correct when there nav buttons are not inline
|
||||
// Spaces should be correct when the nav buttons are not inline
|
||||
if (!areNavButtonsInline) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the maximum width that the hotseat can be
|
||||
int columns = getPanelCount() * inv.numColumns;
|
||||
int maxHotseatWidth = getIconToIconWidthForColumns(columns);
|
||||
int sideSpace = (availableWidthPx - maxHotseatWidth) / 2;
|
||||
int inlineButtonsOverlap = Math.max(0, hotseatBarEndOffset - sideSpace);
|
||||
// decrease how much the nav buttons go "inside" the hotseat
|
||||
maxHotseatWidth -= inlineButtonsOverlap;
|
||||
// The side space with inline buttons should be what is defined in InvariantDeviceProfile
|
||||
int sideSpace = inlineNavButtonsEndSpacing;
|
||||
int maxHotseatWidth = availableWidthPx - sideSpace - hotseatBarEndOffset;
|
||||
int maxHotseatIconsWidth = maxHotseatWidth - (isQsbInline ? hotseatQsbWidth : 0);
|
||||
hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidth,
|
||||
(isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1);
|
||||
|
||||
// Get how much space is required to show the hotseat with QSB
|
||||
int requiredWidth = getHotseatRequiredWidth();
|
||||
|
||||
// If spaces are fine, use them
|
||||
if (requiredWidth <= maxHotseatWidth) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Calculate the difference of widths and remove a little from each space between icons
|
||||
// and QSB if it's inline
|
||||
int spaceDiff = requiredWidth - maxHotseatWidth;
|
||||
int numOfSpaces = numShownHotseatIcons - (isQsbInline ? 0 : 1);
|
||||
hotseatBorderSpace -= (spaceDiff / numOfSpaces);
|
||||
|
||||
int minHotseatIconSpaceDp = res.getDimensionPixelSize(R.dimen.min_hotseat_icon_space);
|
||||
int minHotseatQsbWidthDp = res.getDimensionPixelSize(R.dimen.min_hotseat_qsb_width);
|
||||
|
||||
if (hotseatBorderSpace >= minHotseatIconSpaceDp) {
|
||||
if (hotseatBorderSpace >= minHotseatIconSpacePx) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Border space can't be less than the minimum
|
||||
hotseatBorderSpace = minHotseatIconSpaceDp;
|
||||
requiredWidth = getHotseatRequiredWidth();
|
||||
hotseatBorderSpace = minHotseatIconSpacePx;
|
||||
int requiredWidth = getHotseatRequiredWidth();
|
||||
|
||||
// If there is an inline qsb, change its size
|
||||
if (isQsbInline) {
|
||||
hotseatQsbWidth -= requiredWidth - maxHotseatWidth;
|
||||
if (hotseatQsbWidth >= minHotseatQsbWidthDp) {
|
||||
if (hotseatQsbWidth >= minHotseatQsbWidthPx) {
|
||||
return;
|
||||
}
|
||||
|
||||
// QSB can't be less than the minimum
|
||||
hotseatQsbWidth = minHotseatQsbWidthDp;
|
||||
hotseatQsbWidth = minHotseatQsbWidthPx;
|
||||
}
|
||||
|
||||
maxHotseatIconsWidth = maxHotseatWidth - (isQsbInline ? hotseatQsbWidth : 0);
|
||||
|
||||
// If it still doesn't fit, start removing icons
|
||||
do {
|
||||
numShownHotseatIcons--;
|
||||
requiredWidth = getHotseatRequiredWidth();
|
||||
} while (requiredWidth > maxHotseatWidth && numShownHotseatIcons > 1);
|
||||
hotseatBorderSpace = calculateHotseatBorderSpace(maxHotseatIconsWidth,
|
||||
(isQsbInline ? 1 : 0) + /* border between nav buttons and first icon */ 1);
|
||||
} while (hotseatBorderSpace < minHotseatIconSpacePx && numShownHotseatIcons > 1);
|
||||
|
||||
// Add back some space between the icons
|
||||
spaceDiff = maxHotseatWidth - requiredWidth;
|
||||
numOfSpaces = numShownHotseatIcons - (isQsbInline ? 0 : 1);
|
||||
hotseatBorderSpace += (spaceDiff / numOfSpaces);
|
||||
}
|
||||
|
||||
private Point getCellLayoutBorderSpace(InvariantDeviceProfile idp) {
|
||||
@@ -954,15 +951,14 @@ public class DeviceProfile {
|
||||
}
|
||||
|
||||
/**
|
||||
* Hotseat width spans a certain number of columns on scalable grids.
|
||||
* This method calculates the space between the icons to achieve that width.
|
||||
* This method calculates the space between the icons to achieve a certain width.
|
||||
*/
|
||||
private int calculateHotseatBorderSpace() {
|
||||
if (!isScalableGrid) return 0;
|
||||
int columns = inv.hotseatColumnSpan[mTypeIndex];
|
||||
float hotseatWidthPx = getIconToIconWidthForColumns(columns);
|
||||
private int calculateHotseatBorderSpace(float hotseatWidthPx, int numExtraBorder) {
|
||||
float hotseatIconsTotalPx = iconSizePx * numShownHotseatIcons;
|
||||
return (int) (hotseatWidthPx - hotseatIconsTotalPx) / (numShownHotseatIcons - 1);
|
||||
int hotseatBorderSpace =
|
||||
(int) (hotseatWidthPx - hotseatIconsTotalPx)
|
||||
/ (numShownHotseatIcons - 1 + numExtraBorder);
|
||||
return Math.min(hotseatBorderSpace, maxHotseatIconSpacePx);
|
||||
}
|
||||
|
||||
|
||||
@@ -1283,12 +1279,16 @@ public class DeviceProfile {
|
||||
int hotseatBarTopPadding =
|
||||
hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx;
|
||||
|
||||
// Push icons to the side
|
||||
int requiredWidth = getHotseatRequiredWidth();
|
||||
int hotseatWidth = Math.min(requiredWidth, availableWidthPx - hotseatBarEndOffset);
|
||||
int sideSpacing = (availableWidthPx - hotseatWidth) / 2;
|
||||
int hotseatWidth = getHotseatRequiredWidth();
|
||||
int leftSpacing = (availableWidthPx - hotseatWidth) / 2;
|
||||
int rightSpacing = leftSpacing;
|
||||
// Hotseat aligns to the left with nav buttons
|
||||
if (hotseatBarEndOffset > 0) {
|
||||
leftSpacing = inlineNavButtonsEndSpacing;
|
||||
rightSpacing = availableWidthPx - hotseatWidth - leftSpacing + hotseatBorderSpace;
|
||||
}
|
||||
|
||||
hotseatBarPadding.set(sideSpacing, hotseatBarTopPadding, sideSpacing,
|
||||
hotseatBarPadding.set(leftSpacing, hotseatBarTopPadding, rightSpacing,
|
||||
hotseatBarBottomPadding);
|
||||
|
||||
boolean isRtl = Utilities.isRtl(context.getResources());
|
||||
@@ -1297,14 +1297,6 @@ public class DeviceProfile {
|
||||
} else {
|
||||
hotseatBarPadding.left += getAdditionalQsbSpace();
|
||||
}
|
||||
|
||||
if (hotseatBarEndOffset > sideSpacing) {
|
||||
int diff = isRtl
|
||||
? sideSpacing - hotseatBarEndOffset
|
||||
: hotseatBarEndOffset - sideSpacing;
|
||||
hotseatBarPadding.left -= diff;
|
||||
hotseatBarPadding.right += diff;
|
||||
}
|
||||
} else if (isScalableGrid) {
|
||||
int sideSpacing = (availableWidthPx - hotseatQsbWidth) / 2;
|
||||
hotseatBarPadding.set(sideSpacing,
|
||||
@@ -1340,7 +1332,7 @@ public class DeviceProfile {
|
||||
private int getHotseatRequiredWidth() {
|
||||
int additionalQsbSpace = getAdditionalQsbSpace();
|
||||
return iconSizePx * numShownHotseatIcons
|
||||
+ hotseatBorderSpace * (numShownHotseatIcons - 1)
|
||||
+ hotseatBorderSpace * (numShownHotseatIcons - (areNavButtonsInline ? 0 : 1))
|
||||
+ additionalQsbSpace;
|
||||
}
|
||||
|
||||
|
||||
@@ -422,6 +422,21 @@ public class InvariantDeviceProfile {
|
||||
}
|
||||
supportedProfiles = Collections.unmodifiableList(localSupportedProfiles);
|
||||
|
||||
int numMinShownHotseatIconsForTablet = supportedProfiles
|
||||
.stream()
|
||||
.filter(deviceProfile -> deviceProfile.isTablet)
|
||||
.mapToInt(deviceProfile -> deviceProfile.numShownHotseatIcons)
|
||||
.min()
|
||||
.orElse(0);
|
||||
|
||||
supportedProfiles
|
||||
.stream()
|
||||
.filter(deviceProfile -> deviceProfile.isTablet)
|
||||
.forEach(deviceProfile -> {
|
||||
deviceProfile.numShownHotseatIcons = numMinShownHotseatIconsForTablet;
|
||||
deviceProfile.recalculateHotseatWidthAndBorderSpace();
|
||||
});
|
||||
|
||||
ComponentName cn = new ComponentName(context.getPackageName(), getClass().getName());
|
||||
defaultWidgetPadding = AppWidgetHostView.getDefaultPaddingForWidget(context, cn, null);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ abstract class DeviceProfileBaseTest {
|
||||
numFolderColumns = 3
|
||||
folderStyle = R.style.FolderDefaultStyle
|
||||
|
||||
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_4_5
|
||||
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split
|
||||
|
||||
horizontalMargin = FloatArray(4) { 22f }
|
||||
|
||||
@@ -277,7 +277,7 @@ abstract class DeviceProfileBaseTest {
|
||||
numFolderColumns = 3
|
||||
folderStyle = R.style.FolderDefaultStyle
|
||||
|
||||
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_4_4
|
||||
inlineNavButtonsEndSpacing = R.dimen.taskbar_button_margin_split
|
||||
|
||||
horizontalMargin = floatArrayOf(21.5f, 21.5f, 22.5f, 30.5f)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user