Merge branch 'charlesmchen/attachmentTypeAssets'

This commit is contained in:
Matthew Chen 2018-04-16 16:13:47 -04:00
commit b925f913bd
14 changed files with 120 additions and 48 deletions

View file

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "attachment_audio@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "attachment_audio@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "attachment_audio@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 959 B

View file

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "attachment_file@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "attachment_file@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "attachment_file@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 436 B

View file

@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "attachment_play_button@1x.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "attachment_play_button@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "attachment_play_button@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 365 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 547 B

View file

@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (CGFloat)iconSize
{
return 40.f;
return 44.f;
}
- (CGFloat)iconSize
@ -118,62 +118,31 @@ NS_ASSUME_NONNULL_BEGIN
[contentView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:self.vMargin];
[contentView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:self.vMargin];
OWSBezierPathView *iconCircleView = [OWSBezierPathView new];
UIColor *iconColor
UIView *iconCircleView = [UIView containerView];
iconCircleView.backgroundColor
= (self.isIncoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self foregroundColorWithOpacity:0.15f]);
iconCircleView.configureShapeLayerBlock = ^(CAShapeLayer *_Nonnull layer, CGRect bounds) {
layer.path = [UIBezierPath bezierPathWithOvalInRect:bounds].CGPath;
layer.fillColor = iconColor.CGColor;
};
iconCircleView.layer.cornerRadius = self.iconSize * 0.5f;
[contentView addSubview:iconCircleView];
[iconCircleView autoPinLeadingToSuperviewMarginWithInset:self.iconHMargin];
[iconCircleView autoVCenterInSuperview];
[iconCircleView autoSetDimension:ALDimensionWidth toSize:self.iconSize];
[iconCircleView autoSetDimension:ALDimensionHeight toSize:self.iconSize];
UIImage *image = [UIImage imageNamed:@"generic-attachment-small"];
UIImage *image = [UIImage imageNamed:@"attachment_file"];
OWSAssert(image);
UIImageView *imageView = [UIImageView new];
imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
imageView.tintColor = self.bubbleBackgroundColor;
[contentView addSubview:imageView];
[imageView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:iconCircleView];
[imageView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:iconCircleView];
[imageView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:iconCircleView];
[imageView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:iconCircleView];
[iconCircleView addSubview:imageView];
[imageView autoCenterInSuperview];
const CGFloat kLabelHSpacing = self.iconHSpacing;
UIView *labelsView = [UIView containerView];
[contentView addSubview:labelsView];
[labelsView autoPinLeadingToTrailingEdgeOfView:imageView offset:kLabelHSpacing];
[labelsView autoPinLeadingToTrailingEdgeOfView:iconCircleView offset:kLabelHSpacing];
[labelsView autoPinTrailingToSuperviewMarginWithInset:self.iconHMargin];
[labelsView autoVCenterInSuperview];
NSString *filename = self.attachmentStream.sourceFilename;
if (!filename) {
filename = [[self.attachmentStream filePath] lastPathComponent];
}
NSString *fileExtension = filename.pathExtension;
if (fileExtension.length < 1) {
[MIMETypeUtil fileExtensionForMIMEType:self.attachmentStream.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 = iconColor;
fileTypeLabel.lineBreakMode = NSLineBreakByTruncatingTail;
fileTypeLabel.font = [UIFont ows_mediumFontWithSize:20.f];
fileTypeLabel.adjustsFontSizeToFitWidth = YES;
fileTypeLabel.textAlignment = NSTextAlignmentCenter;
// Center on icon.
[imageView addSubview:fileTypeLabel];
[fileTypeLabel autoCenterInSuperview];
[fileTypeLabel autoSetDimension:ALDimensionWidth toSize:15.f];
const CGFloat kLabelVSpacing = 2;
NSString *topText = [self.attachmentStream.sourceFilename ows_stripped];
if (topText.length < 1) {

View file

@ -104,8 +104,7 @@ NS_ASSUME_NONNULL_BEGIN
- (UIColor *)highlightColor
{
BOOL isQuotingSelf = [NSObject isNullableObject:self.quotedMessage.authorId equalTo:TSAccountManager.localNumber];
return (isQuotingSelf ? OWSMessagesBubbleImageFactory.bubbleColorOutgoingSent
: OWSMessagesBubbleImageFactory.bubbleColorIncoming);
return (isQuotingSelf ? OWSMessagesBubbleImageFactory.bubbleColorOutgoingSent : [UIColor colorWithRGBHex:0xB5B5B5]);
}
#pragma mark -
@ -140,6 +139,17 @@ NS_ASSUME_NONNULL_BEGIN
quotedAttachmentView.layer.cornerRadius = 2.f;
quotedAttachmentView.clipsToBounds = YES;
quotedAttachmentView.backgroundColor = [UIColor whiteColor];
if (self.isVideoAttachment) {
UIImage *contentIcon = [UIImage imageNamed:@"attachment_play_button"];
contentIcon = [contentIcon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *contentImageView = [self imageViewForImage:contentIcon];
contentImageView.tintColor = [UIColor whiteColor];
[quotedAttachmentView addSubview:contentImageView];
[contentImageView autoCenterInSuperview];
[contentImageView setContentHuggingHigh];
[contentImageView setCompressionResistanceHigh];
}
} else if (self.quotedMessage.thumbnailDownloadFailed) {
// TODO design review icon and color
UIImage *contentIcon =
@ -162,17 +172,19 @@ NS_ASSUME_NONNULL_BEGIN
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapFailedThumbnailDownload:)];
[quotedAttachmentView addGestureRecognizer:tapGesture];
} else {
// TODO: This asset is wrong.
// TODO: There's a special asset for audio files.
UIImage *contentIcon = [UIImage imageNamed:@"file-thin-black-filled-large"];
UIImageView *contentImageView = [self imageViewForImage:contentIcon];
quotedAttachmentView = [UIView containerView];
[quotedAttachmentView addSubview:contentImageView];
quotedAttachmentView.backgroundColor = self.highlightColor;
quotedAttachmentView.layer.cornerRadius = self.quotedAttachmentSize * 0.5f;
UIImage *contentIcon =
[UIImage imageNamed:(self.isAudioAttachment ? @"attachment_audio" : @"attachment_file")];
contentIcon = [contentIcon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
UIImageView *contentImageView = [self imageViewForImage:contentIcon];
contentImageView.tintColor = [UIColor whiteColor];
[quotedAttachmentView addSubview:contentImageView];
[contentImageView autoCenterInSuperview];
[contentImageView
autoSetDimensionsToSize:CGSizeMake(self.quotedAttachmentSize * 0.5f, self.quotedAttachmentSize * 0.5f)];
[contentImageView setContentHuggingHigh];
[contentImageView setCompressionResistanceHigh];
}
quotedAttachmentView.userInteractionEnabled = YES;
@ -354,6 +366,28 @@ NS_ASSUME_NONNULL_BEGIN
return nil;
}
- (BOOL)isAudioAttachment
{
// TODO: Are we going to use the filename? For all mimetypes?
NSString *_Nullable contentType = self.quotedMessage.contentType;
if (contentType.length < 1) {
return NO;
}
return [MIMETypeUtil isAudio:contentType];
}
- (BOOL)isVideoAttachment
{
// TODO: Are we going to use the filename? For all mimetypes?
NSString *_Nullable contentType = self.quotedMessage.contentType;
if (contentType.length < 1) {
return NO;
}
return [MIMETypeUtil isVideo:contentType];
}
- (UILabel *)configureQuotedAuthorLabel
{
OWSAssert(self.quotedAuthorLabel);