Merge branch 'charlesmchen/largerAudioWidth'

pull/1/head
Matthew Chen 7 years ago
commit c27800c12c

@ -1,15 +1,13 @@
//
// JSQMediaItem+OWS.h
// Signal
//
// Created by Matthew Douglass on 10/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import <JSQMessagesViewController/JSQMediaItem.h>
@interface JSQMediaItem (OWS)
- (CGFloat)ows_maxMediaBubbleWidth:(CGSize)defaultBubbleSize;
- (CGSize)ows_adjustBubbleSize:(CGSize)bubbleSize forImage:(UIImage *)image;
@end

@ -1,9 +1,5 @@
//
// JSQMediaItem+OWS.m
// Signal
//
// Created by Matthew Douglass on 10/18/16.
// Copyright © 2016 Open Whisper Systems. All rights reserved.
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "JSQMediaItem+OWS.h"
@ -12,12 +8,18 @@
@implementation JSQMediaItem (OWS)
- (CGFloat)ows_maxMediaBubbleWidth:(CGSize)defaultBubbleSize
{
return (
[[UIDevice currentDevice] isiPhoneVersionSixOrMore] ? defaultBubbleSize.width * 1.2 : defaultBubbleSize.width);
}
- (CGSize)ows_adjustBubbleSize:(CGSize)bubbleSize forImage:(UIImage *)image {
double aspectRatio = image.size.height / image.size.width;
double clampedAspectRatio = [NumberUtil clamp:aspectRatio toMin:0.5 andMax:1.5];
if ([[UIDevice currentDevice] isiPhoneVersionSixOrMore]) {
bubbleSize.width *= 1.2;
bubbleSize.width = [self ows_maxMediaBubbleWidth:bubbleSize];
bubbleSize.height = (CGFloat)(bubbleSize.width * clampedAspectRatio);
} else {
if (aspectRatio > 1) {

@ -4,6 +4,7 @@
#import "TSGenericAttachmentAdapter.h"
#import "AttachmentUploadView.h"
#import "JSQMediaItem+OWS.h"
#import "TSAttachmentStream.h"
#import "UIColor+JSQMessages.h"
#import "UIColor+OWS.h"
@ -205,6 +206,7 @@ NS_ASSUME_NONNULL_BEGIN
- (CGSize)mediaViewDisplaySize
{
CGSize size = [super mediaViewDisplaySize];
size.width = [self ows_maxMediaBubbleWidth:size];
size.height = ceil(self.bubbleHeight + self.vMargin * 2);
return size;
}

@ -12,6 +12,7 @@
#import "TSStorageManager+keyingMaterial.h"
#import "UIColor+JSQMessages.h"
#import "UIColor+OWS.h"
#import "UIDevice+TSHardwareVersion.h"
#import "UIFont+OWS.h"
#import "UIView+OWS.h"
#import "ViewControllerUtils.h"
@ -355,6 +356,7 @@ NS_ASSUME_NONNULL_BEGIN
- (CGSize)mediaViewDisplaySize {
CGSize size = [super mediaViewDisplaySize];
if ([self isAudio]) {
size.width = [self ows_maxMediaBubbleWidth:size];
size.height = (CGFloat)ceil(self.audioBubbleHeight + self.vMargin * 2);
} else if ([self isVideo]) {
return [self ows_adjustBubbleSize:size forImage:self.image];

Loading…
Cancel
Save