mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
manager: refine flashing module confirm dialog
Some checks failed
Build Manager / build-lkm (push) Has been cancelled
Build Manager / build-ksud (macos-latest, aarch64-apple-darwin) (push) Has been cancelled
Build Manager / build-ksud (macos-latest, x86_64-apple-darwin) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, aarch64-linux-android) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, aarch64-unknown-linux-musl) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, x86_64-linux-android) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, x86_64-pc-windows-gnu) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, x86_64-unknown-linux-musl) (push) Has been cancelled
Build Manager / build-manager (push) Has been cancelled
Some checks failed
Build Manager / build-lkm (push) Has been cancelled
Build Manager / build-ksud (macos-latest, aarch64-apple-darwin) (push) Has been cancelled
Build Manager / build-ksud (macos-latest, x86_64-apple-darwin) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, aarch64-linux-android) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, aarch64-unknown-linux-musl) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, x86_64-linux-android) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, x86_64-pc-windows-gnu) (push) Has been cancelled
Build Manager / build-ksud (ubuntu-latest, x86_64-unknown-linux-musl) (push) Has been cancelled
Build Manager / build-manager (push) Has been cancelled
This commit is contained in:
parent
1186259365
commit
6e3d556960
@ -135,11 +135,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
|
|
||||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||||
|
|
||||||
var zipUri by remember { mutableStateOf<Uri?>(null) }
|
|
||||||
var zipUris by remember { mutableStateOf<List<Uri>>(emptyList()) }
|
|
||||||
|
|
||||||
var showConfirmDialog by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
val webUILauncher = rememberLauncherForActivityResult(
|
val webUILauncher = rememberLauncherForActivityResult(
|
||||||
contract = ActivityResultContracts.StartActivityForResult()
|
contract = ActivityResultContracts.StartActivityForResult()
|
||||||
) { viewModel.fetchModuleList() }
|
) { viewModel.fetchModuleList() }
|
||||||
@ -208,6 +203,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()
|
||||||
) {
|
) {
|
||||||
@ -226,8 +227,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(
|
||||||
@ -248,35 +260,6 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
|||||||
snackbarHost = { SnackbarHost(hostState = snackBarHost) }
|
snackbarHost = { SnackbarHost(hostState = snackBarHost) }
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
|
|
||||||
// confirmation dialog
|
|
||||||
if (showConfirmDialog && zipUris.isNotEmpty()) {
|
|
||||||
val moduleNames = zipUris.joinToString("\n") { it.getFileName(context).toString() }
|
|
||||||
|
|
||||||
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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user