allow storing multiple emails of same type per contact

This commit is contained in:
tibbi 2017-12-17 23:10:47 +01:00
parent 0a90594d32
commit 4e77674377
3 changed files with 6 additions and 13 deletions

View File

@ -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 {

View File

@ -0,0 +1,3 @@
package com.simplemobiletools.contacts.models
data class Email(var value: String, var type: Int)

View File

@ -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<Email> = ArrayList())