@ -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 ) ,
)
}
}
}