diff options
Diffstat (limited to 'src/com/android/launcher3/FolderInfo.java')
-rw-r--r-- | src/com/android/launcher3/FolderInfo.java | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java index 104bd6cc1..bed1a5d47 100644 --- a/src/com/android/launcher3/FolderInfo.java +++ b/src/com/android/launcher3/FolderInfo.java @@ -28,11 +28,13 @@ import java.util.Arrays; * Represents a folder containing shortcuts or apps. */ public class FolderInfo extends ItemInfo { + public static final int REMOTE_SUBTYPE = 1; /** * Whether this folder has been opened */ boolean opened; + int subType; /** * The apps and shortcuts and hidden status @@ -73,6 +75,50 @@ public class FolderInfo extends ItemInfo { itemsChanged(); } + /** + * Remove all apps and shortcuts. Does not change the DB unless + * LauncherModel.deleteFolderContentsFromDatabase(Context, FolderInfo) is called first. + */ + public void removeAll() { + contents.clear(); + for (int i = 0; i < listeners.size(); i++) { + listeners.get(i).onRemoveAll(); + } + itemsChanged(); + } + + /** + * Remove all supplied shortcuts. Does not change the DB unless + * LauncherModel.deleteFolderContentsFromDatabase(Context, FolderInfo) is called first. + * @param items the shortcuts to remove. + */ + public void removeAll(ArrayList<ShortcutInfo> items) { + contents.removeAll(items); + for (int i = 0; i < listeners.size(); i++) { + listeners.get(i).onRemoveAll(items); + } + itemsChanged(); + } + + /** + * @return true if this info represents a remote folder, false otherwise + */ + public boolean isRemote() { + return (subType & REMOTE_SUBTYPE) != 0; + } + + /** + * Set flag indicating whether this folder is remote + * @param remote true if folder is remote, false otherwise + */ + public void setRemote(final boolean remote) { + if (remote) { + subType |= REMOTE_SUBTYPE; + } else { + subType &= ~REMOTE_SUBTYPE; + } + } + public void setTitle(CharSequence title) { this.title = title; for (int i = 0; i < listeners.size(); i++) { @@ -85,6 +131,7 @@ public class FolderInfo extends ItemInfo { super.onAddToDatabase(context, values); values.put(LauncherSettings.Favorites.TITLE, title.toString()); values.put(LauncherSettings.Favorites.HIDDEN, hidden ? 1 : 0); + values.put(LauncherSettings.BaseLauncherColumns.SUBTYPE, subType); } void addListener(FolderListener listener) { @@ -110,15 +157,17 @@ public class FolderInfo extends ItemInfo { } interface FolderListener { - public void onAdd(ShortcutInfo item); - public void onRemove(ShortcutInfo item); - public void onTitleChanged(CharSequence title); - public void onItemsChanged(); + void onAdd(ShortcutInfo item); + void onRemove(ShortcutInfo item); + void onRemoveAll(); + void onRemoveAll(ArrayList<ShortcutInfo> items); + void onTitleChanged(CharSequence title); + void onItemsChanged(); } @Override public String toString() { - return "FolderInfo(id=" + this.id + " type=" + this.itemType + return "FolderInfo(id=" + this.id + " type=" + this.itemType + " subtype=" + this.subType + " container=" + this.container + " screen=" + screenId + " cellX=" + cellX + " cellY=" + cellY + " spanX=" + spanX + " spanY=" + spanY + " dropPos=" + Arrays.toString(dropPos) + ")"; |