fix: schwarze Systemleisten (Edge-to-Edge), Discord-Statuszeile mit Titel (v1.1.1)

This commit is contained in:
2026-09-27 02:48:39 +02:00
parent 7697bcfaee
commit e3650a6776
7 changed files with 40 additions and 22 deletions
@@ -23,6 +23,9 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.webkit.WebSettingsCompat
import androidx.webkit.WebViewCompat
import androidx.webkit.WebViewFeature
@@ -48,6 +51,7 @@ class MainActivity : AppCompatActivity() {
setContentView(R.layout.activity_main)
webView = findViewById(R.id.webView)
progress = findViewById(R.id.progress)
keepContentBetweenSystemBars()
configureWebView()
onBackPressedDispatcher.addCallback(
@@ -84,6 +88,21 @@ class MainActivity : AppCompatActivity() {
super.onPause()
}
/**
* Ab Android 15 zeichnet jede App unter Status- und Navigationsleiste. Die Seite bekommt deshalb
* Abstand oben/unten (und fuer die Tastatur); dahinter bleiben schwarze Balken stehen.
*/
private fun keepContentBetweenSystemBars() {
val insetsController = WindowCompat.getInsetsController(window, window.decorView)
insetsController.isAppearanceLightStatusBars = false
insetsController.isAppearanceLightNavigationBars = false
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.root)) { view, insets ->
val space = insets.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.ime())
view.setPadding(space.left, space.top, space.right, space.bottom)
WindowInsetsCompat.CONSUMED
}
}
override fun onDestroy() {
handler.removeCallbacksAndMessages(null)
PlaybackHub.commandHandler = null
@@ -21,6 +21,9 @@ data class PresencePlan(
/** Schwankung des Startzeitpunkts durch die 1,5-s-Abfrage, die noch kein Spulen ist. */
const val SEEK_TOLERANCE_MS = 4_000L
/** Discord akzeptiert Bildadressen nur bis 300 Zeichen. */
const val MAX_IMAGE_URL_LENGTH = 300
/** null = nichts anzeigen (nichts laeuft oder Pause). */
fun from(info: NowPlaying, nowMs: Long): PresencePlan? {
if (!info.hasTrack || !info.playing) return null
@@ -28,7 +31,7 @@ data class PresencePlan(
return PresencePlan(
details = info.title,
state = info.artist,
artworkUrl = info.artworkUrl,
artworkUrl = info.artworkUrl?.takeIf { it.length <= MAX_IMAGE_URL_LENGTH },
startMs = start,
endMs = if (info.durationMs > 0) start + info.durationMs else 0L,
)