From f1cb2e30bac34a57feec1ea43507e1b3f46128e7 Mon Sep 17 00:00:00 2001 From: Niko Diamadis Date: Sat, 18 Feb 2023 00:19:55 +0100 Subject: [PATCH] Report number of successful imports --- .../com/cyb3rko/pincredible/utils/BackupHandler.kt | 10 ++++++++-- app/src/main/res/values/strings.xml | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/kotlin/com/cyb3rko/pincredible/utils/BackupHandler.kt b/app/src/main/kotlin/com/cyb3rko/pincredible/utils/BackupHandler.kt index f1b54b6..2cb2330 100644 --- a/app/src/main/kotlin/com/cyb3rko/pincredible/utils/BackupHandler.kt +++ b/app/src/main/kotlin/com/cyb3rko/pincredible/utils/BackupHandler.kt @@ -185,8 +185,10 @@ internal object BackupHandler { ) } val progressStep = 50 / backup.pins.size + var imports = 0 backup.pins.forEach { - savePinFile(context, it.fileName, it.pinTable, it.siid) + val imported = savePinFile(context, it.fileName, it.pinTable, it.siid) + if (imported) imports += 1 progressBar.progress = progressBar.progress + progressStep progressNote.text = context.getString( R.string.dialog_import_state_saving, @@ -194,7 +196,11 @@ internal object BackupHandler { ) } progressBar.progress = 100 - progressNote.text = context.getString(R.string.dialog_import_state_finished) + progressNote.text = context.getString( + R.string.dialog_import_state_finished, + imports, + backup.pins.size + ) progressDialog.dialogReference.setCancelable(true) } catch (e: Exception) { e.printStackTrace() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 99b598b..04ea6fa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,7 +65,7 @@ PIN Import %d\%% - Reading backup file… %d\%% - Saving restored content… - 100% - PIN import completed + 100\%% - PIN import completed\n%1$d of %2$d PINs imported Import error PIN table image Are you sure?\n\nYou are about to save this unencrypted PIN table to %s.