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>
This commit is contained in:
Sebastián Franco
2023-07-14 23:50:00 +00:00
committed by Automerger Merge Worker
@@ -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;
}
}