summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/shortcuts/ShortcutKey.java
blob: c9d66eb7cecabde650ef76c25794fa5e069350c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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());
    }
}