diff --git a/app/src/main/java/de/lolhens/resticui/BackupManager.kt b/app/src/main/java/de/lolhens/resticui/BackupManager.kt index 1e21132..dafa3a3 100644 --- a/app/src/main/java/de/lolhens/resticui/BackupManager.kt +++ b/app/src/main/java/de/lolhens/resticui/BackupManager.kt @@ -92,7 +92,9 @@ class BackupManager private constructor(context: Context) { notificationManager(context).notify( activeBackup.notificationId, NotificationCompat.Builder(context, notificationChannelId) - .setContentTitle("${context.resources.getString(R.string.notification_backup_failed_message)}\n${activeBackup.error}") + .setContentTitle( + "${context.resources.getString(R.string.notification_backup_failed_message)}\n${activeBackup.error}" + ) .setSmallIcon(R.drawable.outline_cloud_error_24) .build() ) diff --git a/app/src/main/java/de/lolhens/resticui/ui/repo/RepoEditFragment.kt b/app/src/main/java/de/lolhens/resticui/ui/repo/RepoEditFragment.kt index 290fae3..c0c8e80 100644 --- a/app/src/main/java/de/lolhens/resticui/ui/repo/RepoEditFragment.kt +++ b/app/src/main/java/de/lolhens/resticui/ui/repo/RepoEditFragment.kt @@ -12,6 +12,7 @@ import de.lolhens.resticui.R import de.lolhens.resticui.config.* import de.lolhens.resticui.databinding.FragmentRepoEditBinding import java.net.URI +import java.util.concurrent.CompletionException class RepoEditFragment : Fragment() { private var _binding: FragmentRepoEditBinding? = null @@ -103,15 +104,16 @@ class RepoEditFragment : Fragment() { val resticRepo = repo.repo(backupManager.restic) resticRepo.stats().handle { _, throwable -> - if (throwable == null) { - saveRepo() - } else { - throwable.printStackTrace() + requireActivity().runOnUiThread { + if (throwable == null) { + saveRepo() + } else { + System.err.println("Error saving repository!") + throwable.printStackTrace() - item.isEnabled = true - binding.progressRepoSave.visibility = INVISIBLE + item.isEnabled = true + binding.progressRepoSave.visibility = INVISIBLE - requireActivity().runOnUiThread { AlertDialog.Builder(requireActivity()) .setTitle(R.string.alert_init_repo_title) .setMessage(R.string.alert_init_repo_message) @@ -120,18 +122,32 @@ class RepoEditFragment : Fragment() { binding.progressRepoSave.visibility = VISIBLE resticRepo.init().handle { _, throwable -> - if (throwable == null) { - saveRepo() - } else { - throwable.printStackTrace() + requireActivity().runOnUiThread { + if (throwable == null) { + saveRepo() + } else { + val throwable = + if (throwable is CompletionException && throwable.cause != null) throwable.cause!! + else throwable - item.isEnabled = true - binding.progressRepoSave.visibility = INVISIBLE + throwable.printStackTrace() + + item.isEnabled = true + binding.progressRepoSave.visibility = INVISIBLE - requireActivity().runOnUiThread { AlertDialog.Builder(requireActivity()) .setTitle(R.string.alert_save_repo_title) - .setMessage(R.string.alert_save_repo_message) + .setMessage( + "${ + requireContext().resources.getString( + R.string.alert_save_repo_message + ) + }\n\n${throwable.message}\n\n${ + requireContext().resources.getString( + R.string.alert_save_repo_question + ) + }" + ) .setPositiveButton(android.R.string.ok) { _, _ -> saveRepo() } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 953bd44..cfcdc42 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,7 +24,8 @@ Initialize Repository No repository found. Do you want to initialize a new Repository at this location? Failed to initialize Repository - Failed to initialize Repository. Do you want to save anyway? + Failed to initialize Repository! + Do you want to save anyway? Delete Folder Configuration Do you want to delete this Folder configuration? Cancel Backup