Added account to local contacts

This commit is contained in:
M66B
2019-03-17 08:26:17 +00:00
parent d63536b3fc
commit 5d98923ffc
10 changed files with 1749 additions and 73 deletions

View File

@@ -509,14 +509,15 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
}
jaccount.put("folders", jfolders);
// Contacts
JSONArray jcontacts = new JSONArray();
for (EntityContact contact : db.contact().getContacts(account.id))
jcontacts.put(contact.toJSON());
jaccount.put("contacts", jcontacts);
jaccounts.put(jaccount);
}
// Contacts
JSONArray jcontacts = new JSONArray();
for (EntityContact contact : db.contact().getContacts())
jcontacts.put(contact.toJSON());
// Answers
JSONArray janswers = new JSONArray();
for (EntityAnswer answer : db.answer().getAnswers())
@@ -535,7 +536,6 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
JSONObject jexport = new JSONObject();
jexport.put("accounts", jaccounts);
jexport.put("contacts", jcontacts);
jexport.put("answers", janswers);
jexport.put("settings", jsettings);
@@ -700,21 +700,22 @@ public class ActivitySetup extends ActivityBilling implements FragmentManager.On
Log.i("Imported folder=" + folder.name);
}
// Contacts
JSONArray jcontacts = jaccount.getJSONArray("contacts");
for (int c = 0; c < jcontacts.length(); c++) {
JSONObject jcontact = (JSONObject) jcontacts.get(c);
EntityContact contact = EntityContact.fromJSON(jcontact);
contact.account = account.id;
if (db.contact().getContact(contact.account, contact.type, contact.email) == null) {
contact.id = db.contact().insertContact(contact);
Log.i("Imported contact=" + contact);
}
}
// Update swipe left/right
db.account().updateAccount(account);
}
// Contacts
JSONArray jcontacts = jimport.getJSONArray("contacts");
for (int c = 0; c < jcontacts.length(); c++) {
JSONObject jcontact = (JSONObject) jcontacts.get(c);
EntityContact contact = EntityContact.fromJSON(jcontact);
if (db.contact().getContact(contact.type, contact.email) == null) {
contact.id = db.contact().insertContact(contact);
Log.i("Imported contact=" + contact);
}
}
// Answers
JSONArray janswers = jimport.getJSONArray("answers");
for (int a = 0; a < janswers.length(); a++) {