From cae4536d2019d8074ff2b38e69bc494e072bcf13 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Tue, 17 May 2022 15:53:20 +0200 Subject: [PATCH] split off openUrlInBrowser() from openOnlineUrl() --- src/org/thoughtcrime/securesms/WebViewActivity.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/WebViewActivity.java b/src/org/thoughtcrime/securesms/WebViewActivity.java index 966e80b68..a86c92d87 100644 --- a/src/org/thoughtcrime/securesms/WebViewActivity.java +++ b/src/org/thoughtcrime/securesms/WebViewActivity.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms; import android.content.ActivityNotFoundException; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; @@ -270,12 +271,16 @@ public class WebViewActivity extends PassphraseRequiredActionBarActivity } } - protected boolean openOnlineUrl(String url) { + public static void openUrlInBrowser(Context context, String url) { try { - startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); } catch (ActivityNotFoundException e) { - Toast.makeText(this, R.string.no_browser_installed, Toast.LENGTH_LONG).show(); + Toast.makeText(context, R.string.no_browser_installed, Toast.LENGTH_LONG).show(); } + } + + protected boolean openOnlineUrl(String url) { + openUrlInBrowser(this, url); // returning `true` causes the WebView to abort loading return true; }