diff --git a/Linphone/Core/CorePreferences.swift b/Linphone/Core/CorePreferences.swift index 9b8b8ef40..a4e04a327 100644 --- a/Linphone/Core/CorePreferences.swift +++ b/Linphone/Core/CorePreferences.swift @@ -141,6 +141,15 @@ class CorePreferences { } } + static var disableAddContact: Bool { + get { + return Config.get().getBool(section: "ui", key: "disable_add_contact", defaultValue: false) + } + set { + Config.get().setBool(section: "ui", key: "disable_add_contact", value: newValue) + } + } + static var showFavoriteContacts: Bool { get { return Config.get().getBool(section: "ui", key: "show_favorites_contacts", defaultValue: true) diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index c05dba1a8..ed242d1f0 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -2,6 +2,6 @@ import Foundation public enum AppGitInfo { public static let branch = "master" - public static let commit = "6827bdc1d" + public static let commit = "d4b10d38a" public static let tag = "6.1.0-alpha" } diff --git a/Linphone/UI/Main/Contacts/ContactsView.swift b/Linphone/UI/Main/Contacts/ContactsView.swift index 22f547de5..dba35cf4a 100644 --- a/Linphone/UI/Main/Contacts/ContactsView.swift +++ b/Linphone/UI/Main/Contacts/ContactsView.swift @@ -32,22 +32,24 @@ struct ContactsView: View { ZStack(alignment: .bottomTrailing) { ContactsFragment(isShowDeletePopup: $isShowDeletePopup, text: $text) - Button { - withAnimation { - contactsListViewModel.selectedEditFriend = nil - isShowEditContactFragment.toggle() + if !CorePreferences.disableAddContact { + Button { + withAnimation { + contactsListViewModel.selectedEditFriend = nil + isShowEditContactFragment.toggle() + } + } label: { + Image("user-plus") + .renderingMode(.template) + .foregroundStyle(.white) + .padding() + .background(Color.orangeMain500) + .clipShape(Circle()) + .shadow(color: .black.opacity(0.2), radius: 4) + } - } label: { - Image("user-plus") - .renderingMode(.template) - .foregroundStyle(.white) - .padding() - .background(Color.orangeMain500) - .clipShape(Circle()) - .shadow(color: .black.opacity(0.2), radius: 4) - + .padding() } - .padding() // For testing crashlytics /*Button(action: CoreContext.shared.crashForCrashlytics, label: { diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift index 2eb448da1..a0ed17ce1 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift @@ -353,59 +353,64 @@ struct ConversationInfoFragment: View { if conversationViewModel.myParticipantConversationModel != nil && conversationViewModel.myParticipantConversationModel!.address != participantConversationModel.address { Menu { - Button( - action: { - let addressConv = participantConversationModel.address - - let friendIndex = contactsManager.avatarListModel.first( - where: {$0.addresses.contains(where: {$0 == addressConv})}) - - SharedMainViewModel.shared.displayedCall = nil - SharedMainViewModel.shared.changeIndexView(indexViewInt: 0) - - if friendIndex != nil { - withAnimation { - SharedMainViewModel.shared.displayedFriend = friendIndex - } - } else { - withAnimation { - isShowEditContactFragment.toggle() - isShowEditContactFragmentAddress = String(participantConversationModel.address.dropFirst(4)) - } - } - }, - label: { - HStack { + let addressConv = participantConversationModel.address + + let friendIndex = contactsManager.lastSearch.firstIndex( + where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})}) + + let disableAddContact = CorePreferences.disableAddContact + + if (!disableAddContact || (disableAddContact && friendIndex != nil)) { + Button( + action: { let addressConv = participantConversationModel.address - let friendIndex = contactsManager.lastSearch.firstIndex( - where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})}) + let friendIndex = contactsManager.avatarListModel.first( + where: {$0.addresses.contains(where: {$0 == addressConv})}) + + SharedMainViewModel.shared.displayedCall = nil + SharedMainViewModel.shared.changeIndexView(indexViewInt: 0) + if friendIndex != nil { - Image("address-book") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c600) - .frame(width: 25, height: 25) - - Text("conversation_info_menu_go_to_contact") - .default_text_style(styleSize: 16) - .frame(maxWidth: .infinity, alignment: .leading) - .lineLimit(1) + withAnimation { + SharedMainViewModel.shared.displayedFriend = friendIndex + } } else { - Image("user-plus") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c600) - .frame(width: 25, height: 25) - - Text("conversation_info_menu_add_to_contacts") - .default_text_style(styleSize: 16) - .frame(maxWidth: .infinity, alignment: .leading) - .lineLimit(1) + withAnimation { + isShowEditContactFragment.toggle() + isShowEditContactFragmentAddress = String(participantConversationModel.address.dropFirst(4)) + } + } + }, + label: { + HStack { + if friendIndex != nil { + Image("address-book") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c600) + .frame(width: 25, height: 25) + + Text("conversation_info_menu_go_to_contact") + .default_text_style(styleSize: 16) + .frame(maxWidth: .infinity, alignment: .leading) + .lineLimit(1) + } else { + Image("user-plus") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c600) + .frame(width: 25, height: 25) + + Text("conversation_info_menu_add_to_contacts") + .default_text_style(styleSize: 16) + .frame(maxWidth: .infinity, alignment: .leading) + .lineLimit(1) + } } } - } - ) + ) + } if conversationViewModel.isUserAdmin { let participantConversationModelIsAdmin = conversationViewModel.participantConversationModelAdmin.first( @@ -527,7 +532,14 @@ struct ConversationInfoFragment: View { VStack(spacing: 0) { if !SharedMainViewModel.shared.displayedConversation!.isReadOnly { - if !SharedMainViewModel.shared.displayedConversation!.isGroup { + let addressConv = conversationViewModel.participantConversationModel.first?.address ?? "" + + let friendIndex = contactsManager.lastSearch.firstIndex( + where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})}) + + let disableAddContact = CorePreferences.disableAddContact + + if !SharedMainViewModel.shared.displayedConversation!.isGroup && (!disableAddContact || (disableAddContact && friendIndex != nil)) { Button( action: { if SharedMainViewModel.shared.displayedConversation != nil { @@ -555,10 +567,6 @@ struct ConversationInfoFragment: View { }, label: { HStack { - let addressConv = conversationViewModel.participantConversationModel.first?.address ?? "" - - let friendIndex = contactsManager.lastSearch.firstIndex( - where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})}) if friendIndex != nil { Image("address-book") .renderingMode(.template) diff --git a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift index 132d4442d..3361d0d23 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift @@ -70,7 +70,10 @@ struct HistoryContactFragment: View { Spacer() Menu { - if !historyModel.isConf { + let disableAddContact = CorePreferences.disableAddContact + let isFriend = historyModel.isFriend == true + + if !historyModel.isConf && (!disableAddContact || (disableAddContact && isFriend)) { Button { isMenuOpen = false diff --git a/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift b/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift index 19551406e..5b682f655 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift @@ -58,68 +58,74 @@ struct HistoryListBottomSheet: View { } Spacer() - Button { - - if #available(iOS 16.0, *) { - if idiom != .pad { - showingSheet.toggle() + + let disableAddContact = CorePreferences.disableAddContact + let isFriend = historyListViewModel.selectedCall?.isFriend == true + + if !disableAddContact || (disableAddContact && isFriend) { + Button { + + if #available(iOS 16.0, *) { + if idiom != .pad { + showingSheet.toggle() + } else { + showingSheet.toggle() + dismiss() + } } else { showingSheet.toggle() dismiss() } - } else { - showingSheet.toggle() - dismiss() - } - - sharedMainViewModel.changeIndexView(indexViewInt: 0) - - if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend { - let friendIndex = contactsManager.avatarListModel.first(where: {$0.addresses.contains(where: {$0 == selectedCall.address})}) - if friendIndex != nil { + + sharedMainViewModel.changeIndexView(indexViewInt: 0) + + if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend { + let friendIndex = contactsManager.avatarListModel.first(where: {$0.addresses.contains(where: {$0 == selectedCall.address})}) + if friendIndex != nil { + withAnimation { + SharedMainViewModel.shared.displayedFriend = friendIndex + } + } + } else if let selectedCall = historyListViewModel.selectedCall { withAnimation { - SharedMainViewModel.shared.displayedFriend = friendIndex + isShowEditContactFragment.toggle() + isShowEditContactFragmentAddress = String(selectedCall.address.dropFirst(4)) } } - } else if let selectedCall = historyListViewModel.selectedCall { - withAnimation { - isShowEditContactFragment.toggle() - isShowEditContactFragmentAddress = String(selectedCall.address.dropFirst(4)) + } label: { + HStack { + if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend { + Image("user-circle") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c500) + .frame(width: 25, height: 25, alignment: .leading) + .padding(.all, 10) + Text("menu_see_existing_contact") + .default_text_style(styleSize: 16) + Spacer() + } else { + Image("plus-circle") + .renderingMode(.template) + .resizable() + .foregroundStyle(Color.grayMain2c500) + .frame(width: 25, height: 25, alignment: .leading) + .padding(.all, 10) + Text("menu_add_address_to_contacts") + .default_text_style(styleSize: 16) + Spacer() + } } + .frame(maxHeight: .infinity) } - } label: { - HStack { - if let selectedCall = historyListViewModel.selectedCall, selectedCall.isFriend { - Image("user-circle") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c500) - .frame(width: 25, height: 25, alignment: .leading) - .padding(.all, 10) - Text("menu_see_existing_contact") - .default_text_style(styleSize: 16) - Spacer() - } else { - Image("plus-circle") - .renderingMode(.template) - .resizable() - .foregroundStyle(Color.grayMain2c500) - .frame(width: 25, height: 25, alignment: .leading) - .padding(.all, 10) - Text("menu_add_address_to_contacts") - .default_text_style(styleSize: 16) - Spacer() - } + .padding(.horizontal, 30) + .background(Color.gray100) + + VStack { + Divider() } - .frame(maxHeight: .infinity) + .frame(maxWidth: .infinity) } - .padding(.horizontal, 30) - .background(Color.gray100) - - VStack { - Divider() - } - .frame(maxWidth: .infinity) Button { if historyListViewModel.selectedCall != nil && historyListViewModel.selectedCall!.isOutgoing { diff --git a/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d30894956..7c8d25d06 100644 --- a/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LinphoneApp.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -124,7 +124,7 @@ "location" : "https://gitlab.linphone.org/BC/public/linphone-sdk-swift-ios.git", "state" : { "branch" : "alpha", - "revision" : "0dc2d9ef5b2e1e1868e3e6143a89a7ba9d983ea6" + "revision" : "1e266452f9e464d8d6ea8359722d9038c5f46b9d" } }, {