Merge "Correctly add seam to MultipageCellLayout when resizing widget" into tm-qpr-dev am: ee24d3f9f4
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/21529646 Change-Id: I8560e17377ea4ae6ce9d32c317a5e8643b77fe5f Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -38,6 +38,8 @@ public class MultipageCellLayout extends CellLayout {
|
|||||||
|
|
||||||
private View mSeam;
|
private View mSeam;
|
||||||
|
|
||||||
|
private boolean mSeamWasAdded = false;
|
||||||
|
|
||||||
public MultipageCellLayout(Context context) {
|
public MultipageCellLayout(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
}
|
}
|
||||||
@@ -64,45 +66,72 @@ public class MultipageCellLayout extends CellLayout {
|
|||||||
setGridSize(mCountX, mCountY);
|
setGridSize(mCountX, mCountY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
boolean createAreaForResize(int cellX, int cellY, int spanX, int spanY, View dragView,
|
||||||
|
int[] direction, boolean commit) {
|
||||||
|
return simulateSeam(
|
||||||
|
() -> super.createAreaForResize(cellX, cellY, spanX, spanY, dragView, direction,
|
||||||
|
commit));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void regionToCenterPoint(int cellX, int cellY, int spanX, int spanY, int[] result) {
|
||||||
|
simulateSeam(() -> {
|
||||||
|
super.regionToCenterPoint(cellX, cellY, spanX, spanY, result);
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX, int minSpanY,
|
ItemConfiguration closestEmptySpaceReorder(int pixelX, int pixelY, int minSpanX, int minSpanY,
|
||||||
int spanX, int spanY) {
|
int spanX, int spanY) {
|
||||||
return simulateSeam(
|
return removeSeamFromSolution(simulateSeam(
|
||||||
() -> super.closestEmptySpaceReorder(pixelX, pixelY, minSpanX, minSpanY, spanX,
|
() -> super.closestEmptySpaceReorder(pixelX, pixelY, minSpanX, minSpanY, spanX,
|
||||||
spanY));
|
spanY)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ItemConfiguration findReorderSolution(int pixelX, int pixelY, int minSpanX,
|
protected ItemConfiguration findReorderSolution(int pixelX, int pixelY, int minSpanX,
|
||||||
int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
|
int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
|
||||||
ItemConfiguration solution) {
|
ItemConfiguration solution) {
|
||||||
return simulateSeam(
|
return removeSeamFromSolution(simulateSeam(
|
||||||
() -> super.findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY,
|
() -> super.findReorderSolution(pixelX, pixelY, minSpanX, minSpanY, spanX, spanY,
|
||||||
direction, dragView, decX, solution));
|
direction, dragView, decX, solution)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemConfiguration dropInPlaceSolution(int pixelX, int pixelY, int spanX, int spanY,
|
public ItemConfiguration dropInPlaceSolution(int pixelX, int pixelY, int spanX, int spanY,
|
||||||
View dragView) {
|
View dragView) {
|
||||||
return simulateSeam(
|
return removeSeamFromSolution(simulateSeam(
|
||||||
() -> super.dropInPlaceSolution(pixelX, pixelY, spanX, spanY, dragView));
|
() -> super.dropInPlaceSolution(pixelX, pixelY, spanX, spanY, dragView)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ItemConfiguration simulateSeam(Supplier<ItemConfiguration> f) {
|
void addSeam() {
|
||||||
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(mCountX / 2, 0, 1, mCountY);
|
CellLayoutLayoutParams lp = new CellLayoutLayoutParams(mCountX / 2, 0, 1, mCountY);
|
||||||
|
mSeamWasAdded = true;
|
||||||
lp.canReorder = false;
|
lp.canReorder = false;
|
||||||
mCountX++;
|
mCountX++;
|
||||||
mShortcutsAndWidgets.addViewInLayout(mSeam, lp);
|
mShortcutsAndWidgets.addViewInLayout(mSeam, lp);
|
||||||
GridOccupancy auxGrid = mOccupied;
|
|
||||||
mOccupied = createGridOccupancy();
|
mOccupied = createGridOccupancy();
|
||||||
mTmpOccupied = new GridOccupancy(mCountX, mCountY);
|
mTmpOccupied = new GridOccupancy(mCountX, mCountY);
|
||||||
|
}
|
||||||
|
|
||||||
ItemConfiguration res = removeSeamFromSolution(f.get());
|
void removeSeam() {
|
||||||
|
|
||||||
mCountX--;
|
mCountX--;
|
||||||
mShortcutsAndWidgets.removeViewInLayout(mSeam);
|
mShortcutsAndWidgets.removeViewInLayout(mSeam);
|
||||||
mOccupied = auxGrid;
|
|
||||||
mTmpOccupied = new GridOccupancy(mCountX, mCountY);
|
mTmpOccupied = new GridOccupancy(mCountX, mCountY);
|
||||||
|
mSeamWasAdded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <T> T simulateSeam(Supplier<T> f) {
|
||||||
|
if (mSeamWasAdded) {
|
||||||
|
return f.get();
|
||||||
|
}
|
||||||
|
GridOccupancy auxGrid = mOccupied;
|
||||||
|
addSeam();
|
||||||
|
T res = f.get();
|
||||||
|
removeSeam();
|
||||||
|
mOccupied = auxGrid;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user