Skip to content

Commit be8a67a

Browse files
Copilotyujincheng08
andcommitted
Fix miuix API usage based on KernelSU reference implementation
- Update compose-bom to 2026.01.01 (per KernelSU) - Update lifecycle versions to 2.10.0 - Use miuix-android and miuix-icons-android artifacts (Android-specific) - Add material-icons-extended dependency for ImageVector icons - Fix MiuixTheme call to use ThemeController(ColorSchemeMode.System) - Fix NavigationBar to use correct miuix API (NavigationBarItem with icon: ImageVector and label: String, not composable lambdas) - Fix Scaffold to use bottomBar instead of navigationBar parameter - Consolidate Settings to a nav bar tab (remove onNavigateToSettings) - Use Material Icons (Rounded.Home/Security/Extension/BugReport/Settings) instead of drawable resources for nav bar icons - Fix SettingsScreen: remove SmallTitle (not in miuix), replace with custom SectionTitle using Text; fix Zygisk.mismatch reference to use Config.zygisk != Info.isZygiskEnabled; fix DenyList.value assignment to use Config.denyList directly Co-authored-by: yujincheng08 <5022927+yujincheng08@users.noreply.github.com>
1 parent 7d71399 commit be8a67a

6 files changed

Lines changed: 56 additions & 104 deletions

File tree

