Navigation bar height multiplier doesn't seem to be doing anything
Checklist
- [X] I am able to reproduce the bug with the latest debug version (Android, Linux, Windows)
- [X] I've checked that there is no open or closed issue about this bug.
- [X] This issue contains only one bug.
- [X] The title of this issue accurately describes the bug.
Steps to reproduce
Set navigation bar multiplier
Expected behavior
When changed and restarted the app would adjust to fit the navigation bar
Actual behavior
nothing happens
Screenshots / recordings
No response
Logs
non
SpMp version
0.4.2
SpMp platform
Android
OS version
android 11
Additional information
I have only tried it on the horizontal position
with these changes in the MainActivity.kt seems to fix it
package com.toasterofbread.spmp
import ProgramArguments import SpMp import SpMp.isDebugBuild import android.content.ComponentCallbacks2 import android.content.Intent import android.net.Uri import android.os.Build import android.os.Bundle import android.os.StrictMode import android.os.StrictMode.VmPolicy import android.view.View import android.view.WindowManager import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.navigationBars import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.getValue import androidx.compose.runtime.setValue import androidx.core.view.WindowCompat import com.toasterofbread.spmp.model.appaction.shortcut.ShortcutState import com.toasterofbread.spmp.platform.AppContext import dev.toastbits.composekit.context.ApplicationContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.runBlocking
class MainActivity : ComponentActivity() { private val coroutine_scope = CoroutineScope(Job())
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Set up a default exception handler for uncaught exceptions.
Thread.setDefaultUncaughtExceptionHandler { _: Thread, error: Throwable ->
if (error is java.nio.channels.UnresolvedAddressException) {
println("WARNING: Skipping error: ${error.stackTraceToString()}")
return@setDefaultUncaughtExceptionHandler
}
error.printStackTrace()
startActivity(Intent(this@MainActivity, ErrorReportActivity::class.java).apply {
putExtra("message", error.message)
putExtra("stack_trace", error.stackTraceToString())
})
}
// Enable debug checks if in debug build.
if (isDebugBuild()) {
StrictMode.setVmPolicy(
VmPolicy.Builder()
.detectLeakedClosableObjects()
.penaltyLog()
.build()
)
}
val shortcutState = ShortcutState()
val context: AppContext = runBlocking {
AppContext.create(this@MainActivity, coroutine_scope, ApplicationContext(this@MainActivity))
}
SpMp.init(context)
// Use edge-to-edge layout.
WindowCompat.setDecorFitsSystemWindows(window, false)
if (!context.isDisplayingAboveNavigationBar()) {
window.setFlags(
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
)
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
window.decorView.systemUiVisibility =
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
} else {
window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING)
}
val openUri: Uri? = if (intent.action == Intent.ACTION_VIEW) intent.data else null
val launchArguments = ProgramArguments()
setContent {
AppContent(launchArguments, shortcutState, openUri)
}
}
override fun onDestroy() {
coroutine_scope.cancel()
SpMp.release()
super.onDestroy()
}
override fun onStart() {
super.onStart()
SpMp.onStart()
}
override fun onStop() {
super.onStop()
SpMp.onStop()
}
override fun onTrimMemory(level: Int) {
super.onTrimMemory(level)
when (level) {
ComponentCallbacks2.TRIM_MEMORY_UI_HIDDEN -> {
// App UI is no longer visible.
}
ComponentCallbacks2.TRIM_MEMORY_RUNNING_MODERATE,
ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW,
ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL -> {
SpMp.onLowMemory()
}
ComponentCallbacks2.TRIM_MEMORY_BACKGROUND,
ComponentCallbacks2.TRIM_MEMORY_MODERATE,
ComponentCallbacks2.TRIM_MEMORY_COMPLETE -> {
// Handle background memory trimming if needed.
}
else -> { }
}
}
}
@Composable fun AppContent( launchArguments: ProgramArguments, shortcutState: ShortcutState, openUri: Uri? ) { val playerCoroutineScope = rememberCoroutineScope() var playerInitialized by remember { mutableStateOf(false) }
LaunchedEffect(Unit) {
SpMp.initPlayer(launchArguments, playerCoroutineScope)
playerInitialized = true
}
// Use Compose's built-in window insets support.
Box(
modifier = androidx.compose.ui.Modifier
.fillMaxSize()
.windowInsetsPadding(WindowInsets.navigationBars)
) {
if (playerInitialized) {
SpMp.App(launchArguments, shortcutState, open_uri = openUri?.toString())
}
}
}