From a29eb5470f95fd6d5f196fda22ee72bdb3724244 Mon Sep 17 00:00:00 2001 From: Frederic Jacobs Date: Sat, 31 Oct 2015 21:30:07 +0100 Subject: [PATCH] Attachment type in notification and description. --- Signal/src/textsecure/Messages/TSAttachment.m | 15 +++++++++++++++ Signal/src/textsecure/Messages/TSMessage.m | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Signal/src/textsecure/Messages/TSAttachment.m b/Signal/src/textsecure/Messages/TSAttachment.m index b5a7bdde6..16d47055f 100644 --- a/Signal/src/textsecure/Messages/TSAttachment.m +++ b/Signal/src/textsecure/Messages/TSAttachment.m @@ -8,6 +8,7 @@ // #import "TSAttachment.h" +#import "MIMETypeUtil.h" @implementation TSAttachment @@ -34,4 +35,18 @@ return [f numberFromString:self.uniqueId]; } +- (NSString*)description { + NSString *attachmentString = NSLocalizedString(@"ATTACHMENT", nil); + + if ([MIMETypeUtil isImage:self.contentType]) { + return [NSString stringWithFormat:@"📷 %@", attachmentString]; + } else if ([MIMETypeUtil isVideo:self.contentType]) { + return [NSString stringWithFormat:@"📽 %@", attachmentString]; + } else if ([MIMETypeUtil isAudio:self.contentType]) { + return [NSString stringWithFormat:@"📻 %@", attachmentString]; + } + + return attachmentString; +} + @end diff --git a/Signal/src/textsecure/Messages/TSMessage.m b/Signal/src/textsecure/Messages/TSMessage.m index ab84d22ee..4c65a07e5 100644 --- a/Signal/src/textsecure/Messages/TSMessage.m +++ b/Signal/src/textsecure/Messages/TSMessage.m @@ -61,7 +61,9 @@ NSString * const TSAttachementsRelationshipEdgeName = @"TSAttachmentEdge"; - (NSString *)description{ if(self.attachments > 0){ - return NSLocalizedString(@"ATTACHMENT", nil); + NSString *attachmentId = self.attachments[0]; + TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentId]; + return attachment.description; } else { return self.body; }