summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2015-09-09 13:50:40 -0700
committerTony Wickham <twickham@google.com>2015-09-09 17:08:50 -0700
commit869306140d3bb8782040ed65d3ae0ba498c2de6c (patch)
tree1bf6de517ed0623e60b77f84344a00e4410f6053 /src/com/android/launcher3/CellLayout.java
parent57a0e98a7d82b16b4f80798f530ce3cec53c79c2 (diff)
downloadandroid_packages_apps_Trebuchet-869306140d3bb8782040ed65d3ae0ba498c2de6c.tar.gz
android_packages_apps_Trebuchet-869306140d3bb8782040ed65d3ae0ba498c2de6c.tar.bz2
android_packages_apps_Trebuchet-869306140d3bb8782040ed65d3ae0ba498c2de6c.zip
When placing a widget, go to a page with enough space.
The search for this page starts at the current one and continues to the right (on LTR) until a page is found that can accomodate the widget, taking possible resizing and reordering into account. Bug: 11338870 Change-Id: I2e9a310eb8f74024dca9150f55a525e1309c2f07
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r--src/com/android/launcher3/CellLayout.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java
index 653ee7ec6..700bf9ee6 100644
--- a/src/com/android/launcher3/CellLayout.java
+++ b/src/com/android/launcher3/CellLayout.java
@@ -2966,6 +2966,26 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler {
return Utilities.findVacantCell(outXY, spanX, spanY, mCountX, mCountY, mOccupied);
}
+ /**
+ * Returns whether an item can be placed in this CellLayout (after rearranging and/or resizing
+ * if necessary).
+ */
+ public boolean hasReorderSolution(ItemInfo itemInfo) {
+ int[] cellPoint = new int[2];
+ // Check for a solution starting at every cell.
+ for (int cellX = 0; cellX < getCountX(); cellX++) {
+ for (int cellY = 0; cellY < getCountY(); cellY++) {
+ cellToPoint(cellX, cellY, cellPoint);
+ if (findReorderSolution(cellPoint[0], cellPoint[1], itemInfo.minSpanX,
+ itemInfo.minSpanY, itemInfo.spanX, itemInfo.spanY, mDirectionVector, null,
+ true, new ItemConfiguration()).isSolution) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
public boolean isRegionVacant(int x, int y, int spanX, int spanY) {
int x2 = x + spanX - 1;
int y2 = y + spanY - 1;