From 7fd760f4f499a2be587df81e9eb155e7a34e351c Mon Sep 17 00:00:00 2001 From: weishu Date: Sat, 16 Mar 2024 11:08:39 +0800 Subject: [PATCH] manager: Fix loading dialog --- .../me/weishu/kernelsu/ui/screen/Install.kt | 17 ++++++++++++----- manager/app/src/main/res/values/strings.xml | 2 ++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Install.kt b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Install.kt index 29f9c5d0..d376b0c7 100644 --- a/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Install.kt +++ b/manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Install.kt @@ -127,6 +127,9 @@ fun InstallScreen(navigator: DestinationsNavigator) { onFileDownloaded(uri) loadingDialog.hide() } + + val failedMessage = stringResource(id = R.string.failed_to_fetch_lkm_url) + val downloadingMessage = stringResource(id = R.string.downloading) Button( modifier = Modifier.fillMaxWidth(), enabled = installMethod != null, @@ -138,18 +141,18 @@ fun InstallScreen(navigator: DestinationsNavigator) { scope.launch(Dispatchers.Main) { Toast.makeText( context, - "Failed to fetch LKM url: ${throwable.message}", + failedMessage.format(throwable.message), Toast.LENGTH_SHORT ).show() } }.onSuccess { result -> - loadingDialog.hide() - download( context = context, url = result.second, fileName = result.first, - description = "Downloading ${result.first}", + description = downloadingMessage.format( + result.first + ), onDownloaded = { uri -> onFileDownloaded(uri) loadingDialog.hide() @@ -159,7 +162,10 @@ fun InstallScreen(navigator: DestinationsNavigator) { } } }) { - Text(stringResource(id = R.string.install_next), fontSize = MaterialTheme.typography.bodyMedium.fontSize) + Text( + stringResource(id = R.string.install_next), + fontSize = MaterialTheme.typography.bodyMedium.fontSize + ) } } } @@ -231,6 +237,7 @@ private fun SelectInstallMethod(onSelected: (InstallMethod) -> Unit = {}) { selectedOption = option onSelected(option) } + is InstallMethod.DirectInstallToInactiveSlot -> { confirmDialog.showConfirm(dialogTitle, dialogContent) } diff --git a/manager/app/src/main/res/values/strings.xml b/manager/app/src/main/res/values/strings.xml index ca6fa9fa..7ecb7578 100644 --- a/manager/app/src/main/res/values/strings.xml +++ b/manager/app/src/main/res/values/strings.xml @@ -115,4 +115,6 @@ Install to Inactive Slot (After OTA) Your device will be **FORCED** to boot to the current inactive slot after a reboot!\nOnly use this option after OTA is done.\nContinue? Next + Failed to fetch LKM url: %1$s + Downloading %1$s