From e321e1b7723533342b52654c7dce0b986973f70f Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Fri, 2 Nov 2018 17:22:08 +0100 Subject: [PATCH] fix UIChatBubblePhotoCell and ImdmView --- .../Base.lproj/UIChatBubblePhotoCell.xib | 8 +- Classes/LinphoneUI/UIChatBubblePhotoCell.m | 2 +- Classes/LinphoneUI/UIChatBubbleTextCell.m | 89 ++++++++++--------- 3 files changed, 51 insertions(+), 48 deletions(-) diff --git a/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib b/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib index 055b18056..d43a61e8e 100644 --- a/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib +++ b/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.xib @@ -1,11 +1,11 @@ - + - + @@ -137,7 +137,7 @@ - + @@ -179,7 +179,7 @@ - + diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index 80391da95..e3ab512e7 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -420,7 +420,7 @@ textFrame.origin = CGPointMake(textFrame.origin.x, self.finalAssetView.frame.origin.y + self.finalAssetView.frame.size.height); else // When image hasn't be download - textFrame.origin = CGPointMake(textFrame.origin.x, 42); + textFrame.origin = CGPointMake(textFrame.origin.x, _imageSubView.frame.size.height + _imageSubView.frame.origin.y - 10); if (!utf8Text) { textFrame.size.height = 0; } else { diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 06179137e..c85f1d950 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -455,7 +455,7 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 44; // 44; // avoid calculating the size each time NSString *chatSize = [LinphoneManager getMessageAppDataForKey:@"chatSize" inMessage:chat]; - if (chatSize) + if (chatSize && !imdnText) return CGSizeFromString(chatSize); NSString *messageText = [UIChatBubbleTextCell TextMessageForChat:chat]; @@ -469,58 +469,61 @@ static const CGFloat CELL_MESSAGE_Y_MARGIN = 44; // 44; width -= 120; /*checkbox + avatar image + imdmLabel*/ CGSize size; const char *url = linphone_chat_message_get_external_body_url(chat); + if (imdnText) { size = [self computeBoundingBox:imdnText - size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) + size:CGSizeMake(width - 4, CGFLOAT_MAX) font:messageFont]; - size.height += 20; + size.width = MAX(size.width + CELL_MESSAGE_X_MARGIN, CELL_MIN_WIDTH); + size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN + 40, CELL_MIN_HEIGHT); + return size; + } + + if (url == nil && linphone_chat_message_get_file_transfer_information(chat) == NULL) { + size = [self computeBoundingBox:messageText + size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) + font:messageFont]; } else { - if (url == nil && linphone_chat_message_get_file_transfer_information(chat) == NULL) { - size = [self computeBoundingBox:messageText - size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) - font:messageFont]; - } else { - NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:chat]; - NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:chat]; - NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:chat]; + NSString *localImage = [LinphoneManager getMessageAppDataForKey:@"localimage" inMessage:chat]; + NSString *localFile = [LinphoneManager getMessageAppDataForKey:@"localfile" inMessage:chat]; + NSString *localVideo = [LinphoneManager getMessageAppDataForKey:@"localvideo" inMessage:chat]; - if(localFile) { - CGSize fileSize = CGSizeMake(230, 50); - size = [self getMediaMessageSizefromOriginalSize:fileSize withWidth:width]; - } else { - CGSize textSize = CGSizeMake(0, 0); - if (![messageText isEqualToString:@"🗻"]) { - textSize = [self computeBoundingBox:messageText - size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) - font:messageFont]; - size.height += textSize.height; - } + if(localFile) { + CGSize fileSize = CGSizeMake(230, 50); + size = [self getMediaMessageSizefromOriginalSize:fileSize withWidth:width]; + } else { + CGSize textSize = CGSizeMake(0, 0); + if (![messageText isEqualToString:@"🗻"]) { + textSize = [self computeBoundingBox:messageText + size:CGSizeMake(width - CELL_MESSAGE_X_MARGIN - 4, CGFLOAT_MAX) + font:messageFont]; + size.height += textSize.height; + } - if (!localImage && !localVideo) { - //We are loading the image - return CGSizeMake(CELL_MIN_WIDTH + CELL_MESSAGE_X_MARGIN, CELL_MIN_HEIGHT + CELL_MESSAGE_Y_MARGIN + textSize.height); - } - PHFetchResult *assets; - if(localImage) - assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localImage] options:nil]; - else - assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localVideo] options:nil]; - if (![assets firstObject]) { - size = CGSizeMake(0, CELL_MESSAGE_Y_MARGIN + textSize.height); - } else { - PHAsset *asset = [assets firstObject]; - CGSize originalImageSize = CGSizeMake([asset pixelWidth], [asset pixelHeight]); - originalImageSize.width = originalImageSize.width; - size = [self getMediaMessageSizefromOriginalSize:originalImageSize withWidth:width]; + if (!localImage && !localVideo) { + //We are loading the image + return CGSizeMake(CELL_MIN_WIDTH + CELL_MESSAGE_X_MARGIN, CELL_MIN_HEIGHT + CELL_MESSAGE_Y_MARGIN + textSize.height + 20); + } + PHFetchResult *assets; + if(localImage) + assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localImage] options:nil]; + else + assets = [PHAsset fetchAssetsWithLocalIdentifiers:[NSArray arrayWithObject:localVideo] options:nil]; + if (![assets firstObject]) { + return CGSizeMake(CELL_MIN_WIDTH, CELL_MIN_WIDTH + CELL_MESSAGE_Y_MARGIN + textSize.height); + } else { + PHAsset *asset = [assets firstObject]; + CGSize originalImageSize = CGSizeMake([asset pixelWidth], [asset pixelHeight]); + originalImageSize.width = originalImageSize.width; + size = [self getMediaMessageSizefromOriginalSize:originalImageSize withWidth:width]; - // add size for message text - size.height += textSize.height; - size.width = MAX(textSize.width, size.width); - } + // add size for message text + size.height += textSize.height; + size.width = MAX(textSize.width, size.width); } } } - + size.width = MAX(size.width + CELL_MESSAGE_X_MARGIN, CELL_MIN_WIDTH); size.height = MAX(size.height + CELL_MESSAGE_Y_MARGIN, CELL_MIN_HEIGHT);