conversations: fixes tap recognizer covering cell tap recognizers

- removes the gesture recognizer used to dismiss the keyboard
  when keyboard is hidden to not prevent the ActiveLabel url tap
  handlers from firing

- prevents url styling in transfer labels

Change-Id: I83566ffb19ab68fb9d056383e8a0801f8c1d4e40
Reviewed-by: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
diff --git a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift
index ef560ca..351bf8f 100644
--- a/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/Cells/MessageCell.swift
@@ -163,8 +163,8 @@
             bubbleColor = type == .received ? UIColor.ringMsgCellReceived : UIColor.ringMsgCellSent
         }
 
-        self.messageLabel.enabledTypes = [.url]
         if item.isTransfer {
+            self.messageLabel.enabledTypes = []
             let contentArr = item.content.components(separatedBy: "\n")
             if contentArr.count > 1 {
                 self.messageLabel.text = contentArr[0]
@@ -173,13 +173,14 @@
                 self.messageLabel.text = item.content
             }
         } else {
+            self.messageLabel.enabledTypes = [.url]
             self.setup()
             self.messageLabel.setTextWithLineSpacing(withText: item.content, withLineSpacing: 2)
-        }
-        self.messageLabel.handleURLTap { url in
-            let urlString = url.absoluteString
-            if let prefixedUrl = URL(string: urlString.contains("http") ? urlString : "http://\(urlString)") {
-                UIApplication.shared.openURL(prefixedUrl)
+            self.messageLabel.handleURLTap { url in
+                let urlString = url.absoluteString
+                if let prefixedUrl = URL(string: urlString.contains("http") ? urlString : "http://\(urlString)") {
+                    UIApplication.shared.openURL(prefixedUrl)
+                }
             }
         }
 
diff --git a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
index 4cdc501..178d601 100644
--- a/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
+++ b/Ring/Ring/Features/Conversations/Conversation/ConversationViewController.swift
@@ -44,6 +44,8 @@
     var bottomOffset: CGFloat = 0
     let scrollOffsetThreshold: CGFloat = 600
 
+    var keyboardDismissTapRecognizer: UITapGestureRecognizer!
+
     override func viewDidLoad() {
         super.viewDidLoad()
 
@@ -60,8 +62,7 @@
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(withNotification:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(withNotification:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil)
 
-        let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ConversationViewController.dismissKeyboard))
-        view.addGestureRecognizer(tap)
+        keyboardDismissTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
     }
 
     func importDocument() {
@@ -213,6 +214,7 @@
 
     @objc func dismissKeyboard() {
         self.becomeFirstResponder()
+        view.removeGestureRecognizer(keyboardDismissTapRecognizer)
     }
 
     @objc func keyboardWillShow(withNotification notification: Notification) {
@@ -226,6 +228,7 @@
         if keyboardHeight != self.messageAccessoryView.frame.height {
             setShareButtonsVisibility(hide: true)
             heightOffset = -24.0
+            self.view.addGestureRecognizer(keyboardDismissTapRecognizer)
         }
 
         self.tableView.contentInset.bottom = keyboardHeight + heightOffset