mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Updated the code to show the document interaction controller for text files as well
This commit is contained in:
parent
185b2d2a97
commit
161a90ad28
5 changed files with 26 additions and 1 deletions
|
@ -472,7 +472,7 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
|||
Storage.shared.getContact(with: thread.contactSessionID())?.isTrusted != true {
|
||||
confirmDownload()
|
||||
}
|
||||
else if viewItem.attachmentStream?.contentType == OWSMimeTypeApplicationPdf, let filePathString: String = viewItem.attachmentStream?.originalFilePath {
|
||||
else if (viewItem.attachmentStream?.isText == true || viewItem.attachmentStream?.contentType == OWSMimeTypeApplicationPdf), let filePathString: String = viewItem.attachmentStream?.originalFilePath {
|
||||
let fileUrl: URL = URL(fileURLWithPath: filePathString)
|
||||
let interactionController: UIDocumentInteractionController = UIDocumentInteractionController(url: fileUrl)
|
||||
interactionController.delegate = self
|
||||
|
|
|
@ -84,6 +84,7 @@ typedef NS_ENUM(NSUInteger, TSAttachmentType) {
|
|||
@property (nonatomic, readonly) BOOL isAudio;
|
||||
@property (nonatomic, readonly) BOOL isVoiceMessage;
|
||||
@property (nonatomic, readonly) BOOL isVisualMedia;
|
||||
@property (nonatomic, readonly) BOOL isText;
|
||||
@property (nonatomic, readonly) BOOL isOversizeText;
|
||||
|
||||
+ (NSString *)emojiForMimeType:(NSString *)contentType;
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
#import "TSAttachmentPointer.h"
|
||||
#import <SignalCoreKit/NSString+OWS.h>
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
|
||||
#else
|
||||
#import <CoreServices/CoreServices.h>
|
||||
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
NSUInteger const TSAttachmentSchemaVersion = 4;
|
||||
|
@ -229,6 +237,10 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
|
|||
return [MIMETypeUtil isVisualMedia:self.contentType];
|
||||
}
|
||||
|
||||
- (BOOL)isText {
|
||||
return [MIMETypeUtil isText:self.contentType];
|
||||
}
|
||||
|
||||
- (BOOL)isOversizeText
|
||||
{
|
||||
return [self.contentType isEqualToString:OWSMimeTypeOversizeTextMessage];
|
||||
|
|
|
@ -41,6 +41,7 @@ extern NSString *const kSyncMessageFileExtension;
|
|||
+ (BOOL)isImage:(NSString *)contentType;
|
||||
+ (BOOL)isVideo:(NSString *)contentType;
|
||||
+ (BOOL)isAudio:(NSString *)contentType;
|
||||
+ (BOOL)isText:(NSString *)contentType;
|
||||
+ (BOOL)isVisualMedia:(NSString *)contentType;
|
||||
|
||||
// filename is optional and should not be trusted.
|
||||
|
|
|
@ -279,6 +279,17 @@ NSString *const kSyncMessageFileExtension = @"bin";
|
|||
return [MIMETypeUtil isSupportedAudioMIMEType:contentType];
|
||||
}
|
||||
|
||||
+ (BOOL)isText:(NSString *)contentType {
|
||||
return [
|
||||
@[
|
||||
@"text/plain",
|
||||
@"text/csv",
|
||||
@"text/tab-separated-values"
|
||||
]
|
||||
containsObject:contentType
|
||||
];
|
||||
}
|
||||
|
||||
+ (BOOL)isVisualMedia:(NSString *)contentType
|
||||
{
|
||||
if ([self isImage:contentType]) {
|
||||
|
|
Loading…
Reference in a new issue