app/apk/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ dependencies {
6565
implementation(libs.compose.ui.tooling.preview)
6666
implementation(libs.compose.foundation)
6767
implementation(libs.compose.material3)
68+
implementation(libs.compose.material.icons.extended)
6869
implementation(libs.activity.compose)
6970
implementation(libs.lifecycle.viewmodel.compose)
7071
implementation(libs.lifecycle.runtime.compose)
7172
implementation(libs.miuix)
73+
implementation(libs.miuix.icons)
7274

7375
// Make sure kapt runs with a proper kotlin-stdlib
7476
kapt(kotlin("stdlib"))

app/apk/src/main/java/com/topjohnwu/magisk/ui/compose/MagiskApp.kt

Lines changed: 25 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
package com.topjohnwu.magisk.ui.compose
22

3-
import androidx.compose.foundation.layout.PaddingValues
3+
import androidx.compose.material.icons.Icons
4+
import androidx.compose.material.icons.rounded.BugReport
5+
import androidx.compose.material.icons.rounded.Extension
6+
import androidx.compose.material.icons.rounded.Home
7+
import androidx.compose.material.icons.rounded.Security
8+
import androidx.compose.material.icons.rounded.Settings
49
import androidx.compose.runtime.Composable
510
import androidx.compose.runtime.getValue
611
import androidx.compose.runtime.mutableStateOf
712
import androidx.compose.runtime.remember
813
import androidx.compose.runtime.setValue
9-
import androidx.compose.ui.res.painterResource
1014
import androidx.compose.ui.res.stringResource
11-
import com.topjohnwu.magisk.R
1215
import com.topjohnwu.magisk.core.Info
1316
import com.topjohnwu.magisk.ui.home.HomeScreen
1417
import com.topjohnwu.magisk.ui.log.LogScreen
1518
import com.topjohnwu.magisk.ui.module.ModulesScreen
1619
import com.topjohnwu.magisk.ui.settings.SettingsScreen
1720
import com.topjohnwu.magisk.ui.superuser.SuperuserScreen
18-
import top.yukonga.miuix.kmp.basic.Icon
19-
import top.yukonga.miuix.kmp.basic.IconButton
2021
import top.yukonga.miuix.kmp.basic.NavigationBar
2122
import top.yukonga.miuix.kmp.basic.NavigationBarItem
2223
import top.yukonga.miuix.kmp.basic.Scaffold
23-
import top.yukonga.miuix.kmp.basic.Text
24-
import top.yukonga.miuix.kmp.basic.TopAppBar
2524
import com.topjohnwu.magisk.core.R as CoreR
2625

2726
enum class MainScreen { HOME, MODULES, SUPERUSER, LOG, SETTINGS }
@@ -44,31 +43,7 @@ fun MagiskApp(initialSection: String? = null) {
4443

4544
MagiskTheme {
4645
Scaffold(
47-
topBar = {
48-
TopAppBar(
49-
title = when (currentScreen) {
50-
MainScreen.HOME -> stringResource(CoreR.string.section_home)
51-
MainScreen.MODULES -> stringResource(CoreR.string.modules)
52-
MainScreen.SUPERUSER -> stringResource(CoreR.string.superuser)
53-
MainScreen.LOG -> stringResource(CoreR.string.logs)
54-
MainScreen.SETTINGS -> stringResource(CoreR.string.settings)
55-
},
56-
navigationIcon = if (currentScreen == MainScreen.SETTINGS) {
57-
{
58-
IconButton(onClick = {
59-
currentScreen = navBackStack.lastOrNull() ?: MainScreen.HOME
60-
navBackStack = navBackStack.dropLast(1)
61-
}) {
62-
Icon(
63-
painter = painterResource(R.drawable.ic_back_md2),
64-
contentDescription = null
65-
)
66-
}
67-
}
68-
} else null
69-
)
70-
},
71-
navigationBar = {
46+
bottomBar = {
7247
if (isRootScreen) {
7348
NavigationBar {
7449
NavigationBarItem(
@@ -77,17 +52,8 @@ fun MagiskApp(initialSection: String? = null) {
7752
currentScreen = MainScreen.HOME
7853
navBackStack = emptyList()
7954
},
80-
icon = {
81-
Icon(
82-
painter = painterResource(
83-
if (currentScreen == MainScreen.HOME)
84-
R.drawable.ic_home_filled_md2
85-
else R.drawable.ic_home_outlined_md2
86-
),
87-
contentDescription = null
88-
)
89-
},
90-
label = { Text(stringResource(CoreR.string.section_home)) }
55+
icon = Icons.Rounded.Home,
56+
label = stringResource(CoreR.string.section_home)
9157
)
9258
NavigationBarItem(
9359
selected = currentScreen == MainScreen.MODULES,
@@ -96,17 +62,8 @@ fun MagiskApp(initialSection: String? = null) {
9662
currentScreen = MainScreen.MODULES
9763
navBackStack = emptyList()
9864
},
99-
icon = {
100-
Icon(
101-
painter = painterResource(
102-
if (currentScreen == MainScreen.MODULES)
103-
R.drawable.ic_module_filled_md2
104-
else R.drawable.ic_module_outlined_md2
105-
),
106-
contentDescription = null
107-
)
108-
},
109-
label = { Text(stringResource(CoreR.string.modules)) }
65+
icon = Icons.Rounded.Extension,
66+
label = stringResource(CoreR.string.modules)
11067
)
11168
NavigationBarItem(
11269
selected = currentScreen == MainScreen.SUPERUSER,
@@ -115,56 +72,39 @@ fun MagiskApp(initialSection: String? = null) {
11572
currentScreen = MainScreen.SUPERUSER
11673
navBackStack = emptyList()
11774
},
118-
icon = {
119-
Icon(
120-
painter = painterResource(
121-
if (currentScreen == MainScreen.SUPERUSER)
122-
R.drawable.ic_superuser_filled_md2
123-
else R.drawable.ic_superuser_outlined_md2
124-
),
125-
contentDescription = null
126-
)
127-
},
128-
label = { Text(stringResource(CoreR.string.superuser)) }
75+
icon = Icons.Rounded.Security,
76+
label = stringResource(CoreR.string.superuser)
12977
)
13078
NavigationBarItem(
13179
selected = currentScreen == MainScreen.LOG,
13280
onClick = {
13381
currentScreen = MainScreen.LOG
13482
navBackStack = emptyList()
13583
},
136-
icon = {
137-
Icon(
138-
painter = painterResource(
139-
if (currentScreen == MainScreen.LOG)
140-
R.drawable.ic_bug_filled_md2
141-
else R.drawable.ic_bug_outlined_md2
142-
),
143-
contentDescription = null
144-
)
84+
icon = Icons.Rounded.BugReport,
85+
label = stringResource(CoreR.string.logs)
86+
)
87+
NavigationBarItem(
88+
selected = currentScreen == MainScreen.SETTINGS,
89+
onClick = {
90+
navBackStack = navBackStack + MainScreen.HOME
91+
currentScreen = MainScreen.SETTINGS
14592
},
146-
label = { Text(stringResource(CoreR.string.logs)) }
93+
icon = Icons.Rounded.Settings,
94+
label = stringResource(CoreR.string.settings)
14795
)
14896
}
14997
}
15098
}
15199
) { paddingValues ->
152100
when (currentScreen) {
153-
MainScreen.HOME -> HomeScreen(
154-
paddingValues = paddingValues,
155-
onNavigateToSettings = {
156-
navBackStack = navBackStack + MainScreen.HOME
157-
currentScreen = MainScreen.SETTINGS
158-
}
159-
)
101+
MainScreen.HOME -> HomeScreen(paddingValues = paddingValues)
160102
MainScreen.MODULES -> ModulesScreen(paddingValues = paddingValues)
161103
MainScreen.SUPERUSER -> SuperuserScreen(paddingValues = paddingValues)
162104
MainScreen.LOG -> LogScreen(paddingValues = paddingValues)
163105
MainScreen.SETTINGS -> SettingsScreen(
164106
paddingValues = paddingValues,
165-
onNavigateToDenyList = {
166-
// DenyList config is handled via Fragment (existing)
167-
}
107+
onNavigateToDenyList = { }
168108
)
169109
}
170110
}

app/apk/src/main/java/com/topjohnwu/magisk/ui/compose/MagiskTheme.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package com.topjohnwu.magisk.ui.compose
33
import androidx.compose.runtime.Composable
44
import top.yukonga.miuix.kmp.theme.ColorSchemeMode
55
import top.yukonga.miuix.kmp.theme.MiuixTheme
6+
import top.yukonga.miuix.kmp.theme.ThemeController
67

78
@Composable
89
fun MagiskTheme(content: @Composable () -> Unit) {
910
MiuixTheme(
10-
colorSchemeMode = ColorSchemeMode.System,
11+
controller = ThemeController(ColorSchemeMode.System),
1112
content = content
1213
)
1314
}

app/apk/src/main/java/com/topjohnwu/magisk/ui/home/HomeScreen.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,12 @@ import com.topjohnwu.magisk.core.Info
2222
import top.yukonga.miuix.kmp.basic.Button
2323
import top.yukonga.miuix.kmp.basic.Card
2424
import top.yukonga.miuix.kmp.basic.Text
25-
import top.yukonga.miuix.kmp.extra.SuperArrow
2625
import top.yukonga.miuix.kmp.theme.MiuixTheme
2726
import com.topjohnwu.magisk.core.R as CoreR
2827

2928
@Composable
3029
fun HomeScreen(
3130
paddingValues: PaddingValues,
32-
onNavigateToSettings: () -> Unit,
3331
vm: HomeViewModel = viewModel(factory = VMFactory)
3432
) {
3533
val appState by vm.appStateFlow.collectAsStateWithLifecycle()
@@ -140,11 +138,6 @@ fun HomeScreen(
140138

141139
Spacer(modifier = Modifier.height(8.dp))
142140

143-
SuperArrow(
144-
title = stringResource(CoreR.string.settings),
145-
onClick = onNavigateToSettings
146-
)
147-
148141
Spacer(modifier = Modifier.height(16.dp))
149142
}
150143
}

app/apk/src/main/java/com/topjohnwu/magisk/ui/settings/SettingsScreen.kt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ import androidx.compose.runtime.remember
1515
import androidx.compose.runtime.setValue
1616
import androidx.compose.ui.Modifier
1717
import androidx.compose.ui.res.stringResource
18+
import androidx.compose.ui.text.font.FontWeight
1819
import androidx.compose.ui.unit.dp
20+
import androidx.compose.ui.unit.sp
1921
import androidx.lifecycle.viewmodel.compose.viewModel
2022
import com.topjohnwu.magisk.arch.VMFactory
2123
import com.topjohnwu.magisk.core.Config
2224
import com.topjohnwu.magisk.core.Const
2325
import com.topjohnwu.magisk.core.Info
24-
import top.yukonga.miuix.kmp.basic.SmallTitle
26+
import top.yukonga.miuix.kmp.basic.Text
2527
import top.yukonga.miuix.kmp.extra.SuperArrow
2628
import top.yukonga.miuix.kmp.extra.SuperSwitch
29+
import top.yukonga.miuix.kmp.theme.MiuixTheme
2730
import com.topjohnwu.magisk.core.R as CoreR
2831

2932
@Composable
@@ -41,7 +44,7 @@ fun SettingsScreen(
4144
Spacer(modifier = Modifier.height(8.dp))
4245

4346
// --- Customization ---
44-
SmallTitle(text = stringResource(CoreR.string.settings_customization))
47+
SectionTitle(stringResource(CoreR.string.settings_customization))
4548

4649
SuperArrow(
4750
title = stringResource(CoreR.string.section_theme),
@@ -51,7 +54,7 @@ fun SettingsScreen(
5154
Spacer(modifier = Modifier.height(8.dp))
5255

5356
// --- App Settings ---
54-
SmallTitle(text = stringResource(CoreR.string.home_app_title))
57+
SectionTitle(stringResource(CoreR.string.home_app_title))
5558

5659
var checkUpdate by remember { mutableStateOf(Config.checkUpdate) }
5760
SuperSwitch(
@@ -90,7 +93,7 @@ fun SettingsScreen(
9093

9194
// --- Magisk ---
9295
if (Info.env.isActive) {
93-
SmallTitle(text = stringResource(CoreR.string.magisk))
96+
SectionTitle(stringResource(CoreR.string.magisk))
9497

9598
SuperArrow(
9699
title = stringResource(CoreR.string.settings_hosts_title),
@@ -103,7 +106,7 @@ fun SettingsScreen(
103106
SuperSwitch(
104107
title = stringResource(CoreR.string.zygisk),
105108
summary = stringResource(
106-
if (Zygisk.mismatch) CoreR.string.reboot_apply_change
109+
if (Config.zygisk != Info.isZygiskEnabled) CoreR.string.reboot_apply_change
107110
else CoreR.string.settings_zygisk_summary
108111
),
109112
checked = zygisk,
@@ -120,7 +123,7 @@ fun SettingsScreen(
120123
checked = denyListEnabled,
121124
onCheckedChange = { checked ->
122125
denyListEnabled = checked
123-
DenyList.value = checked
126+
Config.denyList = checked
124127
}
125128
)
126129

@@ -136,7 +139,7 @@ fun SettingsScreen(
136139

137140
// --- Superuser ---
138141
if (Info.showSuperUser) {
139-
SmallTitle(text = stringResource(CoreR.string.superuser))
142+
SectionTitle(stringResource(CoreR.string.superuser))
140143

141144
var suAuth by remember { mutableStateOf(Config.suAuth) }
142145
SuperSwitch(
@@ -159,3 +162,14 @@ fun SettingsScreen(
159162
Spacer(modifier = Modifier.height(16.dp))
160163
}
161164
}
165+
166+
@Composable
167+
private fun SectionTitle(text: String) {
168+
Text(
169+
text = text,
170+
modifier = Modifier.padding(start = 28.dp, top = 8.dp, bottom = 4.dp, end = 16.dp),
171+
color = MiuixTheme.colorScheme.onSurfaceVariantSummary,
172+
fontSize = 14.sp,
173+
fontWeight = FontWeight.Medium
174+
)
175+
}

app/gradle/libs.versions.toml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ libsu = "6.0.0"
88
okhttp = "5.3.2"
99
retrofit = "3.0.0"
1010
room = "2.8.4"
11-
compose-bom = "2024.12.01"
11+
compose-bom = "2026.01.01"
1212
miuix = "0.8.4"
1313

1414
[libraries]
@@ -73,8 +73,10 @@ compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview"
7373
compose-foundation = { module = "androidx.compose.foundation:foundation" }
7474
compose-material3 = { module = "androidx.compose.material3:material3" }
7575
activity-compose = { module = "androidx.activity:activity-compose", version = "1.12.4" }
76-
lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version = "2.8.7" }
77-
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version = "2.8.7" }
78-
miuix = { module = "top.yukonga.miuix.kmp:miuix", version.ref = "miuix" }
76+
lifecycle-viewmodel-compose = { module = "androidx.lifecycle:lifecycle-viewmodel-compose", version = "2.10.0" }
77+
lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version = "2.10.0" }
78+
miuix = { module = "top.yukonga.miuix.kmp:miuix-android", version.ref = "miuix" }
79+
miuix-icons = { module = "top.yukonga.miuix.kmp:miuix-icons-android", version.ref = "miuix" }
80+
compose-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }
7981

8082
[plugins]

0 commit comments

Comments
 (0)