From 04950bc8c8d8ee24c00a77c504f18920a7363d2b Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Sat, 7 Apr 2018 14:21:54 -0400 Subject: [PATCH] Format phone number when composing message to new address --- .../src/main/java/feature/compose/ComposeViewModel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/presentation/src/main/java/feature/compose/ComposeViewModel.kt b/presentation/src/main/java/feature/compose/ComposeViewModel.kt index 1c7b16c0..5af55169 100644 --- a/presentation/src/main/java/feature/compose/ComposeViewModel.kt +++ b/presentation/src/main/java/feature/compose/ComposeViewModel.kt @@ -59,6 +59,7 @@ import repository.ContactRepository import repository.MessageRepository import util.extensions.asObservable import java.net.URLDecoder +import java.util.* import java.util.concurrent.TimeUnit import javax.inject.Inject @@ -208,7 +209,8 @@ class ComposeViewModel(intent: Intent) : QkViewModel( // If the entry is a valid destination, allow it as a recipient if (PhoneNumberUtils.isWellFormedSmsAddress(query.toString())) { - val newContact = Contact(numbers = RealmList(PhoneNumber(address = query.toString()))) + val newAddress = PhoneNumberUtils.formatNumber(query.toString(), Locale.getDefault().country) + val newContact = Contact(numbers = RealmList(PhoneNumber(address = newAddress ?: query.toString()))) filteredContacts = listOf(newContact) + filteredContacts }