|
|
@ -279,16 +279,6 @@ class SignalAttachment: NSObject {
|
|
|
|
return MIMETypeUtil.supportedAudioUTITypes()
|
|
|
|
return MIMETypeUtil.supportedAudioUTITypes()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class var textUTISet: Set<String> {
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
|
|
|
kUTTypeText as String,
|
|
|
|
|
|
|
|
kUTTypePlainText as String,
|
|
|
|
|
|
|
|
kUTTypeUTF8PlainText as String,
|
|
|
|
|
|
|
|
kUTTypeUTF16PlainText as String,
|
|
|
|
|
|
|
|
kUTTypeURL as String
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public var isImage: Bool {
|
|
|
|
public var isImage: Bool {
|
|
|
|
return SignalAttachment.outputImageUTISet.contains(dataUTI)
|
|
|
|
return SignalAttachment.outputImageUTISet.contains(dataUTI)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -305,10 +295,6 @@ class SignalAttachment: NSObject {
|
|
|
|
return SignalAttachment.audioUTISet.contains(dataUTI)
|
|
|
|
return SignalAttachment.audioUTISet.contains(dataUTI)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public var isText: Bool {
|
|
|
|
|
|
|
|
return SignalAttachment.textUTISet.contains(dataUTI)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class func pasteboardHasPossibleAttachment() -> Bool {
|
|
|
|
public class func pasteboardHasPossibleAttachment() -> Bool {
|
|
|
|
return UIPasteboard.general.numberOfItems > 0
|
|
|
|
return UIPasteboard.general.numberOfItems > 0
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -323,12 +309,34 @@ class SignalAttachment: NSObject {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let pasteboardUTISet = Set<String>(pasteboardUTITypes[0])
|
|
|
|
let pasteboardUTISet = Set<String>(pasteboardUTITypes[0])
|
|
|
|
|
|
|
|
|
|
|
|
let mediaUTISet = inputImageUTISet.union(animatedImageUTISet.union(videoUTISet.union(audioUTISet)))
|
|
|
|
// The pasteboard can be populated with multiple UTI types
|
|
|
|
if pasteboardUTISet.intersection(mediaUTISet).count > 0 {
|
|
|
|
// with different payloads. iMessage for example will copy
|
|
|
|
|
|
|
|
// an animated GIF to the pasteboard with the following UTI
|
|
|
|
|
|
|
|
// types:
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// * "public.url-name"
|
|
|
|
|
|
|
|
// * "public.utf8-plain-text"
|
|
|
|
|
|
|
|
// * "com.compuserve.gif"
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// We want to paste the animated GIF itself, not it's name.
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// In general, our rule is to prefer non-text pasteboard
|
|
|
|
|
|
|
|
// contents, so we return true IFF there is a text UTI type
|
|
|
|
|
|
|
|
// and there is no non-text UTI type.
|
|
|
|
|
|
|
|
var hasTextUTIType = false
|
|
|
|
|
|
|
|
var hasNonTextUTIType = false
|
|
|
|
|
|
|
|
for utiType in pasteboardUTISet {
|
|
|
|
|
|
|
|
Logger.error("\(utiType) is text? \(UTTypeConformsTo(utiType as CFString, kUTTypeText))")
|
|
|
|
|
|
|
|
if UTTypeConformsTo(utiType as CFString, kUTTypeText) {
|
|
|
|
|
|
|
|
hasTextUTIType = true
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
hasNonTextUTIType = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if hasNonTextUTIType {
|
|
|
|
return false
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasTextUTIType
|
|
|
|
return pasteboardUTISet.intersection(textUTISet).count > 0
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns an attachment from the pasteboard, or nil if no attachment
|
|
|
|
// Returns an attachment from the pasteboard, or nil if no attachment
|
|
|
|