summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Franco <fransebas@google.com>2023-07-12 12:46:53 -0700
committerSebastián Franco <fransebas@google.com>2023-07-13 20:45:28 +0000
commit52d9d9780fb5a83302dd6fb3d875635a2ee57e1c (patch)
treec49b4d0687a0bdd66c8aa700495f6c7cb2ecffee
parentaa6612d3731a3e98f716747b0ede473e3bbca161 (diff)
downloadLauncher3-52d9d9780fb5a83302dd6fb3d875635a2ee57e1c.tar.gz
Creating a correctly populated mOccupied grid when reordering on foldables
On ag/21680045 I copy the previous mOccupied but the right thing to do is to create a new one with all the views information. Some test stoped running inadvertently that's why we didn't catch this issue. There is a separate cl with the test to ensure we can catch it later on. Fix: 289584301 Test: ReorderWidgets Change-Id: I27b5a6e38a556d1c73ff8fbbdd552da6045e5b64 (cherry picked from commit 1c5514b56619d0ae76948689bb51479f131d0e30)
-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;
}
}