diff --git a/Linphone/Core/CorePreferences.swift b/Linphone/Core/CorePreferences.swift index 795bb7feb..6e9d44bc2 100644 --- a/Linphone/Core/CorePreferences.swift +++ b/Linphone/Core/CorePreferences.swift @@ -260,6 +260,15 @@ class CorePreferences { } } + static var disableMeetings: Bool { + get { + return Config.get().getBool(section: "ui", key: "disable_meetings_feature", defaultValue: false) + } + set { + Config.get().setBool(section: "ui", key: "disable_meetings_feature", value: newValue) + } + } + private func copy(from: String, to: String, overrideIfExists: Bool = false) { let fileManager = FileManager.default if fileManager.fileExists(atPath: to), !overrideIfExists { diff --git a/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift b/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift index 1cbf1ed88..e03cd93bf 100644 --- a/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/StartConversationFragment.swift @@ -130,43 +130,45 @@ struct StartConversationFragment: View { .padding(.vertical) .padding(.horizontal) - NavigationLink(destination: { - StartGroupConversationFragment(isShowStartConversationFragment: $isShowStartConversationFragment) - .environmentObject(startConversationViewModel) - }, label: { - HStack { - HStack(alignment: .center) { - Image("users-three") + if !startConversationViewModel.hideGroupChatButton { + NavigationLink(destination: { + StartGroupConversationFragment(isShowStartConversationFragment: $isShowStartConversationFragment) + .environmentObject(startConversationViewModel) + }, label: { + HStack { + HStack(alignment: .center) { + Image("users-three") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 28, height: 28) + } + .padding(10) + .background(Color.orangeMain500) + .cornerRadius(40) + + Text("new_conversation_create_group") + .foregroundStyle(.black) + .default_text_style_800(styleSize: 16) + .lineLimit(1) + + Spacer() + + Image("caret-right") .renderingMode(.template) .resizable() - .foregroundStyle(.white) - .frame(width: 28, height: 28) + .foregroundStyle(Color.grayMain2c500) + .frame(width: 25, height: 25, alignment: .leading) } - .padding(10) - .background(Color.orangeMain500) - .cornerRadius(40) - - Text("new_conversation_create_group") - .foregroundStyle(.black) - .default_text_style_800(styleSize: 16) - .lineLimit(1) - - Spacer() - - Image("caret-right") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c500) - .frame(width: 25, height: 25, alignment: .leading) - } - }) - .padding(.vertical, 10) - .padding(.horizontal, 20) - .background( - LinearGradient(gradient: Gradient(colors: [.grayMain2c100, .white]), startPoint: .leading, endPoint: .trailing) - .padding(.vertical, 10) - .padding(.horizontal, 40) - ) + }) + .padding(.vertical, 10) + .padding(.horizontal, 20) + .background( + LinearGradient(gradient: Gradient(colors: [.grayMain2c100, .white]), startPoint: .leading, endPoint: .trailing) + .padding(.vertical, 10) + .padding(.horizontal, 40) + ) + } ScrollView { if !ContactsManager.shared.lastSearch.isEmpty { diff --git a/Linphone/UI/Main/Conversations/ViewModel/StartConversationViewModel.swift b/Linphone/UI/Main/Conversations/ViewModel/StartConversationViewModel.swift index 702c81e71..165d01e73 100644 --- a/Linphone/UI/Main/Conversations/ViewModel/StartConversationViewModel.swift +++ b/Linphone/UI/Main/Conversations/ViewModel/StartConversationViewModel.swift @@ -40,11 +40,21 @@ class StartConversationViewModel: ObservableObject { @Published var operationGroupInProgress: Bool = false @Published var displayedConversation: ConversationModel? + @Published var hideGroupChatButton: Bool = false + private var chatRoomDelegate: ChatRoomDelegate? init() { coreContext.doOnCoreQueue { core in self.domain = core.defaultAccount?.params?.domain ?? "" + self.updateGroupChatButtonVisibility(core: core) + } + } + + func updateGroupChatButtonVisibility(core: Core) { + let hideGroupChat = !LinphoneUtils.isGroupChatAvailable(core: core) + DispatchQueue.main.async { + self.hideGroupChatButton = hideGroupChat } } diff --git a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift index 56707388c..896f53021 100644 --- a/Linphone/UI/Main/History/Fragments/StartCallFragment.swift +++ b/Linphone/UI/Main/History/Fragments/StartCallFragment.swift @@ -195,42 +195,45 @@ struct StartCallFragment: View { .padding(.vertical) .padding(.horizontal) - NavigationLink(destination: { - StartGroupCallFragment(isShowStartCallFragment: $isShowStartCallFragment) - .environmentObject(startCallViewModel) - }, label: { - HStack { - HStack(alignment: .center) { - Image("video-conference") + + if !startCallViewModel.hideGroupCallButton { + NavigationLink(destination: { + StartGroupCallFragment(isShowStartCallFragment: $isShowStartCallFragment) + .environmentObject(startCallViewModel) + }, label: { + HStack { + HStack(alignment: .center) { + Image("video-conference") + .renderingMode(.template) + .resizable() + .foregroundStyle(.white) + .frame(width: 28, height: 28) + } + .padding(10) + .background(Color.orangeMain500) + .cornerRadius(40) + + Text("history_call_start_create_group_call") + .foregroundStyle(.black) + .default_text_style_800(styleSize: 16) + + Spacer() + + Image("caret-right") .renderingMode(.template) .resizable() - .foregroundStyle(.white) - .frame(width: 28, height: 28) + .foregroundStyle(Color.grayMain2c500) + .frame(width: 25, height: 25, alignment: .leading) } - .padding(10) - .background(Color.orangeMain500) - .cornerRadius(40) - - Text("history_call_start_create_group_call") - .foregroundStyle(.black) - .default_text_style_800(styleSize: 16) - - Spacer() - - Image("caret-right") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c500) - .frame(width: 25, height: 25, alignment: .leading) - } - }) - .padding(.vertical, 10) - .padding(.horizontal, 20) - .background( - LinearGradient(gradient: Gradient(colors: [.grayMain2c100, .white]), startPoint: .leading, endPoint: .trailing) - .padding(.vertical, 10) - .padding(.horizontal, 40) - ) + }) + .padding(.vertical, 10) + .padding(.horizontal, 20) + .background( + LinearGradient(gradient: Gradient(colors: [.grayMain2c100, .white]), startPoint: .leading, endPoint: .trailing) + .padding(.vertical, 10) + .padding(.horizontal, 40) + ) + } ScrollView { if !ContactsManager.shared.lastSearch.isEmpty { diff --git a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift index 736f79aeb..1b3580a95 100644 --- a/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift +++ b/Linphone/UI/Main/History/ViewModel/StartCallViewModel.swift @@ -38,14 +38,27 @@ class StartCallViewModel: ObservableObject { @Published var operationInProgress: Bool = false + @Published var hideGroupCallButton: Bool = false + private var conferenceDelegate: ConferenceDelegate? init() { coreContext.doOnCoreQueue { core in self.domain = core.defaultAccount?.params?.domain ?? "" + self.updateGroupCallButtonVisibility(core: core) } + } + func updateGroupCallButtonVisibility(core: Core) { + let hideGroupCall = CorePreferences.disableMeetings || + !LinphoneUtils.isRemoteConferencingAvailable(core: core) || + core.callsNb > 0 + DispatchQueue.main.async { + self.hideGroupCallButton = hideGroupCall + } + } + func addParticipants(participantsToAdd: [SelectedAddressModel]) { var list = participants for selectedAddr in participantsToAdd { diff --git a/Linphone/Utils/LinphoneUtils.swift b/Linphone/Utils/LinphoneUtils.swift index dcd3b420d..acc050cae 100644 --- a/Linphone/Utils/LinphoneUtils.swift +++ b/Linphone/Utils/LinphoneUtils.swift @@ -115,4 +115,12 @@ class LinphoneUtils: NSObject { public class func getAccountForAddress(address: Address) -> Account? { return CoreContext.shared.mCore.accountList.first { $0.params?.identityAddress?.weakEqual(address2: address) == true } } + + public class func isRemoteConferencingAvailable(core: Core) -> Bool { + return core.defaultAccount?.params?.audioVideoConferenceFactoryAddress != nil + } + + public class func isGroupChatAvailable(core: Core) -> Bool { + return core.defaultAccount?.params?.conferenceFactoryUri != nil + } }