From 0ca444ed8d686be9d1dff013d133e8140f5829e9 Mon Sep 17 00:00:00 2001 From: vrubelroman Date: Fri, 23 Oct 2026 14:42:51 +0300 Subject: [PATCH] Android: the system bars follow the app's theme, not the phone's enableEdgeToEdge() picks the bar icons from the system's night mode, so the dark theme of the app on a light phone left dark icons on a dark bar. The bars are set again with the theme chosen in the app whenever it changes. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 5 +++++ .../vrubelroman/chesspenguin/MainActivity.kt | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb34140..9d36ecf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes are listed here. Versions follow [Semantic Versioning](https://semver.org/). +## [Unreleased] + +- Android: the status bar and the navigation bar follow the theme chosen in the app: with + the dark theme on a light phone their icons are light again (they stayed dark on dark). + ## [0.13.0] — 2026-10-23 - Android: **game report** — ⋮ → «Game analysis» lets Stockfish evaluate every move of the diff --git a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/MainActivity.kt b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/MainActivity.kt index f9bb64e..2837643 100644 --- a/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/MainActivity.kt +++ b/androidApp/app/src/main/java/io/github/vrubelroman/chesspenguin/MainActivity.kt @@ -4,7 +4,9 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Bundle +import android.graphics.Color import androidx.activity.ComponentActivity +import androidx.activity.SystemBarStyle import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge import androidx.compose.foundation.layout.fillMaxSize @@ -12,12 +14,17 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.ui.Modifier import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import io.github.vrubelroman.chesspenguin.data.Language import io.github.vrubelroman.chesspenguin.data.Theme import io.github.vrubelroman.chesspenguin.theme.ChessPenguinTheme +/// The scrims behind three-button navigation, as `enableEdgeToEdge` has them by default. +private val LIGHT_SCRIM = Color.argb(0xe6, 0xFF, 0xFF, 0xFF) +private val DARK_SCRIM = Color.argb(0x80, 0x1b, 0x1b, 0x1b) + class MainActivity : ComponentActivity() { override fun attachBaseContext(base: Context) { super.attachBaseContext(Language.wrap(base)) @@ -36,6 +43,15 @@ class MainActivity : ComponentActivity() { Theme.Light -> false Theme.Dark -> true } + // The system bars follow the theme chosen in the app, not the system's: light + // icons over a dark app even when the phone itself is light, and back. + DisposableEffect(dark) { + enableEdgeToEdge( + statusBarStyle = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT) { dark }, + navigationBarStyle = SystemBarStyle.auto(LIGHT_SCRIM, DARK_SCRIM) { dark }, + ) + onDispose {} + } ChessPenguinTheme(darkTheme = dark) { Surface(Modifier.fillMaxSize(), color = MaterialTheme.colorScheme.background) { MainNavigation() } }