You've already forked KernelSU-Next
mirror of
https://github.com/KernelSU-Next/KernelSU-Next.git
synced 2025-08-27 23:46:34 +00:00
manager: refactor: remove FlashModule and update navigation to FlashModules
This commit is contained in:
@@ -218,8 +218,6 @@ sealed class FlashIt : Parcelable {
|
||||
data class FlashBoot(val boot: Uri? = null, val lkm: LkmSelection, val ota: Boolean) :
|
||||
FlashIt()
|
||||
|
||||
data class FlashModule(val uri: Uri) : FlashIt()
|
||||
|
||||
data class FlashModules(val uris: List<Uri>) : FlashIt()
|
||||
|
||||
data object FlashRestore : FlashIt()
|
||||
@@ -241,8 +239,6 @@ fun flashIt(
|
||||
onStderr
|
||||
)
|
||||
|
||||
is FlashIt.FlashModule -> flashModule(flashIt.uri, onStdout, onStderr)
|
||||
|
||||
is FlashIt.FlashModules -> {
|
||||
flashModulesSequentially(flashIt.uris, onStdout, onStderr)
|
||||
}
|
||||
|
||||
@@ -237,19 +237,16 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
data.data?.let { uris.add(it) }
|
||||
}
|
||||
|
||||
if (uris.size == 1) {
|
||||
navigator.navigate(FlashScreenDestination(FlashIt.FlashModule(uris.first())))
|
||||
} else if (uris.size > 1) {
|
||||
// multiple files selected
|
||||
val moduleNames = uris.mapIndexed { index, uri -> "\n${index + 1}. ${uri.getFileName(context)}" }.joinToString("")
|
||||
val confirmContent = context.getString(R.string.module_install_prompt_with_name, moduleNames)
|
||||
zipUris = uris
|
||||
confirmDialog.showConfirm(
|
||||
title = confirmTitle,
|
||||
content = confirmContent,
|
||||
markdown = true
|
||||
)
|
||||
}
|
||||
// Show confirm dialog with selected zip file(s) name(s)
|
||||
val moduleNames = uris.mapIndexed { index, uri -> "\n${index + 1}. ${uri.getFileName(context)}" }.joinToString("")
|
||||
val confirmContent = context.getString(R.string.module_install_prompt_with_name, moduleNames)
|
||||
zipUris = uris
|
||||
confirmDialog.showConfirm(
|
||||
title = confirmTitle,
|
||||
content = confirmContent,
|
||||
markdown = true
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
ExtendedFloatingActionButton(
|
||||
@@ -269,34 +266,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||
snackbarHost = { SnackbarHost(hostState = snackBarHost) }
|
||||
) { innerPadding ->
|
||||
// Confirmation dialog
|
||||
if (showConfirmDialog && zipUris.isNotEmpty()) {
|
||||
val moduleNames = zipUris.joinToString("\n") { getFileName(context, it) }
|
||||
|
||||
AlertDialog(
|
||||
onDismissRequest = { showConfirmDialog = false },
|
||||
confirmButton = {
|
||||
TextButton(onClick = {
|
||||
showConfirmDialog = false
|
||||
navigator.navigate(FlashScreenDestination(FlashIt.FlashModules(zipUris)))
|
||||
viewModel.markNeedRefresh()
|
||||
}) {
|
||||
Text(stringResource(R.string.confirm))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showConfirmDialog = false }) {
|
||||
Text(stringResource(android.R.string.cancel))
|
||||
}
|
||||
},
|
||||
title = { Text(stringResource(R.string.module)) },
|
||||
text = {
|
||||
Text(
|
||||
stringResource(R.string.module_install_prompt_with_name, moduleNames)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
when {
|
||||
hasMagisk -> {
|
||||
Box(
|
||||
@@ -318,7 +288,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
boxModifier = Modifier.padding(innerPadding),
|
||||
onInstallModule = {
|
||||
navigator.navigate(FlashScreenDestination(FlashIt.FlashModule(it)))
|
||||
navigator.navigate(FlashScreenDestination(FlashIt.FlashModules(listOf(it))))
|
||||
},
|
||||
onClickModule = { id, name, hasWebUi ->
|
||||
if (hasWebUi) {
|
||||
|
||||
Reference in New Issue
Block a user