Construct name from structured name
This commit is contained in:
parent
00d69ad40e
commit
4f809426bb
|
@ -55,7 +55,7 @@ class VCardViewerAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupVCardView(view: View, item: VCardWrapper) {
|
private fun setupVCardView(view: View, item: VCardWrapper) {
|
||||||
val name = item.vCard.formattedName?.value
|
val name = item.getFullName()
|
||||||
view.apply {
|
view.apply {
|
||||||
item_contact_name.apply {
|
item_contact_name.apply {
|
||||||
text = name
|
text = name
|
||||||
|
|
|
@ -14,6 +14,21 @@ private val displayedPropertyClasses = arrayOf(
|
||||||
|
|
||||||
data class VCardWrapper(val vCard: VCard, var expanded: Boolean = false) {
|
data class VCardWrapper(val vCard: VCard, var expanded: Boolean = false) {
|
||||||
|
|
||||||
|
fun getFullName(): String? {
|
||||||
|
var formattedName = vCard.formattedName?.value
|
||||||
|
if (formattedName.isNullOrEmpty()) {
|
||||||
|
val structured = vCard.structuredName
|
||||||
|
val given = structured?.given
|
||||||
|
val family = structured.family
|
||||||
|
formattedName = if (family != null) {
|
||||||
|
given?.plus(" ")?.plus(family)
|
||||||
|
} else {
|
||||||
|
given
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return formattedName
|
||||||
|
}
|
||||||
|
|
||||||
fun getVCardProperties(context: Context): List<VCardPropertyWrapper> {
|
fun getVCardProperties(context: Context): List<VCardPropertyWrapper> {
|
||||||
return vCard.properties
|
return vCard.properties
|
||||||
.filter { displayedPropertyClasses.contains(it::class.java) }
|
.filter { displayedPropertyClasses.contains(it::class.java) }
|
||||||
|
|
Loading…
Reference in New Issue