From 999bda3bc4cae1369224f3274ebcf60fd3dbb27c Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 18 Aug 2026 01:43:42 -0700 Subject: [PATCH] app: adopt Material 3 Expressive UI in apk-ng Update apk-ng components and screens to adhere to Material 3 Expressive design guidelines: - Define expressive Shapes and Typography scales in MagiskTheme. - Add active pill indicators with spring animations to floating nav bar. - Update card surfaces to 20dp-24dp rounded containers with tonal depth. - Modernize action buttons and search bar to expressive pill shapes. - Enhance dialogs and su request screens with rounded surfaces. Assisted-by: Gemini 3.7 Flash --- .../com/topjohnwu/magisk/ui/MagiskTheme.kt | 94 +++++- .../com/topjohnwu/magisk/ui/MainScreen.kt | 92 ++++-- .../topjohnwu/magisk/ui/component/Dialog.kt | 24 +- .../magisk/ui/component/SettingsComponents.kt | 19 +- .../magisk/ui/deny/DenyListScreen.kt | 67 +++- .../topjohnwu/magisk/ui/home/HomeScreen.kt | 53 +-- .../com/topjohnwu/magisk/ui/log/LogScreen.kt | 49 ++- .../magisk/ui/module/ModuleScreen.kt | 302 ++++++++++-------- .../magisk/ui/settings/SettingsScreen.kt | 27 +- .../ui/superuser/SuperuserDetailScreen.kt | 55 ++-- .../magisk/ui/superuser/SuperuserScreen.kt | 43 ++- .../magisk/ui/surequest/SuRequestScreen.kt | 65 ++-- 12 files changed, 625 insertions(+), 265 deletions(-) diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MagiskTheme.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MagiskTheme.kt index 40ccb23a7..54dd6787d 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MagiskTheme.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MagiskTheme.kt @@ -2,7 +2,10 @@ package com.topjohnwu.magisk.ui import android.os.Build import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Shapes +import androidx.compose.material3.Typography import androidx.compose.material3.darkColorScheme import androidx.compose.material3.dynamicDarkColorScheme import androidx.compose.material3.dynamicLightColorScheme @@ -11,10 +14,13 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.setValue -import androidx.compose.ui.platform.LocalContext -import com.topjohnwu.magisk.core.Config - import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import com.topjohnwu.magisk.core.Config private val MagiskLightColorScheme = lightColorScheme( primary = Color(0xFF006A5E), @@ -74,6 +80,86 @@ object ThemeState { var colorMode by mutableIntStateOf(Config.colorMode) } +val MagiskShapes = Shapes( + extraSmall = RoundedCornerShape(6.dp), + small = RoundedCornerShape(10.dp), + medium = RoundedCornerShape(16.dp), + large = RoundedCornerShape(24.dp), + extraLarge = RoundedCornerShape(32.dp), +) + +val MagiskTypography = Typography( + headlineLarge = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 32.sp, + lineHeight = 40.sp, + letterSpacing = (-0.25).sp, + ), + headlineMedium = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 28.sp, + lineHeight = 36.sp, + ), + headlineSmall = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 24.sp, + lineHeight = 32.sp, + ), + titleLarge = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 20.sp, + lineHeight = 26.sp, + ), + titleMedium = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.15.sp, + ), + titleSmall = TextStyle( + fontWeight = FontWeight.Medium, + fontSize = 14.sp, + lineHeight = 20.sp, + letterSpacing = 0.1.sp, + ), + bodyLarge = TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp, + ), + bodyMedium = TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 14.sp, + lineHeight = 20.sp, + letterSpacing = 0.25.sp, + ), + bodySmall = TextStyle( + fontWeight = FontWeight.Normal, + fontSize = 12.sp, + lineHeight = 16.sp, + letterSpacing = 0.4.sp, + ), + labelLarge = TextStyle( + fontWeight = FontWeight.SemiBold, + fontSize = 14.sp, + lineHeight = 20.sp, + letterSpacing = 0.1.sp, + ), + labelMedium = TextStyle( + fontWeight = FontWeight.Medium, + fontSize = 12.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp, + ), + labelSmall = TextStyle( + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp, + ), +) + @Composable fun MagiskTheme( content: @Composable () -> Unit @@ -102,6 +188,8 @@ fun MagiskTheme( MaterialTheme( colorScheme = colorScheme, + shapes = MagiskShapes, + typography = MagiskTypography, content = content ) } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt index a318b8bf9..282f35869 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/MainScreen.kt @@ -1,10 +1,13 @@ package com.topjohnwu.magisk.ui import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.animateDpAsState +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.core.spring import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -18,9 +21,11 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.navigationBars import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.layout.width import androidx.compose.foundation.pager.HorizontalPager import androidx.compose.foundation.pager.PagerState import androidx.compose.foundation.pager.rememberPagerState +import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme @@ -33,14 +38,16 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.scale import androidx.compose.ui.draw.shadow +import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.vector.ImageVector import androidx.activity.compose.LocalActivity import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource import androidx.compose.ui.semantics.Role +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import androidx.lifecycle.viewmodel.compose.viewModel import com.topjohnwu.magisk.R import com.topjohnwu.magisk.arch.VMFactory @@ -152,18 +159,18 @@ private fun FloatingNavigationBar( modifier: Modifier = Modifier ) { val scope = rememberCoroutineScope() - val shape = RoundedCornerShape(28.dp) + val shape = RoundedCornerShape(32.dp) val navBarInset = WindowInsets.navigationBars.asPaddingValues().calculateBottomPadding() Row( modifier = modifier - .padding(bottom = navBarInset + 12.dp, start = 24.dp, end = 24.dp) - .shadow(elevation = 6.dp, shape = shape) + .padding(bottom = navBarInset + 12.dp, start = 20.dp, end = 20.dp) + .shadow(elevation = 8.dp, shape = shape) .clip(shape) .background(MaterialTheme.colorScheme.surfaceContainer) .fillMaxWidth() - .height(64.dp) - .padding(horizontal = 4.dp), + .height(68.dp) + .padding(horizontal = 6.dp, vertical = 6.dp), horizontalArrangement = Arrangement.SpaceEvenly, verticalAlignment = Alignment.CenterVertically ) { @@ -189,39 +196,80 @@ private fun FloatingNavItem( onClick: () -> Unit, modifier: Modifier = Modifier ) { - val contentColor by animateColorAsState( + val indicatorColor by animateColorAsState( + targetValue = if (selected) MaterialTheme.colorScheme.secondaryContainer else Color.Transparent, + animationSpec = spring(dampingRatio = Spring.DampingRatioNoBouncy, stiffness = Spring.StiffnessMedium), + label = "navIndicatorColor" + ) + + val iconTint by animateColorAsState( targetValue = when { !enabled -> MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f) - selected -> MaterialTheme.colorScheme.primary + selected -> MaterialTheme.colorScheme.onSecondaryContainer else -> MaterialTheme.colorScheme.onSurfaceVariant }, - animationSpec = tween(200), - label = "navItemColor" + animationSpec = tween(150), + label = "navIconTint" + ) + + val labelColor by animateColorAsState( + targetValue = when { + !enabled -> MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f) + selected -> MaterialTheme.colorScheme.onSurface + else -> MaterialTheme.colorScheme.onSurfaceVariant + }, + animationSpec = tween(150), + label = "navLabelColor" + ) + + val iconScale by animateFloatAsState( + targetValue = if (selected) 1.08f else 1.0f, + animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy, stiffness = Spring.StiffnessMedium), + label = "navIconScale" + ) + + val indicatorWidth by animateDpAsState( + targetValue = if (selected) 48.dp else 24.dp, + animationSpec = spring(dampingRatio = Spring.DampingRatioLowBouncy, stiffness = Spring.StiffnessMedium), + label = "navIndicatorWidth" ) Column( modifier = modifier + .clip(CircleShape) .clickable( enabled = enabled, - indication = null, - interactionSource = remember { MutableInteractionSource() }, role = Role.Tab, onClick = onClick, - ), + ) + .padding(vertical = 2.dp), horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.Center, ) { - Icon( - imageVector = icon, - contentDescription = label, - modifier = Modifier.size(24.dp), - tint = contentColor, - ) + Box( + modifier = Modifier + .width(indicatorWidth) + .height(28.dp) + .clip(CircleShape) + .background(indicatorColor), + contentAlignment = Alignment.Center + ) { + Icon( + imageVector = icon, + contentDescription = label, + modifier = Modifier + .size(22.dp) + .scale(iconScale), + tint = iconTint, + ) + } Spacer(Modifier.height(2.dp)) Text( text = label, - fontSize = 11.sp, - color = contentColor, + style = MaterialTheme.typography.labelSmall, + fontWeight = if (selected) FontWeight.SemiBold else FontWeight.Medium, + color = labelColor, + maxLines = 1, ) } } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/Dialog.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/Dialog.kt index 42007a3bf..6a4247907 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/Dialog.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/Dialog.kt @@ -12,6 +12,7 @@ import androidx.compose.foundation.layout.only import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.systemBars import androidx.compose.foundation.layout.windowInsetsPadding +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.AlertDialog import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.MaterialTheme @@ -36,6 +37,7 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.viewinterop.AndroidView import androidx.compose.ui.window.Dialog import androidx.compose.ui.window.DialogProperties +import com.topjohnwu.magisk.core.R import com.topjohnwu.magisk.core.di.ServiceLocator import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.CoroutineScope @@ -232,7 +234,8 @@ private fun LoadingDialog(showDialog: MutableState) { properties = DialogProperties(dismissOnBackPress = false, dismissOnClickOutside = false) ) { Surface( - shape = MaterialTheme.shapes.extraLarge, + shape = RoundedCornerShape(28.dp), + color = MaterialTheme.colorScheme.surfaceContainerHigh, tonalElevation = 6.dp, modifier = Modifier.fillMaxWidth() ) { @@ -244,10 +247,14 @@ private fun LoadingDialog(showDialog: MutableState) { verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.Start, ) { - CircularProgressIndicator() + CircularProgressIndicator( + color = MaterialTheme.colorScheme.primary, + ) Text( modifier = Modifier.padding(start = 16.dp), - text = stringResource(com.topjohnwu.magisk.core.R.string.loading), + text = stringResource(R.string.loading), + style = MaterialTheme.typography.bodyLarge, + color = MaterialTheme.colorScheme.onSurface, ) } } @@ -270,8 +277,10 @@ private fun ConfirmDialogContent( dismiss() showDialog.value = false }, + shape = RoundedCornerShape(28.dp), + containerColor = MaterialTheme.colorScheme.surfaceContainerHigh, title = if (visuals.title.isNotEmpty()) { - { Text(text = visuals.title) } + { Text(text = visuals.title, style = MaterialTheme.typography.titleLarge) } } else null, text = { visuals.content?.let { content -> @@ -280,6 +289,7 @@ private fun ConfirmDialogContent( } else { Text( text = content, + style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurface, ) } @@ -293,7 +303,8 @@ private fun ConfirmDialogContent( } ) { Text( - text = visuals.confirm ?: stringResource(android.R.string.ok) + text = visuals.confirm ?: stringResource(android.R.string.ok), + style = MaterialTheme.typography.labelLarge, ) } }, @@ -305,7 +316,8 @@ private fun ConfirmDialogContent( } ) { Text( - text = visuals.dismiss ?: stringResource(android.R.string.cancel) + text = visuals.dismiss ?: stringResource(android.R.string.cancel), + style = MaterialTheme.typography.labelLarge, ) } } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/SettingsComponents.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/SettingsComponents.kt index e892a07dd..c723789d1 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/SettingsComponents.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/component/SettingsComponents.kt @@ -11,6 +11,7 @@ import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.ListItem +import androidx.compose.material3.ListItemDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Switch import androidx.compose.material3.Text @@ -20,6 +21,8 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp @Composable @@ -30,10 +33,11 @@ fun SettingsArrow( onClick: () -> Unit ) { ListItem( - headlineContent = { Text(title) }, - supportingContent = summary?.let { { Text(it) } }, + headlineContent = { Text(title, style = MaterialTheme.typography.bodyLarge) }, + supportingContent = summary?.let { { Text(it, style = MaterialTheme.typography.bodyMedium) } }, leadingContent = leadingContent, trailingContent = { Icon(Icons.AutoMirrored.Filled.KeyboardArrowRight, contentDescription = null) }, + colors = ListItemDefaults.colors(containerColor = Color.Transparent), modifier = Modifier.clickable(onClick = onClick) ) } @@ -47,9 +51,10 @@ fun SettingsSwitch( onCheckedChange: (Boolean) -> Unit ) { ListItem( - headlineContent = { Text(title) }, - supportingContent = summary?.takeIf { it.isNotEmpty() }?.let { { Text(it) } }, + headlineContent = { Text(title, style = MaterialTheme.typography.bodyLarge) }, + supportingContent = summary?.takeIf { it.isNotEmpty() }?.let { { Text(it, style = MaterialTheme.typography.bodyMedium) } }, trailingContent = { Switch(checked = checked, onCheckedChange = onCheckedChange, enabled = enabled) }, + colors = ListItemDefaults.colors(containerColor = Color.Transparent), modifier = Modifier.clickable(enabled = enabled, onClick = { onCheckedChange(!checked) }) ) } @@ -67,12 +72,13 @@ fun SettingsDropdown( var expanded by remember { mutableStateOf(false) } Box { ListItem( - headlineContent = { Text(title) }, + headlineContent = { Text(title, style = MaterialTheme.typography.bodyLarge) }, supportingContent = { val currentSummary = summary ?: items.getOrNull(selectedIndex) ?: "" - if (currentSummary.isNotEmpty()) Text(currentSummary) + if (currentSummary.isNotEmpty()) Text(currentSummary, style = MaterialTheme.typography.bodyMedium) }, trailingContent = { Icon(Icons.Default.ArrowDropDown, contentDescription = null) }, + colors = ListItemDefaults.colors(containerColor = Color.Transparent), modifier = Modifier.clickable(enabled = enabled, onClick = { expanded = true }) ) DropdownMenu( @@ -97,6 +103,7 @@ fun SmallTitle(text: String) { Text( text = text, style = MaterialTheme.typography.labelLarge, + fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.primary, modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp) ) diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListScreen.kt index 545b26c0d..127e01ed5 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/deny/DenyListScreen.kt @@ -1,5 +1,9 @@ package com.topjohnwu.magisk.ui.deny + import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.animateContentSize +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.spring import androidx.compose.foundation.Image import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement @@ -17,12 +21,16 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.Sort import androidx.compose.material.icons.filled.Check +import androidx.compose.material.icons.filled.Close +import androidx.compose.material.icons.filled.Search import androidx.compose.material.icons.filled.Tune import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.Checkbox import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.DropdownMenu @@ -33,6 +41,7 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.LinearProgressIndicator import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField +import androidx.compose.material3.OutlinedTextFieldDefaults import androidx.compose.material3.Scaffold import androidx.compose.material3.Text import androidx.compose.material3.TopAppBar @@ -45,6 +54,7 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.res.stringResource import androidx.compose.ui.state.ToggleableState @@ -107,7 +117,7 @@ fun DenyListScreen(viewModel: DenyListViewModel, onBack: () -> Unit) { DropdownMenuItem( text = { Text(stringResource(resId)) }, trailingIcon = if (sortBy == sort) { - { Icon(androidx.compose.material.icons.Icons.Default.Check, contentDescription = null) } + { Icon(Icons.Default.Check, contentDescription = null) } } else null, onClick = { viewModel.setSortBy(sort) @@ -178,7 +188,7 @@ fun DenyListScreen(viewModel: DenyListViewModel, onBack: () -> Unit) { onQueryChange = viewModel::setQuery, modifier = Modifier .fillMaxWidth() - .padding(horizontal = 12.dp, vertical = 4.dp) + .padding(horizontal = 16.dp, vertical = 6.dp) ) if (loading) { @@ -225,14 +235,53 @@ private fun SearchInput(query: String, onQueryChange: (String) -> Unit, modifier value = query, onValueChange = onQueryChange, modifier = modifier, - label = { Text(stringResource(CoreR.string.hide_filter_hint)) } + placeholder = { Text(stringResource(CoreR.string.hide_filter_hint)) }, + leadingIcon = { + Icon( + imageVector = Icons.Default.Search, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant + ) + }, + trailingIcon = if (query.isNotEmpty()) { + { + IconButton(onClick = { onQueryChange("") }) { + Icon( + imageVector = Icons.Default.Close, + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant + ) + } + } + } else null, + shape = RoundedCornerShape(28.dp), + singleLine = true, + colors = OutlinedTextFieldDefaults.colors( + focusedContainerColor = MaterialTheme.colorScheme.surfaceContainerHigh, + unfocusedContainerColor = MaterialTheme.colorScheme.surfaceContainer, + focusedBorderColor = MaterialTheme.colorScheme.primary, + unfocusedBorderColor = MaterialTheme.colorScheme.outlineVariant, + ) ) } @Composable private fun DenyAppCard(app: DenyAppState) { - Card(modifier = Modifier.fillMaxWidth()) { - Column { + Card( + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(20.dp)), + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { + Column( + modifier = Modifier.animateContentSize( + animationSpec = spring( + dampingRatio = Spring.DampingRatioLowBouncy, + stiffness = Spring.StiffnessMedium + ) + ) + ) { if (app.checkedPercent > 0f) { LinearProgressIndicator( progress = { app.checkedPercent }, @@ -244,7 +293,7 @@ private fun DenyAppCard(app: DenyAppState) { modifier = Modifier .fillMaxWidth() .clickable { app.isExpanded = !app.isExpanded } - .padding(12.dp), + .padding(14.dp), verticalAlignment = Alignment.CenterVertically ) { Image( @@ -256,8 +305,9 @@ private fun DenyAppCard(app: DenyAppState) { Column(modifier = Modifier.weight(1f)) { Text( text = app.info.label, - style = MaterialTheme.typography.bodyLarge, + style = MaterialTheme.typography.titleMedium, ) + Spacer(Modifier.height(2.dp)) Text( text = app.info.packageName, style = MaterialTheme.typography.bodyMedium, @@ -279,7 +329,7 @@ private fun DenyAppCard(app: DenyAppState) { Column( modifier = Modifier .fillMaxWidth() - .padding(start = 52.dp) + .padding(start = 52.dp, bottom = 8.dp) ) { app.processes.forEach { proc -> ProcessRow(proc) @@ -295,6 +345,7 @@ private fun ProcessRow(proc: DenyProcessState) { Row( modifier = Modifier .fillMaxWidth() + .clip(RoundedCornerShape(12.dp)) .clickable { proc.toggle() } .padding(horizontal = 12.dp, vertical = 6.dp), verticalAlignment = Alignment.CenterVertically diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt index d01abbc6d..102dc25ea 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt @@ -32,6 +32,7 @@ import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.DropdownMenu import androidx.compose.material3.DropdownMenuItem import androidx.compose.material3.ExperimentalMaterial3Api @@ -66,7 +67,6 @@ import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import androidx.core.content.getSystemService import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.BuildConfig @@ -334,9 +334,9 @@ private fun NoticeCard(onHide: () -> Unit) { .fillMaxWidth() .background( MaterialTheme.colorScheme.tertiaryContainer, - RoundedCornerShape(16.dp) + RoundedCornerShape(20.dp) ) - .padding(start = 16.dp, top = 4.dp, bottom = 4.dp, end = 4.dp) + .padding(start = 16.dp, top = 6.dp, bottom = 6.dp, end = 6.dp) ) { Row( verticalAlignment = Alignment.CenterVertically @@ -347,13 +347,13 @@ private fun NoticeCard(onHide: () -> Unit) { color = MaterialTheme.colorScheme.onTertiaryContainer, modifier = Modifier .weight(1f) - .padding(vertical = 8.dp) + .padding(vertical = 6.dp) ) IconButton(onClick = onHide) { Icon( imageVector = Icons.Default.Close, contentDescription = stringResource(CoreR.string.hide), - modifier = Modifier.size(15.dp), + modifier = Modifier.size(18.dp), tint = MaterialTheme.colorScheme.onTertiaryContainer, ) } @@ -368,18 +368,18 @@ private fun InstallButton( ) { FilledTonalButton( onClick = onClick, - shape = RoundedCornerShape(16.dp), - contentPadding = PaddingValues(horizontal = 12.dp, vertical = 8.dp) + shape = RoundedCornerShape(20.dp), + contentPadding = PaddingValues(horizontal = 14.dp, vertical = 8.dp) ) { Icon( painter = painterResource(R.drawable.ic_download), contentDescription = null, modifier = Modifier.size(18.dp), ) - Spacer(Modifier.width(4.dp)) + Spacer(Modifier.width(6.dp)) Text( text = label, - fontSize = 14.sp + style = MaterialTheme.typography.labelLarge, ) } } @@ -400,12 +400,13 @@ private fun CoreCard( Card( modifier = modifier, - shape = RoundedCornerShape(24.dp) + shape = RoundedCornerShape(24.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow), ) { Row( modifier = Modifier .fillMaxWidth() - .padding(16.dp), + .padding(18.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween ) { @@ -416,6 +417,7 @@ private fun CoreCard( Icon( painter = painterResource(CoreR.drawable.ic_magisk_outline), contentDescription = null, + tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(48.dp) ) Spacer(Modifier.width(16.dp)) @@ -454,7 +456,8 @@ private fun UninstallButton( containerColor = MaterialTheme.colorScheme.errorContainer, contentColor = MaterialTheme.colorScheme.onErrorContainer ), - shape = RoundedCornerShape(16.dp), + shape = RoundedCornerShape(20.dp), + contentPadding = PaddingValues(vertical = 12.dp), modifier = Modifier.fillMaxWidth() ) { Icon( @@ -465,7 +468,7 @@ private fun UninstallButton( Spacer(Modifier.width(8.dp)) Text( text = stringResource(CoreR.string.uninstall_magisk_title), - fontSize = 16.sp + style = MaterialTheme.typography.labelLarge, ) } } @@ -489,12 +492,13 @@ private fun AppCard( Card( modifier = modifier, - shape = RoundedCornerShape(24.dp) + shape = RoundedCornerShape(24.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow), ) { Column( modifier = Modifier .fillMaxWidth() - .padding(16.dp) + .padding(18.dp) ) { Row( modifier = Modifier.fillMaxWidth(), @@ -505,6 +509,7 @@ private fun AppCard( Icon( painter = painterResource(R.drawable.ic_manager), contentDescription = null, + tint = MaterialTheme.colorScheme.primary, modifier = Modifier.size(36.dp) ) Spacer(Modifier.width(12.dp)) @@ -521,7 +526,7 @@ private fun AppCard( Icon( imageVector = hideRestoreIcon, contentDescription = null, - modifier = Modifier.size(18.dp), + modifier = Modifier.size(20.dp), ) } } @@ -591,7 +596,8 @@ private fun StatusCard() { Card( modifier = Modifier.fillMaxWidth(), - shape = RoundedCornerShape(24.dp) + shape = RoundedCornerShape(24.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow), ) { Row( modifier = Modifier @@ -612,6 +618,7 @@ private fun StatusCard() { style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant ) + Spacer(Modifier.height(4.dp)) Text( text = info.status, style = MaterialTheme.typography.titleMedium, @@ -633,9 +640,10 @@ private fun StatusCard() { private fun SupportCard(onLinkClicked: (String) -> Unit) { Card( modifier = Modifier.fillMaxWidth(), - shape = RoundedCornerShape(24.dp) + shape = RoundedCornerShape(24.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow), ) { - Column(modifier = Modifier.padding(16.dp)) { + Column(modifier = Modifier.padding(18.dp)) { Text( text = stringResource(CoreR.string.home_support_content), style = MaterialTheme.typography.bodyMedium @@ -696,14 +704,15 @@ private val developers = listOf( private fun DevelopersCard(onLinkClicked: (String) -> Unit) { Card( modifier = Modifier.fillMaxWidth(), - shape = RoundedCornerShape(24.dp) + shape = RoundedCornerShape(24.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow), ) { Column { developers.forEachIndexed { index, dev -> Row( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp, vertical = 8.dp), + .padding(horizontal = 18.dp, vertical = 10.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.SpaceBetween ) { @@ -728,7 +737,7 @@ private fun DevelopersCard(onLinkClicked: (String) -> Unit) { if (index < developers.lastIndex) { HorizontalDivider( thickness = 0.5.dp, - modifier = Modifier.padding(horizontal = 16.dp) + modifier = Modifier.padding(horizontal = 18.dp) ) } } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/log/LogScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/log/LogScreen.kt index 033137681..fa9cb60d6 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/log/LogScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/log/LogScreen.kt @@ -17,11 +17,13 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Delete import androidx.compose.material.icons.filled.Download import androidx.compose.material3.Badge import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon @@ -219,8 +221,12 @@ private fun SuLogCard(log: SuLog) { } } - Card(modifier = Modifier.fillMaxWidth()) { - Column(modifier = Modifier.padding(12.dp)) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(16.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { + Column(modifier = Modifier.padding(14.dp)) { Row( modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.Top @@ -230,14 +236,15 @@ private fun SuLogCard(log: SuLog) { contentDescription = log.appName, modifier = Modifier.size(36.dp) ) - Spacer(Modifier.width(10.dp)) + Spacer(Modifier.width(12.dp)) Column(modifier = Modifier.weight(1f)) { Text( text = log.appName, - style = MaterialTheme.typography.bodyLarge, + style = MaterialTheme.typography.titleMedium, maxLines = 1, overflow = TextOverflow.Ellipsis, ) + Spacer(Modifier.height(2.dp)) Text( text = uidPidText, style = MaterialTheme.typography.bodyMedium, @@ -261,7 +268,7 @@ private fun SuLogCard(log: SuLog) { } if (details.isNotEmpty()) { - Spacer(Modifier.height(6.dp)) + Spacer(Modifier.height(8.dp)) Text( text = details, fontFamily = FontFamily.Monospace, @@ -282,7 +289,14 @@ private fun SuActionBadge(allowed: Boolean) { Badge( containerColor = bg, contentColor = fg, - ) { Text(text = text) } + ) { + Text( + text = text, + style = MaterialTheme.typography.labelSmall, + fontWeight = FontWeight.SemiBold, + modifier = Modifier.padding(horizontal = 2.dp) + ) + } } @Composable @@ -316,7 +330,7 @@ private fun MagiskLogTab( .verticalScrollbar(listState, contentPadding = PaddingValues(top = 8.dp, bottom = 88.dp)) .padding(horizontal = 12.dp), contentPadding = PaddingValues(top = 8.dp, bottom = 88.dp), - verticalArrangement = Arrangement.spacedBy(4.dp) + verticalArrangement = Arrangement.spacedBy(6.dp) ) { items(entries.size, key = { it }) { index -> MagiskLogCard(entries[index]) @@ -333,9 +347,11 @@ private fun MagiskLogCard(entry: MagiskLogEntry) { Card( modifier = Modifier .fillMaxWidth() - .clickable { expanded = !expanded } + .clickable { expanded = !expanded }, + shape = RoundedCornerShape(16.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) ) { - Column(modifier = Modifier.padding(12.dp)) { + Column(modifier = Modifier.padding(14.dp)) { if (entry.isParsed) { Row( modifier = Modifier.fillMaxWidth(), @@ -344,14 +360,14 @@ private fun MagiskLogCard(entry: MagiskLogEntry) { ) { Row( verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(6.dp), + horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.weight(1f) ) { LogLevelBadge(entry.level) Text( text = entry.tag, - style = MaterialTheme.typography.bodyLarge, - fontWeight = FontWeight.Normal, + style = MaterialTheme.typography.titleMedium, + fontWeight = FontWeight.SemiBold, maxLines = 1, overflow = TextOverflow.Ellipsis, ) @@ -365,7 +381,7 @@ private fun MagiskLogCard(entry: MagiskLogEntry) { maxLines = 1, ) } - Spacer(Modifier.height(4.dp)) + Spacer(Modifier.height(6.dp)) } Text( @@ -396,6 +412,11 @@ private fun LogLevelBadge(level: Char) { containerColor = bg, contentColor = fg, ) { - Text(text = level.toString()) + Text( + text = level.toString(), + style = MaterialTheme.typography.labelSmall, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(horizontal = 2.dp) + ) } } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/module/ModuleScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/module/ModuleScreen.kt index 6446fe6c8..210774ab6 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/module/ModuleScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/module/ModuleScreen.kt @@ -5,6 +5,8 @@ import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.animateContentSize +import androidx.compose.animation.core.Spring +import androidx.compose.animation.core.spring import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.foundation.clickable @@ -22,7 +24,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState -import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.automirrored.filled.Undo import androidx.compose.material.icons.filled.Add @@ -33,6 +35,7 @@ import androidx.compose.material3.AlertDialog import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.FilledTonalButton @@ -58,13 +61,17 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha +import androidx.compose.ui.draw.clip import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalResources +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.dp +import com.topjohnwu.magisk.R import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.di.ServiceLocator import com.topjohnwu.magisk.core.download.DownloadEngine @@ -142,7 +149,9 @@ fun ModuleScreen(viewModel: ModuleViewModel) { floatingActionButton = { FloatingActionButton( onClick = { filePicker.launch("application/zip") }, - shape = CircleShape, + shape = RoundedCornerShape(20.dp), + containerColor = MaterialTheme.colorScheme.primaryContainer, + contentColor = MaterialTheme.colorScheme.onPrimaryContainer, modifier = Modifier.padding(bottom = 88.dp, end = 20.dp), content = { Icon( @@ -173,11 +182,23 @@ fun ModuleScreen(viewModel: ModuleViewModel) { .padding(padding), contentAlignment = Alignment.Center ) { - Text( - text = stringResource(CoreR.string.module_empty), - style = MaterialTheme.typography.bodyLarge, - color = colorScheme.onSurfaceVariant - ) + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(12.dp), + modifier = Modifier.padding(horizontal = 32.dp) + ) { + Icon( + painter = painterResource(R.drawable.ic_module), + contentDescription = null, + tint = colorScheme.onSurfaceVariant.copy(alpha = 0.6f), + modifier = Modifier.size(64.dp) + ) + Text( + text = stringResource(CoreR.string.module_empty), + style = MaterialTheme.typography.bodyLarge, + color = colorScheme.onSurfaceVariant + ) + } } return@Scaffold } @@ -221,7 +242,12 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli val hasDescription = item.module.description.isNotBlank() Card( - modifier = Modifier.fillMaxWidth().clickable(enabled = hasDescription) { expanded = !expanded }, + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(20.dp)) + .clickable(enabled = hasDescription) { expanded = !expanded }, + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = colorScheme.surfaceContainerLow) ) { Column(modifier = Modifier.padding(16.dp)) { Column(modifier = Modifier.alpha(infoAlpha)) { @@ -230,161 +256,171 @@ private fun ModuleCard(item: ModuleItem, viewModel: ModuleViewModel, onUpdateCli horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically ) { - Column( - modifier = Modifier - .weight(1f) - .padding(end = 4.dp) - ) { - Text( - text = item.module.name, - style = MaterialTheme.typography.bodyLarge, - textDecoration = strikeThrough, - ) - Text( - text = stringResource( - CoreR.string.module_version_author, - item.module.version, - item.module.author - ), - style = MaterialTheme.typography.bodyMedium, - color = colorScheme.onSurfaceVariant, - textDecoration = strikeThrough, + Column( + modifier = Modifier + .weight(1f) + .padding(end = 4.dp) + ) { + Text( + text = item.module.name, + style = MaterialTheme.typography.titleMedium, + textDecoration = strikeThrough, + ) + Spacer(Modifier.height(2.dp)) + Text( + text = stringResource( + CoreR.string.module_version_author, + item.module.version, + item.module.author + ), + style = MaterialTheme.typography.bodyMedium, + color = colorScheme.onSurfaceVariant, + textDecoration = strikeThrough, + ) + } + Switch( + checked = item.isEnabled, + onCheckedChange = { viewModel.toggleEnabled(item) } ) } - Switch( - checked = item.isEnabled, - onCheckedChange = { viewModel.toggleEnabled(item) } - ) - } - if (hasDescription) { - Box( - modifier = Modifier - .padding(top = 2.dp) - .animateContentSize() - ) { + if (hasDescription) { + Box( + modifier = Modifier + .padding(top = 6.dp) + .animateContentSize( + animationSpec = spring( + dampingRatio = Spring.DampingRatioLowBouncy, + stiffness = Spring.StiffnessMedium + ) + ) + ) { + Text( + text = item.module.description, + style = MaterialTheme.typography.bodyMedium, + color = colorScheme.onSurfaceVariant, + textDecoration = strikeThrough, + overflow = if (expanded) TextOverflow.Clip else TextOverflow.Ellipsis, + maxLines = if (expanded) Int.MAX_VALUE else 3, + ) + } + } + + if (item.showNotice) { + Spacer(Modifier.height(6.dp)) Text( - text = item.module.description, + text = textHolder(item.noticeText), style = MaterialTheme.typography.bodyMedium, - color = colorScheme.onSurfaceVariant, - textDecoration = strikeThrough, - overflow = if (expanded) TextOverflow.Clip else TextOverflow.Ellipsis, - maxLines = if (expanded) Int.MAX_VALUE else 4, + fontWeight = FontWeight.Medium, + color = colorScheme.primary, ) } } - if (item.showNotice) { - Spacer(Modifier.height(4.dp)) - Text( - text = textHolder(item.noticeText), - style = MaterialTheme.typography.bodyMedium, - color = colorScheme.primary, - ) - } - } + HorizontalDivider( + modifier = Modifier.padding(vertical = 12.dp), + thickness = 0.5.dp, + ) - HorizontalDivider( - modifier = Modifier.padding(vertical = 8.dp), - thickness = 0.5.dp, - ) - - Row(verticalAlignment = Alignment.CenterVertically) { - AnimatedVisibility( - visible = item.isEnabled && !item.isRemoved, - enter = fadeIn(), - exit = fadeOut() - ) { - Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { - if (item.showAction) { - FilledTonalButton( - contentPadding = PaddingValues(horizontal = 10.dp), - onClick = { viewModel.runAction(item.module.id, item.module.name) }, - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(4.dp), + Row(verticalAlignment = Alignment.CenterVertically) { + AnimatedVisibility( + visible = item.isEnabled && !item.isRemoved, + enter = fadeIn(), + exit = fadeOut() + ) { + Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) { + if (item.showAction) { + FilledTonalButton( + shape = RoundedCornerShape(20.dp), + contentPadding = PaddingValues(horizontal = 14.dp, vertical = 8.dp), + onClick = { viewModel.runAction(item.module.id, item.module.name) }, ) { - Icon( - modifier = Modifier.size(20.dp), - imageVector = Icons.Default.PlayArrow, - contentDescription = stringResource(CoreR.string.module_action) - ) - Text( - text = stringResource(CoreR.string.module_action), - style = MaterialTheme.typography.bodyMedium, - ) + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(4.dp), + ) { + Icon( + modifier = Modifier.size(18.dp), + imageVector = Icons.Default.PlayArrow, + contentDescription = stringResource(CoreR.string.module_action) + ) + Text( + text = stringResource(CoreR.string.module_action), + style = MaterialTheme.typography.labelLarge, + ) + } } } } } - } - Spacer(Modifier.weight(1f)) + Spacer(Modifier.weight(1f)) + + AnimatedVisibility( + visible = item.showUpdate && item.updateReady, + enter = fadeIn(), + exit = fadeOut() + ) { + FilledTonalButton( + shape = RoundedCornerShape(20.dp), + modifier = Modifier.padding(end = 8.dp), + colors = ButtonDefaults.filledTonalButtonColors( + containerColor = colorScheme.tertiaryContainer, + contentColor = colorScheme.onTertiaryContainer + ), + contentPadding = PaddingValues(horizontal = 14.dp, vertical = 8.dp), + onClick = { onUpdateClick(item.module.updateInfo) }, + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.spacedBy(4.dp), + ) { + Icon( + modifier = Modifier.size(18.dp), + imageVector = Icons.Default.CloudUpload, + contentDescription = stringResource(CoreR.string.update), + ) + Text( + text = stringResource(CoreR.string.update), + style = MaterialTheme.typography.labelLarge, + ) + } + } + } - AnimatedVisibility( - visible = item.showUpdate && item.updateReady, - enter = fadeIn(), - exit = fadeOut() - ) { FilledTonalButton( - modifier = Modifier.padding(end = 8.dp), - colors = ButtonDefaults.filledTonalButtonColors( - containerColor = colorScheme.tertiaryContainer, - contentColor = colorScheme.onTertiaryContainer - ), - contentPadding = PaddingValues(horizontal = 10.dp), - onClick = { onUpdateClick(item.module.updateInfo) }, + shape = RoundedCornerShape(20.dp), + colors = if (item.isRemoved) { + ButtonDefaults.filledTonalButtonColors() + } else { + ButtonDefaults.filledTonalButtonColors( + containerColor = colorScheme.errorContainer, + contentColor = colorScheme.onErrorContainer + ) + }, + contentPadding = PaddingValues(horizontal = 14.dp, vertical = 8.dp), + onClick = { viewModel.toggleRemove(item) }, + enabled = !item.isUpdated ) { Row( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp), ) { Icon( - modifier = Modifier.size(20.dp), - imageVector = Icons.Default.CloudUpload, - contentDescription = stringResource(CoreR.string.update), + modifier = Modifier.size(18.dp), + imageVector = if (item.isRemoved) Icons.AutoMirrored.Filled.Undo else Icons.Default.Delete, + contentDescription = null ) Text( - text = stringResource(CoreR.string.update), - style = MaterialTheme.typography.bodyMedium, + text = stringResource( + if (item.isRemoved) CoreR.string.module_state_restore + else CoreR.string.module_state_remove + ), + style = MaterialTheme.typography.labelLarge, ) } } } - - 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 - ) { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.spacedBy(4.dp), - ) { - Icon( - modifier = Modifier.size(20.dp), - imageVector = if (item.isRemoved) Icons.AutoMirrored.Filled.Undo else Icons.Default.Delete, - contentDescription = null - ) - Text( - text = stringResource( - if (item.isRemoved) CoreR.string.module_state_restore - else CoreR.string.module_state_remove - ), - style = MaterialTheme.typography.bodyMedium, - ) - } - } - } } } } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt index f41dbc8c8..c4ae7fd44 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt @@ -9,10 +9,13 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll import androidx.compose.material3.AlertDialog import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.Scaffold import androidx.compose.material3.Text @@ -93,7 +96,11 @@ private fun CustomizationSection(viewModel: SettingsViewModel) { val context = LocalContext.current SmallTitle(text = stringResource(CoreR.string.settings_customization)) - Card(modifier = Modifier.fillMaxWidth()) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { if (LocaleSetting.useLocaleManager) { val locale = LocaleSetting.instance.appLocale val summary = locale?.getDisplayName(locale) ?: stringResource(CoreR.string.system_default) @@ -156,7 +163,11 @@ private fun AppSettingsSection() { val resources = LocalResources.current SmallTitle(text = stringResource(CoreR.string.home_app_title)) - Card(modifier = Modifier.fillMaxWidth()) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { // Update Channel val updateChannelEntries = remember { resources.getStringArray(CoreR.array.update_channel).toList() @@ -250,7 +261,11 @@ private fun AppSettingsSection() { @Composable private fun MagiskSection(viewModel: SettingsViewModel) { SmallTitle(text = stringResource(CoreR.string.magisk)) - Card(modifier = Modifier.fillMaxWidth()) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { // Systemless Hosts SettingsArrow( title = stringResource(CoreR.string.settings_hosts_title), @@ -302,7 +317,11 @@ private fun SuperuserSection(viewModel: SettingsViewModel) { val resources = LocalResources.current SmallTitle(text = stringResource(CoreR.string.superuser)) - Card(modifier = Modifier.fillMaxWidth()) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { // Tapjack (SDK < S) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) { var tapjack by remember { mutableStateOf(Config.suTapjack) } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserDetailScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserDetailScreen.kt index 87d686de8..86d9e8d8e 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserDetailScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserDetailScreen.kt @@ -1,12 +1,14 @@ package com.topjohnwu.magisk.ui.superuser import androidx.compose.foundation.Image +import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width @@ -19,6 +21,7 @@ import androidx.compose.material.icons.filled.Cancel import androidx.compose.material3.Button import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton @@ -37,7 +40,6 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp -import androidx.compose.ui.unit.sp import com.google.accompanist.drawablepainter.rememberDrawablePainter import com.topjohnwu.magisk.ui.component.ConfirmResult import com.topjohnwu.magisk.ui.component.SettingsSwitch @@ -94,11 +96,16 @@ fun SuperuserDetailScreen( .verticalScrollbar(scrollState, contentPadding = PaddingValues(bottom = 88.dp)) .verticalScroll(scrollState) .padding(horizontal = 12.dp) - .padding(bottom = 88.dp) + .padding(bottom = 88.dp), + verticalArrangement = Arrangement.spacedBy(12.dp) ) { - Card(modifier = Modifier.fillMaxWidth()) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(24.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { Row( - modifier = Modifier.padding(16.dp), + modifier = Modifier.padding(18.dp), verticalAlignment = Alignment.CenterVertically ) { Image( @@ -119,6 +126,7 @@ fun SuperuserDetailScreen( SharedUidBadge() } } + Spacer(Modifier.height(2.dp)) Text( text = item.packageName, style = MaterialTheme.typography.bodyMedium, @@ -133,23 +141,29 @@ fun SuperuserDetailScreen( } } - if (uiState.suRestrict || item.isRestricted) { + Card( + modifier = Modifier.fillMaxWidth(), + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) + ) { + if (uiState.suRestrict || item.isRestricted) { + SettingsSwitch( + title = stringResource(CoreR.string.settings_su_restrict_title), + checked = item.isRestricted, + onCheckedChange = { viewModel.toggleRestrict(item) } + ) + } SettingsSwitch( - title = stringResource(CoreR.string.settings_su_restrict_title), - checked = item.isRestricted, - onCheckedChange = { viewModel.toggleRestrict(item) } + title = stringResource(CoreR.string.superuser_toggle_notification), + checked = item.notification, + onCheckedChange = { viewModel.updateNotify(item) } + ) + SettingsSwitch( + title = stringResource(CoreR.string.logs), + checked = item.logging, + onCheckedChange = { viewModel.updateLogging(item) } ) } - SettingsSwitch( - title = stringResource(CoreR.string.superuser_toggle_notification), - checked = item.notification, - onCheckedChange = { viewModel.updateNotify(item) } - ) - SettingsSwitch( - title = stringResource(CoreR.string.logs), - checked = item.logging, - onCheckedChange = { viewModel.updateLogging(item) } - ) RevokeButton { if (viewModel.requiresAuth) { @@ -180,7 +194,8 @@ private fun RevokeButton( containerColor = MaterialTheme.colorScheme.errorContainer, contentColor = MaterialTheme.colorScheme.onErrorContainer ), - shape = RoundedCornerShape(16.dp), + shape = RoundedCornerShape(20.dp), + contentPadding = PaddingValues(vertical = 12.dp), modifier = Modifier.fillMaxWidth() ) { Icon( @@ -191,7 +206,7 @@ private fun RevokeButton( Spacer(Modifier.width(8.dp)) Text( text = stringResource(CoreR.string.superuser_toggle_revoke), - fontSize = 16.sp + style = MaterialTheme.typography.labelLarge, ) } } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserScreen.kt index a631c221d..d7dc61cd7 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/superuser/SuperuserScreen.kt @@ -20,10 +20,13 @@ import androidx.compose.foundation.layout.width import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Badge import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.Switch @@ -36,8 +39,11 @@ import androidx.compose.runtime.getValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.alpha +import androidx.compose.ui.draw.clip import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.google.accompanist.drawablepainter.rememberDrawablePainter import com.topjohnwu.magisk.ui.component.verticalScrollbar @@ -79,11 +85,23 @@ fun SuperuserScreen(viewModel: SuperuserViewModel) { .padding(padding), contentAlignment = Alignment.Center ) { - Text( - text = stringResource(CoreR.string.superuser_policy_none), - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurfaceVariant - ) + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(12.dp), + modifier = Modifier.padding(horizontal = 32.dp) + ) { + Icon( + painter = painterResource(CoreR.drawable.ic_superuser), + contentDescription = null, + tint = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.6f), + modifier = Modifier.size(64.dp) + ) + Text( + text = stringResource(CoreR.string.superuser_policy_none), + style = MaterialTheme.typography.bodyLarge, + color = MaterialTheme.colorScheme.onSurfaceVariant + ) + } } return@Scaffold } @@ -122,7 +140,10 @@ private fun PolicyCard( Card( modifier = Modifier .fillMaxWidth() - .alpha(if (item.isEnabled) 1f else 0.5f) + .clip(RoundedCornerShape(20.dp)) + .alpha(if (item.isEnabled) 1f else 0.5f), + shape = RoundedCornerShape(20.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerLow) ) { Row( modifier = Modifier @@ -147,7 +168,7 @@ private fun PolicyCard( Row(verticalAlignment = Alignment.CenterVertically) { Text( text = item.title, - style = MaterialTheme.typography.bodyLarge, + style = MaterialTheme.typography.titleMedium, modifier = Modifier.weight(1f, fill = false), ) if (item.isSharedUid) { @@ -155,6 +176,7 @@ private fun PolicyCard( SharedUidBadge() } } + Spacer(Modifier.height(2.dp)) Text( text = item.packageName, style = MaterialTheme.typography.bodyMedium, @@ -193,6 +215,11 @@ internal fun SharedUidBadge(modifier: Modifier = Modifier) { containerColor = MaterialTheme.colorScheme.secondaryContainer, contentColor = MaterialTheme.colorScheme.onSecondaryContainer, ) { - Text(stringResource(CoreR.string.shared_uid)) + Text( + text = stringResource(CoreR.string.shared_uid), + style = MaterialTheme.typography.labelSmall, + fontWeight = FontWeight.SemiBold, + modifier = Modifier.padding(horizontal = 2.dp) + ) } } diff --git a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestScreen.kt b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestScreen.kt index d2cf00046..76fcb8295 100644 --- a/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestScreen.kt +++ b/app/apk-ng/src/main/java/com/topjohnwu/magisk/ui/surequest/SuRequestScreen.kt @@ -3,9 +3,11 @@ package com.topjohnwu.magisk.ui.surequest import android.view.MotionEvent import android.widget.Toast import androidx.compose.foundation.Image +import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxSize @@ -15,8 +17,10 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.widthIn +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Button import androidx.compose.material3.Card +import androidx.compose.material3.CardDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.OutlinedButton import androidx.compose.material3.Slider @@ -28,6 +32,7 @@ import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip import androidx.compose.ui.input.pointer.pointerInteropFilter import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringArrayResource @@ -79,29 +84,31 @@ fun SuRequestScreen(viewModel: SuRequestViewModel) { Card( modifier = Modifier .widthIn(min = 320.dp, max = 420.dp) - .padding(24.dp) + .padding(24.dp), + shape = RoundedCornerShape(28.dp), + colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceContainerHigh) ) { Column( - modifier = Modifier.padding(20.dp), + modifier = Modifier.padding(24.dp), horizontalAlignment = Alignment.CenterHorizontally ) { Row( verticalAlignment = Alignment.CenterVertically, - modifier = Modifier.padding(horizontal = 8.dp) + modifier = Modifier.padding(horizontal = 4.dp) ) { if (icon != null) { Image( painter = rememberDrawablePainter(icon), contentDescription = null, - modifier = Modifier.size(40.dp) + modifier = Modifier.size(44.dp) ) - Spacer(Modifier.width(12.dp)) + Spacer(Modifier.width(14.dp)) } Column { Row(verticalAlignment = Alignment.CenterVertically) { Text( text = title, - style = MaterialTheme.typography.bodyLarge, + style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.Bold, maxLines = 1, overflow = TextOverflow.Ellipsis, @@ -112,6 +119,7 @@ fun SuRequestScreen(viewModel: SuRequestViewModel) { SharedUidBadge() } } + Spacer(Modifier.height(2.dp)) Text( text = packageName, style = MaterialTheme.typography.bodyMedium, @@ -124,13 +132,22 @@ fun SuRequestScreen(viewModel: SuRequestViewModel) { Spacer(Modifier.height(16.dp)) - Text( - text = stringResource(CoreR.string.su_warning), - style = MaterialTheme.typography.bodyMedium, - color = MaterialTheme.colorScheme.error, - fontWeight = FontWeight.Bold, - textAlign = TextAlign.Center, - ) + Box( + modifier = Modifier + .fillMaxWidth() + .clip(RoundedCornerShape(12.dp)) + .background(MaterialTheme.colorScheme.errorContainer) + .padding(12.dp) + ) { + Text( + text = stringResource(CoreR.string.su_warning), + style = MaterialTheme.typography.bodySmall, + color = MaterialTheme.colorScheme.onErrorContainer, + fontWeight = FontWeight.Medium, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth() + ) + } Spacer(Modifier.height(16.dp)) @@ -138,7 +155,7 @@ fun SuRequestScreen(viewModel: SuRequestViewModel) { text = "${stringResource(CoreR.string.request_timeout)}: $sliderLabel", style = MaterialTheme.typography.bodyMedium, color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.fillMaxWidth().padding(start = 8.dp), + modifier = Modifier.fillMaxWidth().padding(start = 4.dp), ) Spacer(Modifier.height(8.dp)) Slider( @@ -150,23 +167,30 @@ fun SuRequestScreen(viewModel: SuRequestViewModel) { }, valueRange = 0f..5f, steps = 4, - modifier = Modifier.fillMaxWidth().padding(horizontal = 4.dp) + modifier = Modifier.fillMaxWidth() ) - Spacer(Modifier.height(16.dp)) + Spacer(Modifier.height(20.dp)) Row( modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.spacedBy(8.dp) + horizontalArrangement = Arrangement.spacedBy(10.dp) ) { OutlinedButton( onClick = { viewModel.denyPressed() }, + shape = RoundedCornerShape(20.dp), + contentPadding = PaddingValues(vertical = 12.dp), modifier = Modifier.weight(1f), ) { - Text(denyText) + Text( + text = denyText, + style = MaterialTheme.typography.labelLarge, + ) } Button( enabled = grantEnabled, onClick = { viewModel.grantPressed() }, + shape = RoundedCornerShape(20.dp), + contentPadding = PaddingValues(vertical = 12.dp), modifier = Modifier .weight(1f) .then( @@ -189,7 +213,10 @@ fun SuRequestScreen(viewModel: SuRequestViewModel) { } else Modifier ) ) { - Text(stringResource(CoreR.string.grant)) + Text( + text = stringResource(CoreR.string.grant), + style = MaterialTheme.typography.labelLarge, + ) } } }