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