From a0b7e86299ed9baf278e0c1ed73f4a4f6a057322 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 5 Sep 2013 16:03:15 -0700 Subject: Removing any overlapping items with the hotseat. Change-Id: I9634939e6b1e8905d232d5a30608e2c56071d7bc --- src/com/android/launcher3/Launcher.java | 7 +++++ src/com/android/launcher3/LauncherModel.java | 38 +++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 8959e7e09..84d5a09f7 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -3824,6 +3824,13 @@ public class Launcher extends Activity }); } + public boolean isAllAppsButtonRank(int rank) { + if (mHotseat != null) { + return mHotseat.isAllAppsButtonRank(rank); + } + return false; + } + private boolean canRunNewAppsAnimation() { long diff = System.currentTimeMillis() - mDragController.getLastGestureUpTime(); return diff > (NEW_APPS_ANIMATION_INACTIVE_TIMEOUT_SECONDS * 1000); diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index bc0d1bcc1..1d264aa55 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -58,6 +58,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; import java.util.TreeMap; +import java.util.concurrent.atomic.AtomicBoolean; /** * Maintains in-memory state of the Launcher. It is expected that there should be only one @@ -169,6 +170,7 @@ public class LauncherModel extends BroadcastReceiver { boolean matchPackageNamesOnly); public void bindPackagesUpdated(ArrayList widgetsAndShortcuts); public void bindSearchablesChanged(); + public boolean isAllAppsButtonRank(int rank); public void onPageBoundSynchronously(int page); public void dumpLogsToLocalData(); } @@ -1513,7 +1515,8 @@ public class LauncherModel extends BroadcastReceiver { } // check & update map of what's occupied; used to discard overlapping/invalid items - private boolean checkItemPlacement(HashMap occupied, ItemInfo item) { + private boolean checkItemPlacement(HashMap occupied, ItemInfo item, + AtomicBoolean deleteOnItemOverlap) { LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); int countX = (int) grid.numColumns; @@ -1521,6 +1524,13 @@ public class LauncherModel extends BroadcastReceiver { long containerIndex = item.screenId; if (item.container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { + // Return early if we detect that an item is under the hotseat button + if (mCallbacks == null || + mCallbacks.get().isAllAppsButtonRank((int) item.screenId)) { + deleteOnItemOverlap.set(true); + return false; + } + if (occupied.containsKey(LauncherSettings.Favorites.CONTAINER_HOTSEAT)) { if (occupied.get(LauncherSettings.Favorites.CONTAINER_HOTSEAT) [(int) item.screenId][0] != null) { @@ -1658,6 +1668,7 @@ public class LauncherModel extends BroadcastReceiver { Intent intent; while (!mStopped && c.moveToNext()) { + AtomicBoolean deleteOnItemOverlap = new AtomicBoolean(false); try { int itemType = c.getInt(itemTypeIndex); @@ -1672,9 +1683,8 @@ public class LauncherModel extends BroadcastReceiver { if (cn != null && !isValidPackageComponent(manager, cn)) { if (!mAppsCanBeOnRemoveableStorage) { // Log the invalid package, and remove it from the db - Uri uri = LauncherSettings.Favorites.getContentUri(id, - false); - contentResolver.delete(uri, null, null); + Launcher.addDumpLog(TAG, "Invalid package removed: " + cn, true); + itemsToRemove.add(id); } else { // If apps can be on external storage, then we just // leave them for the user to remove (maybe add @@ -1728,7 +1738,11 @@ public class LauncherModel extends BroadcastReceiver { } } // check & update map of what's occupied - if (!checkItemPlacement(occupied, info)) { + deleteOnItemOverlap.set(false); + if (!checkItemPlacement(occupied, info, deleteOnItemOverlap)) { + if (deleteOnItemOverlap.get()) { + itemsToRemove.add(id); + } break; } @@ -1776,7 +1790,12 @@ public class LauncherModel extends BroadcastReceiver { } } // check & update map of what's occupied - if (!checkItemPlacement(occupied, folderInfo)) { + deleteOnItemOverlap.set(false); + if (!checkItemPlacement(occupied, folderInfo, + deleteOnItemOverlap)) { + if (deleteOnItemOverlap.get()) { + itemsToRemove.add(id); + } break; } @@ -1838,7 +1857,12 @@ public class LauncherModel extends BroadcastReceiver { } } // check & update map of what's occupied - if (!checkItemPlacement(occupied, appWidgetInfo)) { + deleteOnItemOverlap.set(false); + if (!checkItemPlacement(occupied, appWidgetInfo, + deleteOnItemOverlap)) { + if (deleteOnItemOverlap.get()) { + itemsToRemove.add(id); + } break; } String providerName = provider.provider.flattenToString(); -- cgit v1.2.3