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: refine flashing module confirm dialog
This commit is contained in:
@@ -213,6 +213,12 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
floatingActionButton = {
|
floatingActionButton = {
|
||||||
if (!hideInstallButton) {
|
if (!hideInstallButton) {
|
||||||
val moduleInstall = stringResource(id = R.string.module_install)
|
val moduleInstall = stringResource(id = R.string.module_install)
|
||||||
|
val confirmTitle = stringResource(R.string.module)
|
||||||
|
var zipUris by remember { mutableStateOf<List<Uri>>(emptyList()) }
|
||||||
|
val confirmDialog = rememberConfirmDialog(onConfirm = {
|
||||||
|
navigator.navigate(FlashScreenDestination(FlashIt.FlashModules(zipUris)))
|
||||||
|
viewModel.markNeedRefresh()
|
||||||
|
})
|
||||||
val selectZipLauncher = rememberLauncherForActivityResult(
|
val selectZipLauncher = rememberLauncherForActivityResult(
|
||||||
contract = ActivityResultContracts.StartActivityForResult()
|
contract = ActivityResultContracts.StartActivityForResult()
|
||||||
) { result ->
|
) { result ->
|
||||||
@@ -231,8 +237,19 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
data.data?.let { uris.add(it) }
|
data.data?.let { uris.add(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
zipUris = uris
|
if (uris.size == 1) {
|
||||||
showConfirmDialog = uris.isNotEmpty()
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExtendedFloatingActionButton(
|
ExtendedFloatingActionButton(
|
||||||
|
|||||||
Reference in New Issue
Block a user