2016-10-19 06:32:48 +02:00
|
|
|
//
|
|
|
|
// JSQMediaItem+OWS.m
|
|
|
|
// Signal
|
|
|
|
//
|
|
|
|
// Created by Matthew Douglass on 10/18/16.
|
|
|
|
// Copyright © 2016 Open Whisper Systems. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "JSQMediaItem+OWS.h"
|
|
|
|
#import "UIDevice+TSHardwareVersion.h"
|
|
|
|
#import "NumberUtil.h"
|
|
|
|
|
|
|
|
@implementation JSQMediaItem (OWS)
|
|
|
|
|
|
|
|
- (CGSize)ows_adjustBubbleSize:(CGSize)bubbleSize forImage:(UIImage *)image {
|
2016-10-28 09:16:45 +02:00
|
|
|
double aspectRatio = image.size.height / image.size.width;
|
|
|
|
double clampedAspectRatio = [NumberUtil clamp:aspectRatio toMin:0.5 andMax:1.5];
|
|
|
|
|
2016-10-19 06:32:48 +02:00
|
|
|
if ([[UIDevice currentDevice] isiPhoneVersionSixOrMore]) {
|
2016-10-28 09:16:45 +02:00
|
|
|
bubbleSize.width *= 1.2;
|
|
|
|
bubbleSize.height = (CGFloat)(bubbleSize.width * clampedAspectRatio);
|
2016-10-19 06:32:48 +02:00
|
|
|
} else {
|
2016-10-28 09:16:45 +02:00
|
|
|
if (aspectRatio > 1) {
|
|
|
|
bubbleSize.height = bubbleSize.width;
|
|
|
|
bubbleSize.width = (CGFloat)(bubbleSize.height / clampedAspectRatio);
|
|
|
|
} else {
|
|
|
|
bubbleSize.height = (CGFloat)(bubbleSize.width * clampedAspectRatio);
|
|
|
|
}
|
2016-10-19 06:32:48 +02:00
|
|
|
}
|
|
|
|
return bubbleSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|