From 04169647c2025131cca5176e193fb7c3e2fe7109 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Mon, 14 Jan 2019 12:14:18 +0100 Subject: [PATCH] fix video play button --- Classes/ChatConversationView.m | 9 +++++++-- Classes/LinphoneUI/UIChatBubblePhotoCell.m | 8 +++++--- Classes/LinphoneUI/UIChatBubbleTextCell.m | 9 +++++---- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Classes/ChatConversationView.m b/Classes/ChatConversationView.m index 4c4a94087..db00435b9 100644 --- a/Classes/ChatConversationView.m +++ b/Classes/ChatConversationView.m @@ -1056,7 +1056,7 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog return FALSE; } - if ([fileManager isUbiquitousItemAtURL:fileURL]) { + if ([fileManager fileExistsAtPath:[fileURL path]]) { // if it exists, replace the file return [data writeToURL:fileURL atomically:TRUE]; } else { @@ -1068,7 +1068,12 @@ void on_chat_room_conference_alert(LinphoneChatRoom *cr, const LinphoneEventLog } NSError *error; - return [[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:localURL destinationURL:fileURL error:&error]; + if ([[NSFileManager defaultManager] setUbiquitous:YES itemAtURL:localURL destinationURL:fileURL error:&error]) { + return TRUE; + } else { + LOGE(@"Cannot write file in Icloud file [%@]",[error localizedDescription]); + return FALSE; + } } } diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index 7f4d4d360..6f6476337 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -165,7 +165,9 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:self.message]; BOOL fullScreenImage = NO; assert(is_external || localImage || localVideo || localFile); - NSString *type = [NSString stringWithUTF8String:linphone_chat_message_get_content_type(self.message)]; + + LinphoneContent *fileContent = linphone_chat_message_get_file_transfer_information(self.message); + NSString *type = fileContent ? [NSString stringWithUTF8String:linphone_content_get_type(fileContent)] : nil; if (!(localImage || localVideo || localFile)) { _playButton.hidden = YES; @@ -194,7 +196,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; } } else if (localFile) { - if ([type isEqualToString:@"video/"]) { + if ([type isEqualToString:@"video"]) { UIImage* image = [UIChatBubbleTextCell getImageFromVideoUrl:[VIEW(ChatConversationView) getICloudFileUrl:localFile]]; [self loadImageAsset:nil image:image]; _imageGestureRecognizer.enabled = YES; @@ -220,7 +222,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; } else { _cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES; fullScreenImage = YES; - _playButton.hidden = ![type isEqualToString:@"video/"]; + _playButton.hidden = ![type isEqualToString:@"video"]; _fileName.hidden = _fileView.hidden = _fileButton.hidden = localFile ? NO : YES; // Should fix cell not resizing after doanloading image. [self layoutSubviews]; diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 9f1b66e3f..93093ec74 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -440,8 +440,9 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN + 50, CELL_MIN_HEIGHT); return size; } - - if (url == nil && linphone_chat_message_get_file_transfer_information(chat) == NULL) { + + LinphoneContent *fileContent = linphone_chat_message_get_file_transfer_information(chat); + if (url == nil && fileContent == NULL) { size = [self computeBoundingBox:messageText size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) font:messageFont]; @@ -460,8 +461,8 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100; if(localFile) { UIImage *image = nil; - NSString *type = [NSString stringWithUTF8String:linphone_chat_message_get_content_type(chat)]; - if ([type isEqualToString:@"video/"]) { + NSString *type = [NSString stringWithUTF8String:linphone_content_get_type(fileContent)]; + if ([type isEqualToString:@"video"]) { image = [self getImageFromVideoUrl:[VIEW(ChatConversationView) getICloudFileUrl:localFile]]; } else if ([localFile hasSuffix:@"JPG"] || [localFile hasSuffix:@"PNG"] || [localFile hasSuffix:@"jpg"] || [localFile hasSuffix:@"png"]) { NSData *data = [NSData dataWithContentsOfURL:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];