diff options
Diffstat (limited to 'src/com/android/launcher3/touch/ItemClickHandler.java')
-rw-r--r-- | src/com/android/launcher3/touch/ItemClickHandler.java | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/com/android/launcher3/touch/ItemClickHandler.java b/src/com/android/launcher3/touch/ItemClickHandler.java index 52fef9f7d..363909002 100644 --- a/src/com/android/launcher3/touch/ItemClickHandler.java +++ b/src/com/android/launcher3/touch/ItemClickHandler.java @@ -22,6 +22,8 @@ import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SAFEMODE; import static com.android.launcher3.ItemInfoWithIcon.FLAG_DISABLED_SUSPENDED; import static com.android.launcher3.Launcher.REQUEST_BIND_PENDING_APPWIDGET; import static com.android.launcher3.Launcher.REQUEST_RECONFIGURE_APPWIDGET; +import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_ALL_APPS; +import static com.android.launcher3.model.AppLaunchTracker.CONTAINER_DEFAULT; import android.app.AlertDialog; import android.content.Intent; @@ -48,6 +50,8 @@ import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.widget.PendingAppWidgetHostView; import com.android.launcher3.widget.WidgetAddFlowHandler; +import androidx.annotation.Nullable; + /** * Class for handling clicks on workspace and all-apps items */ @@ -56,9 +60,13 @@ public class ItemClickHandler { /** * Instance used for click handling on items */ - public static final OnClickListener INSTANCE = ItemClickHandler::onClick; + public static final OnClickListener INSTANCE = getInstance(null); + + public static final OnClickListener getInstance(String sourceContainer) { + return v -> onClick(v, sourceContainer); + } - private static void onClick(View v) { + private static void onClick(View v, String sourceContainer) { // Make sure that rogue clicks don't get through while allapps is launching, or after the // view has detached (it's possible for this to happen if the view is removed mid touch). if (v.getWindowToken() == null) { @@ -72,13 +80,14 @@ public class ItemClickHandler { Object tag = v.getTag(); if (tag instanceof ShortcutInfo) { - onClickAppShortcut(v, (ShortcutInfo) tag, launcher); + onClickAppShortcut(v, (ShortcutInfo) tag, launcher, sourceContainer); } else if (tag instanceof FolderInfo) { if (v instanceof FolderIcon) { onClickFolderIcon(v); } } else if (tag instanceof AppInfo) { - startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher); + startAppShortcutOrInfoActivity(v, (AppInfo) tag, launcher, + sourceContainer == null ? CONTAINER_ALL_APPS: sourceContainer); } else if (tag instanceof LauncherAppWidgetInfo) { if (v instanceof PendingAppWidgetHostView) { onClickPendingWidget((PendingAppWidgetHostView) v, launcher); @@ -154,7 +163,7 @@ public class ItemClickHandler { private static void startMarketIntentForPackage(View v, Launcher launcher, String packageName) { ItemInfo item = (ItemInfo) v.getTag(); Intent intent = new PackageManagerHelper(launcher).getMarketIntent(packageName); - launcher.startActivitySafely(v, intent, item); + launcher.startActivitySafely(v, intent, item, null); } /** @@ -162,7 +171,8 @@ public class ItemClickHandler { * * @param v The view that was clicked. Must be a tagged with a {@link ShortcutInfo}. */ - public static void onClickAppShortcut(View v, ShortcutInfo shortcut, Launcher launcher) { + public static void onClickAppShortcut(View v, ShortcutInfo shortcut, Launcher launcher, + @Nullable String sourceContainer) { if (shortcut.isDisabled()) { final int disabledFlags = shortcut.runtimeStatusFlags & ShortcutInfo.FLAG_DISABLED_MASK; if ((disabledFlags & @@ -201,10 +211,11 @@ public class ItemClickHandler { } // Start activities - startAppShortcutOrInfoActivity(v, shortcut, launcher); + startAppShortcutOrInfoActivity(v, shortcut, launcher, sourceContainer); } - private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher) { + private static void startAppShortcutOrInfoActivity(View v, ItemInfo item, Launcher launcher, + @Nullable String sourceContainer) { Intent intent; if (item instanceof PromiseAppInfo) { PromiseAppInfo promiseAppInfo = (PromiseAppInfo) item; @@ -227,6 +238,6 @@ public class ItemClickHandler { intent.setPackage(null); } } - launcher.startActivitySafely(v, intent, item); + launcher.startActivitySafely(v, intent, item, sourceContainer); } } |