From 09d377f7e2bf49b946409f516948b7dac6a62a3c Mon Sep 17 00:00:00 2001 From: Matthew Douglass Date: Fri, 28 Oct 2016 00:16:45 -0700 Subject: [PATCH] Unifies bubble sizes for media bubbles On iPhone 6 and above, media bubble sizes are 10% wider On iPhone 5s and below, media bubbles are fixed in their larger dimension and the other dimension is calculated based on the aspect ratio of the underlying image (clamped to a reasonable min/max height). // FREEBIE --- .../Models/TSMessageAdapaters/JSQMediaItem+OWS.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Signal/src/Models/TSMessageAdapaters/JSQMediaItem+OWS.m b/Signal/src/Models/TSMessageAdapaters/JSQMediaItem+OWS.m index f95eb1251..c2f5a2bc0 100644 --- a/Signal/src/Models/TSMessageAdapaters/JSQMediaItem+OWS.m +++ b/Signal/src/Models/TSMessageAdapaters/JSQMediaItem+OWS.m @@ -13,13 +13,20 @@ @implementation JSQMediaItem (OWS) - (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.1; + bubbleSize.width *= 1.2; + bubbleSize.height = (CGFloat)(bubbleSize.width * clampedAspectRatio); } else { - bubbleSize.width *= 0.7; + if (aspectRatio > 1) { + bubbleSize.height = bubbleSize.width; + bubbleSize.width = (CGFloat)(bubbleSize.height / clampedAspectRatio); + } else { + bubbleSize.height = (CGFloat)(bubbleSize.width * clampedAspectRatio); + } } - double aspectRatio = image.size.height / image.size.width; - bubbleSize.height = (CGFloat)(bubbleSize.width * [NumberUtil clamp:aspectRatio toMin:0.5 andMax:1.5]); return bubbleSize; }