Bug 1879507 - Show Default prompt when default-browser card disabled

As part of the Set as default optimization experiment, treatment
branch A will show the "Set as Default" System prompt when the
onboarding started, without showing the default-browser card.
This will be controlled from the experimenter and will require
disabling the default-browser card.
If the user already set Firefox as default browser, this prompt
will not be shown.
fenix/125.0
DreVla 4 months ago committed by mergify[bot]
parent 854ef2915c
commit 0b977ba6de

@ -52,7 +52,7 @@ class OnboardingFragment : Fragment() {
private val pagesToDisplay by lazy { private val pagesToDisplay by lazy {
pagesToDisplay( pagesToDisplay(
shouldShowDefaultBrowserCard(requireContext()), isNotDefaultBrowser(requireContext()),
canShowNotificationPage(requireContext()), canShowNotificationPage(requireContext()),
canShowAddWidgetCard(), canShowAddWidgetCard(),
) )
@ -63,6 +63,7 @@ class OnboardingFragment : Fragment() {
@SuppressLint("SourceLockedOrientationActivity") @SuppressLint("SourceLockedOrientationActivity")
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
val context = requireContext()
if (pagesToDisplay.isEmpty()) { if (pagesToDisplay.isEmpty()) {
/* do not continue if there's no onboarding pages to display */ /* do not continue if there's no onboarding pages to display */
onFinish(null) onFinish(null)
@ -72,8 +73,14 @@ class OnboardingFragment : Fragment() {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
} }
val filter = IntentFilter(WidgetPinnedReceiver.ACTION) val filter = IntentFilter(WidgetPinnedReceiver.ACTION)
LocalBroadcastManager.getInstance(requireContext()) LocalBroadcastManager.getInstance(context)
.registerReceiver(pinAppWidgetReceiver, filter) .registerReceiver(pinAppWidgetReceiver, filter)
if (isNotDefaultBrowser(context) &&
pagesToDisplay.none { it.type == OnboardingPageUiData.Type.DEFAULT_BROWSER }
) {
promptToSetAsDefaultBrowser()
}
} }
@RequiresApi(Build.VERSION_CODES.TIRAMISU) @RequiresApi(Build.VERSION_CODES.TIRAMISU)
@ -109,11 +116,7 @@ class OnboardingFragment : Fragment() {
OnboardingScreen( OnboardingScreen(
pagesToDisplay = pagesToDisplay, pagesToDisplay = pagesToDisplay,
onMakeFirefoxDefaultClick = { onMakeFirefoxDefaultClick = {
activity?.openSetDefaultBrowserOption(useCustomTab = true) promptToSetAsDefaultBrowser()
telemetryRecorder.onSetToDefaultClick(
sequenceId = pagesToDisplay.telemetrySequenceId(),
sequencePosition = pagesToDisplay.sequencePosition(OnboardingPageUiData.Type.DEFAULT_BROWSER),
)
}, },
onSkipDefaultClick = { onSkipDefaultClick = {
telemetryRecorder.onSkipSetToDefaultClick( telemetryRecorder.onSkipSetToDefaultClick(
@ -212,7 +215,7 @@ class OnboardingFragment : Fragment() {
) )
} }
private fun shouldShowDefaultBrowserCard(context: Context) = private fun isNotDefaultBrowser(context: Context) =
!BrowsersCache.all(context.applicationContext).isDefaultBrowser !BrowsersCache.all(context.applicationContext).isDefaultBrowser
private fun canShowNotificationPage(context: Context) = private fun canShowNotificationPage(context: Context) =
@ -260,4 +263,12 @@ class OnboardingFragment : Fragment() {
) { condition -> jexlHelper.evalJexlSafe(condition) } ) { condition -> jexlHelper.evalJexlSafe(condition) }
} }
} }
private fun promptToSetAsDefaultBrowser() {
activity?.openSetDefaultBrowserOption(useCustomTab = true)
telemetryRecorder.onSetToDefaultClick(
sequenceId = pagesToDisplay.telemetrySequenceId(),
sequencePosition = pagesToDisplay.sequencePosition(OnboardingPageUiData.Type.DEFAULT_BROWSER),
)
}
} }

Loading…
Cancel
Save