diff --git a/Riot/Modules/Room/TimelineCells/Common/MXKRoomBubbleTableViewCell.m b/Riot/Modules/Room/TimelineCells/Common/MXKRoomBubbleTableViewCell.m index ff1bb71b2..fe4a3558d 100644 --- a/Riot/Modules/Room/TimelineCells/Common/MXKRoomBubbleTableViewCell.m +++ b/Riot/Modules/Room/TimelineCells/Common/MXKRoomBubbleTableViewCell.m @@ -1562,6 +1562,14 @@ static NSMutableDictionary *childClasses; associatedEvent = bubbleComponent.event; } + // Tapping a file attachment who's name triggers a data detector will try to open that URL. + // Detect this and instead map the interaction into a tap on the cell. + if (associatedEvent.isMediaAttachment) + { + [delegate cell:self didRecognizeAction:kMXKRoomBubbleCellTapOnAttachmentView userInfo:nil]; + return NO; + } + // Ask the delegate if iOS can open the link shouldInteractWithURL = [self shouldInteractWithURL:URL urlItemInteraction:interaction associatedEvent:associatedEvent]; } @@ -1569,32 +1577,6 @@ static NSMutableDictionary *childClasses; return shouldInteractWithURL; } -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -// Delegate method only called on iOS 9. iOS 10+ use method above. -- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange -{ - BOOL shouldInteractWithURL = YES; - - if (delegate && URL) - { - MXEvent *associatedEvent; - - if ([textView isMemberOfClass:[MXKMessageTextView class]]) - { - MXKMessageTextView *mxkMessageTextView = (MXKMessageTextView *)textView; - MXKRoomBubbleComponent *bubbleComponent = [self closestBubbleComponentAtPosition:mxkMessageTextView.lastHitTestLocation]; - associatedEvent = bubbleComponent.event; - } - - // Ask the delegate if iOS can open the link - shouldInteractWithURL = [self shouldInteractWithURL:URL urlItemInteractionValue:@(0) associatedEvent:associatedEvent]; - } - - return shouldInteractWithURL; -} -#pragma clang diagnostic pop - #pragma mark - WKNavigationDelegate - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation diff --git a/changelog.d/6031.bugfix b/changelog.d/6031.bugfix new file mode 100644 index 000000000..9b0586c10 --- /dev/null +++ b/changelog.d/6031.bugfix @@ -0,0 +1 @@ +Timeline: When an attachment is named like an email address, open the file instead of Mail.app when tapped.