Fixed wrong country being displayed when picking a prefix if there are multiple countries matching that prefix
This commit is contained in:
parent
4ff06f8494
commit
b463025a0e
1 changed files with 2 additions and 5 deletions
|
@ -20,9 +20,7 @@
|
||||||
|
|
||||||
package org.linphone.activities.assistant.viewmodels
|
package org.linphone.activities.assistant.viewmodels
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.Transformations
|
|
||||||
import androidx.lifecycle.ViewModel
|
import androidx.lifecycle.ViewModel
|
||||||
import org.linphone.activities.assistant.fragments.CountryPickerFragment
|
import org.linphone.activities.assistant.fragments.CountryPickerFragment
|
||||||
import org.linphone.core.AccountCreator
|
import org.linphone.core.AccountCreator
|
||||||
|
@ -39,9 +37,7 @@ abstract class AbstractPhoneViewModel(val accountCreator: AccountCreator) :
|
||||||
val phoneNumber = MutableLiveData<String>()
|
val phoneNumber = MutableLiveData<String>()
|
||||||
val phoneNumberError = MutableLiveData<String>()
|
val phoneNumberError = MutableLiveData<String>()
|
||||||
|
|
||||||
val countryName: LiveData<String> = Transformations.switchMap(prefix) {
|
val countryName = MutableLiveData<String>()
|
||||||
getCountryNameFromPrefix(it)
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
prefix.value = "+"
|
prefix.value = "+"
|
||||||
|
@ -49,6 +45,7 @@ abstract class AbstractPhoneViewModel(val accountCreator: AccountCreator) :
|
||||||
|
|
||||||
override fun onCountryClicked(dialPlan: DialPlan) {
|
override fun onCountryClicked(dialPlan: DialPlan) {
|
||||||
prefix.value = "+${dialPlan.countryCallingCode}"
|
prefix.value = "+${dialPlan.countryCallingCode}"
|
||||||
|
countryName.value = dialPlan.country
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isPhoneNumberOk(): Boolean {
|
fun isPhoneNumberOk(): Boolean {
|
||||||
|
|
Loading…
Reference in a new issue