diff --git a/Classes/Base.lproj/ChatConversationView.xib b/Classes/Base.lproj/ChatConversationView.xib index d5d282672..3f826ae9d 100644 --- a/Classes/Base.lproj/ChatConversationView.xib +++ b/Classes/Base.lproj/ChatConversationView.xib @@ -1,6 +1,7 @@ + @@ -10,7 +11,6 @@ - @@ -120,29 +120,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -205,11 +182,6 @@ - - - - - diff --git a/Classes/ChatsListTableView.m b/Classes/ChatsListTableView.m index 864197026..c9581e53f 100644 --- a/Classes/ChatsListTableView.m +++ b/Classes/ChatsListTableView.m @@ -138,8 +138,8 @@ static void chatTable_free_chatrooms(void *data) { if (![self isEditing]) { LinphoneChatRoom *chatRoom = (LinphoneChatRoom *)ms_list_nth_data(data, (int)[indexPath row]); ChatConversationView *view = VIEW(ChatConversationView); - [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; [view setChatRoom:chatRoom]; + [PhoneMainView.instance changeCurrentView:view.compositeViewDescription push:TRUE]; } } diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 34acaac6a..80e76f97b 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -97,8 +97,10 @@ _messageText.attributedText = attr_text; // Date - _contactDateLabel.text = - [LinphoneUtils timeToString:linphone_chat_message_get_time(message) withStyle:NSDateFormatterMediumStyle]; + _contactDateLabel.text = [NSString + stringWithFormat:@"%@ - %@", [LinphoneUtils timeToString:linphone_chat_message_get_time(message) + withStyle:NSDateFormatterShortStyle], + [FastAddressBook displayNameForAddress:linphone_chat_message_get_peer_address(message)]]; LinphoneChatMessageState state = linphone_chat_message_get_state(message); BOOL outgoing = linphone_chat_message_is_outgoing(message); @@ -213,7 +215,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st static const CGFloat IMAGE_HEIGHT = 100.0f; // TODO: move that in bubblephpto static const CGFloat IMAGE_WIDTH = 100.0f; - CGSize messageSize; + CGSize messageSize, dateSize; int messageAvailableWidth = width - MARGIN_WIDTH; const char *url = linphone_chat_message_get_external_body_url(message); @@ -230,12 +232,24 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st NSFontAttributeName : _messageText.font } context:nil] .size; + dateSize = [_contactDateLabel.text boundingRectWithSize:_contactDateLabel.frame.size + options:(NSStringDrawingUsesLineFragmentOrigin | + NSStringDrawingTruncatesLastVisibleLine | + NSStringDrawingUsesFontLeading) + attributes:@{ + NSFontAttributeName : _contactDateLabel.font + } + context:nil] + .size; } else #endif { messageSize = [text sizeWithFont:_messageText.font constrainedToSize:CGSizeMake(messageAvailableWidth, 10000.0f) lineBreakMode:NSLineBreakByTruncatingTail]; + dateSize = [text sizeWithFont:_contactDateLabel.font + constrainedToSize:_contactDateLabel.frame.size + lineBreakMode:NSLineBreakByTruncatingTail]; } } else { messageSize = CGSizeMake(IMAGE_WIDTH, IMAGE_HEIGHT); @@ -245,7 +259,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st messageSize.height = MAX(TEXT_MIN_HEIGHT, messageSize.height); CGSize bubbleSize = messageSize; - bubbleSize.width += MARGIN_WIDTH; + bubbleSize.width = MAX(messageSize.width, dateSize.width) + MARGIN_WIDTH; bubbleSize.height += MARGIN_HEIGHT; LOGE(@"%d %fx%f for %@", width, bubbleSize.width, bubbleSize.height, @@ -259,6 +273,7 @@ static void message_status(LinphoneChatMessage *msg, LinphoneChatMessageState st BOOL is_outgoing = linphone_chat_message_is_outgoing(message); CGRect bubbleFrame = _bubbleView.frame; bubbleFrame.size = [self viewSizeWithWidth:self.frame.size.width]; + bubbleFrame.size.width += 10; bubbleFrame.origin.x = is_outgoing ? self.frame.size.width - bubbleFrame.size.width : 0; _bubbleView.frame = bubbleFrame; } diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.xib b/Classes/LinphoneUI/UIChatBubbleTextCell.xib index 0a40f32df..300b51ce1 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.xib +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.xib @@ -1,5 +1,5 @@ - + @@ -24,9 +24,9 @@ - + - + @@ -36,7 +36,7 @@ - + @@ -66,7 +66,7 @@ - + static const CGFloat CELL_MESSAGE_WIDTH_MARGIN = 26.0f + 10.0f + 48; static const CGFloat CELL_MESSAGE_HEIGHT_MARGIN = 10.0f + 10; static const CGFloat CELL_IMAGE_HEIGHT = 100.0f; @@ -77,7 +77,7 @@ static const CGFloat CELL_IMAGE_WIDTH = 100.0f; - + @@ -92,8 +92,8 @@ static const CGFloat CELL_IMAGE_WIDTH = 100.0f; - - + +