2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00

Bug 1822750 - Add option to open default browser help page in custom tab

This commit is contained in:
rahulsainani 2023-03-16 09:23:01 +01:00 committed by mergify[bot]
parent bacea723cb
commit d7f511e138

View File

@ -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,11 +96,17 @@ fun Activity.openSetDefaultBrowserOption(
navigateToDefaultBrowserAppsSettings()
}
else -> {
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 = SupportUtils.getSumoURLForTopic(
this,
SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER,
),
searchTermOrURL = sumoDefaultBrowserUrl,
newTab = true,
from = from,
flags = flags,
@ -106,6 +114,7 @@ fun Activity.openSetDefaultBrowserOption(
}
}
}
}
private fun Activity.navigateToDefaultBrowserAppsSettings() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {