From 2e2b13fc723e01f80b400166b5786172c1d2c244 Mon Sep 17 00:00:00 2001 From: Arne Date: Thu, 9 Jan 2025 19:33:22 +0100 Subject: [PATCH] Fix and improve settings import and export --- .../ui/fragment/settings/BackupSettingsFragment.java | 8 +++++++- src/main/res/values/strings.xml | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java b/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java index c9724a4f1..1dbba5f0d 100644 --- a/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/fragment/settings/BackupSettingsFragment.java @@ -239,7 +239,7 @@ public class BackupSettingsFragment extends XmppPreferenceFragment { boolean success; ObjectInputStream input = null; try { - final File file = new File(FileBackend.getBackupDirectory(requireContext()).getAbsolutePath() + "/settings.dat"); + final File file = new File(FileBackend.getBackupDirectory(requireContext()).getAbsolutePath(),"settings.dat"); input = new ObjectInputStream(new FileInputStream(file)); SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(requireSettingsActivity()).edit(); prefEdit.clear(); @@ -309,6 +309,12 @@ public class BackupSettingsFragment extends XmppPreferenceFragment { ex.printStackTrace(); } } + if (success) { + new Thread(() -> runOnUiThread(() -> requireActivity().recreate())).start(); + ToastCompat.makeText(requireActivity(), R.string.success_export_settings, ToastCompat.LENGTH_SHORT).show(); + } else { + ToastCompat.makeText(requireActivity(), R.string.error_export_settings, ToastCompat.LENGTH_SHORT).show(); + } return success; } diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 405a39f94..932bc0a12 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1410,4 +1410,6 @@ Use colored user names in group chats Would you like to delete your avatar? Some clients might continue to display a cached copy of your avatar. Show to contacts only + Settings successfully exported + Error while exporting settings \ No newline at end of file