From 2c31a0bdb5eca2bf6a2e556efc7e26a6542bce55 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 12 May 2017 15:03:24 -0400 Subject: [PATCH 1/3] Rework appearance of audio messages. // FREEBIE --- Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m | 1 - 1 file changed, 1 deletion(-) diff --git a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m index 33623d7a7..b915f4bf2 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m @@ -363,7 +363,6 @@ NS_ASSUME_NONNULL_BEGIN CGSize size = [super mediaViewDisplaySize]; if ([self isAudio]) { size.width = [self ows_maxMediaBubbleWidth:size]; - size.height = (CGFloat)ceil(self.audioBubbleHeight); } else if ([self isVideo]) { return [self ows_adjustBubbleSize:size forImage:self.image]; } From b8b2ae10a20d0e59added5ee1a56e3e031b2bf05 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 12 May 2017 15:29:38 -0400 Subject: [PATCH 2/3] Rework appearance of generic attachment messages. // FREEBIE --- .../Contents.json | 23 ++++++ .../generic-attachment-small@1x.png | Bin 0 -> 1377 bytes .../generic-attachment-small@2x.png | Bin 0 -> 1575 bytes .../generic-attachment-small@3x.png | Bin 0 -> 1914 bytes .../TSGenericAttachmentAdapter.m | 74 +++++++++--------- .../TSVideoAttachmentAdapter.m | 4 +- 6 files changed, 63 insertions(+), 38 deletions(-) create mode 100644 Signal/Images.xcassets/generic-attachment-small.imageset/Contents.json create mode 100644 Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@1x.png create mode 100644 Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@2x.png create mode 100644 Signal/Images.xcassets/generic-attachment-small.imageset/generic-attachment-small@3x.png 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 0000000000000000000000000000000000000000..ae9198feb3da9581be4fd3643a69c523776fb261 GIT binary patch literal 1377 zcmeAS@N?(olHy`uVBq!ia0vp^8X(NU1|)m_?Z^dEjKx9jP7LeL$-D$|I14-?iy0WW zg+Z8+Vb&Z81_llpi<;HsXMd|v6mX?-X(Gs7c7{+3kj2o|M`E)8SrADBDCn&MGAmMZB3v?o0SfkoiGhtiRta>C&iOg{ zMZpD$$*CZRfwdqBp{oX46N$?jBnc#qDalsFrAb+-$t6g!1&lLr+ILD!*GCez(Z{OV z2AC48eDhN>(<)sOOH%EO3=GY64NP?njY14ftqe@9OwDZc(bOQh03_pFl$uzQUlfv` zpJNC1MJ|Y|V5|q#i7XG*YNHRzMM${{l4Zf7z&vZm1+){E|LwR+zE1@e3O77m977^F z-%hdSIusz_y0~Kp)7|DB(i??x-fXfJf66W${jq%6W{FAVikwZ~4{FYdQ8#a&ue(DF3t3K`Ke&f?Z7-<v_HBW zesCGnCEMS>&X|Z!S+{e+5^c`g2}-U~H*vB4?>V?+v%6UWv)PAmHao#1mOD51%lpi<;HsXMd|v6mX?-X(Gs7c7{+3kj2o|M`E)8SrADBDCn&MGAmMZB3v?o0Sfkog@KJeRta>C&iOg{ zMZpD$$*CZRfwdqBp{oX46N$?jBnc#qDalsFrAb+-$t6g!1&lLr+ILD!*GCez(Z{OV z2AC48eDhN>(<)sOOH%EO3=GY64NP?njY14ftqe@9EG=yG(bOQh03_pFl$uzQUlfv` zpJNC1MJ|Y|V60~b(TOY%)oP;;%0)=I3X)~PqQE?B#|6|0%l~#FaFUrWZbzojW<#`%yj63Rj$=f z^PfzrpKra?k57~6mEcflU|_-|9HbiUbtmt7cll1#tk89rb%Il-c9zMC-`u%1^K3)# z+{bH6rzyo}v)%E03U9-ae_^B@}3o8t5(l=B4^6HZLQcW5l0!WgoJaU*`e3` zWP}nF>{gpu3bwOJboj3-51qC-^`?s7)x#EFV2;2XriXu^8NLY8BJX2P+T4h+7G#(wNf8C)|8tppr`5A;1pY)MoasPy)9^>bP0 Hl+XkK;j8++ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1fc55aa31b3622160293ef85e01ec3a52ef67817 GIT binary patch literal 1914 zcmeAS@N?(olHy`uVBq!ia0vp^6(G#P1|%(0%q{^b#^NA%Cx&(BWL^R}oCO|{#S9GG z!XV7ZFl&wk0|SdnW=KRygs+cPa(=E}VoH8es$NBI0Z=sqgH44MkeQoWlBiITo0C^; zRbi_HR$&EXgM{^!6u?SKvTcwsYk*NEcCio^nlW#B-B_{|37a;u=! z;{2RaP!NRXWtP|(*?>KSE{q5fh%V>++=8Oi;$omSJ5#6@WHEI05eRGS%wcvQ3!-cA zFUkb^G!f)3J42`i$YSW~Be7Y4EQq856!caBnH8xy5iXg)00sNP(8$0>AFB+yPUrlb z{G#B3#N zKgSO2ja(2{!C21>q7zvjs?|mxl#h_|6(rMwMS;22jti(0Rsz^@*@^r~W?*1?@9E+g zQo;E4mUowMpiJvW4Xf|Ec4~feJC(XRn(_|mT9$J*b*x|6UBJ5Tps2>HwSnHjCCe`@ zpDg@GG{z(E@B5Q0-zzU<-y5}4z=460g>+&P%fFrtv1_lNWY0WlbvwwV|FWXP2b=4= zlYc+`v-a;T)rx!9TQ~l#TOPZBd#>}~6|#2WMy8mpBgOHlOXwe=l-y_U3(-eRYzr z|2-32UO(xQBT+scn#M@+4coj<#N-~YPrzZE`YF}8L- z{>l0|T3Yo7!`JuC(^tzs{<^#V-ut(wRqb7?e^1C3+rRnQow(k)n%UNW&5y5JH~(?- z{hqJ6YbJlI*uA>l;?GVNd9_KE@rSSam$+r*avj{7WptF|T)`S&#T{Y3%Onm;_HET< zxxVV8h_c1ujb^P6qD*Hdv7}pETP6^*S}nNe0nhPUB2C#>Q@RA_JdBv_RIqlIk71Ls yOm;BGy3om*ZUt@0L)OsVBo2iJ1}4%8;l}-84(7JTGnelLRfwLhelF{r5}E)O=cW(< literal 0 HcmV?d00001 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 From 00d972db4891678de1afeef57474c9f612f3d985 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 12 May 2017 16:04:56 -0400 Subject: [PATCH 3/3] Rework appearance of audio and generic attachment messages. // FREEBIE --- .../TSGenericAttachmentAdapter.m | 54 +++++++++++++++---- .../TSVideoAttachmentAdapter.m | 10 +++- 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m index ceb93e3b1..b7a5a5450 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSGenericAttachmentAdapter.m @@ -77,19 +77,24 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - JSQMessageMediaData protocol -- (CGFloat)audioIconHMargin +- (CGFloat)iconHMargin +{ + return 12.f; +} + +- (CGFloat)iconHSpacing { return 10.f; } -- (CGFloat)audioIconVMargin +- (CGFloat)iconVMargin { return 12.f; } - (CGFloat)bubbleHeight { - return self.iconSize + self.audioIconVMargin * 2; + return self.iconSize + self.iconVMargin * 2; } - (CGFloat)iconSize @@ -107,14 +112,14 @@ NS_ASSUME_NONNULL_BEGIN return self.incoming ? [UIColor jsq_messageBubbleLightGrayColor] : [UIColor ows_materialBlueColor]; } -- (UIColor *)audioTextColor +- (UIColor *)textColor { return (self.incoming ? [UIColor colorWithWhite:0.2f alpha:1.f] : [UIColor whiteColor]); } -- (UIColor *)audioColorWithOpacity:(CGFloat)alpha +- (UIColor *)foregroundColorWithOpacity:(CGFloat)alpha { - return [self.audioTextColor blendWithColor:self.bubbleBackgroundColor alpha:alpha]; + return [self.textColor blendWithColor:self.bubbleBackgroundColor alpha:alpha]; } - (UIView *)mediaView @@ -132,13 +137,13 @@ NS_ASSUME_NONNULL_BEGIN const CGFloat kBubbleTailWidth = 6.f; CGRect contentFrame = CGRectMake(self.incoming ? kBubbleTailWidth : 0.f, self.vMargin, - viewSize.width - kBubbleTailWidth - 15, + viewSize.width - kBubbleTailWidth - self.iconHMargin, viewSize.height - self.vMargin * 2); UIImage *image = [UIImage imageNamed:@"generic-attachment-small"]; OWSAssert(image); UIImageView *imageView = [UIImageView new]; - CGRect iconFrame = CGRectMake(round(contentFrame.origin.x + self.audioIconHMargin), + CGRect iconFrame = CGRectMake(round(contentFrame.origin.x + self.iconHMargin), round(contentFrame.origin.y + (contentFrame.size.height - self.iconSize) * 0.5f), self.iconSize, self.iconSize); @@ -146,12 +151,39 @@ NS_ASSUME_NONNULL_BEGIN imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageView.tintColor = self.bubbleBackgroundColor; imageView.backgroundColor - = (self.incoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self audioColorWithOpacity:0.15f]); + = (self.incoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self foregroundColorWithOpacity:0.15f]); imageView.layer.cornerRadius = MIN(imageView.bounds.size.width, imageView.bounds.size.height) * 0.5f; - [_cachedMediaView addSubview:imageView]; - const CGFloat kLabelHSpacing = self.audioIconHMargin; + 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."); + } + + UILabel *fileTypeLabel = [UILabel new]; + fileTypeLabel.text = fileExtension.uppercaseString; + fileTypeLabel.textColor = imageView.backgroundColor; + 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 = 15.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 = self.iconHSpacing; const CGFloat kLabelVSpacing = 2; NSString *topText = [self.attachment.filename stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; diff --git a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m index a1aa8b6fb..64bc837e7 100644 --- a/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m +++ b/Signal/src/Models/TSMessageAdapaters/TSVideoAttachmentAdapter.m @@ -157,6 +157,11 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - JSQMessageMediaData protocol - (CGFloat)audioIconHMargin +{ + return 12.f; +} + +- (CGFloat)audioIconHSpacing { return 10.f; } @@ -269,7 +274,7 @@ NS_ASSUME_NONNULL_BEGIN const CGFloat kBubbleTailWidth = 6.f; CGRect contentFrame = CGRectMake(self.incoming ? kBubbleTailWidth : 0.f, self.audioIconVMargin, - viewSize.width - kBubbleTailWidth - 15, + viewSize.width - kBubbleTailWidth - self.audioIconHMargin, viewSize.height - self.audioIconVMargin * 2); CGRect iconFrame = CGRectMake((CGFloat)round(contentFrame.origin.x + self.audioIconHMargin), @@ -280,7 +285,7 @@ NS_ASSUME_NONNULL_BEGIN _audioPlayPauseButton.enabled = NO; [mediaView addSubview:_audioPlayPauseButton]; - const CGFloat kLabelHSpacing = self.audioIconHMargin; + const CGFloat kLabelHSpacing = self.audioIconHSpacing; const CGFloat kLabelVSpacing = 2; NSString *topText = [[self.attachment.filename stringByDeletingPathExtension] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; @@ -363,6 +368,7 @@ NS_ASSUME_NONNULL_BEGIN CGSize size = [super mediaViewDisplaySize]; if ([self isAudio]) { size.width = [self ows_maxMediaBubbleWidth:size]; + size.height = (CGFloat)ceil(self.audioBubbleHeight); } else if ([self isVideo]) { return [self ows_adjustBubbleSize:size forImage:self.image]; }