fix: disable dark mode and dynamic color to fix Samsung foldable display issues

Force light theme only, block Samsung Force Dark Mode via forceDarkAllowed=false,
and add explicit text colors to prevent invisible text on light backgrounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-01 11:48:51 +09:00
parent e6334f067a
commit 064f1d1f8d
4 changed files with 9 additions and 30 deletions
@@ -1,21 +1,8 @@
package com.example.medilightv2android.ui.theme
import android.app.Activity
import android.os.Build
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.darkColorScheme
import androidx.compose.material3.dynamicDarkColorScheme
import androidx.compose.material3.dynamicLightColorScheme
import androidx.compose.material3.lightColorScheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
private val DarkColorScheme = darkColorScheme(
primary = Purple80,
secondary = PurpleGrey80,
tertiary = Pink80
)
private val LightColorScheme = lightColorScheme(
primary = Purple40,
@@ -35,23 +22,13 @@ private val LightColorScheme = lightColorScheme(
@Composable
fun Medilightv2androidTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
val context = LocalContext.current
if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context)
}
darkTheme -> DarkColorScheme
else -> LightColorScheme
}
// Always use light color scheme — app is designed for light mode only.
// Dynamic color and dark theme disabled to prevent Samsung Force Dark Mode
// and Material You from overriding custom MediLight colors.
MaterialTheme(
colorScheme = colorScheme,
colorScheme = LightColorScheme,
typography = Typography,
content = content
)
@@ -372,7 +372,7 @@ private fun InfoCard(title: String, value: String, unit: String, color: Color, m
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.spacedBy(6.dp)
) {
Text(value, fontSize = 20.sp, fontWeight = FontWeight.Bold)
Text(value, fontSize = 20.sp, fontWeight = FontWeight.Bold, color = Color(0xFF1C1B1F))
if (unit.isNotEmpty()) Text(unit, fontSize = 11.sp, color = MlSecondaryText)
Text(title, fontSize = 11.sp, fontWeight = FontWeight.SemiBold, color = MlSecondaryText)
}
@@ -404,7 +404,7 @@ private fun MetricBox(title: String, value: Double, unit: String, color: Color,
Spacer(modifier = Modifier.width(4.dp))
Text(title, fontSize = 11.sp, fontWeight = FontWeight.SemiBold, color = MlSecondaryText)
}
Text(String.format("%.1f", value), fontSize = 22.sp, fontWeight = FontWeight.Bold, modifier = Modifier.fillMaxWidth(), textAlign = androidx.compose.ui.text.style.TextAlign.End)
Text(String.format("%.1f", value), fontSize = 22.sp, fontWeight = FontWeight.Bold, color = Color(0xFF1C1B1F), modifier = Modifier.fillMaxWidth(), textAlign = androidx.compose.ui.text.style.TextAlign.End)
Text(unit, fontSize = 10.sp, color = MlSecondaryText, modifier = Modifier.fillMaxWidth(), textAlign = androidx.compose.ui.text.style.TextAlign.End)
}
}
+3 -1
View File
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Medilightv2android" parent="android:Theme.Material.Light.NoActionBar" />
<style name="Theme.Medilightv2android" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:forceDarkAllowed">false</item>
</style>
</resources>