From d7f511e1384a79239bdb97264d2d74acd293392e Mon Sep 17 00:00:00 2001 From: rahulsainani Date: Thu, 16 Mar 2023 09:23:01 +0100 Subject: [PATCH] Bug 1822750 - Add option to open default browser help page in custom tab --- .../java/org/mozilla/fenix/ext/Activity.kt | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/ext/Activity.kt b/app/src/main/java/org/mozilla/fenix/ext/Activity.kt index 00e2004f3b..c48c326442 100644 --- a/app/src/main/java/org/mozilla/fenix/ext/Activity.kt +++ b/app/src/main/java/org/mozilla/fenix/ext/Activity.kt @@ -69,10 +69,12 @@ fun Activity.breadcrumb( * * @param from fallback direction in case, couldn't open the setting. * @param flags fallback flags for when opening the Sumo article page. + * @param useCustomTab fallback to open the Sumo article in a custom tab. */ fun Activity.openSetDefaultBrowserOption( from: BrowserDirection = BrowserDirection.FromSettings, flags: EngineSession.LoadUrlFlags = EngineSession.LoadUrlFlags.none(), + useCustomTab: Boolean = false, ) { when { Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q -> { @@ -94,15 +96,22 @@ fun Activity.openSetDefaultBrowserOption( navigateToDefaultBrowserAppsSettings() } else -> { - (this as HomeActivity).openToBrowserAndLoad( - searchTermOrURL = SupportUtils.getSumoURLForTopic( - this, - SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER, - ), - newTab = true, - from = from, - flags = flags, + val sumoDefaultBrowserUrl = SupportUtils.getSumoURLForTopic( + context = this, + topic = SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER, ) + if (useCustomTab) { + startActivity( + SupportUtils.createCustomTabIntent(context = this, url = sumoDefaultBrowserUrl), + ) + } else { + (this as HomeActivity).openToBrowserAndLoad( + searchTermOrURL = sumoDefaultBrowserUrl, + newTab = true, + from = from, + flags = flags, + ) + } } } }