소스 검색

show message menu also for video and audio messages. Show copy menu item only for messages with text. Copy only text if that menu item was selected in order to avoid pasting of yet unhandled data formats

cyberta 5 년 전
부모
커밋
7700543d19
1개의 변경된 파일13개의 추가작업 그리고 7개의 파일을 삭제
  1. 13 7
      deltachat-ios/MessageKit/Controllers/MessagesViewController.swift

+ 13 - 7
deltachat-ios/MessageKit/Controllers/MessagesViewController.swift

@@ -374,7 +374,7 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
         let message = messagesDataSource.messageForItem(at: indexPath, in: messagesCollectionView)
 
         switch message.kind {
-        case .text, .attributedText, .emoji, .photo, .photoText, .videoText, .fileText:
+        case .text, .attributedText, .emoji, .photo, .photoText, .videoText, .fileText, .audio, .video:
             selectedIndexPathForMenu = indexPath
             return true
         default:
@@ -386,7 +386,18 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
         if isSectionReservedForTypingIndicator(indexPath.section) {
             return false
         }
-        return (action == NSSelectorFromString("copy:"))
+
+        guard let messagesDataSource = messagesCollectionView.messagesDataSource else {
+            fatalError(MessageKitError.nilMessagesDataSource)
+        }
+        let message = messagesDataSource.messageForItem(at: indexPath, in: messagesCollectionView)
+
+        switch message.kind {
+        case .text, .emoji, .attributedText, .fileText, .photoText, .videoText:
+            return (action == NSSelectorFromString("copy:"))
+        default:
+            return false
+        }
     }
 
     open func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) {
@@ -401,14 +412,9 @@ UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
             pasteBoard.string = text
         case .attributedText(let attributedText):
             pasteBoard.string = attributedText.string
-        case .photo(let mediaItem):
-            pasteBoard.image = mediaItem.image ?? mediaItem.placeholderImage
         case .photoText(let mediaItem), .videoText(let mediaItem):
-            pasteBoard.image = mediaItem.image ?? mediaItem.placeholderImage
             pasteBoard.string = mediaItem.text?.string
-            pasteBoard.url = mediaItem.url
         case .fileText(let mediaItem):
-            pasteBoard.url = mediaItem.url
             pasteBoard.string = mediaItem.text?.string
         default:
             break