mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 02:58:07 +00:00
Hide SIP addresses via settings
This commit is contained in:
parent
1c3680df65
commit
e9eebbd45a
7 changed files with 175 additions and 150 deletions
|
|
@ -274,6 +274,15 @@ class CorePreferences {
|
|||
}
|
||||
}
|
||||
|
||||
static var hideSipAddresses: Bool {
|
||||
get {
|
||||
return Config.get().getBool(section: "ui", key: "hide_sip_addresses", defaultValue: false)
|
||||
}
|
||||
set {
|
||||
Config.get().setBool(section: "ui", key: "hide_sip_addresses", value: newValue)
|
||||
}
|
||||
}
|
||||
|
||||
private func copy(from: String, to: String, overrideIfExists: Bool = false) {
|
||||
let fileManager = FileManager.default
|
||||
if fileManager.fileExists(atPath: to), !overrideIfExists {
|
||||
|
|
|
|||
|
|
@ -526,8 +526,10 @@ struct CallView: View {
|
|||
.padding(.top)
|
||||
.default_text_style_white(styleSize: 22)
|
||||
|
||||
Text(callViewModel.remoteAddressCleanedString)
|
||||
.default_text_style_white_300(styleSize: 16)
|
||||
if !CorePreferences.hideSipAddresses {
|
||||
Text(callViewModel.remoteAddressCleanedString)
|
||||
.default_text_style_white_300(styleSize: 16)
|
||||
}
|
||||
|
||||
Spacer()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,127 +39,135 @@ struct ContactInnerActionsFragment: View {
|
|||
|
||||
var actionEditButton: () -> Void
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center) {
|
||||
Text("contact_details_numbers_and_addresses_title")
|
||||
.default_text_style_800(styleSize: 15)
|
||||
|
||||
Spacer()
|
||||
|
||||
Image(informationIsOpen ? "caret-up" : "caret-down")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
}
|
||||
.padding(.top, 30)
|
||||
.padding(.bottom, 10)
|
||||
.padding(.horizontal, 16)
|
||||
.background(Color.gray100)
|
||||
.onTapGesture {
|
||||
withAnimation {
|
||||
informationIsOpen.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
if informationIsOpen {
|
||||
VStack(spacing: 0) {
|
||||
ForEach(0..<contactAvatarModel.addresses.count, id: \.self) { index in
|
||||
HStack {
|
||||
HStack {
|
||||
VStack {
|
||||
Text(String(localized: "sip_address") + ":")
|
||||
.default_text_style_700(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(contactAvatarModel.addresses[index].dropFirst(4))
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
Spacer()
|
||||
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
.padding(.all, 10)
|
||||
}
|
||||
.padding(.vertical, 15)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.background(.white)
|
||||
.onTapGesture {
|
||||
do {
|
||||
let address = try Factory.Instance.createAddress(addr: contactAvatarModel.addresses[index])
|
||||
withAnimation {
|
||||
telecomManager.doCallOrJoinConf(address: address)
|
||||
}
|
||||
} catch {
|
||||
Log.error("[ContactInnerActionsFragment] unable to create address for a new outgoing call : \(contactAvatarModel.addresses[index]) \(error) ")
|
||||
}
|
||||
}
|
||||
.onLongPressGesture(minimumDuration: 0.2) {
|
||||
contactsListViewModel.stringToCopy = contactAvatarModel.addresses[index]
|
||||
showingSheet.toggle()
|
||||
}
|
||||
|
||||
if !contactAvatarModel.phoneNumbersWithLabel.isEmpty
|
||||
|| index < contactAvatarModel.addresses.count - 1 {
|
||||
VStack {
|
||||
Divider()
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
var body: some View {
|
||||
if !CorePreferences.hideSipAddresses || (CorePreferences.hideSipAddresses && !contactAvatarModel.phoneNumbersWithLabel.isEmpty) {
|
||||
HStack(alignment: .center) {
|
||||
Text("contact_details_numbers_and_addresses_title")
|
||||
.default_text_style_800(styleSize: 15)
|
||||
|
||||
ForEach(contactAvatarModel.phoneNumbersWithLabel.indices, id: \.self) { index in
|
||||
let entry = contactAvatarModel.phoneNumbersWithLabel[index]
|
||||
HStack {
|
||||
HStack {
|
||||
VStack {
|
||||
if !entry.label.isEmpty {
|
||||
Text(String(localized: "phone_number") + " (\(entry.label)):")
|
||||
.default_text_style_700(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
} else {
|
||||
Text(String(localized: "phone_number") + ":")
|
||||
.default_text_style_700(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Spacer()
|
||||
|
||||
Image(informationIsOpen ? "caret-up" : "caret-down")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25, alignment: .leading)
|
||||
.padding(.all, 10)
|
||||
}
|
||||
.padding(.top, 30)
|
||||
.padding(.bottom, 10)
|
||||
.padding(.horizontal, 16)
|
||||
.background(Color.gray100)
|
||||
.onTapGesture {
|
||||
withAnimation {
|
||||
informationIsOpen.toggle()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if informationIsOpen {
|
||||
VStack(spacing: 0) {
|
||||
if !CorePreferences.hideSipAddresses {
|
||||
ForEach(0..<contactAvatarModel.addresses.count, id: \.self) { index in
|
||||
HStack {
|
||||
HStack {
|
||||
VStack {
|
||||
Text(String(localized: "sip_address") + ":")
|
||||
.default_text_style_700(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
Text(contactAvatarModel.addresses[index].dropFirst(4))
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
Spacer()
|
||||
|
||||
Image("phone")
|
||||
.renderingMode(.template)
|
||||
.resizable()
|
||||
.foregroundStyle(Color.grayMain2c600)
|
||||
.frame(width: 25, height: 25)
|
||||
.padding(.all, 10)
|
||||
}
|
||||
Text(entry.phoneNumber)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.padding(.vertical, 15)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.background(.white)
|
||||
.onTapGesture {
|
||||
do {
|
||||
let address = try Factory.Instance.createAddress(addr: contactAvatarModel.addresses[index])
|
||||
withAnimation {
|
||||
telecomManager.doCallOrJoinConf(address: address)
|
||||
}
|
||||
} catch {
|
||||
Log.error("[ContactInnerActionsFragment] unable to create address for a new outgoing call : \(contactAvatarModel.addresses[index]) \(error) ")
|
||||
}
|
||||
}
|
||||
.onLongPressGesture(minimumDuration: 0.2) {
|
||||
contactsListViewModel.stringToCopy = contactAvatarModel.addresses[index]
|
||||
showingSheet.toggle()
|
||||
}
|
||||
|
||||
if !contactAvatarModel.phoneNumbersWithLabel.isEmpty
|
||||
|| index < contactAvatarModel.addresses.count - 1 {
|
||||
VStack {
|
||||
Divider()
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 15)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.background(.white)
|
||||
.onLongPressGesture(minimumDuration: 0.2) {
|
||||
contactsListViewModel.stringToCopy = entry.phoneNumber
|
||||
showingSheet.toggle()
|
||||
}
|
||||
|
||||
if index < contactAvatarModel.phoneNumbersWithLabel.count - 1 {
|
||||
VStack {
|
||||
Divider()
|
||||
ForEach(contactAvatarModel.phoneNumbersWithLabel.indices, id: \.self) { index in
|
||||
let entry = contactAvatarModel.phoneNumbersWithLabel[index]
|
||||
HStack {
|
||||
HStack {
|
||||
VStack {
|
||||
if !entry.label.isEmpty {
|
||||
Text(String(localized: "phone_number") + " (\(entry.label)):")
|
||||
.default_text_style_700(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
} else {
|
||||
Text(String(localized: "phone_number") + ":")
|
||||
.default_text_style_700(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
Text(entry.phoneNumber)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
}
|
||||
Spacer()
|
||||
}
|
||||
.padding(.vertical, 15)
|
||||
.padding(.horizontal, 20)
|
||||
}
|
||||
.background(.white)
|
||||
.onLongPressGesture(minimumDuration: 0.2) {
|
||||
contactsListViewModel.stringToCopy = entry.phoneNumber
|
||||
showingSheet.toggle()
|
||||
}
|
||||
|
||||
if index < contactAvatarModel.phoneNumbersWithLabel.count - 1 {
|
||||
VStack {
|
||||
Divider()
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
.padding(.horizontal)
|
||||
}
|
||||
}
|
||||
.background(.white)
|
||||
.cornerRadius(15)
|
||||
.padding(.horizontal)
|
||||
.zIndex(-1)
|
||||
.transition(.move(edge: .top))
|
||||
}
|
||||
} else {
|
||||
HStack {}
|
||||
.frame(height: 20)
|
||||
}
|
||||
.background(.white)
|
||||
.cornerRadius(15)
|
||||
.padding(.horizontal)
|
||||
.zIndex(-1)
|
||||
.transition(.move(edge: .top))
|
||||
}
|
||||
|
||||
if !contactAvatarModel.organization.isEmpty || !contactAvatarModel.jobTitle.isEmpty {
|
||||
VStack {
|
||||
|
|
|
|||
|
|
@ -39,11 +39,11 @@ class EditContactViewModel: ObservableObject {
|
|||
|
||||
func resetValues() {
|
||||
CoreContext.shared.doOnCoreQueue { _ in
|
||||
let nativeUriTmp = (self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.nativeUri) ?? ""
|
||||
let nativeUriTmp = self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.nativeUri
|
||||
let givenNameTmp = (self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.vcard?.givenName) ?? ""
|
||||
let familyNameTmp = (self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.vcard?.familyName) ?? ""
|
||||
let organizationTmp = (self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.organization) ?? ""
|
||||
let jobTitleTmp = (self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.jobTitle) ?? ""
|
||||
let organizationTmp = self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.organization
|
||||
let jobTitleTmp = self.selectedEditFriend == nil ? "" : self.selectedEditFriend!.jobTitle
|
||||
|
||||
var sipAddressesTmp: [String] = []
|
||||
var phoneNumbersTmp: [String] = []
|
||||
|
|
|
|||
|
|
@ -104,12 +104,14 @@ struct ConversationInfoFragment: View {
|
|||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 10)
|
||||
|
||||
Text(conversationViewModel.participantConversationModel.first?.address ?? "")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 5)
|
||||
if !CorePreferences.hideSipAddresses {
|
||||
Text(conversationViewModel.participantConversationModel.first?.address ?? "")
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 5)
|
||||
}
|
||||
|
||||
if !SharedMainViewModel.shared.displayedConversation!.avatarModel.lastPresenceInfo.isEmpty {
|
||||
Text(SharedMainViewModel.shared.displayedConversation!.avatarModel.lastPresenceInfo)
|
||||
|
|
|
|||
|
|
@ -187,12 +187,14 @@ struct HistoryContactFragment: View {
|
|||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 10)
|
||||
|
||||
Text(historyModel.address)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 5)
|
||||
if !CorePreferences.hideSipAddresses {
|
||||
Text(historyModel.address)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.multilineTextAlignment(.center)
|
||||
.default_text_style(styleSize: 14)
|
||||
.frame(maxWidth: .infinity)
|
||||
.padding(.top, 5)
|
||||
}
|
||||
|
||||
if let avatarModel = historyModel.avatarModel {
|
||||
Text(avatarModel.lastPresenceInfo)
|
||||
|
|
|
|||
|
|
@ -270,29 +270,31 @@ struct AccountProfileFragment: View {
|
|||
if accountModel.avatarModel != nil {
|
||||
VStack(spacing: 0) {
|
||||
VStack(spacing: 30) {
|
||||
HStack {
|
||||
Text(String(localized: "sip_address") + ":")
|
||||
.default_text_style_700(styleSize: 15)
|
||||
|
||||
Text(accountModel.avatarModel!.address)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
|
||||
Button(action: {
|
||||
UIPasteboard.general.setValue(
|
||||
accountModel.avatarModel!.address,
|
||||
forPasteboardType: UTType.plainText.identifier
|
||||
)
|
||||
if !CorePreferences.hideSipAddresses {
|
||||
HStack {
|
||||
Text(String(localized: "sip_address") + ":")
|
||||
.default_text_style_700(styleSize: 15)
|
||||
|
||||
ToastViewModel.shared.toastMessage = "Success_address_copied_into_clipboard"
|
||||
ToastViewModel.shared.displayToast.toggle()
|
||||
}, label: {
|
||||
Image("copy")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
})
|
||||
Text(accountModel.avatarModel!.address)
|
||||
.foregroundStyle(Color.grayMain2c700)
|
||||
.default_text_style(styleSize: 15)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.lineLimit(1)
|
||||
|
||||
Button(action: {
|
||||
UIPasteboard.general.setValue(
|
||||
accountModel.avatarModel!.address,
|
||||
forPasteboardType: UTType.plainText.identifier
|
||||
)
|
||||
|
||||
ToastViewModel.shared.toastMessage = "Success_address_copied_into_clipboard"
|
||||
ToastViewModel.shared.displayToast.toggle()
|
||||
}, label: {
|
||||
Image("copy")
|
||||
.resizable()
|
||||
.frame(width: 20, height: 20)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue