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
+2
View File
@@ -51,6 +51,8 @@ Java_de_fojadrachi_playtube_DiscordPresence_nativeUpdate(JNIEnv* env, jobject, j
discordpp::Activity activity;
activity.SetType(discordpp::ActivityTypes::Listening);
// Statuszeile "Hoert <Titel> zu" statt des Namens der Discord-Anwendung.
activity.SetStatusDisplayType(discordpp::StatusDisplayTypes::Details);
activity.SetDetails(textOrNone(toString(env, details)));
activity.SetState(textOrNone(toString(env, state)));
@@ -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,
)
+2 -1
View File
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background">
android:background="@color/system_bars">
<WebView
android:id="@+id/webView"
+3 -2
View File
@@ -14,13 +14,14 @@
<string name="update_later">Später</string>
<color name="background">#0F0F0F</color>
<color name="system_bars">#000000</color>
<color name="brand_from">#7C3AED</color>
<color name="brand_to">#EC4899</color>
<style name="Theme.Playtube" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@color/background</item>
<item name="android:statusBarColor">@color/background</item>
<item name="android:navigationBarColor">@color/background</item>
<item name="android:statusBarColor">@color/system_bars</item>
<item name="android:navigationBarColor">@color/system_bars</item>
<item name="colorPrimary">@color/brand_from</item>
<item name="colorAccent">@color/brand_to</item>
</style>