commit c6623bc09223ea220dc35ee88abff20d25051bf8 parent 901796eddf475e61e1bef195b09d8f61b5a5af95 Author: t-p-white <towhite@mozilla.com> Date: Fri, 21 Nov 2025 18:00:34 +0000 Bug 2001355 - Part 3 Make the onboarding flow an edge to edge view. r=android-reviewers,mavduevskiy | {F41483501} | {F41483472} Differential Revision: https://phabricator.services.mozilla.com/D273598 Diffstat:
3 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/mobile/android/android-components/components/support/ktx/src/main/java/mozilla/components/support/ktx/android/view/Activity.kt b/mobile/android/android-components/components/support/ktx/src/main/java/mozilla/components/support/ktx/android/view/Activity.kt @@ -46,14 +46,7 @@ fun Activity.enterImmersiveMode( setOnApplyWindowInsetsListener(IMMERSIVE_MODE_WINDOW_INSETS_LISTENER, insetsListener) - if (SDK_INT >= VERSION_CODES.P) { - window.setFlags( - WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, - WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, - ) - window.attributes.layoutInDisplayCutoutMode = - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES - } + tryEnableEnterEdgeToEdge() } private fun WindowInsetsControllerCompat.hideInsets() { @@ -81,11 +74,7 @@ fun Activity.exitImmersiveMode( unregisterOnApplyWindowInsetsListener(IMMERSIVE_MODE_WINDOW_INSETS_LISTENER) - if (SDK_INT >= VERSION_CODES.P) { - window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) - window.attributes.layoutInDisplayCutoutMode = - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT - } + tryDisableEdgeToEdge() } /** @@ -106,3 +95,28 @@ fun Activity.reportFullyDrawnSafe(errorLogger: Logger) { errorLogger.error("Fully drawn - unable to call reportFullyDrawn", e) } } + +/** + * For devices running Android 9 Pie, force the given activity to enter edge-to-edge mode. + */ +fun Activity.tryEnableEnterEdgeToEdge() { + if (SDK_INT >= VERSION_CODES.P) { + window.setFlags( + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, + WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, + ) + window.attributes.layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + } +} + +/** + * For devices running Android 9 Pie, force the given activity to exit edge-to-edge mode. + */ +fun Activity.tryDisableEdgeToEdge() { + if (SDK_INT >= VERSION_CODES.P) { + window.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS) + window.attributes.layoutInDisplayCutoutMode = + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT + } +} diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/onboarding/OnboardingFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/onboarding/OnboardingFragment.kt @@ -29,6 +29,8 @@ import mozilla.components.service.nimbus.evalJexlSafe import mozilla.components.service.nimbus.messaging.use import mozilla.components.support.base.feature.ViewBoundFeatureWrapper import mozilla.components.support.base.log.logger.Logger +import mozilla.components.support.ktx.android.view.tryDisableEdgeToEdge +import mozilla.components.support.ktx.android.view.tryEnableEnterEdgeToEdge import mozilla.components.support.utils.BrowsersCache import org.mozilla.fenix.FenixApplication import org.mozilla.fenix.GleanMetrics.Pings @@ -175,6 +177,9 @@ class OnboardingFragment : Fragment() { override fun onResume() { super.onResume() + if (requireContext().settings().useOnboardingRedesign) { + activity?.tryEnableEnterEdgeToEdge() + } hideToolbar() maybeResetBrowserCache() } @@ -205,6 +210,9 @@ class OnboardingFragment : Fragment() { override fun onDestroy() { super.onDestroy() + if (requireContext().settings().useOnboardingRedesign) { + activity?.tryDisableEdgeToEdge() + } if (!isLargeScreenSize()) { activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED } diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/onboarding/redesign/view/OnboardingScreenRedesign.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/onboarding/redesign/view/OnboardingScreenRedesign.kt @@ -19,6 +19,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PageSize import androidx.compose.foundation.pager.PagerState @@ -305,7 +306,10 @@ private fun OnboardingContent( GradientBackground() } - Column(verticalArrangement = Arrangement.Center) { + Column( + modifier = Modifier.systemBarsPadding(), + verticalArrangement = Arrangement.Center, + ) { Spacer(Modifier.weight(1f)) HorizontalPager(