From 9cf836244f7f1dacf40c8a39cb352e2c6fe27c0a Mon Sep 17 00:00:00 2001 From: Roger Yang Date: Wed, 26 Apr 2023 15:51:12 -0400 Subject: [PATCH] Bug 1809264 - Always tries to open links in external app in custom tab --- .../java/org/mozilla/fenix/browser/BaseBrowserFragment.kt | 2 +- app/src/main/java/org/mozilla/fenix/utils/Settings.kt | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index c6535f1a77..5d8b4be3f9 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -639,7 +639,7 @@ abstract class BaseBrowserFragment : store = store, sessionId = customTabSessionId, fragmentManager = parentFragmentManager, - launchInApp = { context.settings().shouldOpenLinksInApp() }, + launchInApp = { context.settings().shouldOpenLinksInApp(customTabSessionId != null) }, loadUrlUseCase = context.components.useCases.sessionUseCases.loadUrl, shouldPrompt = { context.settings().shouldPromptOpenLinksInApp() }, ), diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index d7312bb2d0..611fbd0cb2 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -1212,11 +1212,12 @@ class Settings(private val appContext: Context) : PreferencesHolder { /** * Check to see if we should open the link in an external app */ - fun shouldOpenLinksInApp(): Boolean { + fun shouldOpenLinksInApp(isCustomTab: Boolean = false): Boolean { return when (openLinksInExternalApp) { appContext.getString(R.string.pref_key_open_links_in_apps_always) -> true appContext.getString(R.string.pref_key_open_links_in_apps_ask) -> true - appContext.getString(R.string.pref_key_open_links_in_apps_never) -> false + /* Some applications will not work if custom tab never open links in apps, return true if it's custom tab */ + appContext.getString(R.string.pref_key_open_links_in_apps_never) -> isCustomTab else -> false } }