• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.launcher3.shortcuts;
2 
3 import android.content.ComponentName;
4 import android.content.Intent;
5 import android.os.UserHandle;
6 
7 import com.android.launcher3.ItemInfo;
8 import com.android.launcher3.util.ComponentKey;
9 
10 /**
11  * A key that uniquely identifies a shortcut using its package, id, and user handle.
12  */
13 public class ShortcutKey extends ComponentKey {
14 
ShortcutKey(String packageName, UserHandle user, String id)15     public ShortcutKey(String packageName, UserHandle user, String id) {
16         // Use the id as the class name.
17         super(new ComponentName(packageName, id), user);
18     }
19 
getId()20     public String getId() {
21         return componentName.getClassName();
22     }
23 
fromInfo(ShortcutInfoCompat shortcutInfo)24     public static ShortcutKey fromInfo(ShortcutInfoCompat shortcutInfo) {
25         return new ShortcutKey(shortcutInfo.getPackage(), shortcutInfo.getUserHandle(),
26                 shortcutInfo.getId());
27     }
28 
fromIntent(Intent intent, UserHandle user)29     public static ShortcutKey fromIntent(Intent intent, UserHandle user) {
30         String shortcutId = intent.getStringExtra(
31                 ShortcutInfoCompat.EXTRA_SHORTCUT_ID);
32         return new ShortcutKey(intent.getPackage(), user, shortcutId);
33     }
34 
fromItemInfo(ItemInfo info)35     public static ShortcutKey fromItemInfo(ItemInfo info) {
36         return fromIntent(info.getIntent(), info.user);
37     }
38 }
39