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 3 months ago committed by mergify[bot]
parent 854ef2915c
commit 0b977ba6de

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