Loading src/com/android/launcher3/shortcuts/DeepShortcutManager.java +5 −3 Original line number Diff line number Diff line Loading @@ -81,11 +81,13 @@ public class DeepShortcutManager { } /** * Gets all the shortcuts associated with the given package and user. * Gets all the manifest and dynamic shortcuts associated with the given package and user, * to be displayed in the shortcuts container on long press. */ public List<ShortcutInfoCompat> queryForAllAppShortcuts(ComponentName activity, public List<ShortcutInfoCompat> queryForShortcutsContainer(ComponentName activity, List<String> ids, UserHandleCompat user) { return query(FLAG_GET_ALL, activity.getPackageName(), activity, ids, user); return query(FLAG_MATCH_MANIFEST | FLAG_MATCH_DYNAMIC, activity.getPackageName(), activity, ids, user); } /** Loading src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java +27 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.UiThreadCircularReveal; import java.util.Collections; import java.util.Comparator; import java.util.List; /** Loading Loading @@ -65,6 +67,26 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC private boolean mIsLeftAligned; private boolean mIsAboveIcon; /** * Sorts shortcuts in rank order, with manifest shortcuts coming before dynamic shortcuts. */ private static final Comparator<ShortcutInfoCompat> sShortcutsComparator = new Comparator<ShortcutInfoCompat>() { @Override public int compare(ShortcutInfoCompat a, ShortcutInfoCompat b) { if (a.isDeclaredInManifest() && !b.isDeclaredInManifest()) { return -1; } if (!a.isDeclaredInManifest() && b.isDeclaredInManifest()) { return 1; } return Integer.compare(a.getRank(), b.getRank()); } }; private static final Comparator<ShortcutInfoCompat> sShortcutsComparatorReversed = Collections.reverseOrder(sShortcutsComparator); public DeepShortcutsContainer(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mLauncher = (Launcher) context; Loading Loading @@ -109,7 +131,11 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC @Override public void run() { final List<ShortcutInfoCompat> shortcuts = mDeepShortcutsManager .queryForAllAppShortcuts(activity, ids, user); .queryForShortcutsContainer(activity, ids, user); // We want the lowest rank to be closest to the user's finger. final Comparator<ShortcutInfoCompat> shortcutsComparator = mIsAboveIcon ? sShortcutsComparatorReversed : sShortcutsComparator; Collections.sort(shortcuts, shortcutsComparator); for (int i = 0; i < shortcuts.size(); i++) { final ShortcutInfoCompat shortcut = shortcuts.get(i); final ShortcutInfo launcherShortcutInfo = ShortcutInfo Loading src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java +8 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,14 @@ public class ShortcutInfoCompat { return mShortcutInfo.isPinned(); } public boolean isDeclaredInManifest() { return mShortcutInfo.isDeclaredInManifest(); } public int getRank() { return mShortcutInfo.getRank(); } @Override public String toString() { return mShortcutInfo.toString(); Loading Loading
src/com/android/launcher3/shortcuts/DeepShortcutManager.java +5 −3 Original line number Diff line number Diff line Loading @@ -81,11 +81,13 @@ public class DeepShortcutManager { } /** * Gets all the shortcuts associated with the given package and user. * Gets all the manifest and dynamic shortcuts associated with the given package and user, * to be displayed in the shortcuts container on long press. */ public List<ShortcutInfoCompat> queryForAllAppShortcuts(ComponentName activity, public List<ShortcutInfoCompat> queryForShortcutsContainer(ComponentName activity, List<String> ids, UserHandleCompat user) { return query(FLAG_GET_ALL, activity.getPackageName(), activity, ids, user); return query(FLAG_MATCH_MANIFEST | FLAG_MATCH_DYNAMIC, activity.getPackageName(), activity, ids, user); } /** Loading
src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java +27 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,8 @@ import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import com.android.launcher3.util.UiThreadCircularReveal; import java.util.Collections; import java.util.Comparator; import java.util.List; /** Loading Loading @@ -65,6 +67,26 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC private boolean mIsLeftAligned; private boolean mIsAboveIcon; /** * Sorts shortcuts in rank order, with manifest shortcuts coming before dynamic shortcuts. */ private static final Comparator<ShortcutInfoCompat> sShortcutsComparator = new Comparator<ShortcutInfoCompat>() { @Override public int compare(ShortcutInfoCompat a, ShortcutInfoCompat b) { if (a.isDeclaredInManifest() && !b.isDeclaredInManifest()) { return -1; } if (!a.isDeclaredInManifest() && b.isDeclaredInManifest()) { return 1; } return Integer.compare(a.getRank(), b.getRank()); } }; private static final Comparator<ShortcutInfoCompat> sShortcutsComparatorReversed = Collections.reverseOrder(sShortcutsComparator); public DeepShortcutsContainer(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mLauncher = (Launcher) context; Loading Loading @@ -109,7 +131,11 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC @Override public void run() { final List<ShortcutInfoCompat> shortcuts = mDeepShortcutsManager .queryForAllAppShortcuts(activity, ids, user); .queryForShortcutsContainer(activity, ids, user); // We want the lowest rank to be closest to the user's finger. final Comparator<ShortcutInfoCompat> shortcutsComparator = mIsAboveIcon ? sShortcutsComparatorReversed : sShortcutsComparator; Collections.sort(shortcuts, shortcutsComparator); for (int i = 0; i < shortcuts.size(); i++) { final ShortcutInfoCompat shortcut = shortcuts.get(i); final ShortcutInfo launcherShortcutInfo = ShortcutInfo Loading
src/com/android/launcher3/shortcuts/ShortcutInfoCompat.java +8 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,14 @@ public class ShortcutInfoCompat { return mShortcutInfo.isPinned(); } public boolean isDeclaredInManifest() { return mShortcutInfo.isDeclaredInManifest(); } public int getRank() { return mShortcutInfo.getRank(); } @Override public String toString() { return mShortcutInfo.toString(); Loading