Merge branch 'charlesmchen/multipleItemsInPasteboard'
This commit is contained in:
commit
e3fb0c5987
|
@ -109,9 +109,7 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
|
||||
- (BOOL)pasteBoardHasPossibleAttachment {
|
||||
NSSet *pasteboardUTISet = [NSSet setWithArray:[UIPasteboard generalPasteboard].pasteboardTypes];
|
||||
if ([UIPasteboard generalPasteboard].numberOfItems == 1 &&
|
||||
[[SignalAttachment validInputUTISet] intersectsSet:pasteboardUTISet]) {
|
||||
if ([SignalAttachment pasteboardHasPossibleAttachment]) {
|
||||
// We don't want to load/convert images more than once so we
|
||||
// only do a cursory validation pass at this time.
|
||||
return YES;
|
||||
|
|
|
@ -245,6 +245,19 @@ class SignalAttachment: NSObject {
|
|||
return SignalAttachment.audioUTISet.contains(dataUTI)
|
||||
}
|
||||
|
||||
public class func pasteboardHasPossibleAttachment() -> Bool {
|
||||
guard UIPasteboard.general.numberOfItems >= 1 else {
|
||||
return false
|
||||
}
|
||||
// If pasteboard contains multiple items, use only the first.
|
||||
let itemSet = IndexSet(integer:0)
|
||||
guard let pasteboardUTITypes = UIPasteboard.general.types(forItemSet:itemSet) else {
|
||||
return false
|
||||
}
|
||||
let pasteboardUTISet = Set<String>(pasteboardUTITypes[0])
|
||||
return pasteboardUTISet.intersection(validInputUTISet).count > 0
|
||||
}
|
||||
|
||||
// Returns an attachment from the pasteboard, or nil if no attachment
|
||||
// can be found.
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue