get the prefix and suffix at name fetching too
This commit is contained in:
parent
931f977c65
commit
d1f2046f2a
1 changed files with 5 additions and 1 deletions
|
|
@ -86,9 +86,11 @@ fun Context.getMessages(threadID: Int? = null): ArrayList<Message> {
|
||||||
fun Context.getPersonsName(id: Int): String? {
|
fun Context.getPersonsName(id: Int): String? {
|
||||||
val uri = ContactsContract.Data.CONTENT_URI
|
val uri = ContactsContract.Data.CONTENT_URI
|
||||||
val projection = arrayOf(
|
val projection = arrayOf(
|
||||||
|
CommonDataKinds.StructuredName.PREFIX,
|
||||||
CommonDataKinds.StructuredName.GIVEN_NAME,
|
CommonDataKinds.StructuredName.GIVEN_NAME,
|
||||||
CommonDataKinds.StructuredName.MIDDLE_NAME,
|
CommonDataKinds.StructuredName.MIDDLE_NAME,
|
||||||
CommonDataKinds.StructuredName.FAMILY_NAME,
|
CommonDataKinds.StructuredName.FAMILY_NAME,
|
||||||
|
CommonDataKinds.StructuredName.SUFFIX,
|
||||||
CommonDataKinds.Organization.COMPANY,
|
CommonDataKinds.Organization.COMPANY,
|
||||||
CommonDataKinds.Organization.TITLE,
|
CommonDataKinds.Organization.TITLE,
|
||||||
ContactsContract.Data.MIMETYPE
|
ContactsContract.Data.MIMETYPE
|
||||||
|
|
@ -110,11 +112,13 @@ fun Context.getPersonsName(id: Int): String? {
|
||||||
val mimetype = cursor.getStringValue(ContactsContract.Data.MIMETYPE)
|
val mimetype = cursor.getStringValue(ContactsContract.Data.MIMETYPE)
|
||||||
val isPerson = mimetype == CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE
|
val isPerson = mimetype == CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE
|
||||||
if (isPerson) {
|
if (isPerson) {
|
||||||
|
val prefix = cursor.getStringValue(CommonDataKinds.StructuredName.PREFIX) ?: ""
|
||||||
val firstName = cursor.getStringValue(CommonDataKinds.StructuredName.GIVEN_NAME) ?: ""
|
val firstName = cursor.getStringValue(CommonDataKinds.StructuredName.GIVEN_NAME) ?: ""
|
||||||
val middleName = cursor.getStringValue(CommonDataKinds.StructuredName.MIDDLE_NAME) ?: ""
|
val middleName = cursor.getStringValue(CommonDataKinds.StructuredName.MIDDLE_NAME) ?: ""
|
||||||
val familyName = cursor.getStringValue(CommonDataKinds.StructuredName.FAMILY_NAME) ?: ""
|
val familyName = cursor.getStringValue(CommonDataKinds.StructuredName.FAMILY_NAME) ?: ""
|
||||||
|
val suffix = cursor.getStringValue(CommonDataKinds.StructuredName.SUFFIX) ?: ""
|
||||||
if (firstName.isNotEmpty() || middleName.isNotEmpty() || familyName.isNotEmpty()) {
|
if (firstName.isNotEmpty() || middleName.isNotEmpty() || familyName.isNotEmpty()) {
|
||||||
val names = arrayOf(firstName, middleName, familyName).filter { it.isNotEmpty() }
|
val names = arrayOf(prefix, firstName, middleName, familyName, suffix).filter { it.isNotEmpty() }
|
||||||
return TextUtils.join(" ", names)
|
return TextUtils.join(" ", names)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue