Don't allow changing backup location while backup is running

This commit is contained in:
Torsten Grote 2024-04-16 17:12:37 -03:00
parent 0e4c37e796
commit a4cccabc5e
No known key found for this signature in database
GPG key ID: 3E5F77D92CF891FF
2 changed files with 9 additions and 3 deletions

View file

@ -91,9 +91,15 @@ class SettingsFragment : PreferenceFragmentCompat() {
backupLocation = findPreference("backup_location")!! backupLocation = findPreference("backup_location")!!
backupLocation.setOnPreferenceClickListener { backupLocation.setOnPreferenceClickListener {
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() viewModel.chooseBackupLocation()
true true
} }
}
autoRestore = findPreference(PREF_KEY_AUTO_RESTORE)!! autoRestore = findPreference(PREF_KEY_AUTO_RESTORE)!!
autoRestore.onPreferenceChangeListener = OnPreferenceChangeListener { _, newValue -> autoRestore.onPreferenceChangeListener = OnPreferenceChangeListener { _, newValue ->

View file

@ -80,7 +80,7 @@ internal class SettingsViewModel(
override val isRestoreOperation = false override val isRestoreOperation = false
private val isBackupRunning: StateFlow<Boolean> val isBackupRunning: StateFlow<Boolean>
private val mBackupPossible = MutableLiveData(false) private val mBackupPossible = MutableLiveData(false)
val backupPossible: LiveData<Boolean> = mBackupPossible val backupPossible: LiveData<Boolean> = mBackupPossible