Add call merge feature

This commit is contained in:
Benoit Martins 2024-07-04 10:46:49 +02:00
parent befad07719
commit f2312a2e36
5 changed files with 117 additions and 1 deletions

View file

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "arrows-merge.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M192,40v64a8,8,0,0,1-2.34,5.66L136,163.31v49.38l18.34-18.35a8,8,0,0,1,11.32,11.32l-32,32a8,8,0,0,1-11.32,0l-32-32a8,8,0,0,1,11.32-11.32L120,212.69V163.31L66.34,109.66A8,8,0,0,1,64,104V40a8,8,0,0,1,16,0v60.69l48,48,48-48V40a8,8,0,0,1,16,0Z"></path></svg>

After

Width:  |  Height:  |  Size: 362 B

View file

@ -713,6 +713,40 @@
},
"Calls" : {
},
"calls_list_dialog_merge_into_conference_label" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Create conference"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Créer une conférence"
}
}
}
},
"calls_list_dialog_merge_into_conference_title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Merge all calls into conference?"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Fusionner les appels en une conférence ?"
}
}
}
},
"Cancel" : {
"localizations" : {

View file

@ -31,6 +31,7 @@ struct CallsListFragment: View {
@State private var delayedColor = Color.white
@State var isShowCallsListBottomSheet: Bool = false
@State private var isShowPopup = false
@Binding var isShowCallsListFragment: Bool
@ -65,6 +66,18 @@ struct CallsListFragment: View {
Spacer()
if callViewModel.callsCounter > 1 {
Button {
self.isShowPopup = true
} label: {
Image("arrows-merge")
.renderingMode(.template)
.resizable()
.foregroundStyle(Color.orangeMain500)
.frame(width: 25, height: 25, alignment: .leading)
.padding(.all, 10)
}
}
}
.frame(maxWidth: .infinity)
.frame(height: 50)
@ -87,6 +100,24 @@ struct CallsListFragment: View {
}
}
.background(.white)
if self.isShowPopup {
PopupView(isShowPopup: $isShowPopup,
title: Text("calls_list_dialog_merge_into_conference_title"),
content: nil,
titleFirstButton: Text("Cancel"),
actionFirstButton: {self.isShowPopup.toggle()},
titleSecondButton: Text("calls_list_dialog_merge_into_conference_label"),
actionSecondButton: {
callViewModel.mergeCallsIntoConference()
self.isShowPopup.toggle()
isShowCallsListFragment.toggle()
})
.background(.black.opacity(0.65))
.onTapGesture {
self.isShowPopup.toggle()
}
}
}
.navigationBarHidden(true)
}

View file

@ -158,6 +158,7 @@ class CallViewModel: ObservableObject {
displayNameTmp = self.currentCall!.remoteAddress!.username!
}
}
DispatchQueue.main.async {
self.displayName = displayNameTmp
}
@ -298,7 +299,6 @@ class CallViewModel: ObservableObject {
coreContext.doOnCoreQueue { core in
if self.currentCall?.conference != nil {
let conf = self.currentCall!.conference!
self.isConference = true
let displayNameTmp = conf.subject ?? ""
@ -368,6 +368,8 @@ class CallViewModel: ObservableObject {
DispatchQueue.main.async {
self.displayName = displayNameTmp
self.isConference = true
self.myParticipantModel = myParticipantModelTmp
self.activeSpeakerParticipant = activeSpeakerParticipantTmp
@ -1121,5 +1123,32 @@ class CallViewModel: ObservableObject {
}
}
}
func mergeCallsIntoConference() {
self.coreContext.doOnCoreQueue { core in
let callsCount = core.callsNb
let defaultAccount = core.defaultAccount
var subject = ""
if (defaultAccount != nil && defaultAccount!.params != nil && defaultAccount!.params!.audioVideoConferenceFactoryAddress != nil) {
Log.info("[CallViewModel] Merging \(callsCount) calls into a remotely hosted conference")
subject = "Remote group call"
} else {
Log.info("[CallViewModel] Merging \(callsCount) calls into a locally hosted conference")
subject = "Local group call"
}
do {
let params = try core.createConferenceParams(conference: nil)
params.subject = subject
// Prevent group call to start in audio only layout
params.videoEnabled = true
let conference = try core.createConferenceWithParams(params: params)
try conference.addParticipants(calls: core.calls)
} catch {
}
}
}
}
// swiftlint:enable type_body_length