mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-11 13:11:01 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/18453 - Show SUMO for default browser deeplink on Android <N
Lower Android versions don't offer the possibility of opening system settings at a specific preference. In this cases we already shown a sumo article detailing the manual steps each user is expected to perform to change the system set default browser.
This commit is contained in:
parent
52bad3ad66
commit
bd7ca49b17
@ -21,6 +21,8 @@ import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||
import org.mozilla.fenix.components.SearchWidgetCreator
|
||||
import org.mozilla.fenix.ext.alreadyOnDestination
|
||||
import org.mozilla.fenix.home.intent.DeepLinkIntentProcessor.DeepLinkVerifier
|
||||
import org.mozilla.fenix.settings.SupportUtils
|
||||
|
||||
/**
|
||||
* Deep links in the form of `fenix://host` open different parts of the app.
|
||||
@ -93,6 +95,16 @@ class DeepLinkIntentProcessor(
|
||||
settingsIntent.putExtra(SETTINGS_SHOW_FRAGMENT_ARGS,
|
||||
bundleOf(SETTINGS_SELECT_OPTION_KEY to DEFAULT_BROWSER_APP_OPTION))
|
||||
activity.startActivity(settingsIntent)
|
||||
} else {
|
||||
activity.openToBrowserAndLoad(
|
||||
searchTermOrURL = SupportUtils.getSumoURLForTopic(
|
||||
activity,
|
||||
SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER
|
||||
),
|
||||
newTab = true,
|
||||
from = BrowserDirection.FromGlobal,
|
||||
flags = EngineSession.LoadUrlFlags.external()
|
||||
)
|
||||
}
|
||||
}
|
||||
"open" -> {
|
||||
|
@ -6,6 +6,9 @@ package org.mozilla.fenix.home.intent
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Build.VERSION_CODES.M
|
||||
import android.os.Build.VERSION_CODES.N
|
||||
import android.os.Build.VERSION_CODES.P
|
||||
import androidx.core.net.toUri
|
||||
import androidx.navigation.NavController
|
||||
import io.mockk.Called
|
||||
@ -27,6 +30,8 @@ import org.mozilla.fenix.NavGraphDirections
|
||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||
import org.mozilla.fenix.components.SearchWidgetCreator
|
||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||
import org.mozilla.fenix.settings.SupportUtils
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(FenixRobolectricTestRunner::class)
|
||||
class DeepLinkIntentProcessorTest {
|
||||
@ -244,9 +249,31 @@ class DeepLinkIntentProcessorTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `process make_default_browser deep link`() {
|
||||
@Config(minSdk = N, maxSdk = P)
|
||||
fun `process make_default_browser deep link for above API 23`() {
|
||||
assertTrue(processor.process(testIntent("make_default_browser"), navController, out))
|
||||
|
||||
verify { activity.startActivity(any()) }
|
||||
verify { navController wasNot Called }
|
||||
verify { out wasNot Called }
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(maxSdk = M)
|
||||
fun `process make_default_browser deep link for API 23 and below`() {
|
||||
assertTrue(processor.process(testIntent("make_default_browser"), navController, out))
|
||||
|
||||
verify {
|
||||
activity.openToBrowserAndLoad(
|
||||
searchTermOrURL = SupportUtils.getSumoURLForTopic(
|
||||
activity,
|
||||
SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER
|
||||
),
|
||||
newTab = true,
|
||||
from = BrowserDirection.FromGlobal,
|
||||
flags = EngineSession.LoadUrlFlags.external()
|
||||
)
|
||||
}
|
||||
verify { navController wasNot Called }
|
||||
verify { out wasNot Called }
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ Here is the list of current deep links available, which can be found here in the
|
||||
</tr>
|
||||
<tr>
|
||||
<td>`fenix://make_default_browser`</td>
|
||||
<td>Opens to the Android default apps settings screen. **Only works on Android API >=24**</td>
|
||||
<td>Opens to the Android default apps settings screen. If Android API <= 23 opens tab to support page defined in SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>`fenix://settings_notifications`</td>
|
||||
|
Loading…
Reference in New Issue
Block a user