1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-01-03 05:34:51 +00:00

Fixed/imporoved K9 settings import

This commit is contained in:
M66B 2024-11-07 12:04:38 +01:00
parent f60efcd94f
commit bca1d91e21

View file

@ -1395,7 +1395,10 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
String name = xml.getName(); String name = xml.getName();
switch (name) { switch (name) {
case "account": case "account":
String uuid = xml.getAttributeValue(null, "uuid");
account = new EntityAccount(); account = new EntityAccount();
if (!TextUtils.isEmpty(uuid))
account.uuid = uuid;
account.auth_type = ServiceAuthenticator.AUTH_TYPE_PASSWORD; account.auth_type = ServiceAuthenticator.AUTH_TYPE_PASSWORD;
account.password = ""; account.password = "";
account.synchronize = false; account.synchronize = false;
@ -1463,9 +1466,9 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
break; break;
case "authentication-type": case "authentication-type":
eventType = xml.next(); eventType = xml.next();
if (eventType != XmlPullParser.TEXT || !"PLAIN".equals(xml.getText())) { if (eventType == XmlPullParser.TEXT) {
account = null; String atype = xml.getText();
identity = null; // PLAIN, CRAM_MD5
} }
break; break;
case "username": case "username":
@ -1505,6 +1508,7 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
String name = xml.getName(); String name = xml.getName();
switch (name) { switch (name) {
case "account": case "account":
try {
if (account != null && identity != null) { if (account != null && identity != null) {
if (TextUtils.isEmpty(account.name)) if (TextUtils.isEmpty(account.name))
account.name = account.user; account.name = account.user;
@ -1514,6 +1518,9 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
try { try {
db.beginTransaction(); db.beginTransaction();
EntityAccount existing = db.account().getAccountByUUID(account.uuid);
if (existing == null) {
account.id = db.account().insertAccount(account); account.id = db.account().insertAccount(account);
identity.account = account.id; identity.account = account.id;
for (Pair<String, String> i : identities) { for (Pair<String, String> i : identities) {
@ -1526,14 +1533,17 @@ public class FragmentOptionsBackup extends FragmentBase implements SharedPrefere
identity.email = identity.user; identity.email = identity.user;
identity.id = db.identity().insertIdentity(identity); identity.id = db.identity().insertIdentity(identity);
} }
}
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
} finally { } finally {
account = null; account = null;
identity = null; identity = null;
identities.clear(); identities.clear();
db.endTransaction();
}
} }
break; break;
case "identity": case "identity":