1
0
Fork 1

Fix and improve settings import and export

This commit is contained in:
Arne 2025-01-09 19:33:22 +01:00
parent 83a5a19a4f
commit 2e2b13fc72
2 changed files with 9 additions and 1 deletions

View file

@ -239,7 +239,7 @@ public class BackupSettingsFragment extends XmppPreferenceFragment {
boolean success; boolean success;
ObjectInputStream input = null; ObjectInputStream input = null;
try { 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)); input = new ObjectInputStream(new FileInputStream(file));
SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(requireSettingsActivity()).edit(); SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(requireSettingsActivity()).edit();
prefEdit.clear(); prefEdit.clear();
@ -309,6 +309,12 @@ public class BackupSettingsFragment extends XmppPreferenceFragment {
ex.printStackTrace(); 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; return success;
} }

View file

@ -1410,4 +1410,6 @@
<string name="pref_use_colored_muc_names_summary">Use colored user names in group chats</string> <string name="pref_use_colored_muc_names_summary">Use colored user names in group chats</string>
<string name="delete_avatar_message">Would you like to delete your avatar? Some clients might continue to display a cached copy of your avatar.</string> <string name="delete_avatar_message">Would you like to delete your avatar? Some clients might continue to display a cached copy of your avatar.</string>
<string name="show_to_contacts_only">Show to contacts only</string> <string name="show_to_contacts_only">Show to contacts only</string>
<string name="success_export_settings">Settings successfully exported</string>
<string name="error_export_settings">Error while exporting settings</string>
</resources> </resources>