mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
feat: Improve edge-to-edge and display cutout handling (#4669)
This commit is contained in:
parent
225dc232b6
commit
a07992530c
2 changed files with 21 additions and 12 deletions
|
|
@ -26,6 +26,7 @@ import android.nfc.NdefMessage
|
|||
import android.nfc.NfcAdapter
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.WindowManager
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.SystemBarStyle
|
||||
import androidx.activity.compose.ReportDrawnWhen
|
||||
|
|
@ -75,6 +76,19 @@ class MainActivity : ComponentActivity() {
|
|||
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
enableEdgeToEdge()
|
||||
|
||||
// Explicitly set the cutout mode to ALWAYS for Android 15+ to satisfy Play Console recommendations.
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) {
|
||||
window.attributes.layoutInDisplayCutoutMode =
|
||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS
|
||||
}
|
||||
|
||||
// Ensure the navigation bar remains seamless on modern Android versions
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
window.isNavigationBarContrastEnforced = false
|
||||
}
|
||||
|
||||
setContent {
|
||||
val theme by model.theme.collectAsStateWithLifecycle()
|
||||
val dynamic = theme == MODE_DYNAMIC
|
||||
|
|
@ -85,15 +99,12 @@ class MainActivity : ComponentActivity() {
|
|||
else -> isSystemInDarkTheme()
|
||||
}
|
||||
|
||||
// Apply modern edge-to-edge drawing with theme-aware system bars
|
||||
enableEdgeToEdge(
|
||||
statusBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { dark },
|
||||
navigationBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { dark },
|
||||
)
|
||||
|
||||
// Ensure the navigation bar remains seamless on modern Android versions
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
window.isNavigationBarContrastEnforced = false
|
||||
// Update system bar style when theme changes
|
||||
androidx.compose.runtime.SideEffect {
|
||||
enableEdgeToEdge(
|
||||
statusBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { dark },
|
||||
navigationBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { dark },
|
||||
)
|
||||
}
|
||||
|
||||
@Suppress("SpreadOperator")
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ import androidx.compose.foundation.layout.Box
|
|||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.recalculateWindowInsets
|
||||
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
|
|
@ -448,7 +446,7 @@ fun MainScreen(uIViewModel: UIViewModel = hiltViewModel(), scanModel: ScannerVie
|
|||
NavHost(
|
||||
navController = navController,
|
||||
startDestination = NodesRoutes.NodesGraph,
|
||||
modifier = Modifier.fillMaxSize().recalculateWindowInsets().safeDrawingPadding(),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
) {
|
||||
contactsGraph(navController, uIViewModel.scrollToTopEventFlow)
|
||||
nodesGraph(navController, uIViewModel.scrollToTopEventFlow)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue