summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/FolderInfo.java
diff options
context:
space:
mode:
authorTyson Miller <tmiller@cyngn.com>2015-11-10 08:59:15 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-01-28 17:00:28 -0800
commit7df0227f6a835641a3d41327a65845806ef070fb (patch)
tree3fcf92a1fba468facc675ad47accb08ec2f9f907 /src/com/android/launcher3/FolderInfo.java
parent84dfd2a560442953af78aa77dbd6c909aed63589 (diff)
downloadandroid_packages_apps_Trebuchet-7df0227f6a835641a3d41327a65845806ef070fb.tar.gz
android_packages_apps_Trebuchet-7df0227f6a835641a3d41327a65845806ef070fb.tar.bz2
android_packages_apps_Trebuchet-7df0227f6a835641a3d41327a65845806ef070fb.zip
Port Remote Folder from 12.1 to 13.
Change-Id: If8cf9d5f054e8948ead702883b79f28db26c4d8b
Diffstat (limited to 'src/com/android/launcher3/FolderInfo.java')
-rw-r--r--src/com/android/launcher3/FolderInfo.java63
1 files changed, 58 insertions, 5 deletions
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<ShortcutInfo> 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<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)