From 3e9b3763bab46185e558c3e44d30e41552491aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Sun, 1 Mar 2026 13:37:36 -0500 Subject: [PATCH 1/3] Store links > tries to open overlay (no working) --- .../mtransit/android/commons/LinkUtils.java | 35 ++++++++----------- .../mtransit/android/commons/StoreUtils.java | 18 ++++++++-- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/mtransit/android/commons/LinkUtils.java b/src/main/java/org/mtransit/android/commons/LinkUtils.java index 210b2466..0075b427 100644 --- a/src/main/java/org/mtransit/android/commons/LinkUtils.java +++ b/src/main/java/org/mtransit/android/commons/LinkUtils.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Bundle; import android.text.TextUtils; import androidx.annotation.NonNull; @@ -22,27 +23,23 @@ public String getLogTag() { @Nullable public static final String NO_LABEL = null; + public static boolean open(@NonNull Context context, @Nullable Uri uri, @Nullable String label, @Nullable int... intentFlags) { + return open(context, uri, label, null, intentFlags); // pkg == null (default) + } + public static boolean open(@NonNull Context context, @Nullable Uri uri, @Nullable String label, @Nullable String pkg, @Nullable int... intentFlags) { - if (uri == null) { - return false; - } - Intent intent = new Intent(Intent.ACTION_VIEW, uri); + return open(context, uri, label, pkg, null, intentFlags); + } + + public static boolean open(@NonNull Context context, @Nullable Uri uri, @Nullable String label, @Nullable String pkg, @Nullable Bundle extra, @Nullable int... intentFlags) { + if (uri == null) return false; + final Intent intent = new Intent(Intent.ACTION_VIEW, uri); if (pkg != null) { intent.setPackage(pkg); } - if (intentFlags != null) { - for (int intentFlag : intentFlags) { - intent.addFlags(intentFlag); - } + if (extra != null) { + intent.putExtras(extra); } - return open(context, intent, label); - } - - public static boolean open(@NonNull Context context, @Nullable Uri uri, @Nullable String label, @Nullable int... intentFlags) { - if (uri == null) { - return false; - } - Intent intent = new Intent(Intent.ACTION_VIEW, uri); if (intentFlags != null) { for (int intentFlag : intentFlags) { intent.addFlags(intentFlag); @@ -52,11 +49,9 @@ public static boolean open(@NonNull Context context, @Nullable Uri uri, @Nullabl } public static boolean open(@NonNull Context context, @Nullable Intent intent, @Nullable String label) { - if (intent == null) { - return false; - } + if (intent == null) return false; try { - context.startActivity(intent); // required starting API Level 30+ (else would required android.permission.QUERY_ALL_PACKAGES permission) + context.startActivity(intent); // required starting API Level 30+ (else would require 'android.permission.QUERY_ALL_PACKAGES' permission) } catch (ActivityNotFoundException e) { ToastUtils.makeTextAndShowCentered(context, context.getString(R.string.opening_failed_and_uri, intent.getData())); return false; diff --git a/src/main/java/org/mtransit/android/commons/StoreUtils.java b/src/main/java/org/mtransit/android/commons/StoreUtils.java index 6c771adc..fab3b3ca 100644 --- a/src/main/java/org/mtransit/android/commons/StoreUtils.java +++ b/src/main/java/org/mtransit/android/commons/StoreUtils.java @@ -4,18 +4,19 @@ import android.content.Context; import android.content.Intent; import android.net.Uri; +import android.os.Bundle; import androidx.annotation.NonNull; import androidx.annotation.Nullable; public final class StoreUtils implements MTLog.Loggable { - private static final String TAG = StoreUtils.class.getSimpleName(); + private static final String LOG_TAG = StoreUtils.class.getSimpleName(); @NonNull @Override public String getLogTag() { - return TAG; + return LOG_TAG; } private static final String HTTP_SCHEME = "http"; @@ -30,12 +31,23 @@ public String getLogTag() { private static final String GOOGLE_PLAY_PKG = "com.android.vending"; public static boolean viewAppPage(@NonNull Context context, @NonNull String pkg, @Nullable String label) { - int[] flags = new int[]{ // + final int[] flags = new int[]{ // Intent.FLAG_ACTIVITY_NEW_TASK, // make sure it does NOT open in the stack of your activity Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED, // task re-parenting if needed Intent.FLAG_ACTIVITY_CLEAR_TOP, // make sure it opens on app page even if already open in search result }; boolean success; + extras.putBoolean("overlay", true); + extras.putString("callerId", context.getPackageName()); + // tries to force Google Play Store package 1st and extras (no flags) + success = LinkUtils.open(context, Uri.parse(String.format(GOOGLE_PLAY_STORE_BASE_URI_AND_PKG, pkg)), label, GOOGLE_PLAY_PKG, extras); + if (success) { + return true; + } + success = LinkUtils.open(context, Uri.parse(String.format(GOOGLE_PLAY_STORE_BASE_WWW_URI_AND_PKG, pkg)), label, GOOGLE_PLAY_PKG, extras); + if (success) { + return true; + } // tries to force Google Play Store package 1st success = LinkUtils.open(context, Uri.parse(String.format(GOOGLE_PLAY_STORE_BASE_URI_AND_PKG, pkg)), label, GOOGLE_PLAY_PKG, flags); if (success) { From b7e3f23be47fae154739c0aa9ad4fa4bf1526b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Sun, 1 Mar 2026 13:50:40 -0500 Subject: [PATCH 2/3] missing --- src/main/java/org/mtransit/android/commons/StoreUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/mtransit/android/commons/StoreUtils.java b/src/main/java/org/mtransit/android/commons/StoreUtils.java index fab3b3ca..ee551f6b 100644 --- a/src/main/java/org/mtransit/android/commons/StoreUtils.java +++ b/src/main/java/org/mtransit/android/commons/StoreUtils.java @@ -37,6 +37,7 @@ public static boolean viewAppPage(@NonNull Context context, @NonNull String pkg, Intent.FLAG_ACTIVITY_CLEAR_TOP, // make sure it opens on app page even if already open in search result }; boolean success; + final Bundle extras = new Bundle(); extras.putBoolean("overlay", true); extras.putString("callerId", context.getPackageName()); // tries to force Google Play Store package 1st and extras (no flags) From 1194e12592874b0d50f1a8f43d8001a5d9a141d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20M=C3=A9a?= Date: Sun, 1 Mar 2026 13:50:57 -0500 Subject: [PATCH 3/3] inline++ --- src/main/java/org/mtransit/android/commons/StoreUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/mtransit/android/commons/StoreUtils.java b/src/main/java/org/mtransit/android/commons/StoreUtils.java index ee551f6b..81a8d94b 100644 --- a/src/main/java/org/mtransit/android/commons/StoreUtils.java +++ b/src/main/java/org/mtransit/android/commons/StoreUtils.java @@ -39,6 +39,7 @@ public static boolean viewAppPage(@NonNull Context context, @NonNull String pkg, boolean success; final Bundle extras = new Bundle(); extras.putBoolean("overlay", true); + extras.putBoolean("inline", true); extras.putString("callerId", context.getPackageName()); // tries to force Google Play Store package 1st and extras (no flags) success = LinkUtils.open(context, Uri.parse(String.format(GOOGLE_PLAY_STORE_BASE_URI_AND_PKG, pkg)), label, GOOGLE_PLAY_PKG, extras);