From b0984c30a534a6007fe7359c79ffe3790a195159 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 25 Feb 2019 18:41:02 +0100 Subject: [PATCH] Improve UX when restoring e2e keys (#2999) --- CHANGES.rst | 2 +- .../restore/KeysBackupRestoreFromKeyViewModel.kt | 16 ++++++++++++---- .../KeysBackupRestoreFromPassphraseViewModel.kt | 16 ++++++++++++---- vector/src/main/res/values/strings.xml | 2 +- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 370d6433f0..c488d2f6be 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -8,7 +8,7 @@ Features: - Improvements: - - + - Improve UX when restoring e2e keys (#2999) Other changes: - diff --git a/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt b/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt index 0eb0c204c0..15435c4b01 100644 --- a/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt +++ b/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromKeyViewModel.kt @@ -68,10 +68,18 @@ class KeysBackupRestoreFromKeyViewModel : ViewModel() { isIndeterminate = true) } is StepProgressListener.Step.ImportingKey -> { - sharedViewModel.loadingEvent.value = WaitingViewData(context.getString(R.string.keys_backup_restoring_waiting_message) - + "\n" + context.getString(R.string.keys_backup_restoring_importing_keys_waiting_message), - step.progress, - step.total) + // Progress 0 can take a while, display an indeterminate progress in this case + if (step.progress == 0) { + sharedViewModel.loadingEvent.value = WaitingViewData(context.getString(R.string.keys_backup_restoring_waiting_message) + + "\n" + context.getString(R.string.keys_backup_restoring_importing_keys_waiting_message), + isIndeterminate = true) + + } else { + sharedViewModel.loadingEvent.value = WaitingViewData(context.getString(R.string.keys_backup_restoring_waiting_message) + + "\n" + context.getString(R.string.keys_backup_restoring_importing_keys_waiting_message), + step.progress, + step.total) + } } } } diff --git a/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt b/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt index d770b2a692..969a4d6512 100644 --- a/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt +++ b/vector/src/main/java/im/vector/fragments/keysbackup/restore/KeysBackupRestoreFromPassphraseViewModel.kt @@ -76,10 +76,18 @@ class KeysBackupRestoreFromPassphraseViewModel : ViewModel() { isIndeterminate = true) } is StepProgressListener.Step.ImportingKey -> { - sharedViewModel.loadingEvent.value = WaitingViewData(context.getString(R.string.keys_backup_restoring_waiting_message) - + "\n" + context.getString(R.string.keys_backup_restoring_importing_keys_waiting_message), - step.progress, - step.total) + // Progress 0 can take a while, display an indeterminate progress in this case + if (step.progress == 0) { + sharedViewModel.loadingEvent.value = WaitingViewData(context.getString(R.string.keys_backup_restoring_waiting_message) + + "\n" + context.getString(R.string.keys_backup_restoring_importing_keys_waiting_message), + isIndeterminate = true) + + } else { + sharedViewModel.loadingEvent.value = WaitingViewData(context.getString(R.string.keys_backup_restoring_waiting_message) + + "\n" + context.getString(R.string.keys_backup_restoring_importing_keys_waiting_message), + step.progress, + step.total) + } } } } diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index 18d0a7df6b..06fee1a270 100755 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -1287,7 +1287,7 @@ Why choose Riot.im? Backup could not be decrypted with this passphrase: please verify that you entered the correct recovery passphrase. Network error: please check your connection and retry. - Restoring backup… + Restoring backup: Computing recovery key… Downloading keys… Importing keys…