mirror of
https://github.com/moparisthebest/k-9
synced 2025-02-25 07:01:50 -05:00
Granted some account/identity keys their own XML element (export)
This commit is contained in:
parent
8850915987
commit
70f9a7b852
@ -55,11 +55,17 @@ public class Account implements BaseAccount {
|
|||||||
private static final String DEFAULT_QUOTE_PREFIX = ">";
|
private static final String DEFAULT_QUOTE_PREFIX = ">";
|
||||||
private static final boolean DEFAULT_REPLY_AFTER_QUOTE = false;
|
private static final boolean DEFAULT_REPLY_AFTER_QUOTE = false;
|
||||||
|
|
||||||
|
public static final String ACCOUNT_DESCRIPTION_KEY = "description";
|
||||||
|
|
||||||
|
public static final String IDENTITY_NAME_KEY = "name";
|
||||||
|
public static final String IDENTITY_EMAIL_KEY = "email";
|
||||||
|
public static final String IDENTITY_DESCRIPTION_KEY = "description";
|
||||||
|
|
||||||
public static final Set<String> IDENTITY_KEYS = new HashSet<String>();
|
public static final Set<String> IDENTITY_KEYS = new HashSet<String>();
|
||||||
static {
|
static {
|
||||||
IDENTITY_KEYS.add("name");
|
IDENTITY_KEYS.add(IDENTITY_NAME_KEY);
|
||||||
IDENTITY_KEYS.add("email");
|
IDENTITY_KEYS.add(IDENTITY_EMAIL_KEY);
|
||||||
IDENTITY_KEYS.add("description");
|
IDENTITY_KEYS.add(IDENTITY_DESCRIPTION_KEY);
|
||||||
IDENTITY_KEYS.add("signatureUse");
|
IDENTITY_KEYS.add("signatureUse");
|
||||||
IDENTITY_KEYS.add("signature");
|
IDENTITY_KEYS.add("signature");
|
||||||
IDENTITY_KEYS.add("replyTo");
|
IDENTITY_KEYS.add("replyTo");
|
||||||
@ -1036,11 +1042,11 @@ public class Account implements BaseAccount {
|
|||||||
boolean gotOne = false;
|
boolean gotOne = false;
|
||||||
do {
|
do {
|
||||||
gotOne = false;
|
gotOne = false;
|
||||||
String name = prefs.getString(mUuid + ".name." + ident, null);
|
String name = prefs.getString(mUuid + "." + IDENTITY_NAME_KEY + "." + ident, null);
|
||||||
String email = prefs.getString(mUuid + ".email." + ident, null);
|
String email = prefs.getString(mUuid + "." + IDENTITY_EMAIL_KEY + "." + ident, null);
|
||||||
boolean signatureUse = prefs.getBoolean(mUuid + ".signatureUse." + ident, true);
|
boolean signatureUse = prefs.getBoolean(mUuid + ".signatureUse." + ident, true);
|
||||||
String signature = prefs.getString(mUuid + ".signature." + ident, null);
|
String signature = prefs.getString(mUuid + ".signature." + ident, null);
|
||||||
String description = prefs.getString(mUuid + ".description." + ident, null);
|
String description = prefs.getString(mUuid + "." + IDENTITY_DESCRIPTION_KEY + "." + ident, null);
|
||||||
final String replyTo = prefs.getString(mUuid + ".replyTo." + ident, null);
|
final String replyTo = prefs.getString(mUuid + ".replyTo." + ident, null);
|
||||||
if (email != null) {
|
if (email != null) {
|
||||||
Identity identity = new Identity();
|
Identity identity = new Identity();
|
||||||
@ -1078,13 +1084,13 @@ public class Account implements BaseAccount {
|
|||||||
boolean gotOne = false;
|
boolean gotOne = false;
|
||||||
do {
|
do {
|
||||||
gotOne = false;
|
gotOne = false;
|
||||||
String email = prefs.getString(mUuid + ".email." + ident, null);
|
String email = prefs.getString(mUuid + "." + IDENTITY_EMAIL_KEY + "." + ident, null);
|
||||||
if (email != null) {
|
if (email != null) {
|
||||||
editor.remove(mUuid + ".name." + ident);
|
editor.remove(mUuid + "." + IDENTITY_NAME_KEY + "." + ident);
|
||||||
editor.remove(mUuid + ".email." + ident);
|
editor.remove(mUuid + "." + IDENTITY_EMAIL_KEY + "." + ident);
|
||||||
editor.remove(mUuid + ".signatureUse." + ident);
|
editor.remove(mUuid + ".signatureUse." + ident);
|
||||||
editor.remove(mUuid + ".signature." + ident);
|
editor.remove(mUuid + ".signature." + ident);
|
||||||
editor.remove(mUuid + ".description." + ident);
|
editor.remove(mUuid + "." + IDENTITY_DESCRIPTION_KEY + "." + ident);
|
||||||
editor.remove(mUuid + ".replyTo." + ident);
|
editor.remove(mUuid + ".replyTo." + ident);
|
||||||
gotOne = true;
|
gotOne = true;
|
||||||
}
|
}
|
||||||
@ -1097,11 +1103,11 @@ public class Account implements BaseAccount {
|
|||||||
int ident = 0;
|
int ident = 0;
|
||||||
|
|
||||||
for (Identity identity : identities) {
|
for (Identity identity : identities) {
|
||||||
editor.putString(mUuid + ".name." + ident, identity.getName());
|
editor.putString(mUuid + "." + IDENTITY_NAME_KEY + "." + ident, identity.getName());
|
||||||
editor.putString(mUuid + ".email." + ident, identity.getEmail());
|
editor.putString(mUuid + "." + IDENTITY_EMAIL_KEY + "." + ident, identity.getEmail());
|
||||||
editor.putBoolean(mUuid + ".signatureUse." + ident, identity.getSignatureUse());
|
editor.putBoolean(mUuid + ".signatureUse." + ident, identity.getSignatureUse());
|
||||||
editor.putString(mUuid + ".signature." + ident, identity.getSignature());
|
editor.putString(mUuid + ".signature." + ident, identity.getSignature());
|
||||||
editor.putString(mUuid + ".description." + ident, identity.getDescription());
|
editor.putString(mUuid + "." + IDENTITY_DESCRIPTION_KEY + "." + ident, identity.getDescription());
|
||||||
editor.putString(mUuid + ".replyTo." + ident, identity.getReplyTo());
|
editor.putString(mUuid + ".replyTo." + ident, identity.getReplyTo());
|
||||||
ident++;
|
ident++;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,9 @@ public class StorageExporter {
|
|||||||
private static final String NAME_ATTRIBUTE = "name";
|
private static final String NAME_ATTRIBUTE = "name";
|
||||||
private static final String VALUE_ELEMENT = "value";
|
private static final String VALUE_ELEMENT = "value";
|
||||||
private static final String KEY_ATTRIBUTE = "key";
|
private static final String KEY_ATTRIBUTE = "key";
|
||||||
|
private static final String NAME_ELEMENT = "name";
|
||||||
|
private static final String EMAIL_ELEMENT = "email";
|
||||||
|
private static final String DESCRIPTION_ELEMENT = "description";
|
||||||
|
|
||||||
|
|
||||||
public static String exportToFile(Context context, boolean includeGlobals,
|
public static String exportToFile(Context context, boolean includeGlobals,
|
||||||
@ -169,6 +172,13 @@ public class StorageExporter {
|
|||||||
serializer.startTag(null, ACCOUNT_ELEMENT);
|
serializer.startTag(null, ACCOUNT_ELEMENT);
|
||||||
serializer.attribute(null, UUID_ATTRIBUTE, accountUuid);
|
serializer.attribute(null, UUID_ATTRIBUTE, accountUuid);
|
||||||
|
|
||||||
|
String name = (String) prefs.get(accountUuid + "." + Account.ACCOUNT_DESCRIPTION_KEY);
|
||||||
|
if (name != null) {
|
||||||
|
serializer.startTag(null, NAME_ELEMENT);
|
||||||
|
serializer.text(name);
|
||||||
|
serializer.endTag(null, NAME_ELEMENT);
|
||||||
|
}
|
||||||
|
|
||||||
serializer.startTag(null, SETTINGS_ELEMENT);
|
serializer.startTag(null, SETTINGS_ELEMENT);
|
||||||
for (Map.Entry<String, ? extends Object> entry : prefs.entrySet()) {
|
for (Map.Entry<String, ? extends Object> entry : prefs.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
@ -176,11 +186,13 @@ public class StorageExporter {
|
|||||||
String[] comps = key.split("\\.");
|
String[] comps = key.split("\\.");
|
||||||
if (comps.length >= 2) {
|
if (comps.length >= 2) {
|
||||||
String keyUuid = comps[0];
|
String keyUuid = comps[0];
|
||||||
if (!keyUuid.equals(accountUuid)) {
|
String secondPart = comps[1];
|
||||||
|
|
||||||
|
if (!keyUuid.equals(accountUuid)
|
||||||
|
|| Account.ACCOUNT_DESCRIPTION_KEY.equals(secondPart)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (comps.length == 3) {
|
if (comps.length == 3) {
|
||||||
String secondPart = comps[1];
|
|
||||||
String thirdPart = comps[2];
|
String thirdPart = comps[2];
|
||||||
|
|
||||||
if (Account.IDENTITY_KEYS.contains(secondPart)) {
|
if (Account.IDENTITY_KEYS.contains(secondPart)) {
|
||||||
@ -242,6 +254,28 @@ public class StorageExporter {
|
|||||||
String identity, Map<String, ? extends Object> prefs) throws IOException {
|
String identity, Map<String, ? extends Object> prefs) throws IOException {
|
||||||
|
|
||||||
serializer.startTag(null, IDENTITY_ELEMENT);
|
serializer.startTag(null, IDENTITY_ELEMENT);
|
||||||
|
|
||||||
|
String name = (String) prefs.get(accountUuid + "." + Account.IDENTITY_NAME_KEY +
|
||||||
|
"." + identity);
|
||||||
|
serializer.startTag(null, NAME_ELEMENT);
|
||||||
|
serializer.text(name);
|
||||||
|
serializer.endTag(null, NAME_ELEMENT);
|
||||||
|
|
||||||
|
String email = (String) prefs.get(accountUuid + "." + Account.IDENTITY_EMAIL_KEY +
|
||||||
|
"." + identity);
|
||||||
|
serializer.startTag(null, EMAIL_ELEMENT);
|
||||||
|
serializer.text(email);
|
||||||
|
serializer.endTag(null, EMAIL_ELEMENT);
|
||||||
|
|
||||||
|
String description = (String) prefs.get(accountUuid + "." +
|
||||||
|
Account.IDENTITY_DESCRIPTION_KEY + "." + identity);
|
||||||
|
if (description != null) {
|
||||||
|
serializer.startTag(null, DESCRIPTION_ELEMENT);
|
||||||
|
serializer.text(description);
|
||||||
|
serializer.endTag(null, DESCRIPTION_ELEMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
serializer.startTag(null, SETTINGS_ELEMENT);
|
||||||
for (Map.Entry<String, ? extends Object> entry : prefs.entrySet()) {
|
for (Map.Entry<String, ? extends Object> entry : prefs.entrySet()) {
|
||||||
String key = entry.getKey();
|
String key = entry.getKey();
|
||||||
String value = entry.getValue().toString();
|
String value = entry.getValue().toString();
|
||||||
@ -251,7 +285,10 @@ public class StorageExporter {
|
|||||||
String identityKey = comps[1];
|
String identityKey = comps[1];
|
||||||
String identityIndex = comps[2];
|
String identityIndex = comps[2];
|
||||||
if (!keyUuid.equals(accountUuid) || !identityIndex.equals(identity)
|
if (!keyUuid.equals(accountUuid) || !identityIndex.equals(identity)
|
||||||
|| !Account.IDENTITY_KEYS.contains(identityKey)) {
|
|| !Account.IDENTITY_KEYS.contains(identityKey)
|
||||||
|
|| Account.IDENTITY_NAME_KEY.equals(identityKey)
|
||||||
|
|| Account.IDENTITY_EMAIL_KEY.equals(identityKey)
|
||||||
|
|| Account.IDENTITY_DESCRIPTION_KEY.equals(identityKey)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -264,6 +301,8 @@ public class StorageExporter {
|
|||||||
serializer.text(value);
|
serializer.text(value);
|
||||||
serializer.endTag(null, VALUE_ELEMENT);
|
serializer.endTag(null, VALUE_ELEMENT);
|
||||||
}
|
}
|
||||||
|
serializer.endTag(null, SETTINGS_ELEMENT);
|
||||||
|
|
||||||
serializer.endTag(null, IDENTITY_ELEMENT);
|
serializer.endTag(null, IDENTITY_ELEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user