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) :
|
data class FlashBoot(val boot: Uri? = null, val lkm: LkmSelection, val ota: Boolean) :
|
||||||
FlashIt()
|
FlashIt()
|
||||||
|
|
||||||
data class FlashModule(val uri: Uri) : FlashIt()
|
|
||||||
|
|
||||||
data class FlashModules(val uris: List<Uri>) : FlashIt()
|
data class FlashModules(val uris: List<Uri>) : FlashIt()
|
||||||
|
|
||||||
data object FlashRestore : FlashIt()
|
data object FlashRestore : FlashIt()
|
||||||
@@ -241,8 +239,6 @@ fun flashIt(
|
|||||||
onStderr
|
onStderr
|
||||||
)
|
)
|
||||||
|
|
||||||
is FlashIt.FlashModule -> flashModule(flashIt.uri, onStdout, onStderr)
|
|
||||||
|
|
||||||
is FlashIt.FlashModules -> {
|
is FlashIt.FlashModules -> {
|
||||||
flashModulesSequentially(flashIt.uris, onStdout, onStderr)
|
flashModulesSequentially(flashIt.uris, onStdout, onStderr)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,19 +237,16 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
data.data?.let { uris.add(it) }
|
data.data?.let { uris.add(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uris.size == 1) {
|
// Show confirm dialog with selected zip file(s) name(s)
|
||||||
navigator.navigate(FlashScreenDestination(FlashIt.FlashModule(uris.first())))
|
val moduleNames = uris.mapIndexed { index, uri -> "\n${index + 1}. ${uri.getFileName(context)}" }.joinToString("")
|
||||||
} else if (uris.size > 1) {
|
val confirmContent = context.getString(R.string.module_install_prompt_with_name, moduleNames)
|
||||||
// multiple files selected
|
zipUris = uris
|
||||||
val moduleNames = uris.mapIndexed { index, uri -> "\n${index + 1}. ${uri.getFileName(context)}" }.joinToString("")
|
confirmDialog.showConfirm(
|
||||||
val confirmContent = context.getString(R.string.module_install_prompt_with_name, moduleNames)
|
title = confirmTitle,
|
||||||
zipUris = uris
|
content = confirmContent,
|
||||||
confirmDialog.showConfirm(
|
markdown = true
|
||||||
title = confirmTitle,
|
)
|
||||||
content = confirmContent,
|
|
||||||
markdown = true
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedFloatingActionButton(
|
ExtendedFloatingActionButton(
|
||||||
@@ -269,34 +266,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
contentWindowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||||
snackbarHost = { SnackbarHost(hostState = snackBarHost) }
|
snackbarHost = { SnackbarHost(hostState = snackBarHost) }
|
||||||
) { innerPadding ->
|
) { 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 {
|
when {
|
||||||
hasMagisk -> {
|
hasMagisk -> {
|
||||||
Box(
|
Box(
|
||||||
@@ -318,7 +288,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||||
boxModifier = Modifier.padding(innerPadding),
|
boxModifier = Modifier.padding(innerPadding),
|
||||||
onInstallModule = {
|
onInstallModule = {
|
||||||
navigator.navigate(FlashScreenDestination(FlashIt.FlashModule(it)))
|
navigator.navigate(FlashScreenDestination(FlashIt.FlashModules(listOf(it))))
|
||||||
},
|
},
|
||||||
onClickModule = { id, name, hasWebUi ->
|
onClickModule = { id, name, hasWebUi ->
|
||||||
if (hasWebUi) {
|
if (hasWebUi) {
|
||||||
|
|||||||
Reference in New Issue
Block a user