(commit by Quentin) fix xcode 13 build

This commit is contained in:
buildbot 2023-04-13 11:37:02 +02:00 committed by QuentinArguillere
parent 7f1720ea89
commit f9cbfa1731
5 changed files with 29 additions and 37 deletions

View file

@ -227,8 +227,8 @@ class ChatConversationViewModel: ControlsViewModel {
func startUploadData(_ data: Data?, withType type: String?, withName name: String?, andMessage message: String?, rootMessage: ChatMessage?){
let fileTransfer = FileTransferDelegate.init()
if let message {
fileTransfer.text = message
if let msg = message {
fileTransfer.text = msg
}
var resultType = "file"
var key = "localfile"
@ -251,18 +251,16 @@ class ChatConversationViewModel: ControlsViewModel {
let groupName = "group.\(Bundle.main.bundleIdentifier ?? "").linphoneExtension"
let defaults = UserDefaults(suiteName: groupName)
let dict = defaults?.value(forKey: "photoData") as? [AnyHashable : Any]
let dictFile = defaults?.value(forKey: "icloudData") as? [AnyHashable : Any]
let dictUrl = defaults?.value(forKey: "url") as? [AnyHashable : Any]
if let dict {
if let dict_notnil = dict {
//file shared from photo lib
shareFileMessage = dict["message"] as? String
shareFileName.value = dict["url"] as? String
shareFileMessage = dict_notnil["message"] as? String
shareFileName.value = dict_notnil["url"] as? String
defaults?.removeObject(forKey: "photoData")
} else if let dictFile {
} else if let dictFile = defaults?.value(forKey: "icloudData") as? [AnyHashable : Any] {
shareFileMessage = dict?["message"] as? String
shareFileName.value = dictFile["url"] as? String
defaults?.removeObject(forKey: "icloudData")
} else if let dictUrl {
} else if let dictUrl = defaults?.value(forKey: "url") as? [AnyHashable : Any] {
shareFileMessage = dict?["message"] as? String
shareFileURL.value = dictUrl["url"] as? String
defaults?.removeObject(forKey: "url")
@ -283,8 +281,9 @@ class ChatConversationViewModel: ControlsViewModel {
} else if type == "image" {
image = UIImage(named: filePath ?? "")
}
if let image {
return image
if let img = image {
return img
} else {
return getImageFromFileName(name, forReplyBubble: forReplyBubble)
}

View file

@ -419,8 +419,7 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
func addToContacts(message: ChatMessage) {
let addr = message.fromAddress
addr?.clean()
let lAddress = addr?.asStringUriOnly()
if let lAddress {
if let lAddress = addr?.asStringUriOnly() {
var normSip = String(utf8String: lAddress)
normSip = normSip?.hasPrefix("sip:") ?? false ? (normSip as NSString?)?.substring(from: 4) : normSip
normSip = normSip?.hasPrefix("sips:") ?? false ? (normSip as NSString?)?.substring(from: 5) : normSip

View file

@ -172,8 +172,7 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
}
ChatConversationViewModel.sharedModel.subjectChanged.observe { subject in
let subjectVM = ChatConversationViewModel.sharedModel.subject
if let subjectVM {
if let subjectVM = ChatConversationViewModel.sharedModel.subject {
self.titleGroupLabel.text = subjectVM
self.titleLabel.text = subjectVM
self.tableControllerSwift.refreshData(isOutgoing: false)
@ -344,18 +343,14 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
let firstParticipant = ChatConversationViewModel.sharedModel.chatRoom?.participants.first
let addr = (firstParticipant != nil) ? linphone_participant_get_address(firstParticipant?.getCobject) : linphone_chat_room_get_peer_address(ChatConversationViewModel.sharedModel.chatRoom?.getCobject)
let contact = FastAddressBook.getContactWith(addr)
if let contact {
if let contact = FastAddressBook.getContactWith(addr) {
let view: ContactDetailsView = self.VIEW(ContactDetailsView.compositeViewDescription())
ContactSelection.setSelectionMode(ContactSelectionModeNone)
MagicSearchSingleton.instance().currentFilter = ""
view.contact = contact
PhoneMainView.instance().changeCurrentView(view.compositeViewDescription())
} else {
let lAddress = linphone_address_as_string_uri_only(addr)
if let lAddress {
if let lAddress = linphone_address_as_string_uri_only(addr) {
var normSip = String(utf8String: lAddress)
normSip = normSip?.hasPrefix("sip:") ?? false ? (normSip as NSString?)?.substring(from: 4) : normSip
normSip = normSip?.hasPrefix("sips:") ?? false ? (normSip as NSString?)?.substring(from: 5) : normSip
@ -421,8 +416,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
let peerAddress = String(utf8String: linphone_address_as_string(linphone_chat_room_get_peer_address(ChatConversationViewModel.sharedModel.chatRoom?.getCobject)))
var infoMsg: String? = nil
if let peerAddress, let localAddress {
infoMsg = "Chat room id:\n\(peerAddress)\nLocal account:\n\(localAddress)"
if (peerAddress != nil && localAddress != nil) {
infoMsg = "Chat room id:\n\(peerAddress ?? "nil")\nLocal account:\n\(localAddress ?? "nil")"
}
let popupView = UIAlertController(title: NSLocalizedString("Chatroom debug infos", comment: ""), message: infoMsg, preferredStyle: .alert)
@ -1239,8 +1234,8 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
if messageView.messageText.text != "" {
try sendMessageInMessageField(rootMessage: ChatConversationViewModel.sharedModel.chatRoom?.createEmptyMessage())
}
if let url {
_ = try ChatConversationViewModel.sharedModel.sendMessage(message: url, withExterlBodyUrl: nil, rootMessage: ChatConversationViewModel.sharedModel.chatRoom?.createEmptyMessage())
if let sUrl = url {
_ = try ChatConversationViewModel.sharedModel.sendMessage(message: sUrl, withExterlBodyUrl: nil, rootMessage: ChatConversationViewModel.sharedModel.chatRoom?.createEmptyMessage())
} else {
try startFileUpload(data, withName: fileName, rootMessage: ChatConversationViewModel.sharedModel.chatRoom?.createEmptyMessage())
}

View file

@ -840,14 +840,14 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
if VFSUtil.vfsEnabled(groupName: kLinphoneMsgNotificationAppGroupId) {
var plainFile = content.exportPlainFile()
if let imageMessage = UIImage(named: plainFile){
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
}
ChatConversationViewModel.sharedModel.removeTmpFile(filePath: plainFile)
plainFile = ""
}else{
if let imageMessage = UIImage(named: content.filePath){
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
}
}
@ -876,14 +876,14 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
if VFSUtil.vfsEnabled(groupName: kLinphoneMsgNotificationAppGroupId) {
var plainFile = content.exportPlainFile()
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: plainFile){
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
}
ChatConversationViewModel.sharedModel.removeTmpFile(filePath: plainFile)
plainFile = ""
}else{
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: content.filePath){
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
}
}
@ -1324,8 +1324,8 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
filePath = ""
}
if let image {
return image
if let img = image {
return img
} else {
return getImageFromFileName(name, forReplyBubble: forReplyBubble)
}
@ -1468,7 +1468,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
if VFSUtil.vfsEnabled(groupName: kLinphoneMsgNotificationAppGroupId) {
var plainFile = content.exportPlainFile()
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: plainFile){
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
if (imageVideoViewBubble.image != nil && imagesGridCollectionView.count <= 1){
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
}
@ -1478,7 +1478,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
plainFile = ""
}else{
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: content.filePath){
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
if (imageVideoViewBubble.image != nil && imagesGridCollectionView.count <= 1){
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
}
@ -1488,7 +1488,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
if VFSUtil.vfsEnabled(groupName: kLinphoneMsgNotificationAppGroupId) {
var plainFile = content.exportPlainFile()
if let imageMessage = UIImage(named: plainFile){
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
if (imageViewBubble.image != nil && imagesGridCollectionView.count <= 1 && !(linphone_core_get_max_size_for_auto_download_incoming_files(LinphoneManager.getLc()) > -1)){
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
}
@ -1498,7 +1498,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
plainFile = ""
}else{
if let imageMessage = UIImage(named: content.filePath){
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSize(width: UIScreen.main.bounds.size.width*3/4, height: 300.0))
if (imageViewBubble.image != nil && imagesGridCollectionView.count <= 1 && !(linphone_core_get_max_size_for_auto_download_incoming_files(LinphoneManager.getLc()) > -1)){
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
}

View file

@ -53,8 +53,7 @@ class AudioPlayer: ControlsViewModel {
static func cancelVoiceRecordingVM(_ voiceRecorder: Recorder?) {
voiceRecorder?.close()
let recordingFile = voiceRecorder?.file
if let recordingFile {
if let recordingFile = voiceRecorder?.file {
AppManager.removeFile(file: String(utf8String: recordingFile)!)
}
}