Remove internation prefix from phone number in assistant, if possible

This commit is contained in:
Sylvain Berfini 2021-11-25 10:47:58 +01:00
parent ed59215e9c
commit ef6bbbc3c8

View file

@ -56,14 +56,19 @@ abstract class AbstractPhoneViewModel(val accountCreator: AccountCreator) :
}
fun updateFromPhoneNumberAndOrDialPlan(number: String?, dialPlan: DialPlan?) {
val internationalPrefix = "+${dialPlan?.countryCallingCode}"
if (dialPlan != null) {
Log.i("[Assistant] Found prefix from dial plan: ${dialPlan.countryCallingCode}")
prefix.value = "+${dialPlan.countryCallingCode}"
prefix.value = internationalPrefix
}
if (number != null) {
Log.i("[Assistant] Found phone number: $number")
phoneNumber.value = number!!
phoneNumber.value = if (number.startsWith(internationalPrefix)) {
number.substring(internationalPrefix.length)
} else {
number
}
}
}