|
@@ -148,7 +148,9 @@ class SettingsBackupController : SettingsController() {
|
|
|
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
|
|
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
|
|
|
|
|
- activity.contentResolver.takePersistableUriPermission(uri, flags)
|
|
|
+ if (uri != null) {
|
|
|
+ activity.contentResolver.takePersistableUriPermission(uri, flags)
|
|
|
+ }
|
|
|
|
|
|
// Set backup Uri
|
|
|
preferences.backupsDirectory().set(uri.toString())
|
|
@@ -160,7 +162,10 @@ class SettingsBackupController : SettingsController() {
|
|
|
val flags = Intent.FLAG_GRANT_READ_URI_PERMISSION or
|
|
|
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
|
|
|
|
|
- activity.contentResolver.takePersistableUriPermission(uri, flags)
|
|
|
+ if (uri != null) {
|
|
|
+ activity.contentResolver.takePersistableUriPermission(uri, flags)
|
|
|
+ }
|
|
|
+
|
|
|
val file = UniFile.fromUri(activity, uri)
|
|
|
|
|
|
CreatingBackupDialog().showDialog(router, TAG_CREATING_BACKUP_DIALOG)
|
|
@@ -168,7 +173,9 @@ class SettingsBackupController : SettingsController() {
|
|
|
}
|
|
|
CODE_BACKUP_RESTORE -> if (data != null && resultCode == Activity.RESULT_OK) {
|
|
|
val uri = data.data
|
|
|
- RestoreBackupDialog(uri).showDialog(router)
|
|
|
+ if (uri != null) {
|
|
|
+ RestoreBackupDialog(uri).showDialog(router)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -283,7 +290,7 @@ class SettingsBackupController : SettingsController() {
|
|
|
val context = applicationContext
|
|
|
if (context != null) {
|
|
|
RestoringBackupDialog().showDialog(router, TAG_RESTORING_BACKUP_DIALOG)
|
|
|
- BackupRestoreService.start(context, args.getParcelable(KEY_URI))
|
|
|
+ BackupRestoreService.start(context, args.getParcelable(KEY_URI)!!)
|
|
|
}
|
|
|
}
|
|
|
.build()
|
|
@@ -357,7 +364,7 @@ class SettingsBackupController : SettingsController() {
|
|
|
.negativeText(R.string.action_open_log)
|
|
|
.onNegative { _, _ ->
|
|
|
val context = applicationContext ?: return@onNegative
|
|
|
- if (!path.isEmpty()) {
|
|
|
+ if (!path.isNullOrEmpty()) {
|
|
|
val destFile = File(path, file)
|
|
|
val uri = destFile.getUriCompat(context)
|
|
|
val sendIntent = Intent(Intent.ACTION_VIEW).apply {
|