From e4c30c03897d9b862109f67459aa110e6060ebbf Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Tue, 1 Dec 2020 19:34:03 +0900 Subject: [PATCH] Open urls in new browser tabs. Closes https://github.com/austinhuang0131/barinsta/issues/367 --- app/src/main/java/awais/instagrabber/utils/Utils.java | 9 ++++++--- app/src/main/res/values/strings.xml | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) mode change 100755 => 100644 app/src/main/java/awais/instagrabber/utils/Utils.java diff --git a/app/src/main/java/awais/instagrabber/utils/Utils.java b/app/src/main/java/awais/instagrabber/utils/Utils.java old mode 100755 new mode 100644 index e3982f86..04cba7fc --- a/app/src/main/java/awais/instagrabber/utils/Utils.java +++ b/app/src/main/java/awais/instagrabber/utils/Utils.java @@ -9,6 +9,7 @@ import android.content.Context; import android.content.Intent; import android.content.res.Resources; import android.net.Uri; +import android.provider.Browser; import android.util.DisplayMetrics; import android.util.Log; import android.util.Pair; @@ -181,12 +182,14 @@ public final class Utils { if (context == null || TextUtils.isEmpty(url)) { return; } - final Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse(url)); + final Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + i.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); + i.putExtra(Browser.EXTRA_CREATE_NEW_TAB, true); try { context.startActivity(i); } catch (ActivityNotFoundException e) { - Log.e(TAG, "openURL: No activity found to handle URL view", e); + Log.e(TAG, "openURL: No activity found to handle URLs", e); + Toast.makeText(context, context.getString(R.string.no_external_app_url), Toast.LENGTH_LONG).show(); } catch (Exception e) { Log.e(TAG, "openURL", e); } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1fed88f7..d2434604 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -310,6 +310,7 @@ Disable animation Please wait for the current task to complete first! Post not found! + No app found which opens urls %d like %d likes