mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-27 15:26:58 +00:00
Merge "Fixes bug where app suggestions incorrectly calculate available space when bottom row is full" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
97b0c90ae0
@@ -1718,7 +1718,7 @@ public class CellLayout extends ViewGroup {
|
||||
|
||||
// First we determine if things have moved enough to cause a different layout
|
||||
ItemConfiguration swapSolution = findReorderSolution(pixelXY[0], pixelXY[1], spanX, spanY,
|
||||
spanX, spanY, direction, dragView, true, new ItemConfiguration());
|
||||
spanX, spanY, direction, dragView, true);
|
||||
|
||||
setUseTempCoords(true);
|
||||
if (swapSolution != null && swapSolution.isSolution) {
|
||||
@@ -1747,13 +1747,13 @@ public class CellLayout extends ViewGroup {
|
||||
}
|
||||
|
||||
protected ItemConfiguration findReorderSolution(int pixelX, int pixelY, int minSpanX,
|
||||
int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
|
||||
ItemConfiguration solution) {
|
||||
int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX) {
|
||||
ItemConfiguration configuration = new ItemConfiguration();
|
||||
copyCurrentStateToSolution(configuration);
|
||||
ReorderParameters parameters = new ReorderParameters(pixelX, pixelY, spanX, spanY, minSpanX,
|
||||
minSpanY, dragView, configuration);
|
||||
return createReorderAlgorithm().findReorderSolution(parameters, decX);
|
||||
int[] directionVector = direction != null ? direction : mDirectionVector;
|
||||
return createReorderAlgorithm().findReorderSolution(parameters, directionVector, decX);
|
||||
}
|
||||
|
||||
public void copyCurrentStateToSolution(ItemConfiguration solution) {
|
||||
@@ -2077,7 +2077,7 @@ public class CellLayout extends ViewGroup {
|
||||
cellToPoint(cellX, cellY, cellPoint);
|
||||
if (findReorderSolution(cellPoint[0], cellPoint[1], itemInfo.minSpanX,
|
||||
itemInfo.minSpanY, itemInfo.spanX, itemInfo.spanY, mDirectionVector, null,
|
||||
true, new ItemConfiguration()).isSolution) {
|
||||
true).isSolution) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2092,9 +2092,18 @@ public class CellLayout extends ViewGroup {
|
||||
int[] cellPoint = new int[2];
|
||||
int[] directionVector = new int[]{0, -1};
|
||||
cellToPoint(0, mCountY, cellPoint);
|
||||
ItemConfiguration configuration = new ItemConfiguration();
|
||||
if (findReorderSolution(cellPoint[0], cellPoint[1], mCountX, 1, mCountX, 1,
|
||||
directionVector, null, false, configuration).isSolution) {
|
||||
ItemConfiguration configuration = findReorderSolution(
|
||||
cellPoint[0] /* pixelX */,
|
||||
cellPoint[1] /* pixelY */,
|
||||
mCountX /* minSpanX */,
|
||||
1 /* minSpanY */,
|
||||
mCountX /* spanX */,
|
||||
1 /* spanY */,
|
||||
directionVector /* direction */,
|
||||
null /* dragView */,
|
||||
false /* decX */
|
||||
);
|
||||
if (configuration.isSolution) {
|
||||
if (commitConfig) {
|
||||
copySolutionToTempState(configuration, null);
|
||||
commitTempPlacement(null);
|
||||
|
||||
@@ -49,21 +49,37 @@ public class ReorderAlgorithm {
|
||||
* When changing the size of the widget this method will try first subtracting -1 in the x
|
||||
* dimension and then subtracting -1 in the y dimension until finding a possible solution or
|
||||
* until it no longer can reduce the span.
|
||||
*
|
||||
* @param decX whether it will decrease the horizontal or vertical span if it can't find a
|
||||
* solution for the current span.
|
||||
* @return the same solution variable
|
||||
*/
|
||||
public ItemConfiguration findReorderSolution(ReorderParameters reorderParameters,
|
||||
boolean decX) {
|
||||
return findReorderSolution(reorderParameters, mCellLayout.mDirectionVector, decX);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method differs from closestEmptySpaceReorder and dropInPlaceSolution because this method
|
||||
* will move items around and will change the shape of the item if possible to try to find a
|
||||
* solution.
|
||||
* <p>
|
||||
* When changing the size of the widget this method will try first subtracting -1 in the x
|
||||
* dimension and then subtracting -1 in the y dimension until finding a possible solution or
|
||||
* until it no longer can reduce the span.
|
||||
* @param direction Direction to attempt to push items if needed
|
||||
* @param decX whether it will decrease the horizontal or vertical span if it can't find a
|
||||
* solution for the current span.
|
||||
* @return the same solution variable
|
||||
*/
|
||||
public ItemConfiguration findReorderSolution(ReorderParameters reorderParameters,
|
||||
int[] direction, boolean decX) {
|
||||
return findReorderSolutionRecursive(reorderParameters.getPixelX(),
|
||||
reorderParameters.getPixelY(), reorderParameters.getMinSpanX(),
|
||||
reorderParameters.getMinSpanY(), reorderParameters.getSpanX(),
|
||||
reorderParameters.getSpanY(), mCellLayout.mDirectionVector,
|
||||
reorderParameters.getSpanY(), direction,
|
||||
reorderParameters.getDragView(), decX, reorderParameters.getSolution());
|
||||
}
|
||||
|
||||
|
||||
private ItemConfiguration findReorderSolutionRecursive(int pixelX, int pixelY, int minSpanX,
|
||||
int minSpanY, int spanX, int spanY, int[] direction, View dragView, boolean decX,
|
||||
ItemConfiguration solution) {
|
||||
|
||||
Reference in New Issue
Block a user