|
|
@ -57,12 +57,21 @@ object BackupRestoreUi { |
|
|
|
path: String |
|
|
|
path: String |
|
|
|
) { |
|
|
|
) { |
|
|
|
fragment.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { |
|
|
|
fragment.registerForActivityResult(ActivityResultContracts.RequestMultiplePermissions()) { |
|
|
|
|
|
|
|
var hasPermission = true |
|
|
|
|
|
|
|
it.forEach { (t, u) -> |
|
|
|
|
|
|
|
if (!u) { |
|
|
|
|
|
|
|
hasPermission = false |
|
|
|
|
|
|
|
fragment.toastOnUi(t) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (hasPermission) { |
|
|
|
Coroutine.async { |
|
|
|
Coroutine.async { |
|
|
|
AppConfig.backupPath = path |
|
|
|
AppConfig.backupPath = path |
|
|
|
Backup.backup(fragment.requireContext(), path) |
|
|
|
Backup.backup(fragment.requireContext(), path) |
|
|
|
}.onSuccess { |
|
|
|
}.onSuccess { |
|
|
|
fragment.toastOnUi(R.string.backup_success) |
|
|
|
fragment.toastOnUi(R.string.backup_success) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}.launch(Permissions.Group.STORAGE) |
|
|
|
}.launch(Permissions.Group.STORAGE) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|