mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-02-07 14:58:24 +00:00
Fixed used of some interpretUrl method calls
This commit is contained in:
parent
a871fb971b
commit
578b372335
9 changed files with 26 additions and 12 deletions
|
|
@ -225,7 +225,7 @@ class ContactLoader : LoaderManager.LoaderCallbacks<Cursor> {
|
|||
)
|
||||
)
|
||||
if (sipAddress != null) {
|
||||
val address = core.interpretUrl(sipAddress, true)
|
||||
val address = core.interpretUrl(sipAddress, false)
|
||||
if (address != null &&
|
||||
friendsAddresses.find {
|
||||
it.weakEqual(address)
|
||||
|
|
|
|||
|
|
@ -735,8 +735,12 @@ fun Friend.getListOfSipAddressesAndPhoneNumbers(listener: ContactNumberOrAddress
|
|||
}
|
||||
|
||||
// phone numbers are disabled is secure mode unless linked to a SIP address
|
||||
val enablePhoneNumbers = hasPresenceInfo || core.defaultAccount?.isInSecureMode() == false
|
||||
val address = presenceAddress ?: core.interpretUrl(number.phoneNumber, true)
|
||||
val defaultAccount = LinphoneUtils.getDefaultAccount()
|
||||
val enablePhoneNumbers = hasPresenceInfo || defaultAccount?.isInSecureMode() == false
|
||||
val address = presenceAddress ?: core.interpretUrl(
|
||||
number.phoneNumber,
|
||||
LinphoneUtils.applyInternationalPrefix(defaultAccount)
|
||||
)
|
||||
val label = PhoneNumberUtils.vcardParamStringToAddressBookLabel(
|
||||
coreContext.context.resources,
|
||||
number.label ?: ""
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import org.linphone.ui.main.history.model.ContactOrSuggestionModel
|
|||
import org.linphone.ui.main.history.viewmodel.StartCallViewModel
|
||||
import org.linphone.ui.main.model.isInSecureMode
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.RecyclerViewHeaderDecoration
|
||||
import org.linphone.utils.hideKeyboard
|
||||
import org.linphone.utils.setKeyboardInsetListener
|
||||
|
|
@ -233,7 +234,7 @@ abstract class AbstractNewTransferCallFragment : GenericCallFragment() {
|
|||
action(address)
|
||||
} else if (addressesCount == 0 && numbersCount == 1 && enablePhoneNumbers) {
|
||||
val number = friend.phoneNumbers.first()
|
||||
val address = core.interpretUrl(number, true)
|
||||
val address = core.interpretUrl(number, LinphoneUtils.applyInternationalPrefix())
|
||||
if (address != null) {
|
||||
Log.i(
|
||||
"$TAG Only 1 phone number found for contact [${friend.name}], starting call directly"
|
||||
|
|
|
|||
|
|
@ -594,10 +594,9 @@ class MainActivity : GenericActivity() {
|
|||
}.replace("%40", "@") // Unescape @ character if needed
|
||||
|
||||
coreContext.postOnCoreThread {
|
||||
val applyPrefix = LinphoneUtils.getDefaultAccount()?.params?.useInternationalPrefixForCallsAndChats ?: false
|
||||
val address = coreContext.core.interpretUrl(
|
||||
sipUriToCall,
|
||||
applyPrefix
|
||||
LinphoneUtils.applyInternationalPrefix()
|
||||
)
|
||||
Log.i("$TAG Interpreted SIP URI is [${address?.asStringUriOnly()}]")
|
||||
if (address != null) {
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ class ContactNewOrEditViewModel @UiThread constructor() : ViewModel() {
|
|||
for (address in sipAddresses) {
|
||||
val data = address.value.value.orEmpty().trim()
|
||||
if (data.isNotEmpty()) {
|
||||
val parsedAddress = core.interpretUrl(data, true)
|
||||
val parsedAddress = core.interpretUrl(data, false)
|
||||
if (parsedAddress != null) {
|
||||
friend.addAddress(parsedAddress)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
coreContext.startCall(address)
|
||||
} else if (addressesCount == 0 && numbersCount == 1 && enablePhoneNumbers) {
|
||||
val number = friend.phoneNumbers.first()
|
||||
val address = core.interpretUrl(number, true)
|
||||
val address = core.interpretUrl(number, LinphoneUtils.applyInternationalPrefix())
|
||||
if (address != null) {
|
||||
Log.i(
|
||||
"$TAG Only 1 phone number found for contact [${friend.name}], starting audio call directly"
|
||||
|
|
@ -447,7 +447,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
coreContext.startCall(address, params)
|
||||
} else if (addressesCount == 0 && numbersCount == 1 && enablePhoneNumbers) {
|
||||
val number = friend.phoneNumbers.first()
|
||||
val address = core.interpretUrl(number, true)
|
||||
val address = core.interpretUrl(number, LinphoneUtils.applyInternationalPrefix())
|
||||
if (address != null) {
|
||||
Log.i(
|
||||
"$TAG Only 1 phone number found for contact [${friend.name}], starting video call directly"
|
||||
|
|
@ -485,7 +485,7 @@ class ContactViewModel @UiThread constructor() : ViewModel() {
|
|||
goToConversation(friend.addresses.first())
|
||||
} else if (addressesCount == 0 && numbersCount == 1 && enablePhoneNumbers) {
|
||||
val number = friend.phoneNumbers.first()
|
||||
val address = core.interpretUrl(number, true)
|
||||
val address = core.interpretUrl(number, LinphoneUtils.applyInternationalPrefix())
|
||||
if (address != null) {
|
||||
Log.i(
|
||||
"$TAG Only 1 phone number found for contact [${friend.name}], sending message directly"
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import org.linphone.ui.main.model.SelectedAddressModel
|
|||
import org.linphone.ui.main.model.isInSecureMode
|
||||
import org.linphone.ui.main.viewmodel.AddressSelectionViewModel
|
||||
import org.linphone.utils.DialogUtils
|
||||
import org.linphone.utils.LinphoneUtils
|
||||
import org.linphone.utils.RecyclerViewHeaderDecoration
|
||||
|
||||
@UiThread
|
||||
|
|
@ -169,7 +170,7 @@ abstract class GenericAddressPickerFragment : GenericFragment() {
|
|||
onAddressSelected(address, friend)
|
||||
} else if (addressesCount == 0 && numbersCount == 1 && enablePhoneNumbers) {
|
||||
val number = friend.phoneNumbers.first()
|
||||
val address = core.interpretUrl(number, true)
|
||||
val address = core.interpretUrl(number, LinphoneUtils.applyInternationalPrefix())
|
||||
if (address != null) {
|
||||
Log.i("$TAG Only 1 phone number found for contact [${friend.name}], using it")
|
||||
onAddressSelected(address, friend)
|
||||
|
|
|
|||
|
|
@ -116,7 +116,10 @@ class StartCallViewModel @UiThread constructor() : AddressSelectionViewModel() {
|
|||
if (suggestion.isNotEmpty()) {
|
||||
Log.i("$TAG Using numpad dial button to call [$suggestion]")
|
||||
coreContext.postOnCoreThread { core ->
|
||||
val address = core.interpretUrl(suggestion, true)
|
||||
val address = core.interpretUrl(
|
||||
suggestion,
|
||||
LinphoneUtils.applyInternationalPrefix()
|
||||
)
|
||||
if (address != null) {
|
||||
Log.i("$TAG Calling [${address.asStringUriOnly()}]")
|
||||
coreContext.startCall(address)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ class LinphoneUtils {
|
|||
return coreContext.core.defaultAccount ?: coreContext.core.accountList.firstOrNull()
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun applyInternationalPrefix(account: Account? = null): Boolean {
|
||||
return account?.params?.useInternationalPrefixForCallsAndChats
|
||||
?: (getDefaultAccount()?.params?.useInternationalPrefixForCallsAndChats ?: false)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
fun getAddressAsCleanStringUriOnly(address: Address): String {
|
||||
val scheme = address.scheme ?: "sip"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue