allow storing multiple emails of same type per contact
This commit is contained in:
parent
0a90594d32
commit
4e77674377
|
@ -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 {
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package com.simplemobiletools.contacts.models
|
||||
|
||||
data class Email(var value: String, var type: Int)
|
|
@ -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())
|
||||
|
|
Loading…
Reference in New Issue