summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/shortcuts/ShortcutKey.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/shortcuts/ShortcutKey.java')
-rw-r--r--src/com/android/launcher3/shortcuts/ShortcutKey.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/com/android/launcher3/shortcuts/ShortcutKey.java b/src/com/android/launcher3/shortcuts/ShortcutKey.java
new file mode 100644
index 000000000..c9d66eb7c
--- /dev/null
+++ b/src/com/android/launcher3/shortcuts/ShortcutKey.java
@@ -0,0 +1,30 @@
+package com.android.launcher3.shortcuts;
+
+import android.content.ComponentName;
+
+import com.android.launcher3.LauncherAppState;
+import com.android.launcher3.compat.UserHandleCompat;
+import com.android.launcher3.util.ComponentKey;
+
+/**
+ * A key that uniquely identifies a shortcut using its package, id, and user handle.
+ */
+public class ShortcutKey extends ComponentKey {
+ final String id;
+
+ public ShortcutKey(String packageName, UserHandleCompat user, String id) {
+ // Use the id as the class name.
+ super(new ComponentName(packageName, id), user);
+ this.id = id;
+ }
+
+ public static ShortcutKey fromInfo(ShortcutInfoCompat shortcutInfo) {
+ return new ShortcutKey(shortcutInfo.getPackage(), shortcutInfo.getUserHandle(),
+ shortcutInfo.getId());
+ }
+
+ @Override
+ public String toString() {
+ return flattenToString(LauncherAppState.getInstance().getContext());
+ }
+}