mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Added support for Microsoft Word, Excel & Powerpoint previews
This commit is contained in:
parent
161a90ad28
commit
1b820c48c6
5 changed files with 47 additions and 1 deletions
|
@ -472,7 +472,11 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
|
||||||
Storage.shared.getContact(with: thread.contactSessionID())?.isTrusted != true {
|
Storage.shared.getContact(with: thread.contactSessionID())?.isTrusted != true {
|
||||||
confirmDownload()
|
confirmDownload()
|
||||||
}
|
}
|
||||||
else if (viewItem.attachmentStream?.isText == true || viewItem.attachmentStream?.contentType == OWSMimeTypeApplicationPdf), let filePathString: String = viewItem.attachmentStream?.originalFilePath {
|
else if (
|
||||||
|
viewItem.attachmentStream?.isText == true ||
|
||||||
|
viewItem.attachmentStream?.isMicrosoftDoc == true ||
|
||||||
|
viewItem.attachmentStream?.contentType == OWSMimeTypeApplicationPdf
|
||||||
|
), let filePathString: String = viewItem.attachmentStream?.originalFilePath {
|
||||||
let fileUrl: URL = URL(fileURLWithPath: filePathString)
|
let fileUrl: URL = URL(fileURLWithPath: filePathString)
|
||||||
let interactionController: UIDocumentInteractionController = UIDocumentInteractionController(url: fileUrl)
|
let interactionController: UIDocumentInteractionController = UIDocumentInteractionController(url: fileUrl)
|
||||||
interactionController.delegate = self
|
interactionController.delegate = self
|
||||||
|
|
|
@ -85,6 +85,7 @@ typedef NS_ENUM(NSUInteger, TSAttachmentType) {
|
||||||
@property (nonatomic, readonly) BOOL isVoiceMessage;
|
@property (nonatomic, readonly) BOOL isVoiceMessage;
|
||||||
@property (nonatomic, readonly) BOOL isVisualMedia;
|
@property (nonatomic, readonly) BOOL isVisualMedia;
|
||||||
@property (nonatomic, readonly) BOOL isText;
|
@property (nonatomic, readonly) BOOL isText;
|
||||||
|
@property (nonatomic, readonly) BOOL isMicrosoftDoc;
|
||||||
@property (nonatomic, readonly) BOOL isOversizeText;
|
@property (nonatomic, readonly) BOOL isOversizeText;
|
||||||
|
|
||||||
+ (NSString *)emojiForMimeType:(NSString *)contentType;
|
+ (NSString *)emojiForMimeType:(NSString *)contentType;
|
||||||
|
|
|
@ -241,6 +241,10 @@ NSUInteger const TSAttachmentSchemaVersion = 4;
|
||||||
return [MIMETypeUtil isText:self.contentType];
|
return [MIMETypeUtil isText:self.contentType];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)isMicrosoftDoc {
|
||||||
|
return [MIMETypeUtil isMicrosoftDoc:self.contentType];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)isOversizeText
|
- (BOOL)isOversizeText
|
||||||
{
|
{
|
||||||
return [self.contentType isEqualToString:OWSMimeTypeOversizeTextMessage];
|
return [self.contentType isEqualToString:OWSMimeTypeOversizeTextMessage];
|
||||||
|
|
|
@ -42,6 +42,7 @@ extern NSString *const kSyncMessageFileExtension;
|
||||||
+ (BOOL)isVideo:(NSString *)contentType;
|
+ (BOOL)isVideo:(NSString *)contentType;
|
||||||
+ (BOOL)isAudio:(NSString *)contentType;
|
+ (BOOL)isAudio:(NSString *)contentType;
|
||||||
+ (BOOL)isText:(NSString *)contentType;
|
+ (BOOL)isText:(NSString *)contentType;
|
||||||
|
+ (BOOL)isMicrosoftDoc:(NSString *)contentType;
|
||||||
+ (BOOL)isVisualMedia:(NSString *)contentType;
|
+ (BOOL)isVisualMedia:(NSString *)contentType;
|
||||||
|
|
||||||
// filename is optional and should not be trusted.
|
// filename is optional and should not be trusted.
|
||||||
|
|
|
@ -290,6 +290,42 @@ NSString *const kSyncMessageFileExtension = @"bin";
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (BOOL)isMicrosoftDoc:(NSString *)contentType {
|
||||||
|
return [
|
||||||
|
@[
|
||||||
|
// Word files
|
||||||
|
@"application/msword",
|
||||||
|
|
||||||
|
@"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
||||||
|
@"application/vnd.ms-word.document.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-word.template.macroEnabled.12",
|
||||||
|
|
||||||
|
// Excel files
|
||||||
|
@"application/vnd.ms-excel",
|
||||||
|
|
||||||
|
@"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
||||||
|
@"application/vnd.ms-excel.sheet.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-excel.template.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-excel.addin.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-excel.sheet.binary.macroEnabled.12",
|
||||||
|
|
||||||
|
// Powerpoint files
|
||||||
|
@"application/vnd.ms-powerpoint",
|
||||||
|
|
||||||
|
@"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.presentationml.template",
|
||||||
|
@"application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
||||||
|
@"application/vnd.ms-powerpoint.addin.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-powerpoint.presentation.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-powerpoint.template.macroEnabled.12",
|
||||||
|
@"application/vnd.ms-powerpoint.slideshow.macroEnabled.12"
|
||||||
|
]
|
||||||
|
containsObject:contentType
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
+ (BOOL)isVisualMedia:(NSString *)contentType
|
+ (BOOL)isVisualMedia:(NSString *)contentType
|
||||||
{
|
{
|
||||||
if ([self isImage:contentType]) {
|
if ([self isImage:contentType]) {
|
||||||
|
|
Loading…
Reference in a new issue