From a4cccabc5ec5acef031a686587ea6a7037d79dfa Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Tue, 16 Apr 2024 17:12:37 -0300 Subject: [PATCH] Don't allow changing backup location while backup is running --- .../stevesoltys/seedvault/settings/SettingsFragment.kt | 10 ++++++++-- .../seedvault/settings/SettingsViewModel.kt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt index 132b3147..a48deb23 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt @@ -91,8 +91,14 @@ class SettingsFragment : PreferenceFragmentCompat() { backupLocation = findPreference("backup_location")!! backupLocation.setOnPreferenceClickListener { - viewModel.chooseBackupLocation() - true + if (viewModel.isBackupRunning.value) { + // don't allow changing backup destination while backup is running + // TODO we could show toast or snackbar here + false + } else { + viewModel.chooseBackupLocation() + true + } } autoRestore = findPreference(PREF_KEY_AUTO_RESTORE)!! diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt index 7981fed0..e1de8f1f 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -80,7 +80,7 @@ internal class SettingsViewModel( override val isRestoreOperation = false - private val isBackupRunning: StateFlow + val isBackupRunning: StateFlow private val mBackupPossible = MutableLiveData(false) val backupPossible: LiveData = mBackupPossible