From 9d2589535b7a35d5c50ec418fed43069cfa17b04 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Tue, 25 Jan 2022 16:01:06 +0100 Subject: [PATCH] Fix chat bubble to have both clickable hypertext links AND popup menu for reply/transfer actions --- Classes/LinphoneUI/UIChatBubblePhotoCell.m | 5 +---- Classes/LinphoneUI/UIChatBubbleTextCell.m | 5 +---- Classes/LinphoneUI/UITextViewNoDefine.h | 2 +- Classes/LinphoneUI/UITextViewNoDefine.m | 26 ++++++++++++++-------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Classes/LinphoneUI/UIChatBubblePhotoCell.m b/Classes/LinphoneUI/UIChatBubblePhotoCell.m index 1ef810ca1..30e0c212b 100644 --- a/Classes/LinphoneUI/UIChatBubblePhotoCell.m +++ b/Classes/LinphoneUI/UIChatBubblePhotoCell.m @@ -66,10 +66,7 @@ self.vrView.layer.cornerRadius = 30.0f; self.vrView.layer.masksToBounds = YES; [self.innerView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onPopupMenuPressed)]]; - self.messageText.userInteractionEnabled = true; - self.messageText.editable = false; - self.messageText.selectable = true; - self.messageText.dataDetectorTypes = UIDataDetectorTypeLink; + [self.messageText addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onPopupMenuPressed)]]; } return self; } diff --git a/Classes/LinphoneUI/UIChatBubbleTextCell.m b/Classes/LinphoneUI/UIChatBubbleTextCell.m index 45d5ca78f..5653143f5 100644 --- a/Classes/LinphoneUI/UIChatBubbleTextCell.m +++ b/Classes/LinphoneUI/UIChatBubbleTextCell.m @@ -47,10 +47,7 @@ [_innerView addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onPopupMenuPressed)]]; - _messageText.userInteractionEnabled = true; - _messageText.editable = false; - _messageText.selectable = true; - _messageText.dataDetectorTypes = UIDataDetectorTypeLink; + [_messageText addGestureRecognizer:[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(onPopupMenuPressed)]]; self.contentView.userInteractionEnabled = NO; diff --git a/Classes/LinphoneUI/UITextViewNoDefine.h b/Classes/LinphoneUI/UITextViewNoDefine.h index ec3247b5e..cc370c6d1 100644 --- a/Classes/LinphoneUI/UITextViewNoDefine.h +++ b/Classes/LinphoneUI/UITextViewNoDefine.h @@ -19,7 +19,7 @@ #import -@interface UITextViewNoDefine : UITextView +@interface UITextViewNoDefine : UITextView @property BOOL allowSelectAll; diff --git a/Classes/LinphoneUI/UITextViewNoDefine.m b/Classes/LinphoneUI/UITextViewNoDefine.m index b84cdae77..023852314 100644 --- a/Classes/LinphoneUI/UITextViewNoDefine.m +++ b/Classes/LinphoneUI/UITextViewNoDefine.m @@ -23,15 +23,23 @@ @synthesize allowSelectAll; -- (BOOL)canPerformAction:(SEL)action withSender:(id)sender { - // disable "define" option, since it messes with the keyboard - if ([[NSStringFromSelector(action) lowercaseString] rangeOfString:@"define"].location != NSNotFound) { - return NO; - } else if (action == @selector(selectAll:) && allowSelectAll) { - return YES; - } else { - return [super canPerformAction:action withSender:sender]; - } +-(void)awakeFromNib{ + [super awakeFromNib]; + self.delegate = self; + self.userInteractionEnabled = true; + self.editable = false; + self.selectable = true; + self.dataDetectorTypes = UIDataDetectorTypeLink; +} + +- (BOOL)canBecomeFirstResponder { + return NO; +} + +- (void)textViewDidChangeSelection:(UITextView *)textView +{ + textView.selectedTextRange = nil; + [textView endEditing:YES]; } @end