diff --git a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m index 71942fbfc..a27ae2448 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m @@ -85,11 +85,6 @@ NS_ASSUME_NONNULL_BEGIN return [UIFont ows_regularFontWithSize:11.f]; } -- (UIFont *)fileTypeLabelFont -{ - return [UIFont ows_mediumFontWithSize:16.f]; -} - - (UIView *)mediaView { if (_cachedMediaView == nil) { @@ -132,10 +127,11 @@ NS_ASSUME_NONNULL_BEGIN fileTypeLabel.text = fileExtension.uppercaseString; fileTypeLabel.textColor = textColor; fileTypeLabel.lineBreakMode = NSLineBreakByTruncatingTail; - fileTypeLabel.font = [self fileTypeLabelFont]; + fileTypeLabel.font = [UIFont ows_mediumFontWithSize:20.f]; + fileTypeLabel.adjustsFontSizeToFitWidth = YES; CGRect fileTypeLabelFrame = CGRectZero; fileTypeLabelFrame.size = [fileTypeLabel sizeThatFits:CGSizeZero]; - fileTypeLabelFrame.size.width = floor(MIN(self.iconSize * 0.5f, fileTypeLabelFrame.size.width)); + fileTypeLabelFrame.size.width = ceil(MIN(self.iconSize * 0.45f, fileTypeLabelFrame.size.width)); // Center on icon. fileTypeLabelFrame.origin.x = round(iconFrame.origin.x + (iconFrame.size.width - fileTypeLabelFrame.size.width) * 0.5f); diff --git a/Signal/src/view controllers/AttachmentSharing.h b/Signal/src/view controllers/AttachmentSharing.h index a55e01ee7..f9adbea7a 100644 --- a/Signal/src/view controllers/AttachmentSharing.h +++ b/Signal/src/view controllers/AttachmentSharing.h @@ -10,4 +10,6 @@ + (void)showShareUIForAttachment:(TSAttachmentStream *)stream; ++ (void)showShareUIForURL:(NSURL *)url; + @end diff --git a/Signal/src/view controllers/AttachmentSharing.m b/Signal/src/view controllers/AttachmentSharing.m index 40d569d6d..82e8cc0bf 100644 --- a/Signal/src/view controllers/AttachmentSharing.m +++ b/Signal/src/view controllers/AttachmentSharing.m @@ -10,29 +10,18 @@ + (void)showShareUIForAttachment:(TSAttachmentStream *)stream { OWSAssert(stream); - NSString *filePath = stream.filePath; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSError *error; - NSData *data = [NSData dataWithContentsOfFile:filePath options:0 error:&error]; - if (!data || error) { - DDLogError(@"%@ %s could not read data from attachment: %@.", - self.tag, - __PRETTY_FUNCTION__, - error); - return; - } - - dispatch_async(dispatch_get_main_queue(), ^{ - [AttachmentSharing showShareUIForData:data]; - }); + dispatch_async(dispatch_get_main_queue(), ^{ + [AttachmentSharing showShareUIForURL:stream.mediaURL]; }); } -+ (void)showShareUIForData:(NSData *)data { ++ (void)showShareUIForURL:(NSURL *)url { AssertIsOnMainThread(); - OWSAssert(data); + OWSAssert(url); - UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[data, ] + UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[ + url, + ] applicationActivities:@[ ]]; diff --git a/Signal/src/view controllers/DebugUITableViewController.m b/Signal/src/view controllers/DebugUITableViewController.m index 98fd07e85..d5fe2fdbb 100644 --- a/Signal/src/view controllers/DebugUITableViewController.m +++ b/Signal/src/view controllers/DebugUITableViewController.m @@ -247,9 +247,15 @@ NSString * const kDebugUITableCellIdentifier = @"kDebugUITableCellIdentifier"; actionBlock:^{ [DebugUITableViewController sendOversizeTextMessage:thread]; }], - [OWSTableItem actionWithTitle:@"Send unknown/mimetype" + [OWSTableItem actionWithTitle:@"Send unknown mimetype" actionBlock:^{ - [DebugUITableViewController sendUnknownMimetypeAttachment:thread]; + [DebugUITableViewController sendRandomAttachment:thread + uti:SignalAttachment.kUnknownTestAttachmentUTI]; + }], + [OWSTableItem actionWithTitle:@"Send pdf" + actionBlock:^{ + [DebugUITableViewController sendRandomAttachment:thread + uti:(NSString *) kUTTypePDF]; }], ]]]; @@ -275,7 +281,11 @@ NSString * const kDebugUITableCellIdentifier = @"kDebugUITableCellIdentifier"; + (void)sendOversizeTextMessage:(TSThread *)thread { OWSMessageSender *messageSender = [Environment getCurrent].messageSender; - NSString *message = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse consequat, ligula et tincidunt mattis, nisl risus ultricies justo, vitae dictum augue risus vel ante. Suspendisse convallis bibendum lectus. Etiam molestie nisi ac orci sodales sollicitudin vitae eu quam. Morbi lacinia scelerisque risus. Quisque sagittis mauris enim, ac vestibulum dui commodo quis. Nullam at commodo nisl, ut pulvinar dui. Nunc tempus volutpat sagittis. Vestibulum eget maximus sem, sit amet tristique ex posuere."; + NSMutableString *message = [NSMutableString new]; + for (int i=0; i < 32; i++) { + [message appendString:@"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse rutrum, nulla vitae pretium hendrerit, tellus turpis pharetra libero, vitae sodales tortor ante vel sem. Fusce sed nisl a lorem gravida tincidunt. Suspendisse efficitur non quam ac sodales. Aenean ut velit maximus, posuere sem a, accumsan nunc. Donec ullamcorper turpis lorem. Quisque dignissim purus eu placerat ultricies. Proin at urna eget mi semper congue. Aenean non elementum ex. Praesent pharetra quam at sem vestibulum, vestibulum ornare dolor elementum. Vestibulum massa tortor, scelerisque sit amet pulvinar a, rhoncus vitae nisl. Sed mi nunc, tempus at varius in, malesuada vitae dui. Vivamus efficitur pulvinar erat vitae congue. Proin vehicula turpis non felis congue facilisis. Nullam aliquet dapibus ligula ac mollis. Etiam sit amet posuere lorem, in rhoncus nisi."]; + } + SignalAttachment *attachment = [SignalAttachment oversizeTextAttachmentWithText:message]; [ThreadUtil sendMessageWithAttachment:attachment inThread:thread @@ -295,10 +305,11 @@ NSString * const kDebugUITableCellIdentifier = @"kDebugUITableCellIdentifier"; return data; } -+ (void)sendUnknownMimetypeAttachment:(TSThread *)thread { ++ (void)sendRandomAttachment:(TSThread *)thread + uti:(NSString *)uti { OWSMessageSender *messageSender = [Environment getCurrent].messageSender; SignalAttachment *attachment = [SignalAttachment genericAttachmentWithData:[self createRandomNSDataOfSize:256] - dataUTI:SignalAttachment.kUnknownTestAttachmentUTI]; + dataUTI:uti]; [ThreadUtil sendMessageWithAttachment:attachment inThread:thread messageSender:messageSender]; diff --git a/Signal/src/view controllers/MessagesViewController.m b/Signal/src/view controllers/MessagesViewController.m index 39054a0f2..dc50da9f2 100644 --- a/Signal/src/view controllers/MessagesViewController.m +++ b/Signal/src/view controllers/MessagesViewController.m @@ -3,7 +3,7 @@ // #import "AppDelegate.h" - +#import "AttachmentSharing.h" #import "Environment.h" #import "FingerprintViewController.h" #import "FullImageViewController.h" @@ -29,6 +29,7 @@ #import "TSContentAdapters.h" #import "TSDatabaseView.h" #import "TSErrorMessage.h" +#import "TSGenericAttachmentAdapter.h" #import "TSGroupThread.h" #import "TSIncomingMessage.h" #import "TSInfoMessage.h" @@ -1554,6 +1555,21 @@ typedef enum : NSUInteger { DDLogDebug(@"Unhandled bubble touch for interaction: %@.", interaction); break; } + + if (messageItem.messageType == TSOutgoingMessageAdapter || + messageItem.messageType == TSIncomingMessageAdapter) { + TSMessage *message = (TSMessage *)interaction; + if ([message hasAttachments]) { + NSString *attachmentID = message.attachmentIds[0]; + TSAttachment *attachment = [TSAttachment fetchObjectWithUniqueID:attachmentID]; + if ([attachment isKindOfClass:[TSAttachmentStream class]]) { + TSAttachmentStream *stream = (TSAttachmentStream *)attachment; + if ([[messageItem media] isKindOfClass:[TSGenericAttachmentAdapter class]]) { + [AttachmentSharing showShareUIForAttachment:stream]; + } + } + } + } } - (void)handleWarningTap:(TSInteraction *)interaction diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index a9ca26be4..fdb37bb01 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -97,12 +97,6 @@ /* No comment provided by engineer. */ "ATTACHMENT_QUEUED" = "New attachment queued for retrieval."; -/* A message indicating that an attachment of unknown type was received. */ -"ATTACHMENT_UNKNOWN_TYPE" = "Unknown attachment received"; - -/* No comment provided by engineer. */ -"AUDIO_PERMISSION_MESSAGE" = "Signal requires access to your microphone to work properly. You can grant this permission in the Settings app >> Privacy >> Microphone >> Signal"; - /* Accessibilty label for placing call button */ "CALL_LABEL" = "Call";