manager: Simplify state management of components for installation method selection

Remove unnecessary LKM upload logic
This commit is contained in:
ShirkNeko
2025-06-03 16:57:41 +08:00
parent 17288c086a
commit 6375bf4b7c

View File

@@ -193,21 +193,6 @@ fun InstallScreen(navigator: DestinationsNavigator) {
} }
} }
val selectLkmLauncher = rememberLauncherForActivityResult(
contract = ActivityResultContracts.StartActivityForResult()
) {
if (it.resultCode == Activity.RESULT_OK) {
it.data?.data?.let { uri ->
lkmSelection = LkmSelection.LkmUri(uri)
}
}
}
val onLkmUpload = {
selectLkmLauncher.launch(Intent(Intent.ACTION_GET_CONTENT).apply {
type = "application/octet-stream"
})
}
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
@@ -215,7 +200,6 @@ fun InstallScreen(navigator: DestinationsNavigator) {
topBar = { topBar = {
TopBar( TopBar(
onBack = { navigator.popBackStack() }, onBack = { navigator.popBackStack() },
onLkmUpload = onLkmUpload,
scrollBehavior = scrollBehavior scrollBehavior = scrollBehavior
) )
}, },
@@ -232,7 +216,6 @@ fun InstallScreen(navigator: DestinationsNavigator) {
) { ) {
SelectInstallMethod( SelectInstallMethod(
isGKI = isGKI, isGKI = isGKI,
isAbDevice = isAbDevice,
onSelected = { method -> onSelected = { method ->
if (method is InstallMethod.HorizonKernel && method.uri != null) { if (method is InstallMethod.HorizonKernel && method.uri != null) {
if (isAbDevice) { if (isAbDevice) {
@@ -383,7 +366,6 @@ sealed class InstallMethod {
@Composable @Composable
private fun SelectInstallMethod( private fun SelectInstallMethod(
isGKI: Boolean = false, isGKI: Boolean = false,
isAbDevice: Boolean = false,
onSelected: (InstallMethod) -> Unit = {} onSelected: (InstallMethod) -> Unit = {}
) { ) {
val rootAvailable = rootAvailable() val rootAvailable = rootAvailable()
@@ -470,8 +452,8 @@ private fun SelectInstallMethod(
} }
} }
var LKMExpanded by remember { mutableStateOf(false) } var lkmExpanded by remember { mutableStateOf(false) }
var GKIExpanded by remember { mutableStateOf(false) } var gkiExpanded by remember { mutableStateOf(false) }
Column( Column(
modifier = Modifier.padding(horizontal = 16.dp) modifier = Modifier.padding(horizontal = 16.dp)
@@ -483,17 +465,12 @@ private fun SelectInstallMethod(
elevation = getCardElevation(), elevation = getCardElevation(),
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.padding(bottom = 12.dp) .padding(bottom = 16.dp)
.clip(MaterialTheme.shapes.large) .clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.1f)
)
) { ) {
MaterialTheme( MaterialTheme(
colorScheme = MaterialTheme.colorScheme.copy( colorScheme = MaterialTheme.colorScheme.copy(
surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else MaterialTheme.colorScheme.surfaceContainerHigh surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else MaterialTheme.colorScheme.surfaceVariant
) )
) { ) {
ListItem( ListItem(
@@ -511,13 +488,13 @@ private fun SelectInstallMethod(
) )
}, },
modifier = Modifier.clickable { modifier = Modifier.clickable {
LKMExpanded = !LKMExpanded lkmExpanded = !lkmExpanded
} }
) )
} }
AnimatedVisibility( AnimatedVisibility(
visible = LKMExpanded, visible = lkmExpanded,
enter = fadeIn() + expandVertically(), enter = fadeIn() + expandVertically(),
exit = shrinkVertically() + fadeOut() exit = shrinkVertically() + fadeOut()
) { ) {
@@ -597,15 +574,10 @@ private fun SelectInstallMethod(
.fillMaxWidth() .fillMaxWidth()
.padding(bottom = 12.dp) .padding(bottom = 12.dp)
.clip(MaterialTheme.shapes.large) .clip(MaterialTheme.shapes.large)
.shadow(
elevation = cardElevation,
shape = MaterialTheme.shapes.large,
spotColor = MaterialTheme.colorScheme.primary.copy(alpha = 0.1f)
)
) { ) {
MaterialTheme( MaterialTheme(
colorScheme = MaterialTheme.colorScheme.copy( colorScheme = MaterialTheme.colorScheme.copy(
surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else MaterialTheme.colorScheme.surfaceContainerHigh surface = if (CardConfig.isCustomBackgroundEnabled) Color.Transparent else MaterialTheme.colorScheme.surfaceVariant
) )
) { ) {
ListItem( ListItem(
@@ -623,13 +595,13 @@ private fun SelectInstallMethod(
) )
}, },
modifier = Modifier.clickable { modifier = Modifier.clickable {
GKIExpanded = !GKIExpanded gkiExpanded = !gkiExpanded
} }
) )
} }
AnimatedVisibility( AnimatedVisibility(
visible = GKIExpanded, visible = gkiExpanded,
enter = fadeIn() + expandVertically(), enter = fadeIn() + expandVertically(),
exit = shrinkVertically() + fadeOut() exit = shrinkVertically() + fadeOut()
) { ) {
@@ -743,7 +715,6 @@ fun rememberSelectKmiDialog(onSelected: (String?) -> Unit): DialogHandle {
@Composable @Composable
private fun TopBar( private fun TopBar(
onBack: () -> Unit = {}, onBack: () -> Unit = {},
onLkmUpload: () -> Unit = {},
scrollBehavior: TopAppBarScrollBehavior? = null scrollBehavior: TopAppBarScrollBehavior? = null
) { ) {
val colorScheme = MaterialTheme.colorScheme val colorScheme = MaterialTheme.colorScheme