diff --git a/Signal/Images.xcassets/file-white-60.imageset/Contents.json b/Signal/Images.xcassets/file-black-40.imageset/Contents.json similarity index 67% rename from Signal/Images.xcassets/file-white-60.imageset/Contents.json rename to Signal/Images.xcassets/file-black-40.imageset/Contents.json index a57cb66ce..17d4e7afc 100644 --- a/Signal/Images.xcassets/file-white-60.imageset/Contents.json +++ b/Signal/Images.xcassets/file-black-40.imageset/Contents.json @@ -2,17 +2,17 @@ "images" : [ { "idiom" : "universal", - "filename" : "file-white-60@1x.png", + "filename" : "file-black-40@1x.png", "scale" : "1x" }, { "idiom" : "universal", - "filename" : "file-white-60@2x.png", + "filename" : "file-black-40@2x.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "file-white-60@3x.png", + "filename" : "file-black-40@3x.png", "scale" : "3x" } ], diff --git a/Signal/Images.xcassets/file-black-40.imageset/file-black-40@1x.png b/Signal/Images.xcassets/file-black-40.imageset/file-black-40@1x.png new file mode 100644 index 000000000..2342d9986 Binary files /dev/null and b/Signal/Images.xcassets/file-black-40.imageset/file-black-40@1x.png differ diff --git a/Signal/Images.xcassets/file-black-40.imageset/file-black-40@2x.png b/Signal/Images.xcassets/file-black-40.imageset/file-black-40@2x.png new file mode 100644 index 000000000..567c8a0f6 Binary files /dev/null and b/Signal/Images.xcassets/file-black-40.imageset/file-black-40@2x.png differ diff --git a/Signal/Images.xcassets/file-black-40.imageset/file-black-40@3x.png b/Signal/Images.xcassets/file-black-40.imageset/file-black-40@3x.png new file mode 100644 index 000000000..c63bc75d2 Binary files /dev/null and b/Signal/Images.xcassets/file-black-40.imageset/file-black-40@3x.png differ diff --git a/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@1x.png b/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@1x.png deleted file mode 100644 index 873b27287..000000000 Binary files a/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@1x.png and /dev/null differ diff --git a/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@2x.png b/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@2x.png deleted file mode 100644 index fd1009293..000000000 Binary files a/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@2x.png and /dev/null differ diff --git a/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@3x.png b/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@3x.png deleted file mode 100644 index 98f2d35e4..000000000 Binary files a/Signal/Images.xcassets/file-black-60.imageset/file-icon-60@3x.png and /dev/null differ diff --git a/Signal/Images.xcassets/file-black-60.imageset/Contents.json b/Signal/Images.xcassets/file-thin-black-large.imageset/Contents.json similarity index 67% rename from Signal/Images.xcassets/file-black-60.imageset/Contents.json rename to Signal/Images.xcassets/file-thin-black-large.imageset/Contents.json index 9dd859a99..28adc23cf 100644 --- a/Signal/Images.xcassets/file-black-60.imageset/Contents.json +++ b/Signal/Images.xcassets/file-thin-black-large.imageset/Contents.json @@ -2,17 +2,15 @@ "images" : [ { "idiom" : "universal", - "filename" : "file-icon-60@1x.png", + "filename" : "file-thin-black-large.png", "scale" : "1x" }, { "idiom" : "universal", - "filename" : "file-icon-60@2x.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "file-icon-60@3x.png", "scale" : "3x" } ], diff --git a/Signal/Images.xcassets/file-thin-black-large.imageset/file-thin-black-large.png b/Signal/Images.xcassets/file-thin-black-large.imageset/file-thin-black-large.png new file mode 100644 index 000000000..b6edcde30 Binary files /dev/null and b/Signal/Images.xcassets/file-thin-black-large.imageset/file-thin-black-large.png differ diff --git a/Signal/Images.xcassets/file-white-40.imageset/Contents.json b/Signal/Images.xcassets/file-white-40.imageset/Contents.json new file mode 100644 index 000000000..c768f53a9 --- /dev/null +++ b/Signal/Images.xcassets/file-white-40.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "file-white-40@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "file-white-40@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "file-white-40@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/file-white-40.imageset/file-white-40@1x.png b/Signal/Images.xcassets/file-white-40.imageset/file-white-40@1x.png new file mode 100644 index 000000000..694c889be Binary files /dev/null and b/Signal/Images.xcassets/file-white-40.imageset/file-white-40@1x.png differ diff --git a/Signal/Images.xcassets/file-white-40.imageset/file-white-40@2x.png b/Signal/Images.xcassets/file-white-40.imageset/file-white-40@2x.png new file mode 100644 index 000000000..568366f35 Binary files /dev/null and b/Signal/Images.xcassets/file-white-40.imageset/file-white-40@2x.png differ diff --git a/Signal/Images.xcassets/file-white-40.imageset/file-white-40@3x.png b/Signal/Images.xcassets/file-white-40.imageset/file-white-40@3x.png new file mode 100644 index 000000000..c80f78c3f Binary files /dev/null and b/Signal/Images.xcassets/file-white-40.imageset/file-white-40@3x.png differ diff --git a/Signal/Images.xcassets/file-white-60.imageset/file-white-60@1x.png b/Signal/Images.xcassets/file-white-60.imageset/file-white-60@1x.png deleted file mode 100644 index 5940a14f5..000000000 Binary files a/Signal/Images.xcassets/file-white-60.imageset/file-white-60@1x.png and /dev/null differ diff --git a/Signal/Images.xcassets/file-white-60.imageset/file-white-60@2x.png b/Signal/Images.xcassets/file-white-60.imageset/file-white-60@2x.png deleted file mode 100644 index 8581139d8..000000000 Binary files a/Signal/Images.xcassets/file-white-60.imageset/file-white-60@2x.png and /dev/null differ diff --git a/Signal/Images.xcassets/file-white-60.imageset/file-white-60@3x.png b/Signal/Images.xcassets/file-white-60.imageset/file-white-60@3x.png deleted file mode 100644 index be6e88ec1..000000000 Binary files a/Signal/Images.xcassets/file-white-60.imageset/file-white-60@3x.png and /dev/null differ diff --git a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m index 56e571c65..95315bf20 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m @@ -8,6 +8,8 @@ #import "UIColor+JSQMessages.h" #import "UIColor+OWS.h" #import "UIFont+OWS.h" +#import "UIView+OWS.h" +#import "ViewControllerUtils.h" #import #import #import @@ -74,9 +76,14 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - JSQMessageMediaData protocol +- (CGFloat)bubbleHeight +{ + return 45.f; +} + - (CGFloat)iconSize { - return 60.f; + return 40.f; } - (CGFloat)hMargin @@ -89,11 +96,6 @@ NS_ASSUME_NONNULL_BEGIN return 10.f; } -- (UIFont *)attachmentLabelFont -{ - return [UIFont ows_regularFontWithSize:11.f]; -} - - (UIView *)mediaView { if (_cachedMediaView == nil) { @@ -110,14 +112,14 @@ NS_ASSUME_NONNULL_BEGIN const CGFloat kBubbleTailWidth = 6.f; CGRect contentFrame = CGRectMake(self.incoming ? kBubbleTailWidth : 0.f, self.vMargin, - viewSize.width - kBubbleTailWidth, + viewSize.width - kBubbleTailWidth - 10, viewSize.height - self.vMargin * 2.f); - UIImage *image = [UIImage imageNamed:(self.incoming ? @"file-black-60" : @"file-white-60")]; + UIImage *image = [UIImage imageNamed:(self.incoming ? @"file-black-40" : @"file-white-40")]; OWSAssert(image); UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; - CGRect iconFrame = CGRectMake(round(contentFrame.origin.x + (contentFrame.size.width - self.iconSize) * 0.5f), - round(contentFrame.origin.y), + CGRect iconFrame = CGRectMake(round(contentFrame.origin.x + 10.f), + round(contentFrame.origin.y + (contentFrame.size.height - self.iconSize) * 0.5f), self.iconSize, self.iconSize); imageView.frame = iconFrame; @@ -131,35 +133,66 @@ NS_ASSUME_NONNULL_BEGIN UILabel *fileTypeLabel = [UILabel new]; fileTypeLabel.text = fileExtension.uppercaseString; - fileTypeLabel.textColor = textColor; + fileTypeLabel.textColor = [textColor colorWithAlphaComponent:0.85f]; fileTypeLabel.lineBreakMode = NSLineBreakByTruncatingTail; fileTypeLabel.font = [UIFont ows_mediumFontWithSize:20.f]; fileTypeLabel.adjustsFontSizeToFitWidth = YES; + fileTypeLabel.textAlignment = NSTextAlignmentCenter; CGRect fileTypeLabelFrame = CGRectZero; fileTypeLabelFrame.size = [fileTypeLabel sizeThatFits:CGSizeZero]; - fileTypeLabelFrame.size.width = ceil(MIN(self.iconSize * 0.45f, fileTypeLabelFrame.size.width)); + // This dimension depends on the space within the icon boundaries. + fileTypeLabelFrame.size.width = 20.f; // Center on icon. fileTypeLabelFrame.origin.x = round(iconFrame.origin.x + (iconFrame.size.width - fileTypeLabelFrame.size.width) * 0.5f); fileTypeLabelFrame.origin.y - = round(iconFrame.origin.y + (iconFrame.size.height - fileTypeLabelFrame.size.height) * 0.5f + 5); + = round(iconFrame.origin.y + (iconFrame.size.height - fileTypeLabelFrame.size.height) * 0.5f); fileTypeLabel.frame = fileTypeLabelFrame; [_cachedMediaView addSubview:fileTypeLabel]; - UILabel *attachmentLabel = [UILabel new]; - attachmentLabel.text = NSLocalizedString(@"GENERIC_ATTACHMENT_LABEL", @"A label for generic attachments."); - attachmentLabel.textColor = [textColor colorWithAlphaComponent:0.85f]; - attachmentLabel.lineBreakMode = NSLineBreakByTruncatingTail; - attachmentLabel.font = [self attachmentLabelFont]; - [attachmentLabel sizeToFit]; - CGRect attachmentLabelFrame = CGRectZero; - attachmentLabelFrame.size = attachmentLabel.bounds.size; - attachmentLabelFrame.origin.x - = round(contentFrame.origin.x + (contentFrame.size.width - attachmentLabelFrame.size.width) * 0.5f); - attachmentLabelFrame.origin.y - = round(contentFrame.origin.y + contentFrame.size.height - attachmentLabelFrame.size.height); - attachmentLabel.frame = attachmentLabelFrame; - [_cachedMediaView addSubview:attachmentLabel]; + const CGFloat kLabelHSpacing = 3; + const CGFloat kLabelVSpacing = 2; + NSString *topText = + [self.attachment.filename stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; + if (topText.length < 1) { + topText = [MIMETypeUtil fileExtensionForMIMEType:self.attachment.contentType].uppercaseString; + } + if (topText.length < 1) { + topText = NSLocalizedString(@"GENERIC_ATTACHMENT_LABEL", @"A label for generic attachments."); + } + UILabel *topLabel = [UILabel new]; + topLabel.text = topText; + topLabel.textColor = textColor; + topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; + topLabel.font = [UIFont ows_mediumFontWithSize:15.f]; + [topLabel sizeToFit]; + [_cachedMediaView addSubview:topLabel]; + + NSError *error; + unsigned long long fileSize = + [[NSFileManager defaultManager] attributesOfItemAtPath:self.attachment.filePath error:&error].fileSize; + OWSAssert(!error); + NSString *bottomText = [ViewControllerUtils formatFileSize:fileSize]; + UILabel *bottomLabel = [UILabel new]; + bottomLabel.text = bottomText; + bottomLabel.textColor = [textColor colorWithAlphaComponent:0.85f]; + bottomLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; + bottomLabel.font = [UIFont ows_regularFontWithSize:13.f]; + [bottomLabel sizeToFit]; + [_cachedMediaView addSubview:bottomLabel]; + + CGRect topLabelFrame = CGRectZero; + topLabelFrame.size = topLabel.bounds.size; + topLabelFrame.origin.x = round(iconFrame.origin.x + iconFrame.size.width + kLabelHSpacing); + topLabelFrame.origin.y = round(contentFrame.origin.y + + (contentFrame.size.height - (topLabel.frame.size.height + bottomLabel.frame.size.height + kLabelVSpacing)) + * 0.5f); + topLabelFrame.size.width = round((contentFrame.origin.x + contentFrame.size.width) - topLabelFrame.origin.x); + topLabel.frame = topLabelFrame; + + CGRect bottomLabelFrame = topLabelFrame; + bottomLabelFrame.origin.y += topLabelFrame.size.height + kLabelVSpacing; + bottomLabel.frame = bottomLabelFrame; if (!self.incoming) { self.attachmentUploadView = [[AttachmentUploadView alloc] initWithAttachment:self.attachment @@ -173,8 +206,9 @@ NS_ASSUME_NONNULL_BEGIN - (CGSize)mediaViewDisplaySize { - const CGFloat kVSpacing = 1.f; - return CGSizeMake(100, ceil(self.iconSize + self.attachmentLabelFont.lineHeight + kVSpacing + self.vMargin * 2)); + CGSize size = [super mediaViewDisplaySize]; + size.height = ceil(self.bubbleHeight + self.vMargin * 2); + return size; } #pragma mark - OWSMessageEditing Protocol diff --git a/Signal/src/UIColor+OWS.h b/Signal/src/UIColor+OWS.h index 7a9ab87f0..66d4aee72 100644 --- a/Signal/src/UIColor+OWS.h +++ b/Signal/src/UIColor+OWS.h @@ -8,6 +8,7 @@ + (UIColor *)ows_signalBrandBlueColor; + (UIColor *)ows_materialBlueColor; ++ (UIColor *)ows_destructiveRedColor; + (UIColor *)ows_fadedBlueColor; + (UIColor *)ows_darkBackgroundColor; + (UIColor *)ows_darkGrayColor; diff --git a/Signal/src/UIColor+OWS.m b/Signal/src/UIColor+OWS.m index d16d0e909..30005f90f 100644 --- a/Signal/src/UIColor+OWS.m +++ b/Signal/src/UIColor+OWS.m @@ -58,6 +58,11 @@ return [UIColor colorWithRed:255. / 255.f green:56.f / 255.f blue:103.f / 255.f alpha:1.f]; } ++ (UIColor *)ows_destructiveRedColor +{ + return [UIColor colorWithRed:0.98639106750488281 green:0.10408364236354828 blue:0.33135244250297546 alpha:1.f]; +} + + (UIColor *)ows_errorMessageBorderColor { return [UIColor colorWithRed:195.f / 255.f green:0 blue:22.f / 255.f alpha:1.0f]; diff --git a/Signal/src/ViewControllers/AttachmentApprovalViewController.swift b/Signal/src/ViewControllers/AttachmentApprovalViewController.swift index d7afbbc3d..91102edf7 100644 --- a/Signal/src/ViewControllers/AttachmentApprovalViewController.swift +++ b/Signal/src/ViewControllers/AttachmentApprovalViewController.swift @@ -45,17 +45,24 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor.black + view.backgroundColor = UIColor.white self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem:.stop, target:self, action:#selector(donePressed)) - self.navigationItem.title = NSLocalizedString("ATTACHMENT_APPROVAL_DIALOG_TITLE", - comment: "Title for the 'attachment approval' dialog.") + self.navigationItem.title = dialogTitle() createViews() } + private func dialogTitle() -> String { + guard let filename = formattedFileName() else { + return NSLocalizedString("ATTACHMENT_APPROVAL_DIALOG_TITLE", + comment: "Title for the 'attachment approval' dialog.") + } + return filename + } + override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) @@ -140,10 +147,11 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay audioPlayButton.autoSetDimension(.height, toSize:buttonSize) subviews.append(audioPlayButton) - if let fileExtensionLabel = createFileExtensionLabel() { + if let fileNameLabel = createFileNameLabel() { + subviews.append(fileNameLabel) + } else if let fileExtensionLabel = createFileExtensionLabel() { subviews.append(fileExtensionLabel) } - let fileSizeLabel = createFileSizeLabel() subviews.append(fileSizeLabel) @@ -209,13 +217,14 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay private func createGenericPreview(attachmentPreviewView: UIView) { var subviews = [UIView]() - let imageView = createHeroImageView(imageName: "file-icon-large") + let imageView = createHeroImageView(imageName: "file-thin-black-large") subviews.append(imageView) - if let fileExtensionLabel = createFileExtensionLabel() { + if let fileNameLabel = createFileNameLabel() { + subviews.append(fileNameLabel) + } else if let fileExtensionLabel = createFileExtensionLabel() { subviews.append(fileExtensionLabel) } - let fileSizeLabel = createFileSizeLabel() subviews.append(fileSizeLabel) @@ -256,34 +265,48 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay comment: "Format string for file extension label in call interstitial view"), fileExtension.uppercased()) - fileExtensionLabel.textColor = UIColor.white + fileExtensionLabel.textColor = UIColor.ows_materialBlue() fileExtensionLabel.font = labelFont() fileExtensionLabel.textAlignment = .center return fileExtensionLabel } + private func formattedFileName() -> String? { + guard let rawFilename = attachment.filename else { + return nil + } + let filename = rawFilename.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) + guard filename.characters.count > 0 else { + return nil + } + return filename + } + + private func createFileNameLabel() -> UIView? { + guard let filename = formattedFileName() else { + return nil + } + let label = UILabel() + label.text = filename + label.textColor = UIColor.ows_materialBlue() + label.font = labelFont() + label.textAlignment = .center + return label + } + private func createFileSizeLabel() -> UIView { - let numberFormatter = NumberFormatter() - numberFormatter.numberStyle = NumberFormatter.Style.decimal - let fileSizeLabel = UILabel() + let label = UILabel() let fileSize = attachment.data.count - let kOneKilobyte = 1024 - let kOneMegabyte = kOneKilobyte * kOneKilobyte - let fileSizeText = (fileSize > kOneMegabyte - ? numberFormatter.string(from: NSNumber(value: fileSize / kOneMegabyte))! + " mb" - : (fileSize > kOneKilobyte - ? numberFormatter.string(from: NSNumber(value: fileSize / kOneKilobyte))! + " kb" - : numberFormatter.string(from: NSNumber(value: fileSize))!)) - fileSizeLabel.text = String(format:NSLocalizedString("ATTACHMENT_APPROVAL_FILE_SIZE_FORMAT", + label.text = String(format:NSLocalizedString("ATTACHMENT_APPROVAL_FILE_SIZE_FORMAT", comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."), - fileSizeText) + ViewControllerUtils.formatFileSize(UInt(fileSize))) - fileSizeLabel.textColor = UIColor.white - fileSizeLabel.font = labelFont() - fileSizeLabel.textAlignment = .center + label.textColor = UIColor.ows_materialBlue() + label.font = labelFont() + label.textAlignment = .center - return fileSizeLabel + return label } private func createButtonRow(attachmentPreviewView: UIView) { @@ -308,7 +331,7 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay let cancelButton = createButton(title: NSLocalizedString("TXT_CANCEL_TITLE", comment: ""), - color : UIColor(rgbHex:0xff3B30), + color : UIColor.ows_destructiveRed(), action: #selector(cancelPressed)) buttonRow.addSubview(cancelButton) cancelButton.autoPinEdge(toSuperviewEdge:.top) @@ -317,7 +340,7 @@ class AttachmentApprovalViewController: UIViewController, OWSAudioAttachmentPlay let sendButton = createButton(title: NSLocalizedString("ATTACHMENT_APPROVAL_SEND_BUTTON", comment: "Label for 'send' button in the 'attachment approval' dialog."), - color : UIColor(rgbHex:0x4CD964), + color : UIColor(rgbHex:0x2ecc71), action: #selector(sendPressed)) buttonRow.addSubview(sendButton) sendButton.autoPinEdge(toSuperviewEdge:.top) diff --git a/Signal/src/ViewControllers/ViewControllerUtils.h b/Signal/src/ViewControllers/ViewControllerUtils.h index ccb96260f..fd26f69cc 100644 --- a/Signal/src/ViewControllers/ViewControllerUtils.h +++ b/Signal/src/ViewControllers/ViewControllerUtils.h @@ -18,4 +18,6 @@ + (void)setAudioIgnoresHardwareMuteSwitch:(BOOL)shouldIgnore; ++ (NSString *)formatFileSize:(unsigned long)fileSize; + @end diff --git a/Signal/src/ViewControllers/ViewControllerUtils.m b/Signal/src/ViewControllers/ViewControllerUtils.m index 53553268e..d3ead206c 100644 --- a/Signal/src/ViewControllers/ViewControllerUtils.m +++ b/Signal/src/ViewControllers/ViewControllerUtils.m @@ -80,6 +80,20 @@ NS_ASSUME_NONNULL_BEGIN } } ++ (NSString *)formatFileSize:(unsigned long)fileSize +{ + const unsigned long kOneKilobyte = 1024; + const unsigned long kOneMegabyte = kOneKilobyte * kOneKilobyte; + + NSNumberFormatter *numberFormatter = [NSNumberFormatter new]; + numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; + return (fileSize > kOneMegabyte + ? [[numberFormatter stringFromNumber:@(fileSize / kOneMegabyte)] stringByAppendingString:@" mb"] + : (fileSize > kOneKilobyte + ? [[numberFormatter stringFromNumber:@(fileSize / kOneKilobyte)] stringByAppendingString:@" kb"] + : [[numberFormatter stringFromNumber:@(fileSize)] stringByAppendingString:@" bytes"])); +} + #pragma mark - Logging + (NSString *)tag diff --git a/Signal/test/ViewControllers/Signals/TSMessageAdapters/TSMessageAdapterTest.m b/Signal/test/ViewControllers/Signals/TSMessageAdapters/TSMessageAdapterTest.m index e98a37e74..6d91be59c 100644 --- a/Signal/test/ViewControllers/Signals/TSMessageAdapters/TSMessageAdapterTest.m +++ b/Signal/test/ViewControllers/Signals/TSMessageAdapters/TSMessageAdapterTest.m @@ -1,4 +1,6 @@ -// Copyright © 2016 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "TSAttachmentStream.h" #import "TSContentAdapters.h" @@ -99,7 +101,7 @@ - (void)testCanPerformEditingActionWithVideoMessage { - TSAttachmentStream *videoAttachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4"]; + TSAttachmentStream *videoAttachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4" filename:nil]; self.messageAdapter.mediaItem = [[TSVideoAttachmentAdapter alloc] initWithAttachment:videoAttachment incoming:NO]; XCTAssertTrue([self.messageAdapter canPerformEditingAction:@selector(delete:)]); @@ -112,7 +114,7 @@ - (void)testCanPerformEditingActionWithAudioMessage { - TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3"]; + TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3" filename:nil]; self.messageAdapter.mediaItem = [[TSVideoAttachmentAdapter alloc] initWithAttachment:audioAttachment incoming:NO]; XCTAssertTrue([self.messageAdapter canPerformEditingAction:@selector(delete:)]); @@ -159,7 +161,7 @@ XCTAssertNotNil([TSMessage fetchObjectWithUniqueID:self.message.uniqueId]); NSError *error; - TSAttachmentStream *videoAttachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4"]; + TSAttachmentStream *videoAttachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4" filename:nil]; [videoAttachment writeData:[NSData new] error:&error]; [videoAttachment save]; @@ -181,7 +183,7 @@ XCTAssertNotNil([TSMessage fetchObjectWithUniqueID:self.message.uniqueId]); NSError *error; - TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3"]; + TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3" filename:nil]; [audioAttachment writeData:[NSData new] error:&error]; [audioAttachment save]; @@ -215,7 +217,7 @@ XCTAssertNil(UIPasteboard.generalPasteboard.image); NSError *error; - TSAttachmentStream *attachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg"]; + TSAttachmentStream *attachment = [[TSAttachmentStream alloc] initWithContentType:@"image/jpeg" filename:nil]; [attachment writeData:self.fakeAudioData error:&error]; [attachment save]; @@ -243,7 +245,7 @@ UIPasteboard.generalPasteboard.items = @[]; NSError *error; - TSAttachmentStream *videoAttachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4"]; + TSAttachmentStream *videoAttachment = [[TSAttachmentStream alloc] initWithContentType:@"video/mp4" filename:nil]; [videoAttachment writeData:self.fakeVideoData error:&error]; self.messageAdapter.mediaItem = [[TSVideoAttachmentAdapter alloc] initWithAttachment:videoAttachment incoming:YES]; @@ -259,7 +261,7 @@ XCTAssertNil([UIPasteboard.generalPasteboard dataForPasteboardType:(NSString *)kUTTypeMP3]); NSError *error; - TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3"]; + TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/mp3" filename:nil]; [audioAttachment writeData:self.fakeAudioData error:&error]; self.messageAdapter.mediaItem = [[TSVideoAttachmentAdapter alloc] initWithAttachment:audioAttachment incoming:NO]; @@ -273,7 +275,7 @@ XCTAssertNil([UIPasteboard.generalPasteboard dataForPasteboardType:(NSString *)kUTTypeMPEG4Audio]); NSError *error; - TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/x-m4a"]; + TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/x-m4a" filename:nil]; [audioAttachment writeData:self.fakeAudioData error:&error]; self.messageAdapter.mediaItem = [[TSVideoAttachmentAdapter alloc] initWithAttachment:audioAttachment incoming:NO]; @@ -287,7 +289,7 @@ XCTAssertNil([UIPasteboard.generalPasteboard dataForPasteboardType:(NSString *)kUTTypeAudio]); NSError *error; - TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/wav"]; + TSAttachmentStream *audioAttachment = [[TSAttachmentStream alloc] initWithContentType:@"audio/wav" filename:nil]; [audioAttachment writeData:self.fakeAudioData error:&error]; self.messageAdapter.mediaItem = [[TSVideoAttachmentAdapter alloc] initWithAttachment:audioAttachment incoming:NO];