瀏覽代碼

make OPENPGP4FPR tappable

B. Petersen 3 年之前
父節點
當前提交
9767a783da
共有 2 個文件被更改,包括 9 次插入2 次删除
  1. 5 2
      deltachat-ios/Chat/Views/Cells/BaseMessageCell.swift
  2. 4 0
      deltachat-ios/Chat/Views/DetectorType.swift

+ 5 - 2
deltachat-ios/Chat/Views/Cells/BaseMessageCell.swift

@@ -85,13 +85,14 @@ public class BaseMessageCell: UITableViewCell {
         view.setContentHuggingPriority(.defaultLow, for: .vertical)
         view.font = UIFont.preferredFont(for: .body, weight: .regular)
         view.delegate = self
-        view.enabledDetectors = [.url, .phoneNumber]
+        view.enabledDetectors = [.url, .phoneNumber, .openpgp4fpr]
         let attributes: [NSAttributedString.Key: Any] = [
             NSAttributedString.Key.foregroundColor: DcColors.defaultTextColor,
             NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue,
             NSAttributedString.Key.underlineColor: DcColors.defaultTextColor ]
         view.label.setAttributes(attributes, detector: .url)
         view.label.setAttributes(attributes, detector: .phoneNumber)
+        view.label.setAttributes(attributes, detector: .openpgp4fpr)
         view.isUserInteractionEnabled = true
         view.isAccessibilityElement = false
         return view
@@ -462,7 +463,9 @@ extension BaseMessageCell: MessageLabelDelegate {
 
     public func didSelectHashtag(_ hashtag: String) {}
 
-    public func didSelectCustom(_ pattern: String, match: String?) {}
+    public func didSelectCustom(_ pattern: String, match: String?) {
+        logger.debug("did select CUSTOM")
+    }
 }
 
 // MARK: - BaseMessageCellDelegate

+ 4 - 0
deltachat-ios/Chat/Views/DetectorType.swift

@@ -36,8 +36,12 @@ public enum DetectorType: Hashable {
     // swiftlint:disable force_try
     public static var hashtag = DetectorType.custom(try! NSRegularExpression(pattern: "#[a-zA-Z0-9]{4,}", options: []))
     public static var mention = DetectorType.custom(try! NSRegularExpression(pattern: "@[a-zA-Z0-9]{4,}", options: []))
+    public static var openpgp4fpr = DetectorType.custom(
+        try! NSRegularExpression(pattern: "openpgp4fpr:[0-9a-f]{40,40}#[a-z0-9&=%\\.\\-_]{16,}",
+                                 options: [.caseInsensitive]))
     // swiftlint:enable force_try
 
+
     internal var textCheckingType: NSTextCheckingResult.CheckingType {
         switch self {
         case .address: return .address