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.

(cherry picked from commit f98e606dca8d4d27f174a237fb329dead7d70959)
fenix/124.1.0
DreVla 3 months ago committed by mergify[bot]
parent 23a137054e
commit 8eeeadc48f

@ -51,7 +51,7 @@ class OnboardingFragment : Fragment() {
private val pagesToDisplay by lazy {
pagesToDisplay(
shouldShowDefaultBrowserCard(requireContext()),
isNotDefaultBrowser(requireContext()),
canShowNotificationPage(requireContext()),
canShowAddWidgetCard(),
)
@ -62,6 +62,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)
@ -71,8 +72,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)
@ -108,11 +115,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(
@ -211,7 +214,7 @@ class OnboardingFragment : Fragment() {
)
}
private fun shouldShowDefaultBrowserCard(context: Context) =
private fun isNotDefaultBrowser(context: Context) =
!BrowsersCache.all(context.applicationContext).isDefaultBrowser
private fun canShowNotificationPage(context: Context) =
@ -257,4 +260,12 @@ class OnboardingFragment : Fragment() {
jexlConditions,
) { 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