Merge pull request #875 from Naveen3Singh/add_extension
Export formatted name as well as structured name
This commit is contained in:
commit
c38bb2a759
|
@ -63,7 +63,7 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:f6ddbdf19b'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:141660c8f9'
|
||||||
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
|
||||||
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
implementation 'com.github.tibbi:IndicatorFastScroll:4524cd0b61'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
|
|
|
@ -27,7 +27,6 @@ import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.letterBackgroundColors
|
import com.simplemobiletools.commons.helpers.letterBackgroundColors
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.extensions.sendEmailIntent
|
|
||||||
import com.simplemobiletools.contacts.pro.extensions.shareContacts
|
import com.simplemobiletools.contacts.pro.extensions.shareContacts
|
||||||
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
|
import com.simplemobiletools.contacts.pro.helpers.ContactsHelper
|
||||||
import com.simplemobiletools.contacts.pro.models.Contact
|
import com.simplemobiletools.contacts.pro.models.Contact
|
||||||
|
|
|
@ -11,7 +11,9 @@ import android.os.Looper
|
||||||
import android.provider.ContactsContract
|
import android.provider.ContactsContract
|
||||||
import androidx.core.content.FileProvider
|
import androidx.core.content.FileProvider
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.PERMISSION_READ_CONTACTS
|
||||||
|
import com.simplemobiletools.commons.helpers.PERMISSION_WRITE_CONTACTS
|
||||||
|
import com.simplemobiletools.commons.helpers.SimpleContactsHelper
|
||||||
import com.simplemobiletools.contacts.pro.BuildConfig
|
import com.simplemobiletools.contacts.pro.BuildConfig
|
||||||
import com.simplemobiletools.contacts.pro.R
|
import com.simplemobiletools.contacts.pro.R
|
||||||
import com.simplemobiletools.contacts.pro.databases.ContactsDatabase
|
import com.simplemobiletools.contacts.pro.databases.ContactsDatabase
|
||||||
|
@ -40,13 +42,6 @@ fun Context.getEmptyContact(): Contact {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.sendEmailIntent(recipient: String) {
|
|
||||||
Intent(Intent.ACTION_SENDTO).apply {
|
|
||||||
data = Uri.fromParts(KEY_MAILTO, recipient, null)
|
|
||||||
launchActivityIntent(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Context.sendAddressIntent(address: String) {
|
fun Context.sendAddressIntent(address: String) {
|
||||||
val location = Uri.encode(address)
|
val location = Uri.encode(address)
|
||||||
val uri = Uri.parse("geo:0,0?q=$location")
|
val uri = Uri.parse("geo:0,0?q=$location")
|
||||||
|
|
|
@ -51,6 +51,12 @@ class VcfExporter {
|
||||||
val cards = ArrayList<VCard>()
|
val cards = ArrayList<VCard>()
|
||||||
for (contact in contacts) {
|
for (contact in contacts) {
|
||||||
val card = VCard()
|
val card = VCard()
|
||||||
|
|
||||||
|
val formattedName = arrayOf(contact.prefix, contact.firstName, contact.middleName, contact.surname, contact.suffix)
|
||||||
|
.filter { it.isNotEmpty() }
|
||||||
|
.joinToString(separator = " ")
|
||||||
|
card.formattedName = FormattedName(formattedName)
|
||||||
|
|
||||||
StructuredName().apply {
|
StructuredName().apply {
|
||||||
prefixes.add(contact.prefix)
|
prefixes.add(contact.prefix)
|
||||||
given = contact.firstName
|
given = contact.firstName
|
||||||
|
|
Loading…
Reference in New Issue