1
0
Fork 1

Fix up settings import

This commit is contained in:
Arne 2025-01-11 16:48:05 +01:00
parent bf63b17ad6
commit 6aa24b4698

View file

@ -40,6 +40,7 @@ import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.persistance.FileBackend; import eu.siacs.conversations.persistance.FileBackend;
import eu.siacs.conversations.ui.activity.SettingsActivity; import eu.siacs.conversations.ui.activity.SettingsActivity;
import eu.siacs.conversations.utils.FileUtils;
import eu.siacs.conversations.worker.ExportBackupWorker; import eu.siacs.conversations.worker.ExportBackupWorker;
import me.drakeet.support.toast.ToastCompat; import me.drakeet.support.toast.ToastCompat;
@ -54,7 +55,6 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class BackupSettingsFragment extends XmppPreferenceFragment { public class BackupSettingsFragment extends XmppPreferenceFragment {
@ -266,12 +266,7 @@ public class BackupSettingsFragment extends XmppPreferenceFragment {
private void importSettings(Uri uri, SettingsActivity settingsActivity) { private void importSettings(Uri uri, SettingsActivity settingsActivity) {
boolean success = false; boolean success = false;
try { try {
String path = uri.getPath(); File file = new File(FileUtils.getPath(requireSettingsActivity(), uri));
if (path == null) {
success = false;
throw new IllegalArgumentException("Uri path cannot be null.");
}
File file = new File(path);
try (ObjectInputStream input = new ObjectInputStream(new FileInputStream(file))) { try (ObjectInputStream input = new ObjectInputStream(new FileInputStream(file))) {
SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(settingsActivity).edit(); SharedPreferences.Editor prefEdit = PreferenceManager.getDefaultSharedPreferences(settingsActivity).edit();
prefEdit.clear(); prefEdit.clear();