From 7de707c60a3810442b7c6800c10e8fca36c37edb Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 30 Jan 2022 10:46:46 -0500 Subject: [PATCH] Avoid invalid unset default browser (fixes #6520) --- .../eu/kanade/tachiyomi/util/system/ContextExtensions.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt index 0204ba92b..4ab874c09 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/system/ContextExtensions.kt @@ -293,7 +293,7 @@ fun Context.openInBrowser(uri: Uri, @ColorInt toolbarColor: Int? = null) { ) .build() // Force default browser so that verified extensions don't re-open Tachiyomi - intent.intent.setPackage(defaultBrowserPackageName()) + defaultBrowserPackageName()?.let { intent.intent.setPackage(it) } intent.launchUrl(this, uri) } catch (e: Exception) { toast(e.message) @@ -302,7 +302,9 @@ fun Context.openInBrowser(uri: Uri, @ColorInt toolbarColor: Int? = null) { fun Context.defaultBrowserPackageName(): String? { val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse("http://")) - return packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY)?.activityInfo?.packageName + return packageManager.resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY) + ?.activityInfo?.packageName + ?.takeIf { it != "android" } } fun Context.createFileInCacheDir(name: String): File {