mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Fix Crashlytics bugs
This commit is contained in:
parent
989471fca2
commit
3d99102426
3 changed files with 89 additions and 12 deletions
|
|
@ -40,6 +40,7 @@ class MessageView: UIView, UITextViewDelegate {
|
|||
var fileContext = false
|
||||
var isComposing = false
|
||||
var isLoading = false
|
||||
var lastNumLines = 0.0
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
|
@ -103,7 +104,29 @@ class MessageView: UIView, UITextViewDelegate {
|
|||
let chatRoom = ChatRoom.getSwiftObject(cObject: PhoneMainView.instance().currentRoom)
|
||||
if ((messageText.text.isEmpty && !fileContext) || isLoading) {
|
||||
sendButton.isEnabled = false
|
||||
emojisButton.isHidden = false
|
||||
messageText.setWidth(80)
|
||||
NotificationCenter.default.post(name: Notification.Name("LinphoneTextViewSize"), object: self)
|
||||
lastNumLines = 0
|
||||
} else {
|
||||
if (messageText.text.trimmingCharacters(in: .whitespacesAndNewlines).unicodeScalars.first?.properties.isEmojiPresentation == true){
|
||||
var onlyEmojis = true
|
||||
messageText.text.trimmingCharacters(in: .whitespacesAndNewlines).unicodeScalars.forEach { emoji in
|
||||
if !emoji.properties.isEmojiPresentation && !emoji.properties.isWhitespace{
|
||||
onlyEmojis = false
|
||||
}
|
||||
}
|
||||
if onlyEmojis {
|
||||
emojisButton.isHidden = false
|
||||
messageText.setWidth(100)
|
||||
} else {
|
||||
emojisButton.isHidden = true
|
||||
messageText.setWidth(80)
|
||||
}
|
||||
} else {
|
||||
emojisButton.isHidden = true
|
||||
messageText.setWidth(80)
|
||||
}
|
||||
if !isComposing {
|
||||
chatRoom.compose()
|
||||
let timer = Timer.scheduledTimer(withTimeInterval: 10.0, repeats: false) { timer in
|
||||
|
|
@ -113,6 +136,29 @@ class MessageView: UIView, UITextViewDelegate {
|
|||
isComposing = true
|
||||
|
||||
sendButton.isEnabled = true
|
||||
|
||||
let numLines = (messageText.contentSize.height / messageText.font!.lineHeight)
|
||||
if(Int(numLines) != Int(lastNumLines)){
|
||||
NotificationCenter.default.post(name: Notification.Name("LinphoneTextViewSize"), object: self)
|
||||
}
|
||||
lastNumLines = numLines
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UIView {
|
||||
func setWidth(_ h:CGFloat, animateTime:TimeInterval?=nil) {
|
||||
if let c = self.constraints.first(where: { $0.firstAttribute == .width && $0.relation == .equal }) {
|
||||
c.constant = CGFloat(h)
|
||||
|
||||
if let animateTime = animateTime {
|
||||
UIView.animate(withDuration: animateTime, animations:{
|
||||
self.superview?.layoutIfNeeded()
|
||||
})
|
||||
}
|
||||
else {
|
||||
self.superview?.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -998,7 +998,7 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
|
|||
meetingView.isHidden = true
|
||||
|
||||
event.chatMessage!.contents.forEach { content in
|
||||
if (content.isFileTransfer && content.name != "") {
|
||||
if (content.isFileTransfer && content.name != "" && !content.isVoiceRecording) {
|
||||
imagesGridCollectionView.append(getImageFrom(content, forReplyBubble: false)!)
|
||||
collectionViewImagesGrid.reloadData()
|
||||
|
||||
|
|
@ -1009,7 +1009,7 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
|
|||
imageViewBubble.isHidden = true
|
||||
}
|
||||
|
||||
if (event.chatMessage?.isOutgoing == true && content.isFileTransfer && event.chatMessage?.isFileTransferInProgress == true) {
|
||||
if (event.chatMessage?.isOutgoing == true && content.isFileTransfer && event.chatMessage?.isFileTransferInProgress == true && !content.isVoiceRecording) {
|
||||
var filePath = ""
|
||||
if VFSUtil.vfsEnabled(groupName: kLinphoneMsgNotificationAppGroupId) {
|
||||
filePath = content.exportPlainFile()
|
||||
|
|
@ -1521,15 +1521,19 @@ class MultilineMessageCell: SwipeCollectionViewCell, UICollectionViewDataSource,
|
|||
|
||||
func createThumbnailOfVideoFromFileURL(videoURL: String) -> UIImage? {
|
||||
if let urlEncoded = videoURL.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed){
|
||||
if let urlVideo = URL(string: "file://" + urlEncoded){
|
||||
let asset = AVAsset(url: urlVideo)
|
||||
let assetImgGenerate = AVAssetImageGenerator(asset: asset)
|
||||
assetImgGenerate.appliesPreferredTrackTransform = true
|
||||
do {
|
||||
let img = try assetImgGenerate.copyCGImage(at: CMTimeMake(value: 1, timescale: 10), actualTime: nil)
|
||||
let thumbnail = UIImage(cgImage: img)
|
||||
return thumbnail
|
||||
} catch _{
|
||||
if !urlEncoded.isEmpty {
|
||||
if let urlVideo = URL(string: "file://" + urlEncoded){
|
||||
do {
|
||||
let asset = AVAsset(url: urlVideo)
|
||||
let assetImgGenerate = AVAssetImageGenerator(asset: asset)
|
||||
assetImgGenerate.appliesPreferredTrackTransform = true
|
||||
let img = try assetImgGenerate.copyCGImage(at: CMTimeMake(value: 1, timescale: 10), actualTime: nil)
|
||||
let thumbnail = UIImage(cgImage: img)
|
||||
return thumbnail
|
||||
} catch _{
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ class BackActionsNavigationView: UIViewController {
|
|||
mediaSelector.isHidden = true
|
||||
|
||||
stackView.addArrangedSubview(messageView)
|
||||
messageView.alignParentBottom().height(top_bar_height).matchParentSideBorders().done()
|
||||
messageView.alignParentBottom().height(66).matchParentSideBorders().done()
|
||||
|
||||
stackView.translatesAutoresizingMaskIntoConstraints = false;
|
||||
view.addSubview(stackView)
|
||||
|
|
@ -276,6 +276,7 @@ class BackActionsNavigationView: UIViewController {
|
|||
}
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.rotated), name: UIDevice.orientationDidChangeNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(self.changeSizeOfTextView), name: Notification.Name("LinphoneTextViewSize"), object: nil)
|
||||
}
|
||||
|
||||
func resetRecordingProgressBar(){
|
||||
|
|
@ -396,4 +397,30 @@ class BackActionsNavigationView: UIViewController {
|
|||
|
||||
func deleteSelected(){
|
||||
}
|
||||
|
||||
@objc func changeSizeOfTextView(){
|
||||
let numLines = (messageView.messageText.contentSize.height / messageView.messageText.font!.lineHeight)
|
||||
if numLines >= 3 && numLines <= 6 {
|
||||
messageView.setHeight(33*numLines - 33, animateTime: 0.1)
|
||||
} else if numLines < 3 {
|
||||
messageView.setHeight(66, animateTime: 0.1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UIView {
|
||||
func setHeight(_ h:CGFloat, animateTime:TimeInterval?=nil) {
|
||||
if let c = self.constraints.first(where: { $0.firstAttribute == .height && $0.relation == .equal }) {
|
||||
c.constant = CGFloat(h)
|
||||
|
||||
if let animateTime = animateTime {
|
||||
UIView.animate(withDuration: animateTime, animations:{
|
||||
self.superview?.layoutIfNeeded()
|
||||
})
|
||||
}
|
||||
else {
|
||||
self.superview?.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue