diff --git a/lawnchair/res/values/strings.xml b/lawnchair/res/values/strings.xml
index 4b0ea10d67..dd23088969 100644
--- a/lawnchair/res/values/strings.xml
+++ b/lawnchair/res/values/strings.xml
@@ -776,6 +776,7 @@
Open in store
Dock icons
+ Dock rows
%1$s (folded)
%1$s (unfolded)
Folded
diff --git a/lawnchair/src/app/lawnchair/DeviceProfileOverrides.kt b/lawnchair/src/app/lawnchair/DeviceProfileOverrides.kt
index 2c6924a54b..9caecbb91d 100644
--- a/lawnchair/src/app/lawnchair/DeviceProfileOverrides.kt
+++ b/lawnchair/src/app/lawnchair/DeviceProfileOverrides.kt
@@ -102,6 +102,8 @@ class DeviceProfileOverrides @Inject constructor(
val enableTaskbarOnPhone: Boolean,
+ val numHotseatRows: Int = 1,
+
// Foldable overrides (-1 means don't override)
val foldableShownHotseatIcons: Int = -1,
val foldableDatabaseHotseatIcons: Int = -1,
@@ -129,6 +131,8 @@ class DeviceProfileOverrides @Inject constructor(
enableTaskbarOnPhone = prefs2.enableTaskbarOnPhone.firstCached(),
+ numHotseatRows = prefs.hotseatRows.get().coerceIn(1, 2),
+
foldableShownHotseatIcons = if (deviceType == InvariantDeviceProfile.TYPE_MULTI_DISPLAY) {
val folded = prefs.hotseatColumns.get()
val unfolded = previewOverrides.foldableDatabaseHotseatIcons ?: prefs.hotseatColumnsUnfolded.get()
@@ -168,6 +172,12 @@ class DeviceProfileOverrides @Inject constructor(
idp.numDatabaseAllAppsColumns = foldableDatabaseAllAppsColumns
}
+ // Ensure database can hold enough icons for multi-row dock
+ val requiredSlots = idp.numShownHotseatIcons * numHotseatRows
+ if (idp.numDatabaseHotseatIcons < requiredSlots) {
+ idp.numDatabaseHotseatIcons = requiredSlots
+ }
+
// apply icon and text size
idp.iconSize[INDEX_DEFAULT] *= iconSizeFactor
idp.iconSize[INDEX_LANDSCAPE] *= iconSizeFactor
diff --git a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt
index 06e03dd221..64a88eb018 100644
--- a/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt
+++ b/lawnchair/src/app/lawnchair/preferences/PreferenceManager.kt
@@ -100,6 +100,7 @@ class PreferenceManager @Inject constructor(
val hotseatColumns = IntPref("pref_hotseatColumns", calculatedGridSpec.hotseatColumns, reloadGrid)
val hotseatColumnsUnfolded = IntPref("pref_hotseatColumnsUnfolded", calculatedGridSpec.hotseatColumnsUnfolded, reloadGrid)
+ val hotseatRows = IntPref("pref_hotseatRows", 1, reloadGrid)
val workspaceColumns = IntPref("pref_workspaceColumns", calculatedGridSpec.workspaceColumns)
val workspaceRows = IntPref("pref_workspaceRows", calculatedGridSpec.workspaceRows)
val workspaceIncreaseMaxGridSize = BoolPref("pref_workspace_increase_max_grid_size", false)
diff --git a/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt b/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt
index ff826a7e87..086df23cb6 100644
--- a/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt
+++ b/lawnchair/src/app/lawnchair/ui/preferences/destinations/DockPreferences.kt
@@ -138,6 +138,7 @@ fun GridSettings(prefs: PreferenceManager, prefs2: PreferenceManager2) {
val isFoldable = InvariantDeviceProfile.deviceType == InvariantDeviceProfile.TYPE_MULTI_DISPLAY
val hotseatColumnsAdapter = prefs.hotseatColumns.getAdapter()
val hotseatColumnsUnfoldedAdapter = prefs.hotseatColumnsUnfolded.getAdapter()
+ val hotseatRowsAdapter = prefs.hotseatRows.getAdapter()
PreferenceGroup(heading = stringResource(id = R.string.grid)) {
if (isFoldable) {
@@ -168,6 +169,12 @@ fun GridSettings(prefs: PreferenceManager, prefs2: PreferenceManager2) {
valueRange = 3..10,
)
}
+ SliderPreference(
+ label = stringResource(id = R.string.dock_rows),
+ adapter = hotseatRowsAdapter,
+ step = 1,
+ valueRange = 1..2,
+ )
SliderPreference(
adapter = prefs2.hotseatBottomFactor.getAdapter(),
label = stringResource(id = R.string.hotseat_bottom_space_label),
@@ -195,6 +202,7 @@ fun ColumnScope.DockPreferencesPreview(modifier: Modifier = Modifier) {
prefs2.hotseatMode.getAdapter(),
prefs.hotseatColumns.getAdapter(),
prefs.hotseatColumnsUnfolded.getAdapter(),
+ prefs.hotseatRows.getAdapter(),
prefs2.themedHotseatQsb.getAdapter(),
prefs.hotseatQsbCornerRadius.getAdapter(),
prefs.hotseatQsbAlpha.getAdapter(),
diff --git a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
index 3d46cb7f43..621a5c9a24 100644
--- a/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
+++ b/quickstep/src/com/android/launcher3/hybridhotseat/HotseatPredictionController.java
@@ -128,7 +128,8 @@ public class HotseatPredictionController implements DragController.DragListener,
public HotseatPredictionController(QuickstepLauncher launcher) {
mLauncher = launcher;
mHotseat = launcher.getHotseat();
- mHotSeatItemsCount = mLauncher.getDeviceProfile().numShownHotseatIcons;
+ mHotSeatItemsCount = mLauncher.getDeviceProfile().numShownHotseatIcons
+ * mLauncher.getDeviceProfile().numHotseatRows;
mLauncher.getDragController().addDragListener(this);
launcher.addOnDeviceProfileChangeListener(this);
@@ -417,7 +418,7 @@ public class HotseatPredictionController implements DragController.DragListener,
@Override
public void onDeviceProfileChanged(DeviceProfile profile) {
- this.mHotSeatItemsCount = profile.numShownHotseatIcons;
+ this.mHotSeatItemsCount = profile.numShownHotseatIcons * profile.numHotseatRows;
}
@Override
diff --git a/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt b/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt
index 0dce63a838..e707a636c7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/PinToTaskbarShortcut.kt
@@ -90,15 +90,16 @@ class PinToTaskbarShortcut(
val dp: DeviceProfile = mTarget.deviceProfile
var targetIdx = -1
- for (i in 0 until dp.numShownHotseatIcons) {
+ val totalSlots = dp.numShownHotseatIcons * dp.numHotseatRows
+ for (i in 0 until totalSlots) {
if (mPinnedInfoList[i] == null) {
targetIdx = i
break
}
}
- val cellX = if (dp.isVerticalBarLayout()) 0 else targetIdx
- val cellY = if (dp.isVerticalBarLayout()) (dp.numShownHotseatIcons - (targetIdx + 1)) else 0
+ val cellX = if (dp.isVerticalBarLayout()) 0 else targetIdx % dp.numShownHotseatIcons
+ val cellY = if (dp.isVerticalBarLayout()) (dp.numShownHotseatIcons - (targetIdx + 1)) else targetIdx / dp.numShownHotseatIcons
writer.addItemToDatabase(newInfo, CONTAINER_HOTSEAT, mItemInfo.screenId, cellX, cellY)
}
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index bb115b1125..8459796da3 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -93,6 +93,7 @@ import app.lawnchair.DeviceProfileOverrides;
import app.lawnchair.LawnchairApp;
import app.lawnchair.LawnchairAppKt;
import app.lawnchair.hotseat.HotseatMode;
+import app.lawnchair.preferences.PreferenceManager;
import app.lawnchair.preferences2.PreferenceManager2;
import app.lawnchair.theme.color.ColorOption;
@@ -219,6 +220,7 @@ public class DeviceProfile {
// Hotseat
private final HotseatProfile hotseatProfile;
public int numShownHotseatIcons;
+ public int numHotseatRows;
public int hotseatCellHeightPx;
private int mHotseatColumnSpan;
private int mHotseatWidthPx; // not used in vertical bar layout
@@ -328,6 +330,7 @@ public class DeviceProfile {
folderLabelTextScale = 0;
hotseatQsbWidth = 0;
hotseatBorderSpace = 0;
+ numHotseatRows = 1;
mBubbleBarSpaceThresholdPx = 0;
numShownAllAppsColumns = 0;
mViewScaleProvider = null;
@@ -513,6 +516,7 @@ public class DeviceProfile {
boolean isQsbEnable = hotseatMode.getLayoutResourceId() != R.layout.empty_view;
numShownHotseatIcons = displayOptionSpec.numShownHotseatIcons;
+ numHotseatRows = Math.max(1, Math.min(2, PreferenceManager.getInstance(context).getHotseatRows().get()));
mHotseatColumnSpan = inv.numColumns;
numShownAllAppsColumns = displayOptionSpec.numAllAppsColumns;
@@ -902,24 +906,30 @@ public class DeviceProfile {
hotseatBarBottomSpacePx *= PreferenceCacheExtensionsKt
.firstCached(preferenceManager2.getHotseatBottomFactor());
+ // Extra height needed for additional dock rows
+ int extraRowsHeight = (numHotseatRows - 1) * hotseatCellHeightPx;
+
if (isVerticalBarLayout()) {
hotseatBarSizePx = hotseatIconSizePx + getHotseatProfile().getBarEdgePaddingPx()
+ getHotseatProfile().getBarWorkspaceSpacePx()
+ space;
} else if (isQsbInline) {
hotseatBarSizePx = Math.max(hotseatIconSizePx, getHotseatProfile().getQsbVisualHeight())
- + hotseatBarBottomSpacePx;
+ + hotseatBarBottomSpacePx
+ + extraRowsHeight;
} else if (isQsbOnTop()) { // LC-Note: isQsbOnTop, this usually is a foldable device, not a tablet
hotseatBarSizePx = hotseatIconSizePx
+ hotseatQsbSpace
+ getHotseatProfile().getQsbVisualHeight()
- + hotseatBarBottomSpacePx;
+ + hotseatBarBottomSpacePx
+ + extraRowsHeight;
} else {
hotseatBarSizePx = hotseatIconSizePx
+ hotseatQsbSpace
+ getHotseatProfile().getQsbVisualHeight()
+ hotseatBarBottomSpacePx
- + space;
+ + space
+ + extraRowsHeight;
}
var isHotseatEnabled = PreferenceCacheExtensionsKt.firstCached(preferenceManager2.isHotseatEnabled());
if (!isHotseatEnabled) {
@@ -1886,7 +1896,7 @@ public class DeviceProfile {
hotseatBarPadding.set(
remainingSpaceOnSide + mInsets.left + workspacePadding.left
+ cellLayoutPaddingPx.left,
- hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx,
+ hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx * numHotseatRows,
remainingSpaceOnSide + mInsets.right + workspacePadding.right
+ cellLayoutPaddingPx.right,
hotseatBarBottomPadding
@@ -1900,7 +1910,7 @@ public class DeviceProfile {
// Keep the hotseat icons in the lower section so the QSB can sit above them.
int hotseatBarBottomPadding = getHotseatBarBottomPadding();
int hotseatBarTopPadding =
- hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx;
+ hotseatBarSizePx - hotseatBarBottomPadding - hotseatCellHeightPx * numHotseatRows;
int hotseatWidth = getHotseatRequiredWidth();
int startSpacing;
@@ -2028,7 +2038,7 @@ public class DeviceProfile {
if (isQsbOnTop() || isQsbInline) { // LC-Note: isQsbOnTop
return hotseatBarBottomSpacePx - (Math.abs(hotseatCellHeightPx - iconSizePx) / 2);
} else {
- return hotseatBarSizePx - hotseatCellHeightPx;
+ return hotseatBarSizePx - hotseatCellHeightPx * numHotseatRows;
}
}
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index d79d98636a..5c490ff3e3 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -200,14 +200,24 @@ public class Hotseat extends CellLayout implements Insettable {
* Returns orientation specific cell X given invariant order in the hotseat
*/
public int getCellXFromOrder(int rank) {
- return mHasVerticalHotseat ? 0 : rank;
+ if (mHasVerticalHotseat) {
+ return 0;
+ }
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ int numColumns = dp.numShownHotseatIcons;
+ return rank % numColumns;
}
/**
* Returns orientation specific cell Y given invariant order in the hotseat
*/
public int getCellYFromOrder(int rank) {
- return mHasVerticalHotseat ? (getCountY() - (rank + 1)) : 0;
+ if (mHasVerticalHotseat) {
+ return getCountY() - (rank + 1);
+ }
+ DeviceProfile dp = mActivity.getDeviceProfile();
+ int numColumns = dp.numShownHotseatIcons;
+ return rank / numColumns;
}
boolean isHasVerticalHotseat() {
@@ -245,7 +255,7 @@ public class Hotseat extends CellLayout implements Insettable {
if (hasVerticalHotseat) {
setGridSize(1, dp.numShownHotseatIcons);
} else {
- setGridSize(dp.numShownHotseatIcons, 1);
+ setGridSize(dp.numShownHotseatIcons, dp.numHotseatRows);
}
}
diff --git a/src/com/android/launcher3/celllayout/CellPosMapper.java b/src/com/android/launcher3/celllayout/CellPosMapper.java
index b133a1d59f..2d9ac4da04 100644
--- a/src/com/android/launcher3/celllayout/CellPosMapper.java
+++ b/src/com/android/launcher3/celllayout/CellPosMapper.java
@@ -49,8 +49,12 @@ public class CellPosMapper {
public CellPos mapPresenterToModel(int presenterX, int presenterY, int presenterScreen,
int container) {
if (container == Favorites.CONTAINER_HOTSEAT) {
- presenterScreen = mHasVerticalHotseat
- ? mNumOfHotseat - presenterY - 1 : presenterX;
+ if (mHasVerticalHotseat) {
+ presenterScreen = mNumOfHotseat - presenterY - 1;
+ } else {
+ // For multi-row hotseat, screenId (rank) = row * numColumns + column
+ presenterScreen = presenterY * mNumOfHotseat + presenterX;
+ }
}
return new CellPos(presenterX, presenterY, presenterScreen);
}
diff --git a/src/com/android/launcher3/preview/LauncherPreviewRenderer.java b/src/com/android/launcher3/preview/LauncherPreviewRenderer.java
index 83fd79d11f..2839147e89 100644
--- a/src/com/android/launcher3/preview/LauncherPreviewRenderer.java
+++ b/src/com/android/launcher3/preview/LauncherPreviewRenderer.java
@@ -373,7 +373,8 @@ public class LauncherPreviewRenderer extends BaseContext
private void populateHotseatPredictions(WorkspaceData itemIdMap) {
List predictions = itemIdMap.getPredictedContents(CONTAINER_HOTSEAT_PREDICTION);
int predictionIndex = 0;
- for (int rank = 0; rank < mDp.numShownHotseatIcons; rank++) {
+ int totalHotseatSlots = mDp.numShownHotseatIcons * mDp.numHotseatRows;
+ for (int rank = 0; rank < totalHotseatSlots; rank++) {
if (predictions.size() <= predictionIndex) continue;
int cellX = mHotseat.getCellXFromOrder(rank);