summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
authorcretin45 <cretin45@gmail.com>2016-05-20 10:46:16 -0700
committerTom Powell <zifnab@zifnab06.net>2017-03-26 16:23:05 -0700
commit65b5178078ba85cd8b0d5c21bf94f0ddfda0bc59 (patch)
treec8d7b43b69065b9624c0ffa3e893dc314c37361b /src/com
parent72457c8d51d061c2d25184c99def37b96f764aa0 (diff)
downloadandroid_packages_apps_Trebuchet-65b5178078ba85cd8b0d5c21bf94f0ddfda0bc59.tar.gz
android_packages_apps_Trebuchet-65b5178078ba85cd8b0d5c21bf94f0ddfda0bc59.tar.bz2
android_packages_apps_Trebuchet-65b5178078ba85cd8b0d5c21bf94f0ddfda0bc59.zip
Move icons to fit within Dynamic grid upon resize.
Missed part of this patch during forward port: https://github.com/CyanogenMod/android_packages_apps_Trebuchet/commit/e25ab7bd9525d7a2c67eb8a6d8e88d54940dba58 Issue-id: CYNGNOS-2908 Change-Id: I49fb4e4a1b86d41be263d4f9b84020450f54d3f9
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/Launcher.java2
-rw-r--r--src/com/android/launcher3/LauncherModel.java55
2 files changed, 49 insertions, 8 deletions
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 9d3ff4c1a..84517bc13 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -1921,7 +1921,7 @@ public class Launcher extends Activity
if (gridSize != size.getValue() || customValuesChanged) {
SettingsProvider.putInt(this,
SettingsProvider.SETTINGS_UI_DYNAMIC_GRID_SIZE, size.getValue());
- reloadLauncher(false, true);
+ reloadLauncher(true, true);
}
mOverviewSettingsPanel.notifyDataSetInvalidated();
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index a815f1bbf..03e52d3ef 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1768,13 +1768,54 @@ public class LauncherModel extends BroadcastReceiver
// Check if any workspace icons overlap with each other
for (int x = item.cellX; x < (item.cellX+item.spanX); x++) {
for (int y = item.cellY; y < (item.cellY+item.spanY); y++) {
- if (!shouldResizeAndUpdateDB && screens[x][y] != null) {
- Log.e(TAG, "Error loading shortcut " + item
- + " into cell (" + containerIndex + "-" + item.screenId + ":"
- + x + "," + y
- + ") occupied by "
- + screens[x][y]);
- return false;
+ if (screens[x][y] != null) {
+ if (!shouldResizeAndUpdateDB) {
+ Log.e(TAG, "Error loading shortcut " + item
+ + " into cell (" + containerIndex + "-" + item.screenId + ":"
+ + x + "," + y
+ + ") occupied by "
+ + screens[x][y]);
+ return false;
+ }
+ ItemInfo occupiedItem = screens[x][y];
+ // If an item is overlapping another because one of them
+ // was moved due to the size of the grid changing,
+ // move the current item to a free spot past this one.
+ if (occupiedItem.wasMovedDueToReducedSpace
+ || item.wasMovedDueToReducedSpace) {
+ // overlapping icon exists here
+ // we must find a free space.
+ boolean freeFound = false;
+ int nextX = 0;
+ int nextY = 0;
+ while (!freeFound) {
+ if (screens[nextX][nextY] == null) {
+ item.cellX = nextX;
+ item.cellY = nextY;
+ freeFound = true;
+ } else {
+ if (nextX + item.spanX == countX) {
+ if (nextY + item.spanY == countY) {
+ // If we've reached the bottom of the page and are still
+ // searching, add a new page to place this item.
+ item.screenId += 1;
+ nextY = 0;
+ nextX = 0;
+ if (!occupied.containsKey(item.screenId)) {
+ ItemInfo[][] items = new ItemInfo[countX][countY];
+ occupied.put(item.screenId, items);
+ }
+ screens = occupied.get(item.screenId);
+ } else {
+ nextX = 0;
+ nextY++;
+ }
+ } else {
+ nextX++;
+ }
+ }
+ }
+ }
}
}
}