fill in the first email and phone number of the contact
This commit is contained in:
parent
bb18218c0a
commit
77f1c2f2fa
4 changed files with 45 additions and 5 deletions
|
@ -36,7 +36,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.2.19'
|
||||
implementation 'com.simplemobiletools:commons:3.2.20'
|
||||
|
||||
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
|
||||
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
|
||||
|
|
|
@ -146,9 +146,25 @@ class ContactActivity : SimpleActivity() {
|
|||
contact_first_name.setText(contact!!.firstName)
|
||||
contact_middle_name.setText(contact!!.middleName)
|
||||
contact_surname.setText(contact!!.surname)
|
||||
//contact_number.setText(contact!!.number)
|
||||
//contact_email.setText(contact!!.email)
|
||||
contact_source.text = contact!!.source
|
||||
|
||||
contact!!.phoneNumbers.forEachIndexed { index, number ->
|
||||
if (index == 0) {
|
||||
contact_number.setText(number.value)
|
||||
contact_number_type.setText(number.getTextId())
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
contact!!.emails.forEachIndexed { index, email ->
|
||||
if (index == 0) {
|
||||
contact_email.setText(email.value)
|
||||
contact_email_type.setText(email.getTextId())
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupNewContact() {
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
package com.simplemobiletools.contacts.models
|
||||
|
||||
data class Email(var value: String, var type: Int)
|
||||
import android.provider.ContactsContract
|
||||
import com.simplemobiletools.contacts.R
|
||||
|
||||
data class Email(var value: String, var type: Int) {
|
||||
fun getTextId() = when (type) {
|
||||
ContactsContract.CommonDataKinds.Email.TYPE_HOME -> R.string.home
|
||||
ContactsContract.CommonDataKinds.Email.TYPE_WORK -> R.string.work
|
||||
ContactsContract.CommonDataKinds.Email.TYPE_MOBILE -> R.string.mobile
|
||||
else -> R.string.other
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
package com.simplemobiletools.contacts.models
|
||||
|
||||
data class PhoneNumber(var value: String, var type: Int)
|
||||
import android.provider.ContactsContract
|
||||
import com.simplemobiletools.contacts.R
|
||||
|
||||
data class PhoneNumber(var value: String, var type: Int) {
|
||||
fun getTextId() = when (type) {
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE -> R.string.mobile
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_HOME -> R.string.home
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_WORK -> R.string.work
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_MAIN -> R.string.main_number
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_FAX_WORK -> R.string.work_fax
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME -> R.string.home_fax
|
||||
ContactsContract.CommonDataKinds.Phone.TYPE_PAGER -> R.string.pager
|
||||
else -> R.string.other
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue