mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
fix chat cell view when it's a video type
This commit is contained in:
parent
d5c11c70ba
commit
a62b5b932c
3 changed files with 21 additions and 11 deletions
|
|
@ -165,6 +165,7 @@ 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)];
|
||||
|
||||
if (!(localImage || localVideo || localFile)) {
|
||||
_playButton.hidden = YES;
|
||||
|
|
@ -193,13 +194,13 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
|
|||
}
|
||||
}
|
||||
else if (localFile) {
|
||||
if ([localFile hasSuffix:@"JPG"] || [localFile hasSuffix:@"PNG"] || [localFile hasSuffix:@"jpg"] || [localFile hasSuffix:@"png"]) {
|
||||
NSData *data = [NSData dataWithContentsOfURL:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];
|
||||
UIImage *image = [[UIImage alloc] initWithData:data];
|
||||
if ([type isEqualToString:@"video/"]) {
|
||||
UIImage* image = [UIChatBubbleTextCell getImageFromVideoUrl:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];
|
||||
[self loadImageAsset:nil image:image];
|
||||
_imageGestureRecognizer.enabled = YES;
|
||||
} else if ([localFile hasSuffix:@"MOV"] || [localFile hasSuffix:@"mov"]) {
|
||||
UIImage* image = [UIChatBubbleTextCell 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]];
|
||||
UIImage *image = [[UIImage alloc] initWithData:data];
|
||||
[self loadImageAsset:nil image:image];
|
||||
_imageGestureRecognizer.enabled = YES;
|
||||
} else {
|
||||
|
|
@ -219,7 +220,7 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
|
|||
} else {
|
||||
_cancelButton.hidden = _fileTransferProgress.hidden = _downloadButton.hidden = YES;
|
||||
fullScreenImage = YES;
|
||||
_playButton.hidden = localVideo ? NO : ([localFile hasSuffix:@"MOV"] || [localFile hasSuffix:@"mov"]) ? NO : YES;
|
||||
_playButton.hidden = ![type isEqualToString:@"video/"];
|
||||
_fileName.hidden = _fileView.hidden = _fileButton.hidden = localFile ? NO : YES;
|
||||
// Should fix cell not resizing after doanloading image.
|
||||
[self layoutSubviews];
|
||||
|
|
|
|||
|
|
@ -467,11 +467,12 @@ static const CGFloat CELL_IMAGE_X_MARGIN = 100;
|
|||
|
||||
if(localFile) {
|
||||
UIImage *image = nil;
|
||||
if ([localFile hasSuffix:@"JPG"] || [localFile hasSuffix:@"PNG"] || [localFile hasSuffix:@"jpg"] || [localFile hasSuffix:@"png"]) {
|
||||
NSString *type = [NSString stringWithUTF8String:linphone_chat_message_get_content_type(chat)];
|
||||
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]];
|
||||
image = [[UIImage alloc] initWithData:data];
|
||||
} else if ([localFile hasSuffix:@"MOV"] || [localFile hasSuffix:@"mov"]) {
|
||||
image = [self getImageFromVideoUrl:[VIEW(ChatConversationView) getICloudFileUrl:localFile]];
|
||||
}
|
||||
|
||||
if (image) {
|
||||
|
|
|
|||
|
|
@ -296,8 +296,16 @@ static LinphoneBuffer *linphone_iphone_file_transfer_send(LinphoneChatMessage *m
|
|||
- (void)uploadFile:(NSData *)data forChatRoom:(LinphoneChatRoom *)chatRoom withName:(NSString *)name {
|
||||
// we will write local files into ours folder of icloud
|
||||
ChatConversationView *view = VIEW(ChatConversationView);
|
||||
if ([view writeFileInICloud:data fileURL:[view getICloudFileUrl:name]])
|
||||
[self uploadData:data forChatRoom:chatRoom type:@"file" subtype:nil name:name key:@"localfile" keyData:name qualityData:nil];
|
||||
NSURL *url = [view getICloudFileUrl:name];
|
||||
if ([view writeFileInICloud:data fileURL:url]) {
|
||||
AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
|
||||
if ([[asset tracksWithMediaType:AVMediaTypeVideo] count] > 0) {
|
||||
// if it's a video
|
||||
[self uploadData:data forChatRoom:chatRoom type:@"video" subtype:nil name:name key:@"localfile" keyData:name qualityData:nil];
|
||||
} else {
|
||||
[self uploadData:data forChatRoom:chatRoom type:@"file" subtype:nil name:name key:@"localfile" keyData:name qualityData:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue