From b8947ecd25ddccdbcf87ffdf05729bc2ebc71dfc Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 2 Feb 2019 19:49:25 +0000 Subject: [PATCH] Export/import realm, fixed bcc import, refactoring --- .../java/eu/faircode/email/EntityAccount.java | 43 +++++++++++-------- .../eu/faircode/email/EntityIdentity.java | 12 +++--- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityAccount.java b/app/src/main/java/eu/faircode/email/EntityAccount.java index bc3a9f9238..615f4b8b9a 100644 --- a/app/src/main/java/eu/faircode/email/EntityAccount.java +++ b/app/src/main/java/eu/faircode/email/EntityAccount.java @@ -108,24 +108,28 @@ public class EntityAccount implements Serializable { public JSONObject toJSON() throws JSONException { JSONObject json = new JSONObject(); - json.put("name", name); - json.put("prefix", prefix); + json.put("auth_type", auth_type); json.put("host", host); json.put("starttls", starttls); json.put("insecure", insecure); json.put("port", port); json.put("user", user); json.put("password", password); - json.put("auth_type", auth_type); + json.put("realm", password); + + json.put("name", name); + json.put("color", color); + json.put("synchronize", synchronize); json.put("primary", primary); + json.put("notify", notify); json.put("browse", browse); + json.put("swipe_left", swipe_left); json.put("swipe_right", swipe_right); - if (color != null) - json.put("color", color); - json.put("notify", notify); + json.put("poll_interval", poll_interval); + json.put("prefix", prefix); // not created // not state // not error @@ -135,36 +139,37 @@ public class EntityAccount implements Serializable { public static EntityAccount fromJSON(JSONObject json) throws JSONException { EntityAccount account = new EntityAccount(); - if (json.has("name")) - account.name = json.getString("name"); - if (json.has("prefix")) - account.prefix = json.getString("prefix"); + account.auth_type = json.getInt("auth_type"); account.host = json.getString("host"); account.starttls = (json.has("starttls") && json.getBoolean("starttls")); account.insecure = (json.has("insecure") && json.getBoolean("insecure")); account.port = json.getInt("port"); account.user = json.getString("user"); account.password = json.getString("password"); - account.auth_type = json.getInt("auth_type"); + if (json.has("realm")) + account.realm = json.getString("realm"); + + if (json.has("name")) + account.name = json.getString("name"); + if (json.has("color")) + account.color = json.getInt("color"); + account.synchronize = json.getBoolean("synchronize"); account.primary = json.getBoolean("primary"); - + if (json.has("notify")) + account.notify = json.getBoolean("notify"); if (json.has("browse")) account.browse = json.getBoolean("browse"); if (json.has("swipe_left")) account.swipe_left = json.getLong("swipe_left"); - if (json.has("swipe_right")) account.swipe_right = json.getLong("swipe_right"); - if (json.has("color")) - account.color = json.getInt("color"); - - if (json.has("notify")) - account.notify = json.getBoolean("notify"); - account.poll_interval = json.getInt("poll_interval"); + if (json.has("prefix")) + account.prefix = json.getString("prefix"); + return account; } diff --git a/app/src/main/java/eu/faircode/email/EntityIdentity.java b/app/src/main/java/eu/faircode/email/EntityIdentity.java index 4b02599007..d942500a56 100644 --- a/app/src/main/java/eu/faircode/email/EntityIdentity.java +++ b/app/src/main/java/eu/faircode/email/EntityIdentity.java @@ -96,6 +96,7 @@ public class EntityIdentity { json.put("color", color); json.put("signature", signature); // not account + json.put("auth_type", auth_type); json.put("host", host); json.put("starttls", starttls); @@ -103,11 +104,14 @@ public class EntityIdentity { json.put("port", port); json.put("user", user); json.put("password", password); + json.put("realm", realm); + json.put("synchronize", synchronize); json.put("primary", primary); json.put("replyto", replyto); json.put("bcc", bcc); + json.put("delivery_receipt", delivery_receipt); json.put("read_receipt", read_receipt); json.put("store_sent", store_sent); @@ -120,10 +124,8 @@ public class EntityIdentity { EntityIdentity identity = new EntityIdentity(); identity.name = json.getString("name"); identity.email = json.getString("email"); - if (json.has("display")) identity.display = json.getString("display"); - if (json.has("color")) identity.color = json.getInt("color"); if (json.has("signature")) @@ -136,19 +138,19 @@ public class EntityIdentity { identity.port = json.getInt("port"); identity.user = json.getString("user"); identity.password = json.getString("password"); + if (json.has("realm")) + identity.realm = json.getString("realm"); identity.synchronize = json.getBoolean("synchronize"); identity.primary = json.getBoolean("primary"); if (json.has("replyto")) identity.replyto = json.getString("replyto"); - if (json.has("bcc")) - identity.replyto = json.getString("bcc"); + identity.bcc = json.getString("bcc"); if (json.has("delivery_receipt")) identity.delivery_receipt = json.getBoolean("delivery_receipt"); - if (json.has("read_receipt")) identity.read_receipt = json.getBoolean("read_receipt");