diff --git a/Signal/Images.xcassets/generic-attachment-small.imageset/Contents.json b/Signal/Images.xcassets/generic-attachment-small.imageset/Contents.json new file mode 100644 index 000000000..97580a965 --- /dev/null +++ b/Signal/Images.xcassets/generic-attachment-small.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "generic-attachment-small@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "generic-attachment-small@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "generic-attachment-small@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@1x.png b/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@1x.png new file mode 100644 index 000000000..ae9198feb Binary files /dev/null and b/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@1x.png differ diff --git a/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@2x.png b/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@2x.png new file mode 100644 index 000000000..682b0faca Binary files /dev/null and b/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@2x.png differ diff --git a/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@3x.png b/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@3x.png new file mode 100644 index 000000000..1fc55aa31 Binary files /dev/null and b/Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@3x.png differ diff --git a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m index fc0ca4001..ceb93e3b1 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m @@ -77,9 +77,19 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - JSQMessageMediaData protocol +- (CGFloat)audioIconHMargin +{ + return 10.f; +} + +- (CGFloat)audioIconVMargin +{ + return 12.f; +} + - (CGFloat)bubbleHeight { - return 45.f; + return self.iconSize + self.audioIconVMargin * 2; } - (CGFloat)iconSize @@ -92,6 +102,21 @@ NS_ASSUME_NONNULL_BEGIN return 10.f; } +- (UIColor *)bubbleBackgroundColor +{ + return self.incoming ? [UIColor jsq_messageBubbleLightGrayColor] : [UIColor ows_materialBlueColor]; +} + +- (UIColor *)audioTextColor +{ + return (self.incoming ? [UIColor colorWithWhite:0.2f alpha:1.f] : [UIColor whiteColor]); +} + +- (UIColor *)audioColorWithOpacity:(CGFloat)alpha +{ + return [self.audioTextColor blendWithColor:self.bubbleBackgroundColor alpha:alpha]; +} + - (UIView *)mediaView { if (_cachedMediaView == nil) { @@ -100,8 +125,7 @@ NS_ASSUME_NONNULL_BEGIN _cachedMediaView = [[UIView alloc] initWithFrame:CGRectMake(0.f, 0.f, viewSize.width, viewSize.height)]; - _cachedMediaView.backgroundColor - = self.incoming ? [UIColor jsq_messageBubbleLightGrayColor] : [UIColor ows_materialBlueColor]; + _cachedMediaView.backgroundColor = self.bubbleBackgroundColor; [JSQMessagesMediaViewBubbleImageMasker applyBubbleImageMaskToMediaView:_cachedMediaView isOutgoing:!self.incoming]; @@ -111,45 +135,23 @@ NS_ASSUME_NONNULL_BEGIN viewSize.width - kBubbleTailWidth - 15, viewSize.height - self.vMargin * 2); - UIImage *image = [UIImage imageNamed:(self.incoming ? @"file-black-40" : @"file-white-40")]; + UIImage *image = [UIImage imageNamed:@"generic-attachment-small"]; OWSAssert(image); - UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; - CGRect iconFrame = CGRectMake(round(contentFrame.origin.x + 10.f), + UIImageView *imageView = [UIImageView new]; + CGRect iconFrame = CGRectMake(round(contentFrame.origin.x + self.audioIconHMargin), round(contentFrame.origin.y + (contentFrame.size.height - self.iconSize) * 0.5f), self.iconSize, self.iconSize); imageView.frame = iconFrame; - [_cachedMediaView addSubview:imageView]; + imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; + imageView.tintColor = self.bubbleBackgroundColor; + imageView.backgroundColor + = (self.incoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self audioColorWithOpacity:0.15f]); + imageView.layer.cornerRadius = MIN(imageView.bounds.size.width, imageView.bounds.size.height) * 0.5f; - NSString *fileExtension = self.attachment.filePath.pathExtension; - if (fileExtension.length < 1) { - [MIMETypeUtil fileExtensionForMIMEType:self.attachment.contentType]; - } - if (fileExtension.length < 1) { - fileExtension = NSLocalizedString(@"GENERIC_ATTACHMENT_DEFAULT_TYPE", - @"A default label for attachment whose file extension cannot be determined."); - } + [_cachedMediaView addSubview:imageView]; - UILabel *fileTypeLabel = [UILabel new]; - fileTypeLabel.text = fileExtension.uppercaseString; - 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]; - // 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); - fileTypeLabel.frame = fileTypeLabelFrame; - [_cachedMediaView addSubview:fileTypeLabel]; - - const CGFloat kLabelHSpacing = 3; + const CGFloat kLabelHSpacing = self.audioIconHMargin; const CGFloat kLabelVSpacing = 2; NSString *topText = [self.attachment.filename stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; @@ -207,7 +209,7 @@ NS_ASSUME_NONNULL_BEGIN { CGSize size = [super mediaViewDisplaySize]; size.width = [self ows_maxMediaBubbleWidth:size]; - size.height = ceil(self.bubbleHeight + self.vMargin * 2); + size.height = (CGFloat)ceil(self.bubbleHeight); return size; } diff --git a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m index b915f4bf2..a1aa8b6fb 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m @@ -128,12 +128,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)setAudioIconToPlay { [self setAudioIcon:[UIImage imageNamed:@"audio_play_black_40"] - iconColor:(self.incoming ? [UIColor colorWithRGBHex:0x9494B2] : [self audioColorWithOpacity:0.15f])]; + iconColor:(self.incoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self audioColorWithOpacity:0.15f])]; } - (void)setAudioIconToPause { [self setAudioIcon:[UIImage imageNamed:@"audio_pause_black_40"] - iconColor:(self.incoming ? [UIColor colorWithRGBHex:0x9494B2] : [self audioColorWithOpacity:0.1f])]; + iconColor:(self.incoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self audioColorWithOpacity:0.15f])]; } - (void)setIsAudioPlaying:(BOOL)isAudioPlaying