From 7df0227f6a835641a3d41327a65845806ef070fb Mon Sep 17 00:00:00 2001 From: Tyson Miller Date: Tue, 10 Nov 2015 08:59:15 -0800 Subject: Port Remote Folder from 12.1 to 13. Change-Id: If8cf9d5f054e8948ead702883b79f28db26c4d8b --- src/com/android/launcher3/FolderInfo.java | 63 ++++++++++++++++++++++++++++--- 1 file changed, 58 insertions(+), 5 deletions(-) (limited to 'src/com/android/launcher3/FolderInfo.java') diff --git a/src/com/android/launcher3/FolderInfo.java b/src/com/android/launcher3/FolderInfo.java index a1147408f..7969d627b 100644 --- a/src/com/android/launcher3/FolderInfo.java +++ b/src/com/android/launcher3/FolderInfo.java @@ -28,6 +28,7 @@ import java.util.Arrays; * Represents a folder containing shortcuts or apps. */ public class FolderInfo extends ItemInfo { + public static final int REMOTE_SUBTYPE = 1; public static final int NO_FLAGS = 0x00000000; @@ -50,6 +51,7 @@ public class FolderInfo extends ItemInfo { * Whether this folder has been opened */ boolean opened; + int subType; public int options; @@ -92,6 +94,54 @@ 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() { + if (contents.isEmpty()) return; + + 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 items) { + if (items.isEmpty()) return; + + 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++) { @@ -105,6 +155,7 @@ public class FolderInfo extends ItemInfo { values.put(LauncherSettings.Favorites.TITLE, title.toString()); values.put(LauncherSettings.Favorites.OPTIONS, options); values.put(LauncherSettings.Favorites.HIDDEN, hidden ? 1 : 0); + values.put(LauncherSettings.BaseLauncherColumns.SUBTYPE, subType); } void addListener(FolderListener listener) { @@ -130,15 +181,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 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) -- cgit v1.2.3