- This CL has no UI but provides the necessary backing for one. - Adds new item type: ITEM_TYPE_DEEP_SHORTCUT, to distinguish from ITEM_TYPE_SHORTCUT. We can reconsider these names. - Adds ShortcutCache, using LruCache for up to 30 dynamic shortcuts (pinned shortcuts are always cached in a HashMap). - DeepShortcutManager queries for shortcuts and other things like pin them. In a future CL it will use the cache, but for now it simply makes an RPC for all queries. - LauncherModel maintains counts for pinned shortcuts, pinning and unpinning when counts reach 1 or 0, respectively. - LauncherModel maintains a map of components to lists of shortcut ids, which Launcher gets a copy of after it is changed in the background. This will allow us to know how many shortcuts an app has immediately, and query for details as the UI is animating. Change-Id: Ic526f374dd10d72a261bae67f07f098fca8d8bca
31 lines
938 B
Java
31 lines
938 B
Java
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());
|
|
}
|
|
}
|