mirror of
				https://github.com/SimpleMobileTools/Simple-SMS-Messenger.git
				synced 2025-06-05 21:49:22 +02:00 
			
		
		
		
	Construct name from structured name
This commit is contained in:
		| @@ -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) } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user