diff --git a/Linphone/Contacts/ContactsManager.swift b/Linphone/Contacts/ContactsManager.swift index 194e7a556..1338effcc 100644 --- a/Linphone/Contacts/ContactsManager.swift +++ b/Linphone/Contacts/ContactsManager.swift @@ -318,7 +318,7 @@ final class ContactsManager: ObservableObject { // Clear existing addresses and add new ones friend.addresses.forEach { friend.removeAddress(address: $0) } for sipAddress in contact.sipAddresses where !sipAddress.isEmpty { - if let address = core.interpretUrl(url: sipAddress, applyInternationalPrefix: true), + if let address = core.interpretUrl(url: sipAddress, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)), !friend.addresses.contains(where: { $0.asString() == address.asString() }) { friend.addAddress(address: address) } diff --git a/Linphone/Localizable/en.lproj/Localizable.strings b/Linphone/Localizable/en.lproj/Localizable.strings index a8f3001d7..0a30c7940 100644 --- a/Linphone/Localizable/en.lproj/Localizable.strings +++ b/Linphone/Localizable/en.lproj/Localizable.strings @@ -47,6 +47,8 @@ "account_settings_im_encryption_mandatory_title" = "IM encryption mandatory"; "account_settings_lime_server_url_title" = "E2E encryption keys server URL"; "account_settings_mwi_uri_title" = "MWI server URI (Message Waiting Indicator)"; +"account_settings_apply_international_prefix_title" = "Format phone numbers using international prefix"; +"account_settings_replace_plus_by_00_title" = "Replace + by 00 when formatting phone numbers"; "account_settings_nat_policy_title" = "NAT policy settings"; "account_settings_outbound_proxy_title" = "Outbound proxy"; "account_settings_push_notification_not_available_title" = "Push notifications aren't available!"; diff --git a/Linphone/Localizable/fr.lproj/Localizable.strings b/Linphone/Localizable/fr.lproj/Localizable.strings index 9d05cf509..02d7afec5 100644 --- a/Linphone/Localizable/fr.lproj/Localizable.strings +++ b/Linphone/Localizable/fr.lproj/Localizable.strings @@ -47,6 +47,8 @@ "account_settings_im_encryption_mandatory_title" = "Chiffrement obligatoire des conversations"; "account_settings_lime_server_url_title" = "URL du serveur d'échange de clés de chiffrement"; "account_settings_mwi_uri_title" = "URI du serveur MWI (Message Waiting Indicator)"; +"account_settings_apply_international_prefix_title" = "Formater les numéros en utilisant l'indicatif international"; +"account_settings_replace_plus_by_00_title" = "Remplacer + par 00 lors du formatage des numéros de téléphone"; "account_settings_nat_policy_title" = "Paramètres de politique NAT"; "account_settings_outbound_proxy_title" = "Serveur mandataire sortant"; "account_settings_push_notification_not_available_title" = "Notifications push non disponibles"; diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift index cdd0f4b98..fe1c0c62d 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift @@ -156,7 +156,7 @@ struct ContactInnerActionsFragment: View { .background(.white) .onTapGesture { CoreContext.shared.doOnCoreQueue { core in - let address = core.interpretUrl(url: contactAvatarModel.phoneNumbersWithLabel[index].phoneNumber, applyInternationalPrefix: true) + let address = core.interpretUrl(url: contactAvatarModel.phoneNumbersWithLabel[index].phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) if address != nil { TelecomManager.shared.doCallOrJoinConf(address: address!) } diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift index c920aba7b..bece283f3 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift @@ -153,7 +153,7 @@ struct ContactInnerFragment: View { Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") } } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { - if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) { + if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) { telecomManager.doCallOrJoinConf(address: address, isVideo: false) } } else { @@ -194,7 +194,7 @@ struct ContactInnerFragment: View { Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") } } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { - if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) { + if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) { contactsListViewModel.createOneToOneChatRoomWith(remote: address) } } else { @@ -235,7 +235,7 @@ struct ContactInnerFragment: View { Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") } } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { - if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) { + if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) { telecomManager.doCallOrJoinConf(address: address, isVideo: true) } } else { diff --git a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift index 1b3580a95..3b69db4cf 100644 --- a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift +++ b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift @@ -157,7 +157,7 @@ class StartCallViewModel: ObservableObject { func interpretAndStartCall() { CoreContext.shared.doOnCoreQueue { core in - let address = core.interpretUrl(url: self.searchField, applyInternationalPrefix: true) + let address = core.interpretUrl(url: self.searchField, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) if address != nil { TelecomManager.shared.doCallOrJoinConf(address: address!) } diff --git a/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift b/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift index 7b8732cc5..82ac76af4 100644 --- a/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift +++ b/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift @@ -132,6 +132,12 @@ struct AccountSettingsFragment: View { ) .focused($isMwiUriFocused) } + + Toggle("account_settings_apply_international_prefix_title", isOn: $accountSettingsViewModel.applyInternationalPrefix) + .default_text_style_700(styleSize: 15) + + Toggle("account_settings_replace_plus_by_00_title", isOn: $accountSettingsViewModel.replacePlusBy00) + .default_text_style_700(styleSize: 15) } .padding(.vertical, 30) .padding(.horizontal, 20) diff --git a/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift b/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift index 011edb193..2670e4ec5 100644 --- a/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift +++ b/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift @@ -30,6 +30,8 @@ class AccountSettingsViewModel: ObservableObject { @Published var imEncryptionMandatory: Bool @Published var voicemailUri: String @Published var mwiUri: String + @Published var applyInternationalPrefix: Bool + @Published var replacePlusBy00: Bool @Published var stunServerUrl: String @Published var enableIce: Bool @Published var enableTurn: Bool @@ -57,6 +59,8 @@ class AccountSettingsViewModel: ObservableObject { self.imEncryptionMandatory = accountModel.account.params?.instantMessagingEncryptionMandatory ?? false self.voicemailUri = accountModel.account.params?.voicemailAddress?.asStringUriOnly() ?? "" self.mwiUri = accountModel.account.params?.mwiServerAddress?.asStringUriOnly() ?? "" + self.applyInternationalPrefix = accountModel.account.params?.useInternationalPrefixForCallsAndChats ?? false + self.replacePlusBy00 = accountModel.account.params?.dialEscapePlusEnabled ?? false self.natPolicy = accountModel.account.params?.natPolicy self.stunServerUrl = accountModel.account.params?.natPolicy?.stunServer ?? "" @@ -190,6 +194,9 @@ class AccountSettingsViewModel: ObservableObject { newParams.voicemailAddress = nil } + newParams.useInternationalPrefixForCallsAndChats = self.applyInternationalPrefix + newParams.dialEscapePlusEnabled = self.replacePlusBy00 + let expireInt: Int = { if !self.expire.isEmpty { return Int(self.expire) ?? 31536000