summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Sebastian Franco <fransebas@google.com> 2023-03-01 12:51:12 -0800
committer Sebastian Franco <fransebas@google.com> 2023-03-01 13:51:24 -0800
commitc515d02f282517fbf50b990c30e74c8ed3883039 (patch)
tree673a58fd2d3771483ad0286ad2cb42009aa17ef1
parenta695986d566968a82e36298a2f78b8a5250380e7 (diff)
Fix widget resize if it last for too long on Multipage CellLayout
We need to make sure the seam is added when the countX is even checking for => and if you reszie for a while the occupied grid starts to have incorrect values. Fix: 270227019 Test: atest FoldableItemsIntegrity Test: atest ReorderWidgets Change-Id: I3faf5d23427dc966c48ce5c613e68e42a101f45b
-rw-r--r--src/com/android/launcher3/MultipageCellLayout.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/com/android/launcher3/MultipageCellLayout.java b/src/com/android/launcher3/MultipageCellLayout.java
index 0d59848bfa..6a518a79e7 100644
--- a/src/com/android/launcher3/MultipageCellLayout.java
+++ b/src/com/android/launcher3/MultipageCellLayout.java
@@ -70,7 +70,7 @@ public class MultipageCellLayout extends CellLayout {
boolean createAreaForResize(int cellX, int cellY, int spanX, int spanY, View dragView,
int[] direction, boolean commit) {
// Add seam to x position
- if (cellX > mCountX / 2) {
+ if (cellX >= mCountX / 2) {
cellX++;
}
int finalCellX = cellX;
@@ -109,7 +109,7 @@ public class MultipageCellLayout extends CellLayout {
lp.canReorder = false;
mCountX++;
mShortcutsAndWidgets.addViewInLayout(mSeam, lp);
- mOccupied = createGridOccupancy();
+ mOccupied = createGridOccupancyWithSeam(mOccupied);
mTmpOccupied = new GridOccupancy(mCountX, mCountY);
}
@@ -139,14 +139,19 @@ public class MultipageCellLayout extends CellLayout {
return solution;
}
- GridOccupancy createGridOccupancy() {
- GridOccupancy grid = new GridOccupancy(mCountX, mCountY);
- for (int i = 0; i < mShortcutsAndWidgets.getChildCount(); i++) {
- View view = mShortcutsAndWidgets.getChildAt(i);
- CellLayoutLayoutParams lp = (CellLayoutLayoutParams) view.getLayoutParams();
- int seamOffset = lp.getCellX() >= mCountX / 2 && lp.canReorder ? 1 : 0;
- grid.markCells(lp.getCellX() + seamOffset, lp.getCellY(), lp.cellHSpan, lp.cellVSpan,
- true);
+
+
+ GridOccupancy createGridOccupancyWithSeam(GridOccupancy gridOccupancy) {
+ GridOccupancy grid = new GridOccupancy(getCountX(), getCountY());
+ for (int x = 0; x < getCountX(); x++) {
+ for (int y = 0; y < getCountY(); y++) {
+ int offset = x >= getCountX() / 2 ? 1 : 0;
+ if (x == getCountX() / 2) {
+ grid.cells[x][y] = true;
+ } else {
+ grid.cells[x][y] = gridOccupancy.cells[x - offset][y];
+ }
+ }
}
return grid;
}