From 4884997db606b82d77fdf37f784753f9082f69df Mon Sep 17 00:00:00 2001 From: Benoit Martins Date: Wed, 3 Jul 2024 09:38:17 +0200 Subject: [PATCH] Fix dialer in startcallview --- Linphone/Localizable.xcstrings | 12 +++++ Linphone/UI/Call/CallView.swift | 6 +++ Linphone/UI/Main/ContentView.swift | 4 ++ .../History/Fragments/DialerBottomSheet.swift | 52 +++++++++++++++++-- .../ViewModel/StartCallViewModel.swift | 9 ++++ 5 files changed, 78 insertions(+), 5 deletions(-) diff --git a/Linphone/Localizable.xcstrings b/Linphone/Localizable.xcstrings index 19e09775f..39a593c52 100644 --- a/Linphone/Localizable.xcstrings +++ b/Linphone/Localizable.xcstrings @@ -850,6 +850,9 @@ }, "Delete this contact" : { + }, + "Delete this meeting" : { + }, "Demande d’autorisations" : { @@ -1424,6 +1427,9 @@ }, "Send Logs" : { + }, + "Send notification to participants ?" : { + }, "settings_title" : { "extractionState" : "manual", @@ -1471,6 +1477,9 @@ }, "subscribe.linphone.org" : { + }, + "Successfully removed meeting" : { + }, "Suggestions" : { @@ -1486,6 +1495,9 @@ }, "Temp Help" : { + }, + "The meeting has been cancelled" : { + }, "The user name or password is incorrects" : { diff --git a/Linphone/UI/Call/CallView.swift b/Linphone/UI/Call/CallView.swift index 5e0fe18c7..cca0615f6 100644 --- a/Linphone/UI/Call/CallView.swift +++ b/Linphone/UI/Call/CallView.swift @@ -93,6 +93,8 @@ struct CallView: View { .sheet(isPresented: $showingDialer) { DialerBottomSheet( startCallViewModel: StartCallViewModel(), + callViewModel: callViewModel, + isShowStartCallFragment: $isShowStartCallFragment, showingDialer: $showingDialer, currentCall: callViewModel.currentCall ) @@ -128,6 +130,8 @@ struct CallView: View { .sheet(isPresented: $showingDialer) { DialerBottomSheet( startCallViewModel: StartCallViewModel(), + callViewModel: callViewModel, + isShowStartCallFragment: $isShowStartCallFragment, showingDialer: $showingDialer, currentCall: callViewModel.currentCall ) @@ -158,6 +162,8 @@ struct CallView: View { .halfSheet(showSheet: $showingDialer) { DialerBottomSheet( startCallViewModel: StartCallViewModel(), + callViewModel: callViewModel, + isShowStartCallFragment: $isShowStartCallFragment, showingDialer: $showingDialer, currentCall: callViewModel.currentCall ) diff --git a/Linphone/UI/Main/ContentView.swift b/Linphone/UI/Main/ContentView.swift index d6d1efbb3..395acc513 100644 --- a/Linphone/UI/Main/ContentView.swift +++ b/Linphone/UI/Main/ContentView.swift @@ -852,6 +852,8 @@ struct ContentView: View { .sheet(isPresented: $showingDialer) { DialerBottomSheet( startCallViewModel: startCallViewModel, + callViewModel: callViewModel, + isShowStartCallFragment: $isShowStartCallFragment, showingDialer: $showingDialer, currentCall: nil ) @@ -871,6 +873,8 @@ struct ContentView: View { .halfSheet(showSheet: $showingDialer) { DialerBottomSheet( startCallViewModel: startCallViewModel, + callViewModel: callViewModel, + isShowStartCallFragment: $isShowStartCallFragment, showingDialer: $showingDialer, currentCall: nil ) diff --git a/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift b/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift index 7a5a3bda9..7231934d8 100644 --- a/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift +++ b/Linphone/UI/Main/History/Fragments/DialerBottomSheet.swift @@ -33,10 +33,13 @@ struct DialerBottomSheet: View { @ObservedObject private var telecomManager = TelecomManager.shared @ObservedObject var startCallViewModel: StartCallViewModel + @ObservedObject var callViewModel: CallViewModel @State private var orientation = UIDevice.current.orientation @State var dialerField = "" + + @Binding var isShowStartCallFragment: Bool @Binding var showingDialer: Bool let currentCall: Call? @@ -449,11 +452,50 @@ struct DialerBottomSheet: View { Button { if !startCallViewModel.searchField.isEmpty { - do { - let address = try Factory.Instance.createAddress(addr: String("sip:" + startCallViewModel.searchField + "@" + startCallViewModel.domain)) - telecomManager.doCallOrJoinConf(address: address) - } catch { + if callViewModel.isTransferInsteadCall { + showingDialer = false + DispatchQueue.global().asyncAfter(deadline: .now() + 0.2) { + magicSearch.searchForContacts( + sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue) + + if callViewModel.isTransferInsteadCall == true { + callViewModel.isTransferInsteadCall = false + } + + callViewModel.resetCallView() + } + + magicSearch.currentFilterSuggestions = "" + + withAnimation { + isShowStartCallFragment.toggle() + startCallViewModel.interpretAndStartCall() + } + + startCallViewModel.searchField = "" + } else { + showingDialer = false + + DispatchQueue.global().asyncAfter(deadline: .now() + 0.2) { + magicSearch.searchForContacts( + sourceFlags: MagicSearch.Source.Friends.rawValue | MagicSearch.Source.LdapServers.rawValue) + + if callViewModel.isTransferInsteadCall == true { + callViewModel.isTransferInsteadCall = false + } + + callViewModel.resetCallView() + } + + magicSearch.currentFilterSuggestions = "" + + withAnimation { + isShowStartCallFragment.toggle() + startCallViewModel.interpretAndStartCall() + } + + startCallViewModel.searchField = "" } } } label: { @@ -502,6 +544,6 @@ struct DialerBottomSheet: View { #Preview { DialerBottomSheet( - startCallViewModel: StartCallViewModel(), showingDialer: .constant(false), currentCall: nil + startCallViewModel: StartCallViewModel(), callViewModel: CallViewModel(), isShowStartCallFragment: .constant(false), showingDialer: .constant(false), currentCall: nil ) } diff --git a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift index 56abb30ab..b5540b777 100644 --- a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift +++ b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift @@ -161,4 +161,13 @@ class StartCallViewModel: ObservableObject { ) } } + + func interpretAndStartCall() { + CoreContext.shared.doOnCoreQueue { core in + let address = core.interpretUrl(url: self.searchField, applyInternationalPrefix: true) + if address != nil { + TelecomManager.shared.doCallOrJoinConf(address: address!) + } + } + } }