mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-25 15:32:52 +00:00
Fixed importing swipe left/right target
This commit is contained in:
parent
c0f45d34d9
commit
99732b22c3
6 changed files with 29 additions and 0 deletions
|
@ -621,6 +621,13 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
for (int a = 0; a < jaccounts.length(); a++) {
|
||||
JSONObject jaccount = (JSONObject) jaccounts.get(a);
|
||||
EntityAccount account = EntityAccount.fromJSON(jaccount);
|
||||
|
||||
// Forward referenced
|
||||
Long swipe_left = account.swipe_left;
|
||||
Long swipe_right = account.swipe_right;
|
||||
account.swipe_left = null;
|
||||
account.swipe_right = null;
|
||||
|
||||
account.created = new Date().getTime();
|
||||
account.id = db.account().insertAccount(account);
|
||||
Log.i("Imported account=" + account.name);
|
||||
|
@ -642,8 +649,17 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
for (int f = 0; f < jfolders.length(); f++) {
|
||||
JSONObject jfolder = (JSONObject) jfolders.get(f);
|
||||
EntityFolder folder = EntityFolder.fromJSON(jfolder);
|
||||
long id = folder.id;
|
||||
folder.id = null;
|
||||
|
||||
folder.account = account.id;
|
||||
folder.id = db.folder().insertFolder(folder);
|
||||
|
||||
if (swipe_left != null && swipe_left.equals(id))
|
||||
account.swipe_left = folder.id;
|
||||
if (swipe_right != null && swipe_right.equals(id))
|
||||
account.swipe_right = folder.id;
|
||||
|
||||
if (jfolder.has("rules")) {
|
||||
JSONArray jrules = jfolder.getJSONArray("rules");
|
||||
for (int r = 0; r < jrules.length(); r++) {
|
||||
|
@ -655,6 +671,9 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
|
|||
}
|
||||
Log.i("Imported folder=" + folder.name);
|
||||
}
|
||||
|
||||
// Update swipe left/right
|
||||
db.account().updateAccount(account);
|
||||
}
|
||||
|
||||
JSONArray janswers = jimport.getJSONArray("answers");
|
||||
|
|
|
@ -108,6 +108,7 @@ public class EntityAccount implements Serializable {
|
|||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", id);
|
||||
json.put("auth_type", auth_type);
|
||||
json.put("host", host);
|
||||
json.put("starttls", starttls);
|
||||
|
@ -139,6 +140,7 @@ public class EntityAccount implements Serializable {
|
|||
|
||||
public static EntityAccount fromJSON(JSONObject json) throws JSONException {
|
||||
EntityAccount account = new EntityAccount();
|
||||
// id
|
||||
account.auth_type = json.getInt("auth_type");
|
||||
account.host = json.getString("host");
|
||||
account.starttls = (json.has("starttls") && json.getBoolean("starttls"));
|
||||
|
|
|
@ -71,6 +71,7 @@ public class EntityAnswer implements Serializable {
|
|||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", id);
|
||||
json.put("name", name);
|
||||
json.put("text", text);
|
||||
return json;
|
||||
|
@ -78,6 +79,7 @@ public class EntityAnswer implements Serializable {
|
|||
|
||||
public static EntityAnswer fromJSON(JSONObject json) throws JSONException {
|
||||
EntityAnswer answer = new EntityAnswer();
|
||||
// id
|
||||
answer.name = json.getString("name");
|
||||
answer.text = json.getString("text");
|
||||
return answer;
|
||||
|
|
|
@ -253,6 +253,7 @@ public class EntityFolder implements Serializable {
|
|||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", id);
|
||||
json.put("name", name);
|
||||
json.put("type", type);
|
||||
json.put("level", level);
|
||||
|
@ -270,6 +271,7 @@ public class EntityFolder implements Serializable {
|
|||
|
||||
public static EntityFolder fromJSON(JSONObject json) throws JSONException {
|
||||
EntityFolder folder = new EntityFolder();
|
||||
folder.id = json.getLong("id");
|
||||
folder.name = json.getString("name");
|
||||
folder.type = json.getString("type");
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ public class EntityIdentity {
|
|||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", id);
|
||||
json.put("name", name);
|
||||
json.put("email", email);
|
||||
json.put("display", display);
|
||||
|
@ -122,6 +123,7 @@ public class EntityIdentity {
|
|||
|
||||
public static EntityIdentity fromJSON(JSONObject json) throws JSONException {
|
||||
EntityIdentity identity = new EntityIdentity();
|
||||
// id
|
||||
identity.name = json.getString("name");
|
||||
identity.email = json.getString("email");
|
||||
if (json.has("display"))
|
||||
|
|
|
@ -240,6 +240,7 @@ public class EntityRule {
|
|||
|
||||
public JSONObject toJSON() throws JSONException {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", id);
|
||||
json.put("name", name);
|
||||
json.put("order", order);
|
||||
json.put("enabled", enabled);
|
||||
|
@ -251,6 +252,7 @@ public class EntityRule {
|
|||
|
||||
public static EntityRule fromJSON(JSONObject json) throws JSONException {
|
||||
EntityRule rule = new EntityRule();
|
||||
// id
|
||||
rule.name = json.getString("name");
|
||||
rule.order = json.getInt("order");
|
||||
rule.enabled = json.getBoolean("enabled");
|
||||
|
|
Loading…
Reference in a new issue