mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-23 14:41:08 +00:00
Added contact group to vCard import/export
This commit is contained in:
parent
0e107b0f76
commit
43f26cac88
2 changed files with 16 additions and 0 deletions
|
@ -168,6 +168,10 @@ public class EntityContact implements Serializable {
|
|||
}
|
||||
|
||||
public static void update(Context context, long account, Address[] addresses, int type, long time) {
|
||||
update(context, account, addresses, null, type, time);
|
||||
}
|
||||
|
||||
public static void update(Context context, long account, Address[] addresses, String group, int type, long time) {
|
||||
if (addresses == null)
|
||||
return;
|
||||
|
||||
|
@ -192,6 +196,7 @@ public class EntityContact implements Serializable {
|
|||
contact.type = type;
|
||||
contact.email = email;
|
||||
contact.name = name;
|
||||
contact.group = group;
|
||||
contact.avatar = (avatar == null ? null : avatar.toString());
|
||||
contact.times_contacted = 1;
|
||||
contact.first_contacted = time;
|
||||
|
@ -201,6 +206,8 @@ public class EntityContact implements Serializable {
|
|||
} else {
|
||||
if (contact.name == null && name != null)
|
||||
contact.name = name;
|
||||
if (contact.group == null && group != null)
|
||||
contact.group = group;
|
||||
contact.avatar = (avatar == null ? null : avatar.toString());
|
||||
contact.times_contacted++;
|
||||
contact.first_contacted = Math.min(contact.first_contacted, time);
|
||||
|
|
|
@ -71,6 +71,7 @@ import ezvcard.VCard;
|
|||
import ezvcard.VCardVersion;
|
||||
import ezvcard.io.text.VCardReader;
|
||||
import ezvcard.io.text.VCardWriter;
|
||||
import ezvcard.property.Categories;
|
||||
import ezvcard.property.Email;
|
||||
import ezvcard.property.FormattedName;
|
||||
|
||||
|
@ -401,6 +402,11 @@ public class FragmentContacts extends FragmentBase {
|
|||
FormattedName fn = vcard.getFormattedName();
|
||||
String name = (fn == null) ? null : fn.getValue();
|
||||
|
||||
List<String> categories = new ArrayList<>();
|
||||
if (vcard.getCategories() != null)
|
||||
categories.addAll(vcard.getCategories().getValues());
|
||||
String group = (categories.size() < 1 ? null : categories.get(0));
|
||||
|
||||
List<Address> addresses = new ArrayList<>();
|
||||
for (Email email : emails) {
|
||||
String address = email.getValue();
|
||||
|
@ -412,6 +418,7 @@ public class FragmentContacts extends FragmentBase {
|
|||
EntityContact.update(context,
|
||||
account,
|
||||
addresses.toArray(new Address[0]),
|
||||
group,
|
||||
EntityContact.TYPE_TO,
|
||||
now);
|
||||
}
|
||||
|
@ -474,6 +481,8 @@ public class FragmentContacts extends FragmentBase {
|
|||
vcard.addEmail(contact.email);
|
||||
if (!TextUtils.isEmpty(contact.name))
|
||||
vcard.setFormattedName(contact.name);
|
||||
if (!TextUtils.isEmpty(contact.group))
|
||||
vcard.setCategories(contact.group);
|
||||
vcards.add(vcard);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue