summaryrefslogtreecommitdiff
path: root/src/com/android
diff options
context:
space:
mode:
authorSebastián Franco <fransebas@google.com>2023-07-14 23:50:00 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-07-14 23:50:00 +0000
commitadd37239db821470829a7c68a5f129bc7ce2c9c7 (patch)
treeecac0b1c0f12934a196c4bd0bb2b28b274f9c9b2 /src/com/android
parent9711ba0a7d356f7c593eb5d8236f18d215239578 (diff)
parentbe4a43c1d9f8796a2f96bdbac0bccd2d8f9e79e8 (diff)
downloadLauncher3-add37239db821470829a7c68a5f129bc7ce2c9c7.tar.gz
Merge "Creating a correctly populated mOccupied grid when reordering on foldables" into udc-dev am: be4a43c1d9
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/24060456 Change-Id: I58ecf6e04aa29055e1a16b92adff8c2d9913215a Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
index cb1216109a..a2e26b37f3 100644
--- a/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
+++ b/src/com/android/launcher3/celllayout/MulticellReorderAlgorithm.java
@@ -19,8 +19,10 @@ import android.view.View;
import com.android.launcher3.CellLayout;
import com.android.launcher3.MultipageCellLayout;
+import com.android.launcher3.ShortcutAndWidgetContainer;
import com.android.launcher3.util.GridOccupancy;
+import java.util.Arrays;
import java.util.function.Supplier;
/**
@@ -79,7 +81,7 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm {
lp.canReorder = false;
mcl.setCountX(mcl.getCountX() + 1);
mcl.getShortcutsAndWidgets().addViewInLayout(mSeam, lp);
- mcl.setOccupied(createGridOccupancyWithSeam(mcl.getOccupied()));
+ mcl.setOccupied(createGridOccupancyWithSeam());
mcl.mTmpOccupied = new GridOccupancy(mcl.getCountX(), mcl.getCountY());
}
@@ -93,7 +95,8 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm {
/**
* The function supplied here will execute while the CellLayout has a simulated seam added.
- * @param f function to run under simulation
+ *
+ * @param f function to run under simulation
* @param <T> return value of the supplied function
* @return Value of supplied function
*/
@@ -110,18 +113,17 @@ public class MulticellReorderAlgorithm extends ReorderAlgorithm {
return res;
}
- GridOccupancy createGridOccupancyWithSeam(GridOccupancy gridOccupancy) {
+ GridOccupancy createGridOccupancyWithSeam() {
+ ShortcutAndWidgetContainer shortcutAndWidgets = mCellLayout.getShortcutsAndWidgets();
GridOccupancy grid = new GridOccupancy(mCellLayout.getCountX(), mCellLayout.getCountY());
- for (int x = 0; x < mCellLayout.getCountX(); x++) {
- for (int y = 0; y < mCellLayout.getCountY(); y++) {
- int offset = x >= mCellLayout.getCountX() / 2 ? 1 : 0;
- if (x == mCellLayout.getCountX() / 2) {
- grid.cells[x][y] = true;
- } else {
- grid.cells[x][y] = gridOccupancy.cells[x - offset][y];
- }
- }
+ for (int i = 0; i < shortcutAndWidgets.getChildCount(); i++) {
+ View view = shortcutAndWidgets.getChildAt(i);
+ CellLayoutLayoutParams lp = (CellLayoutLayoutParams) view.getLayoutParams();
+ int seamOffset = lp.getCellX() >= mCellLayout.getCountX() / 2 && lp.canReorder ? 1 : 0;
+ grid.markCells(lp.getCellX() + seamOffset, lp.getCellY(), lp.cellHSpan, lp.cellVSpan,
+ true);
}
+ Arrays.fill(grid.cells[mCellLayout.getCountX() / 2], true);
return grid;
}
}