app: improve Material 3 colors in apk-ng

Improve Material 3 color system compliance and legibility across apk-ng:
- Add custom Magisk-branded light and dark fallback color schemes.
- Fix button color token pairings and remove custom alpha blending.
- Fix surface/background tokens in dialogs and markdown views.
- Harmonize badges and warnings with semantic M3 color roles.
- Remove redundant TopAppBar icon tint overrides.

Assisted-by: Gemini 3.7 Flash
This commit is contained in:
topjohnwu
2026-08-18 17:56:10 +00:00
committed by John Wu
parent fa6867b6a7
commit 6177c7c52b
10 changed files with 109 additions and 57 deletions
@@ -14,6 +14,62 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.platform.LocalContext
import com.topjohnwu.magisk.core.Config
import androidx.compose.ui.graphics.Color
private val MagiskLightColorScheme = lightColorScheme(
primary = Color(0xFF006A5E),
onPrimary = Color(0xFFFFFFFF),
primaryContainer = Color(0xFF70F7E2),
onPrimaryContainer = Color(0xFF00201C),
secondary = Color(0xFF4A635E),
onSecondary = Color(0xFFFFFFFF),
secondaryContainer = Color(0xFFCCE8E1),
onSecondaryContainer = Color(0xFF05201B),
tertiary = Color(0xFF456179),
onTertiary = Color(0xFFFFFFFF),
tertiaryContainer = Color(0xFFCCE5FF),
onTertiaryContainer = Color(0xFF001E31),
error = Color(0xFFBA1A1A),
onError = Color(0xFFFFFFFF),
errorContainer = Color(0xFFFFDAD6),
onErrorContainer = Color(0xFF410002),
background = Color(0xFFFAFDFB),
onBackground = Color(0xFF191C1B),
surface = Color(0xFFFAFDFB),
onSurface = Color(0xFF191C1B),
surfaceVariant = Color(0xFFDAE5E1),
onSurfaceVariant = Color(0xFF3F4946),
outline = Color(0xFF6F7976),
outlineVariant = Color(0xFFBFC9C5),
)
private val MagiskDarkColorScheme = darkColorScheme(
primary = Color(0xFF51DBC6),
onPrimary = Color(0xFF003730),
primaryContainer = Color(0xFF005047),
onPrimaryContainer = Color(0xFF70F7E2),
secondary = Color(0xFFB1CCC6),
onSecondary = Color(0xFF1C3530),
secondaryContainer = Color(0xFF334B46),
onSecondaryContainer = Color(0xFFCCE8E1),
tertiary = Color(0xFFAEC9E6),
onTertiary = Color(0xFF143349),
tertiaryContainer = Color(0xFF2D4960),
onTertiaryContainer = Color(0xFFCCE5FF),
error = Color(0xFFFFB4AB),
onError = Color(0xFF690005),
errorContainer = Color(0xFF93000A),
onErrorContainer = Color(0xFFFFDAD6),
background = Color(0xFF191C1B),
onBackground = Color(0xFFE0E3E1),
surface = Color(0xFF191C1B),
onSurface = Color(0xFFE0E3E1),
surfaceVariant = Color(0xFF3F4946),
onSurfaceVariant = Color(0xFFBFC9C5),
outline = Color(0xFF899390),
outlineVariant = Color(0xFF3F4946),
)
object ThemeState {
var colorMode by mutableIntStateOf(Config.colorMode)
}
@@ -40,12 +96,12 @@ fun MagiskTheme(
val colorScheme = when {
useDynamicColor && isDarkTheme -> dynamicDarkColorScheme(context)
useDynamicColor && !isDarkTheme -> dynamicLightColorScheme(context)
isDarkTheme -> darkColorScheme()
else -> lightColorScheme()
isDarkTheme -> MagiskDarkColorScheme
else -> MagiskLightColorScheme
}
MaterialTheme(
colorScheme = colorScheme,
content = content
)
}
}
@@ -244,9 +244,7 @@ private fun LoadingDialog(showDialog: MutableState<Boolean>) {
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Start,
) {
CircularProgressIndicator(
color = MaterialTheme.colorScheme.onSurface
)
CircularProgressIndicator()
Text(
modifier = Modifier.padding(start = 16.dp),
text = stringResource(com.topjohnwu.magisk.core.R.string.loading),
@@ -317,7 +315,7 @@ private fun ConfirmDialogContent(
@Composable
fun MarkdownText(text: String) {
val contentColor = MaterialTheme.colorScheme.onBackground.toArgb()
val contentColor = MaterialTheme.colorScheme.onSurface.toArgb()
AndroidView(
factory = { context ->
TextView(context).apply {
@@ -356,7 +354,7 @@ fun MarkdownTextAsync(getMarkdownText: suspend () -> String) {
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.Center
) {
CircularProgressIndicator(color = MaterialTheme.colorScheme.onBackground)
CircularProgressIndicator()
}
}
}
@@ -80,7 +80,6 @@ fun DenyListScreen(viewModel: DenyListViewModel, onBack: () -> Unit) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null,
tint = MaterialTheme.colorScheme.onBackground
)
}
},
@@ -67,7 +67,6 @@ fun FlashScreen(viewModel: FlashViewModel, action: String, onBack: () -> Unit) {
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null,
tint = MaterialTheme.colorScheme.onSurface
)
}
},
@@ -80,7 +79,6 @@ fun FlashScreen(viewModel: FlashViewModel, action: String, onBack: () -> Unit) {
Icon(
painter = painterResource(R.drawable.ic_save),
contentDescription = stringResource(CoreR.string.menuSaveLog),
tint = MaterialTheme.colorScheme.onSurface
)
}
}
@@ -92,7 +90,6 @@ fun FlashScreen(viewModel: FlashViewModel, action: String, onBack: () -> Unit) {
Icon(
painter = painterResource(R.drawable.ic_restart),
contentDescription = stringResource(CoreR.string.reboot),
tint = MaterialTheme.colorScheme.onSurface
)
}
}
@@ -35,6 +35,7 @@ import androidx.compose.material3.Card
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@@ -365,9 +366,8 @@ private fun InstallButton(
label: String,
onClick: () -> Unit,
) {
Button(
FilledTonalButton(
onClick = onClick,
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.secondary),
shape = RoundedCornerShape(16.dp),
contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp)
) {
@@ -427,6 +427,7 @@ private fun CoreCard(
Text(
text = version.ifEmpty { stringResource(CoreR.string.not_available) },
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
@@ -560,8 +561,16 @@ private fun AppDetailRow(label: String, value: String) {
.padding(vertical = 4.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(text = label, style = MaterialTheme.typography.bodyMedium)
Text(text = value, style = MaterialTheme.typography.bodyMedium)
Text(
text = label,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Text(
text = value,
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface
)
}
}
@@ -600,11 +609,13 @@ private fun StatusCard() {
) {
Text(
text = info.label,
style = MaterialTheme.typography.bodyLarge
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Text(
text = info.status,
style = MaterialTheme.typography.bodyMedium
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurface
)
}
if (index < statuses.lastIndex) {
@@ -43,7 +43,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
@@ -277,10 +276,12 @@ private fun SuLogCard(log: SuLog) {
@Composable
private fun SuActionBadge(allowed: Boolean) {
val bg = if (allowed) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.error
val bg = if (allowed) MaterialTheme.colorScheme.primaryContainer else MaterialTheme.colorScheme.errorContainer
val fg = if (allowed) MaterialTheme.colorScheme.onPrimaryContainer else MaterialTheme.colorScheme.onErrorContainer
val text = if (allowed) stringResource(CoreR.string.granted) else stringResource(CoreR.string.denied)
Badge(
containerColor = bg,
contentColor = fg,
) { Text(text = text) }
}
@@ -382,14 +383,14 @@ private fun MagiskLogCard(entry: MagiskLogEntry) {
@Composable
private fun LogLevelBadge(level: Char) {
val colorScheme = MaterialTheme.colorScheme
val (bg, fg) = when (level) {
'V' -> Color(0xFF9E9E9E) to Color.White
'D' -> Color(0xFF2196F3) to Color.White
'I' -> Color(0xFF4CAF50) to Color.White
'W' -> Color(0xFFFFC107) to Color.Black
'E' -> Color(0xFFF44336) to Color.White
'F' -> Color(0xFF9C27B0) to Color.White
else -> Color(0xFF757575) to Color.White
'V' -> colorScheme.surfaceVariant to colorScheme.onSurfaceVariant
'D' -> colorScheme.secondaryContainer to colorScheme.onSecondaryContainer
'I' -> colorScheme.primaryContainer to colorScheme.onPrimaryContainer
'W' -> colorScheme.tertiaryContainer to colorScheme.onTertiaryContainer
'E', 'F' -> colorScheme.errorContainer to colorScheme.onErrorContainer
else -> colorScheme.surfaceVariant to colorScheme.onSurfaceVariant
}
Badge(
containerColor = bg,
@@ -7,7 +7,6 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarDefaults
@@ -45,7 +44,6 @@ fun ActionScreen(viewModel: ActionViewModel, actionName: String, onBack: () -> U
Icon(
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
contentDescription = null,
tint = MaterialTheme.colorScheme.onBackground
)
}
},
@@ -58,7 +56,6 @@ fun ActionScreen(viewModel: ActionViewModel, actionName: String, onBack: () -> U
Icon(
painter = painterResource(R.drawable.ic_save),
contentDescription = stringResource(CoreR.string.menuSaveLog),
tint = MaterialTheme.colorScheme.onBackground
)
}
}
@@ -7,7 +7,6 @@ import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateContentSize
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
@@ -36,6 +35,7 @@ import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Card
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.FilledTonalButton
import androidx.compose.material3.FloatingActionButton
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
@@ -143,15 +143,12 @@ fun ModuleScreen(viewModel: ModuleViewModel) {
FloatingActionButton(
onClick = { filePicker.launch("application/zip") },
shape = CircleShape,
modifier = Modifier
.padding(bottom = 88.dp, end = 20.dp)
.border(0.05.dp, colorScheme.outline.copy(alpha = 0.5f), CircleShape),
modifier = Modifier.padding(bottom = 88.dp, end = 20.dp),
content = {
Icon(
imageVector = Icons.Default.Add,
contentDescription = stringResource(CoreR.string.module_action_install_external),
modifier = Modifier.size(28.dp),
tint = colorScheme.onPrimaryContainer
)
},
)
@@ -220,12 +217,6 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
val infoAlpha = if (!item.isRemoved && item.isEnabled && !item.showNotice) 1f else 0.5f
val strikeThrough = if (item.isRemoved) TextDecoration.LineThrough else TextDecoration.None
val colorScheme = MaterialTheme.colorScheme
val actionIconTint = colorScheme.onSurface.copy(alpha = 0.8f)
val actionBg = colorScheme.secondaryContainer.copy(alpha = 0.8f)
val updateBg = colorScheme.tertiaryContainer.copy(alpha = 0.6f)
val updateTint = colorScheme.onTertiaryContainer.copy(alpha = 0.8f)
val removeBg = colorScheme.errorContainer.copy(alpha = 0.6f)
val removeTint = colorScheme.onErrorContainer.copy(alpha = 0.8f)
var expanded by rememberSaveable(item.module.id) { mutableStateOf(false) }
val hasDescription = item.module.description.isNotBlank()
@@ -296,7 +287,6 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
HorizontalDivider(
modifier = Modifier.padding(vertical = 8.dp),
thickness = 0.5.dp,
color = colorScheme.outline.copy(alpha = 0.5f)
)
Row(verticalAlignment = Alignment.CenterVertically) {
@@ -307,8 +297,7 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
) {
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
if (item.showAction) {
Button(
colors = ButtonDefaults.buttonColors(containerColor = actionBg),
FilledTonalButton(
contentPadding = PaddingValues(horizontal = 10.dp),
onClick = { viewModel.runAction(item.module.id, item.module.name) },
) {
@@ -319,12 +308,10 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
Icon(
modifier = Modifier.size(20.dp),
imageVector = Icons.Default.PlayArrow,
tint = actionIconTint,
contentDescription = stringResource(CoreR.string.module_action)
)
Text(
text = stringResource(CoreR.string.module_action),
color = actionIconTint,
style = MaterialTheme.typography.bodyMedium,
)
}
@@ -340,9 +327,12 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
enter = fadeIn(),
exit = fadeOut()
) {
Button(
FilledTonalButton(
modifier = Modifier.padding(end = 8.dp),
colors = ButtonDefaults.buttonColors(containerColor = updateBg),
colors = ButtonDefaults.filledTonalButtonColors(
containerColor = colorScheme.tertiaryContainer,
contentColor = colorScheme.onTertiaryContainer
),
contentPadding = PaddingValues(horizontal = 10.dp),
onClick = { onUpdateClick(item.module.updateInfo) },
) {
@@ -353,25 +343,29 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
Icon(
modifier = Modifier.size(20.dp),
imageVector = Icons.Default.CloudUpload,
tint = updateTint,
contentDescription = stringResource(CoreR.string.update),
)
Text(
text = stringResource(CoreR.string.update),
color = updateTint,
style = MaterialTheme.typography.bodyMedium,
)
}
}
}
Button(
colors = ButtonDefaults.buttonColors(containerColor = if (item.isRemoved) actionBg else removeBg),
FilledTonalButton(
colors = if (item.isRemoved) {
ButtonDefaults.filledTonalButtonColors()
} else {
ButtonDefaults.filledTonalButtonColors(
containerColor = colorScheme.errorContainer,
contentColor = colorScheme.onErrorContainer
)
},
contentPadding = PaddingValues(horizontal = 10.dp),
onClick = { viewModel.toggleRemove(item) },
enabled = !item.isUpdated
) {
val tint = if (item.isRemoved) actionIconTint else removeTint
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(4.dp),
@@ -379,7 +373,6 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
Icon(
modifier = Modifier.size(20.dp),
imageVector = if (item.isRemoved) Icons.AutoMirrored.Filled.Undo else Icons.Default.Delete,
tint = tint,
contentDescription = null
)
Text(
@@ -387,7 +380,6 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli
if (item.isRemoved) CoreR.string.module_state_restore
else CoreR.string.module_state_remove
),
color = tint,
style = MaterialTheme.typography.bodyMedium,
)
}
@@ -190,7 +190,8 @@ private fun PolicyCard(
internal fun SharedUidBadge(modifier: Modifier = Modifier) {
Badge(
modifier = modifier,
containerColor = MaterialTheme.colorScheme.primary,
containerColor = MaterialTheme.colorScheme.secondaryContainer,
contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
) {
Text(stringResource(CoreR.string.shared_uid))
}
@@ -127,7 +127,7 @@ fun SuRequestScreen(viewModel: SuRequestViewModel) {
Text(
text = stringResource(CoreR.string.su_warning),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.primary,
color = MaterialTheme.colorScheme.error,
fontWeight = FontWeight.Bold,
textAlign = TextAlign.Center,
)