From d6bd36ad8b3d403be83dfea726a486e854845f32 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 22 Feb 2021 15:37:46 -0300 Subject: [PATCH] Backup now: run storage backup before app backup --- .../com/stevesoltys/seedvault/settings/SettingsViewModel.kt | 5 +++++ 1 file changed, 5 insertions(+) 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 57cf1af6..a4aa02e3 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -31,6 +31,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch import org.calyxos.backup.storage.api.StorageBackup import org.calyxos.backup.storage.backup.BackupJobService +import org.calyxos.backup.storage.backup.NotificationBackupObserver import java.util.concurrent.TimeUnit.HOURS private const val TAG = "SettingsViewModel" @@ -152,6 +153,10 @@ internal class SettingsViewModel( if (notificationManager.hasActiveBackupNotifications()) { Toast.makeText(app, R.string.notification_backup_already_running, LENGTH_LONG).show() } else viewModelScope.launch(Dispatchers.IO) { + if (settingsManager.isStorageBackupEnabled()) { + val backupObserver = NotificationBackupObserver(app) + storageBackup.runBackup(backupObserver) + } requestBackup(app) } }