From 4e7767437723c10fdc9f0413d95b72d072425e13 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 17 Dec 2017 23:10:47 +0100 Subject: [PATCH] allow storing multiple emails of same type per contact --- .../contacts/helpers/ContactsHelper.kt | 3 ++- .../com/simplemobiletools/contacts/models/Email.kt | 3 +++ .../com/simplemobiletools/contacts/models/Emails.kt | 13 +------------ 3 files changed, 6 insertions(+), 13 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt index 2e024ea8..3424e6fb 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/ContactsHelper.kt @@ -14,6 +14,7 @@ import com.simplemobiletools.commons.helpers.SORT_BY_SURNAME import com.simplemobiletools.commons.helpers.SORT_DESCENDING import com.simplemobiletools.contacts.extensions.config import com.simplemobiletools.contacts.models.Contact +import com.simplemobiletools.contacts.models.Email import com.simplemobiletools.contacts.models.Emails import com.simplemobiletools.contacts.overloads.times import java.util.* @@ -138,7 +139,7 @@ class ContactsHelper(val activity: BaseSimpleActivity) { emails.put(id, Emails()) } - emails[id]!!.fillEmail(email, type) + emails[id]!!.emails.add(Email(email, type)) } while (cursor.moveToNext()) } } finally { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt new file mode 100644 index 00000000..268bf7e9 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Email.kt @@ -0,0 +1,3 @@ +package com.simplemobiletools.contacts.models + +data class Email(var value: String, var type: Int) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Emails.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Emails.kt index 403e592d..7089a81c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/models/Emails.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/models/Emails.kt @@ -1,14 +1,3 @@ package com.simplemobiletools.contacts.models -import android.provider.ContactsContract - -data class Emails(var home: String = "", var work: String = "", var mobile: String = "", var other: String = "") { - fun fillEmail(email: String, type: Int) { - when (type) { - ContactsContract.CommonDataKinds.Email.TYPE_HOME -> home = email - ContactsContract.CommonDataKinds.Email.TYPE_WORK -> work = email - ContactsContract.CommonDataKinds.Email.TYPE_MOBILE -> mobile = email - ContactsContract.CommonDataKinds.Email.TYPE_OTHER -> other = email - } - } -} +data class Emails(var emails: ArrayList = ArrayList())