Bug 1929321 - Fix app letterboxing in onboarding on foldables r=android-reviewers,boek

Differential Revision: https://phabricator.services.mozilla.com/D236589
This commit is contained in:
Nicholas Poon
2025-02-05 14:03:17 +00:00
parent 90a80982c4
commit 58049f9bc7
2 changed files with 23 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ import org.mozilla.fenix.NavHostActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.components.Components
import org.mozilla.fenix.components.toolbar.ToolbarContainerView
import org.mozilla.fenix.utils.isLargeScreenSize
/**
* Get the requireComponents of this application.
@@ -147,12 +148,19 @@ fun Fragment.registerForActivityResult(
}
/**
* Checks whether the current fragment is running on a tablet.
* Checks whether the current fragment is running on a large window.
*/
fun Fragment.isLargeWindow(): Boolean {
return requireContext().isLargeWindow()
}
/**
* Checks whether the current fragment is running on a tablet.
*/
fun Fragment.isLargeScreenSize(): Boolean {
return requireContext().isLargeScreenSize()
}
/**
*
* Manages the state of the microsurvey prompt on orientation change.

View File

@@ -8,6 +8,7 @@ import android.annotation.SuppressLint
import android.content.Context
import android.content.IntentFilter
import android.content.pm.ActivityInfo
import android.content.res.Configuration
import android.os.Build
import android.os.Bundle
import android.os.StrictMode
@@ -35,7 +36,7 @@ import org.mozilla.fenix.compose.LinkTextState
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.hideToolbar
import org.mozilla.fenix.ext.isDefaultBrowserPromptSupported
import org.mozilla.fenix.ext.isLargeWindow
import org.mozilla.fenix.ext.isLargeScreenSize
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.ext.openSetDefaultBrowserOption
import org.mozilla.fenix.ext.requireComponents
@@ -120,7 +121,7 @@ class OnboardingFragment : Fragment() {
onFinish(null)
}
if (!isLargeWindow()) {
if (!isLargeScreenSize()) {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
val filter = IntentFilter(WidgetPinnedReceiver.ACTION)
@@ -154,9 +155,19 @@ class OnboardingFragment : Fragment() {
hideToolbar()
}
@SuppressLint("SourceLockedOrientationActivity")
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (!isLargeScreenSize()) {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
} else {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
}
}
override fun onDestroy() {
super.onDestroy()
if (!isLargeWindow()) {
if (!isLargeScreenSize()) {
activity?.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
}
LocalBroadcastManager.getInstance(requireContext()).unregisterReceiver(pinAppWidgetReceiver)