From 03c8684e5df7cff496abaffc694ea5710f02a11b Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Wed, 28 Jun 2017 18:51:05 +0200 Subject: [PATCH 1/2] Bug Fix - Chat screen: the message overlaps its timestamp (related to #1361) --- .../MXKRoomBubbleTableViewCell+Riot.m | 51 ++++++++++++++----- Riot/Model/Room/RoomBubbleCellData.h | 5 ++ Riot/Model/Room/RoomBubbleCellData.m | 21 ++++++++ 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m index a5e16ec20..02cb801b6 100644 --- a/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m +++ b/Riot/Categories/MXKRoomBubbleTableViewCell+Riot.m @@ -47,8 +47,15 @@ NSString *const kMXKRoomBubbleCellRiotEditButtonPressed = @"kMXKRoomBubbleCellRi if (component && component.date) { + // Check whether this is the first displayed component. + BOOL isFirstDisplayedComponent = (componentIndex == 0); + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + isFirstDisplayedComponent = (componentIndex == ((RoomBubbleCellData*)bubbleData).oldestComponentIndex); + } + CGFloat timeLabelPosX = self.bubbleInfoContainer.frame.size.width - VECTOR_ROOMBUBBLETABLEVIEWCELL_TIMELABEL_WIDTH; - CGFloat timeLabelPosY = componentIndex ? component.position.y + self.msgTextViewTopConstraint.constant - self.bubbleInfoContainerTopConstraint.constant: 0; + CGFloat timeLabelPosY = isFirstDisplayedComponent ? 0 : component.position.y + self.msgTextViewTopConstraint.constant - self.bubbleInfoContainerTopConstraint.constant; UILabel *timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(timeLabelPosX, timeLabelPosY, VECTOR_ROOMBUBBLETABLEVIEWCELL_TIMELABEL_WIDTH , 18)]; timeLabel.text = [bubbleData.eventFormatter timeStringFromDate:component.date]; @@ -104,7 +111,7 @@ NSString *const kMXKRoomBubbleCellRiotEditButtonPressed = @"kMXKRoomBubbleCellRi [NSLayoutConstraint activateConstraints:@[rightConstraint, topConstraint, widthConstraint, heightConstraint]]; // Check whether a vertical whitespace was applied to display correctly the timestamp. - if (componentIndex || bubbleData.shouldHideSenderInformation || bubbleData.shouldHideSenderName) + if (!isFirstDisplayedComponent || bubbleData.shouldHideSenderInformation || bubbleData.shouldHideSenderName) { // Adjust the position of the potential encryption icon in this case. if (self.encryptionStatusContainerView) @@ -170,19 +177,30 @@ NSString *const kMXKRoomBubbleCellRiotEditButtonPressed = @"kMXKRoomBubbleCellRi // Define the marker frame CGFloat markPosY = component.position.y + self.msgTextViewTopConstraint.constant; - - CGFloat markHeight; - if (componentIndex == bubbleComponents.count - 1) + + NSInteger mostRecentComponentIndex = bubbleComponents.count - 1; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) { - // There is no component after this component in the cell, - // use the rest of the cell height - markHeight = self.contentView.frame.size.height - markPosY; + mostRecentComponentIndex = ((RoomBubbleCellData*)bubbleData).mostRecentComponentIndex; } - else + + // Compute the mark height. + // Use the rest of the cell height by default. + CGFloat markHeight = self.contentView.frame.size.height - markPosY; + if (componentIndex != mostRecentComponentIndex) { - // Stop the marker height to the top of the next component in the cell - MXKRoomBubbleComponent *nextComponent = bubbleComponents[componentIndex + 1]; - markHeight = nextComponent.position.y - component.position.y; + // There is another component (with display) after this component in the cell. + // Stop the marker height to the top of this component. + for (NSInteger index = componentIndex + 1; index < bubbleComponents.count; index ++) + { + MXKRoomBubbleComponent *nextComponent = bubbleComponents[index]; + + if (nextComponent.attributedTextMessage) + { + markHeight = nextComponent.position.y - component.position.y; + break; + } + } } UIView *markerView = [[UIView alloc] initWithFrame:CGRectMake(VECTOR_ROOMBUBBLETABLEVIEWCELL_MARK_X, @@ -394,10 +412,17 @@ NSString *const kMXKRoomBubbleCellRiotEditButtonPressed = @"kMXKRoomBubbleCellRi { MXKRoomBubbleComponent *component = bubbleData.bubbleComponents[componentIndex]; + // Check whether this is the first displayed component. + BOOL isFirstDisplayedComponent = (componentIndex == 0); + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + isFirstDisplayedComponent = (componentIndex == ((RoomBubbleCellData*)bubbleData).oldestComponentIndex); + } + // Define 'Edit' button frame UIImage *editIcon = [UIImage imageNamed:@"edit_icon"]; CGFloat editBtnPosX = self.bubbleInfoContainer.frame.size.width - VECTOR_ROOMBUBBLETABLEVIEWCELL_TIMELABEL_WIDTH - 22 - editIcon.size.width / 2; - CGFloat editBtnPosY = componentIndex ? component.position.y + self.msgTextViewTopConstraint.constant - self.bubbleInfoContainerTopConstraint.constant - 13 : -13; + CGFloat editBtnPosY = isFirstDisplayedComponent ? -13 : component.position.y + self.msgTextViewTopConstraint.constant - self.bubbleInfoContainerTopConstraint.constant - 13; UIButton *editButton = [[UIButton alloc] initWithFrame:CGRectMake(editBtnPosX, editBtnPosY, 44, 44)]; [editButton setImage:editIcon forState:UIControlStateNormal]; diff --git a/Riot/Model/Room/RoomBubbleCellData.h b/Riot/Model/Room/RoomBubbleCellData.h index a59d3103d..70e128448 100644 --- a/Riot/Model/Room/RoomBubbleCellData.h +++ b/Riot/Model/Room/RoomBubbleCellData.h @@ -37,6 +37,11 @@ */ @property(nonatomic) NSString *selectedEventId; +/** + The index of the oldest component (component with a timestamp, and an actual display). NSNotFound by default. + */ +@property(nonatomic, readonly) NSInteger oldestComponentIndex; + /** The index of the most recent component (component with a timestamp, and an actual display). NSNotFound by default. */ diff --git a/Riot/Model/Room/RoomBubbleCellData.m b/Riot/Model/Room/RoomBubbleCellData.m index 36388b619..e4cd8995a 100644 --- a/Riot/Model/Room/RoomBubbleCellData.m +++ b/Riot/Model/Room/RoomBubbleCellData.m @@ -348,6 +348,27 @@ static NSAttributedString *readReceiptVerticalWhitespace = nil; } } +- (NSInteger)oldestComponentIndex +{ + // Update the related component index + NSInteger oldestComponentIndex = NSNotFound; + + NSArray *components = self.bubbleComponents; + NSInteger index = 0; + while (index < components.count) + { + MXKRoomBubbleComponent *component = components[index]; + if (component.attributedTextMessage && component.date) + { + oldestComponentIndex = index; + break; + } + index++; + } + + return oldestComponentIndex; +} + - (NSInteger)mostRecentComponentIndex { // Update the related component index From 739749494dc15a91798b5c43572e70ff0699e036 Mon Sep 17 00:00:00 2001 From: Giom Foret Date: Wed, 28 Jun 2017 21:15:09 +0200 Subject: [PATCH 2/2] Bug Fix - Chat screen: several encryption icons are displayed on the same event. Fix tap handling on encryption icons (related to #1361) --- .../Encryption/RoomEncryptedDataBubbleCell.m | 6 +++++ .../RoomIncomingEncryptedTextMsgBubbleCell.m | 20 ++++++++++++++--- ...ptedTextMsgWithPaginationTitleBubbleCell.m | 20 ++++++++++++++--- ...ginationTitleWithoutSenderNameBubbleCell.m | 20 ++++++++++++++--- ...ryptedTextMsgWithoutSenderInfoBubbleCell.m | 20 ++++++++++++++--- ...ryptedTextMsgWithoutSenderNameBubbleCell.m | 20 ++++++++++++++--- .../RoomOutgoingEncryptedTextMsgBubbleCell.m | 22 +++++++++++++++---- ...ptedTextMsgWithPaginationTitleBubbleCell.m | 22 +++++++++++++++---- ...ginationTitleWithoutSenderNameBubbleCell.m | 22 +++++++++++++++---- ...ryptedTextMsgWithoutSenderInfoBubbleCell.m | 22 +++++++++++++++---- ...ryptedTextMsgWithoutSenderNameBubbleCell.m | 22 +++++++++++++++---- 11 files changed, 181 insertions(+), 35 deletions(-) diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomEncryptedDataBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomEncryptedDataBubbleCell.m index 37881a14f..3f7b8b918 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomEncryptedDataBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomEncryptedDataBubbleCell.m @@ -95,6 +95,12 @@ NSString *const kRoomEncryptedDataBubbleCellTapOnEncryptionIcon = @"kRoomEncrypt for (NSUInteger componentIndex = 0; componentIndex < bubbleComponents.count; componentIndex++) { component = bubbleComponents[componentIndex]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } UIImage *icon = [RoomEncryptedDataBubbleCell encryptionIconForEvent:component.event andSession:bubbleData.mxSession]; UIImageView *encryptStatusImageView = [[UIImageView alloc] initWithImage:icon]; diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgBubbleCell.m index 11a486890..fc83e86da 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomIncomingEncryptedTextMsgBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell.m index 9d2c10c66..5497ff296 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomIncomingEncryptedTextMsgWithPaginationTitleBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m index 0e56d8794..51673332c 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomIncomingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.m index c39cff80a..babc8f4af 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomIncomingEncryptedTextMsgWithoutSenderInfoBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell.m index 1767a3337..f08b38d90 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomIncomingEncryptedTextMsgWithoutSenderNameBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgBubbleCell.m index 028b4c3b5..d99b16b8e 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomOutgoingEncryptedTextMsgBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; @@ -88,4 +102,4 @@ } } -@end \ No newline at end of file +@end diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell.m index 814a5fead..dedd93223 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomOutgoingEncryptedTextMsgWithPaginationTitleBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; @@ -88,4 +102,4 @@ } } -@end \ No newline at end of file +@end diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m index cb68f1d92..4dbbbe797 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomOutgoingEncryptedTextMsgWithPaginationTitleWithoutSenderNameBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; @@ -88,4 +102,4 @@ } } -@end \ No newline at end of file +@end diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell.m index 0d509a0c3..250dcc7fd 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomOutgoingEncryptedTextMsgWithoutSenderInfoBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; @@ -88,4 +102,4 @@ } } -@end \ No newline at end of file +@end diff --git a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.m b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.m index 160f0afdb..63c38b5eb 100644 --- a/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.m +++ b/Riot/Views/RoomBubbleList/Encryption/RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell.m @@ -18,6 +18,8 @@ #import "RoomEncryptedDataBubbleCell.h" +#import "RoomBubbleCellData.h" + @implementation RoomOutgoingEncryptedTextMsgWithoutSenderNameBubbleCell - (void)awakeFromNib @@ -64,15 +66,27 @@ // Check which bubble component is displayed in front of the tapped line. NSArray *bubbleComponents = bubbleData.bubbleComponents; - // Consider by default the first component - MXKRoomBubbleComponent *tappedComponent = bubbleComponents.firstObject; + // Consider by default the first display component + NSInteger firstComponentIndex = 0; + if ([bubbleData isKindOfClass:RoomBubbleCellData.class]) + { + firstComponentIndex = ((RoomBubbleCellData*)bubbleData).oldestComponentIndex; + } + MXKRoomBubbleComponent *tappedComponent = bubbleComponents[firstComponentIndex++]; CGPoint tapPoint = [sender locationInView:self.messageTextView]; - for (NSInteger index = 1; index < bubbleComponents.count; index++) + for (NSInteger index = firstComponentIndex; index < bubbleComponents.count; index++) { // Here the bubble is composed by multiple text messages MXKRoomBubbleComponent *component = bubbleComponents[index]; + + // Ignore components without display. + if (!component.attributedTextMessage) + { + continue; + } + if (tapPoint.y < component.position.y) { break; @@ -88,4 +102,4 @@ } } -@end \ No newline at end of file +@end