diff --git a/Linphone/Core/CorePreferences.swift b/Linphone/Core/CorePreferences.swift index 0ce271eac..8cf6c9386 100644 --- a/Linphone/Core/CorePreferences.swift +++ b/Linphone/Core/CorePreferences.swift @@ -150,6 +150,15 @@ class CorePreferences: ObservableObject { } } + var hideContactEdition: Bool { + get { + config.getBool(section: "ui", key: "hide_contact_edition", defaultValue: false) + } + set { + config.setBool(section: "ui", key: "hide_contact_edition", value: newValue) + } + } + var disableAddContact: Bool { get { config.getBool(section: "ui", key: "disable_add_contact", defaultValue: false) diff --git a/Linphone/UI/Main/Contacts/ContactsView.swift b/Linphone/UI/Main/Contacts/ContactsView.swift index 374e09afd..5a0908959 100644 --- a/Linphone/UI/Main/Contacts/ContactsView.swift +++ b/Linphone/UI/Main/Contacts/ContactsView.swift @@ -32,7 +32,7 @@ struct ContactsView: View { ZStack(alignment: .bottomTrailing) { ContactsFragment(isShowDeletePopup: $isShowDeletePopup, text: $text) - if !AppServices.corePreferences.disableAddContact { + if !AppServices.corePreferences.disableAddContact && !AppServices.corePreferences.hideContactEdition { Button { withAnimation { contactsListViewModel.selectedEditFriend = nil diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift index 8d14f9212..4bab9d22b 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerActionsFragment.swift @@ -490,7 +490,7 @@ struct ContactInnerActionsFragment: View { .background(Color.gray100) VStack(spacing: 0) { - if !contactAvatarModel.isReadOnly { + if !contactAvatarModel.isReadOnly && !AppServices.corePreferences.hideContactEdition { if !contactAvatarModel.editable { Button { actionEditButton() @@ -502,7 +502,7 @@ struct ContactInnerActionsFragment: View { .foregroundStyle(Color.grayMain2c600) .frame(width: 25, height: 25) .padding(.all, 10) - + Text("contact_details_edit") .default_text_style(styleSize: 14) .frame(maxWidth: .infinity, alignment: .leading) @@ -525,7 +525,7 @@ struct ContactInnerActionsFragment: View { .foregroundStyle(Color.grayMain2c600) .frame(width: 25, height: 25) .padding(.all, 10) - + Text("contact_details_edit") .default_text_style(styleSize: 14) .frame(maxWidth: .infinity, alignment: .leading) @@ -542,12 +542,12 @@ struct ContactInnerActionsFragment: View { } ) } - + VStack { Divider() } .padding(.horizontal) - + Button { contactsListViewModel.toggleStarredSelectedFriend() } label: { @@ -570,7 +570,7 @@ struct ContactInnerActionsFragment: View { .padding(.vertical, 15) .padding(.horizontal, 20) } - + VStack { Divider() } @@ -599,12 +599,12 @@ struct ContactInnerActionsFragment: View { .padding(.horizontal, 20) } - if !contactAvatarModel.isReadOnly { + if !contactAvatarModel.isReadOnly && !AppServices.corePreferences.hideContactEdition { VStack { Divider() } .padding(.horizontal) - + Button { isShowDeletePopup.toggle() } label: { @@ -615,7 +615,7 @@ struct ContactInnerActionsFragment: View { .foregroundStyle(Color.redDanger500) .frame(width: 25, height: 25) .padding(.all, 10) - + Text("contact_details_delete") .foregroundStyle(Color.redDanger500) .default_text_style(styleSize: 14) diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift index cdf38530c..1274f85e0 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactInnerFragment.swift @@ -77,7 +77,7 @@ struct ContactInnerFragment: View { Spacer() - if !contactAvatarModel.isReadOnly { + if !contactAvatarModel.isReadOnly && !AppServices.corePreferences.hideContactEdition { if !contactAvatarModel.editable { Button(action: { editNativeContact() diff --git a/Linphone/UI/Main/Contacts/Fragments/ContactsListBottomSheet.swift b/Linphone/UI/Main/Contacts/Fragments/ContactsListBottomSheet.swift index d7b583da7..113cbe2ab 100644 --- a/Linphone/UI/Main/Contacts/Fragments/ContactsListBottomSheet.swift +++ b/Linphone/UI/Main/Contacts/Fragments/ContactsListBottomSheet.swift @@ -55,7 +55,7 @@ struct ContactsListBottomSheet: View { .padding(.trailing) } - if !contactsListViewModel.selectedFriend!.isReadOnly { + if !contactsListViewModel.selectedFriend!.isReadOnly && !AppServices.corePreferences.hideContactEdition { Spacer() Button { @@ -137,12 +137,12 @@ struct ContactsListBottomSheet: View { .padding(.horizontal, 30) .background(Color.gray100) - if !contactsListViewModel.selectedFriend!.isReadOnly { + if !contactsListViewModel.selectedFriend!.isReadOnly && !AppServices.corePreferences.hideContactEdition { VStack { Divider() } .frame(maxWidth: .infinity) - + Button { if contactsListViewModel.selectedFriend != nil { isShowDeletePopup.toggle() diff --git a/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift b/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift index d8f6f583c..ab3270ea6 100644 --- a/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift +++ b/Linphone/UI/Main/Conversations/Fragments/ConversationInfoFragment.swift @@ -436,12 +436,13 @@ struct ConversationInfoFragment: View { where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})}) let disableAddContact = AppServices.corePreferences.disableAddContact - - if (!disableAddContact || (disableAddContact && friendIndex != nil)) { + let hideContactEdition = AppServices.corePreferences.hideContactEdition + + if (!disableAddContact || (disableAddContact && friendIndex != nil)) && !hideContactEdition { Button( action: { let addressConv = participantConversationModel.address - + let friendIndex = contactsManager.avatarListModel.first( where: {$0.addresses.contains(where: {$0 == addressConv})}) @@ -679,8 +680,9 @@ struct ConversationInfoFragment: View { where: {$0.friend!.addresses.contains(where: {$0.asStringUriOnly() == addressConv})}) let disableAddContact = AppServices.corePreferences.disableAddContact - - if !SharedMainViewModel.shared.displayedConversation!.isGroup && (!disableAddContact || (disableAddContact && friendIndex != nil)) { + let hideContactEdition = AppServices.corePreferences.hideContactEdition + + if !SharedMainViewModel.shared.displayedConversation!.isGroup && (!disableAddContact || (disableAddContact && friendIndex != nil)) && !hideContactEdition { Button( action: { if SharedMainViewModel.shared.displayedConversation != nil { diff --git a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift index e0098abd8..3ec52f694 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryContactFragment.swift @@ -71,9 +71,10 @@ struct HistoryContactFragment: View { Menu { let disableAddContact = AppServices.corePreferences.disableAddContact + let hideContactEdition = AppServices.corePreferences.hideContactEdition let isFriend = historyModel.isFriend == true - - if !historyModel.isConf && (!disableAddContact || (disableAddContact && isFriend)) { + + if !historyModel.isConf && (!disableAddContact || (disableAddContact && isFriend)) && !hideContactEdition { Button { isMenuOpen = false diff --git a/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift b/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift index 72e10523a..51c760db7 100644 --- a/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift +++ b/Linphone/UI/Main/History/Fragments/HistoryListBottomSheet.swift @@ -60,9 +60,10 @@ struct HistoryListBottomSheet: View { Spacer() let disableAddContact = AppServices.corePreferences.disableAddContact + let hideContactEdition = AppServices.corePreferences.hideContactEdition let isFriend = historyListViewModel.selectedCall?.isFriend == true - if !disableAddContact || (disableAddContact && isFriend) { + if (!disableAddContact || (disableAddContact && isFriend)) && !hideContactEdition { Button { if #available(iOS 16.0, *) {