mirror of
				https://github.com/SimpleMobileTools/Simple-Contacts.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	handle exporting and importing contact nicknames
This commit is contained in:
		| @@ -42,6 +42,10 @@ class VcfExporter { | ||||
|                         out.writeLn(VERSION_2_1) | ||||
|                         out.writeLn("$N${getNames(contact)}") | ||||
|  | ||||
|                         if (contact.nickname.isNotEmpty()) { | ||||
|                             out.writeLn("$NICKNAME:${contact.nickname}") | ||||
|                         } | ||||
|  | ||||
|                         contact.phoneNumbers.forEach { | ||||
|                             out.writeLn("$TEL;${getPhoneNumberLabel(it.type)}:${it.value}") | ||||
|                         } | ||||
|   | ||||
| @@ -93,7 +93,7 @@ class VcfImporter(val activity: SimpleActivity) { | ||||
|                     when { | ||||
|                         line.toUpperCase() == BEGIN_VCARD -> resetValues() | ||||
|                         line.toUpperCase().startsWith(NOTE) -> addNotes(line.substring(NOTE.length)) | ||||
|                         line.toUpperCase().startsWith(NICKNAME) -> { } | ||||
|                         line.toUpperCase().startsWith(NICKNAME) -> addNickname(line.substring(NICKNAME.length)) | ||||
|                         line.toUpperCase().startsWith(N) -> addNames(line.substring(N.length)) | ||||
|                         line.toUpperCase().startsWith(TEL) -> addPhoneNumber(line.substring(TEL.length)) | ||||
|                         line.toUpperCase().startsWith(EMAIL) -> addEmail(line.substring(EMAIL.length)) | ||||
| @@ -148,6 +148,14 @@ class VcfImporter(val activity: SimpleActivity) { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun addNickname(nickname: String) { | ||||
|         curNickname = if (nickname.startsWith(";CHARSET", true)) { | ||||
|             nickname.substringAfter(":") | ||||
|         } else { | ||||
|             nickname.substring(1) | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private fun addPhoneNumber(phoneNumber: String) { | ||||
|         val phoneParts = phoneNumber.trimStart(';').split(":") | ||||
|         var rawType = phoneParts[0] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user