mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Storing & using international prefix iso country code
This commit is contained in:
parent
c8a20f4f57
commit
110ff995f8
5 changed files with 24 additions and 5 deletions
|
|
@ -141,6 +141,7 @@ class LoginFragment : Fragment() {
|
|||
val dialPlan = PhoneNumberUtils.getDeviceDialPlan(requireContext())
|
||||
if (dialPlan != null) {
|
||||
viewModel.internationalPrefix.postValue(dialPlan.countryCallingCode)
|
||||
viewModel.internationalPrefixIsoCountryCode.postValue(dialPlan.isoCountryCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ class ThirdPartySipAccountLoginFragment : Fragment() {
|
|||
val dialPlan = PhoneNumberUtils.getDeviceDialPlan(requireContext())
|
||||
if (dialPlan != null) {
|
||||
viewModel.internationalPrefix.postValue(dialPlan.countryCallingCode)
|
||||
viewModel.internationalPrefixIsoCountryCode.postValue(dialPlan.isoCountryCode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val internationalPrefix = MutableLiveData<String>()
|
||||
|
||||
val internationalPrefixIsoCountryCode = MutableLiveData<String>()
|
||||
|
||||
val showPassword = MutableLiveData<Boolean>()
|
||||
|
||||
val loginEnabled = MediatorLiveData<Boolean>()
|
||||
|
|
@ -171,6 +173,7 @@ class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
accountParams.identityAddress = identityAddress
|
||||
|
||||
val prefix = internationalPrefix.value.orEmpty().trim()
|
||||
val isoCountryCode = internationalPrefixIsoCountryCode.value.orEmpty()
|
||||
if (prefix.isNotEmpty()) {
|
||||
val prefixDigits = if (prefix.startsWith("+")) {
|
||||
prefix.substring(1)
|
||||
|
|
@ -178,8 +181,11 @@ class AccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
prefix
|
||||
}
|
||||
if (prefixDigits.isNotEmpty()) {
|
||||
Log.i("$TAG Setting international prefix [$prefixDigits] in account params")
|
||||
Log.i(
|
||||
"$TAG Setting international prefix [$prefixDigits]($isoCountryCode) in account params"
|
||||
)
|
||||
accountParams.internationalPrefix = prefixDigits
|
||||
accountParams.internationalPrefixIsoCountryCode = isoCountryCode
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ class ThirdPartySipAccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val internationalPrefix = MutableLiveData<String>()
|
||||
|
||||
val internationalPrefixIsoCountryCode = MutableLiveData<String>()
|
||||
|
||||
val showPassword = MutableLiveData<Boolean>()
|
||||
|
||||
val loginEnabled = MediatorLiveData<Boolean>()
|
||||
|
|
@ -171,6 +173,7 @@ class ThirdPartySipAccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
accountParams.serverAddress = serverAddress
|
||||
|
||||
val prefix = internationalPrefix.value.orEmpty().trim()
|
||||
val isoCountryCode = internationalPrefixIsoCountryCode.value.orEmpty()
|
||||
if (prefix.isNotEmpty()) {
|
||||
val prefixDigits = if (prefix.startsWith("+")) {
|
||||
prefix.substring(1)
|
||||
|
|
@ -178,8 +181,11 @@ class ThirdPartySipAccountLoginViewModel @UiThread constructor() : ViewModel() {
|
|||
prefix
|
||||
}
|
||||
if (prefixDigits.isNotEmpty()) {
|
||||
Log.i("$TAG Setting international prefix [$prefixDigits] in account params")
|
||||
Log.i(
|
||||
"$TAG Setting international prefix [$prefixDigits]($isoCountryCode) in account params"
|
||||
)
|
||||
accountParams.internationalPrefix = prefixDigits
|
||||
accountParams.internationalPrefixIsoCountryCode = isoCountryCode
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,11 +115,14 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() {
|
|||
devices.postValue(devicesList)
|
||||
|
||||
val prefix = account.params.internationalPrefix
|
||||
if (!prefix.isNullOrEmpty()) {
|
||||
val isoCountryCode = account.params.internationalPrefixIsoCountryCode
|
||||
if (!prefix.isNullOrEmpty() || !isoCountryCode.isNullOrEmpty()) {
|
||||
Log.i(
|
||||
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] prefix is [$prefix]"
|
||||
"$TAG Account [${account.params.identityAddress?.asStringUriOnly()}] prefix is [$prefix]($isoCountryCode)"
|
||||
)
|
||||
val dialPlan = Factory.instance().dialPlans.find {
|
||||
it.isoCountryCode == isoCountryCode
|
||||
} ?: Factory.instance().dialPlans.find {
|
||||
it.countryCallingCode == prefix
|
||||
}
|
||||
if (dialPlan != null) {
|
||||
|
|
@ -238,9 +241,10 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() {
|
|||
val params = account.params
|
||||
val copy = params.clone()
|
||||
copy.internationalPrefix = dialPlan.countryCallingCode
|
||||
copy.internationalPrefixIsoCountryCode = dialPlan.isoCountryCode
|
||||
account.params = copy
|
||||
Log.i(
|
||||
"$TAG Updated international prefix for account [${account.params.identityAddress?.asStringUriOnly()}] to [${copy.internationalPrefix}]"
|
||||
"$TAG Updated international prefix for account [${account.params.identityAddress?.asStringUriOnly()}] to [${copy.internationalPrefix} (${copy.internationalPrefixIsoCountryCode})]"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -251,6 +255,7 @@ class AccountProfileViewModel @UiThread constructor() : ViewModel() {
|
|||
val params = account.params
|
||||
val copy = params.clone()
|
||||
copy.internationalPrefix = ""
|
||||
copy.internationalPrefixIsoCountryCode = ""
|
||||
account.params = copy
|
||||
Log.i(
|
||||
"$TAG Removed international prefix for account [${account.params.identityAddress?.asStringUriOnly()}]"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue