From 11819d9b8a5894fb13b540d2f1ea81ca9b66c66d Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 28 Mar 2018 10:33:17 -0400 Subject: [PATCH] Bubble collapse. --- .../ViewControllers/DebugUI/DebugUIMessages.m | 201 ++++++++++++++---- .../DebugUI/DebugUIMessagesAssetLoader.h | 7 +- .../DebugUI/DebugUIMessagesAssetLoader.m | 49 ++++- .../utils/OWSMessagesBubbleImageFactory.swift | 1 - 4 files changed, 214 insertions(+), 44 deletions(-) diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m index bae44a297..145c46bd7 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m @@ -550,29 +550,55 @@ NS_ASSUME_NONNULL_BEGIN thread:thread]; } -+ (DebugUIMessagesAction *)fakeOutgoingPortraitPngAction:(TSThread *)thread - messageState:(TSOutgoingMessageState)messageState - hasCaption:(BOOL)hasCaption ++ (DebugUIMessagesAction *)fakeOutgoingCompactPortraitPngAction:(TSThread *)thread + messageState:(TSOutgoingMessageState)messageState + hasCaption:(BOOL)hasCaption { OWSAssert(thread); return [self fakeOutgoingMediaAction:@"Fake Outgoing Portrait Png" messageState:messageState hasCaption:hasCaption - fakeAssetLoader:[DebugUIMessagesAssetLoader landscapePngInstance] + fakeAssetLoader:[DebugUIMessagesAssetLoader compactLandscapePngInstance] thread:thread]; } -+ (DebugUIMessagesAction *)fakeOutgoingLandscapePngAction:(TSThread *)thread - messageState:(TSOutgoingMessageState)messageState - hasCaption:(BOOL)hasCaption ++ (DebugUIMessagesAction *)fakeOutgoingCompactLandscapePngAction:(TSThread *)thread + messageState:(TSOutgoingMessageState)messageState + hasCaption:(BOOL)hasCaption { OWSAssert(thread); return [self fakeOutgoingMediaAction:@"Fake Outgoing Landscape Png" messageState:messageState hasCaption:hasCaption - fakeAssetLoader:[DebugUIMessagesAssetLoader portraitPngInstance] + fakeAssetLoader:[DebugUIMessagesAssetLoader compactPortraitPngInstance] + thread:thread]; +} + ++ (DebugUIMessagesAction *)fakeOutgoingTallPortraitPngAction:(TSThread *)thread + messageState:(TSOutgoingMessageState)messageState + hasCaption:(BOOL)hasCaption +{ + OWSAssert(thread); + + return [self fakeOutgoingMediaAction:@"Fake Outgoing Tall Portrait Png" + messageState:messageState + hasCaption:hasCaption + fakeAssetLoader:[DebugUIMessagesAssetLoader tallPortraitPngInstance] + thread:thread]; +} + ++ (DebugUIMessagesAction *)fakeOutgoingWideLandscapePngAction:(TSThread *)thread + messageState:(TSOutgoingMessageState)messageState + hasCaption:(BOOL)hasCaption +{ + OWSAssert(thread); + + return [self fakeOutgoingMediaAction:@"Fake Outgoing Wide Landscape Png" + messageState:messageState + hasCaption:hasCaption + fakeAssetLoader:[DebugUIMessagesAssetLoader wideLandscapePngInstance] thread:thread]; } @@ -589,6 +615,19 @@ NS_ASSUME_NONNULL_BEGIN thread:thread]; } ++ (DebugUIMessagesAction *)fakeOutgoingTinyPngAction:(TSThread *)thread + messageState:(TSOutgoingMessageState)messageState + hasCaption:(BOOL)hasCaption +{ + OWSAssert(thread); + + return [self fakeOutgoingMediaAction:@"Fake Outgoing Tiny Png" + messageState:messageState + hasCaption:hasCaption + fakeAssetLoader:[DebugUIMessagesAssetLoader tinyPngInstance] + thread:thread]; +} + + (DebugUIMessagesAction *)fakeOutgoingTinyPdfAction:(TSThread *)thread messageState:(TSOutgoingMessageState)messageState hasCaption:(BOOL)hasCaption @@ -813,29 +852,55 @@ NS_ASSUME_NONNULL_BEGIN thread:thread]; } -+ (DebugUIMessagesAction *)fakeIncomingPortraitPngAction:(TSThread *)thread - isAttachmentDownloaded:(BOOL)isAttachmentDownloaded - hasCaption:(BOOL)hasCaption ++ (DebugUIMessagesAction *)fakeIncomingCompactPortraitPngAction:(TSThread *)thread + isAttachmentDownloaded:(BOOL)isAttachmentDownloaded + hasCaption:(BOOL)hasCaption { OWSAssert(thread); return [self fakeIncomingMediaAction:@"Fake Incoming Portrait Png" isAttachmentDownloaded:isAttachmentDownloaded hasCaption:hasCaption - fakeAssetLoader:[DebugUIMessagesAssetLoader portraitPngInstance] + fakeAssetLoader:[DebugUIMessagesAssetLoader compactPortraitPngInstance] thread:thread]; } -+ (DebugUIMessagesAction *)fakeIncomingLandscapePngAction:(TSThread *)thread - isAttachmentDownloaded:(BOOL)isAttachmentDownloaded - hasCaption:(BOOL)hasCaption ++ (DebugUIMessagesAction *)fakeIncomingCompactLandscapePngAction:(TSThread *)thread + isAttachmentDownloaded:(BOOL)isAttachmentDownloaded + hasCaption:(BOOL)hasCaption { OWSAssert(thread); return [self fakeIncomingMediaAction:@"Fake Incoming Landscape Png" isAttachmentDownloaded:isAttachmentDownloaded hasCaption:hasCaption - fakeAssetLoader:[DebugUIMessagesAssetLoader landscapePngInstance] + fakeAssetLoader:[DebugUIMessagesAssetLoader compactLandscapePngInstance] + thread:thread]; +} + ++ (DebugUIMessagesAction *)fakeIncomingTallPortraitPngAction:(TSThread *)thread + isAttachmentDownloaded:(BOOL)isAttachmentDownloaded + hasCaption:(BOOL)hasCaption +{ + OWSAssert(thread); + + return [self fakeIncomingMediaAction:@"Fake Incoming Tall Portrait Png" + isAttachmentDownloaded:isAttachmentDownloaded + hasCaption:hasCaption + fakeAssetLoader:[DebugUIMessagesAssetLoader tallPortraitPngInstance] + thread:thread]; +} + ++ (DebugUIMessagesAction *)fakeIncomingWideLandscapePngAction:(TSThread *)thread + isAttachmentDownloaded:(BOOL)isAttachmentDownloaded + hasCaption:(BOOL)hasCaption +{ + OWSAssert(thread); + + return [self fakeIncomingMediaAction:@"Fake Incoming Wide Landscape Png" + isAttachmentDownloaded:isAttachmentDownloaded + hasCaption:hasCaption + fakeAssetLoader:[DebugUIMessagesAssetLoader wideLandscapePngInstance] thread:thread]; } @@ -852,6 +917,19 @@ NS_ASSUME_NONNULL_BEGIN thread:thread]; } ++ (DebugUIMessagesAction *)fakeIncomingTinyPngAction:(TSThread *)thread + isAttachmentDownloaded:(BOOL)isAttachmentDownloaded + hasCaption:(BOOL)hasCaption +{ + OWSAssert(thread); + + return [self fakeIncomingMediaAction:@"Tiny Incoming Large Png" + isAttachmentDownloaded:isAttachmentDownloaded + hasCaption:hasCaption + fakeAssetLoader:[DebugUIMessagesAssetLoader tinyPngInstance] + thread:thread]; +} + + (DebugUIMessagesAction *)fakeIncomingTinyPdfAction:(TSThread *)thread isAttachmentDownloaded:(BOOL)isAttachmentDownloaded hasCaption:(BOOL)hasCaption @@ -1052,22 +1130,60 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], // - [self fakeOutgoingLandscapePngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], - [self fakeOutgoingLandscapePngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], - [self fakeOutgoingLandscapePngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], - [self fakeOutgoingLandscapePngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], - [self fakeOutgoingLandscapePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], - [self fakeOutgoingLandscapePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], + [self fakeOutgoingCompactLandscapePngAction:thread + messageState:TSOutgoingMessageStateAttemptingOut + hasCaption:NO], + [self fakeOutgoingCompactLandscapePngAction:thread + messageState:TSOutgoingMessageStateAttemptingOut + hasCaption:YES], + [self fakeOutgoingCompactLandscapePngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], + [self fakeOutgoingCompactLandscapePngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], + [self fakeOutgoingCompactLandscapePngAction:thread + messageState:TSOutgoingMessageStateSentToService + hasCaption:NO], + [self fakeOutgoingCompactLandscapePngAction:thread + messageState:TSOutgoingMessageStateSentToService + hasCaption:YES], + // + [self fakeOutgoingCompactPortraitPngAction:thread + messageState:TSOutgoingMessageStateAttemptingOut + hasCaption:NO], + [self fakeOutgoingCompactPortraitPngAction:thread + messageState:TSOutgoingMessageStateAttemptingOut + hasCaption:YES], + [self fakeOutgoingCompactPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], + [self fakeOutgoingCompactPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], + [self fakeOutgoingCompactPortraitPngAction:thread + messageState:TSOutgoingMessageStateSentToService + hasCaption:NO], + [self fakeOutgoingCompactPortraitPngAction:thread + messageState:TSOutgoingMessageStateSentToService + hasCaption:YES], + // + [self fakeOutgoingWideLandscapePngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], + [self fakeOutgoingWideLandscapePngAction:thread + messageState:TSOutgoingMessageStateAttemptingOut + hasCaption:YES], + [self fakeOutgoingWideLandscapePngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], + [self fakeOutgoingWideLandscapePngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], + [self fakeOutgoingWideLandscapePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], + [self fakeOutgoingWideLandscapePngAction:thread + messageState:TSOutgoingMessageStateSentToService + hasCaption:YES], // - [self fakeOutgoingPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], - [self fakeOutgoingPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], - [self fakeOutgoingPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], - [self fakeOutgoingPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], - [self fakeOutgoingPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], - [self fakeOutgoingPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], + [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], + [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], + [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], + [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], + [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], + [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], // + [self fakeOutgoingLargePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingLargePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], // + [self fakeOutgoingTinyPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], + [self fakeOutgoingTinyPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], + // [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], @@ -1103,19 +1219,32 @@ NS_ASSUME_NONNULL_BEGIN [self fakeIncomingMp4Action:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingMp4Action:thread isAttachmentDownloaded:YES hasCaption:YES], // - [self fakeIncomingLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:NO], - [self fakeIncomingLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:NO], - [self fakeIncomingLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:YES], - [self fakeIncomingLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:YES], + [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:NO], + [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:NO], + [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:YES], + [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:YES], + // + [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:NO], + [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], + [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:YES], + [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], // - [self fakeIncomingPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:NO], - [self fakeIncomingPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], - [self fakeIncomingPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:YES], - [self fakeIncomingPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], + [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:NO], + [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:NO], + [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:YES], + [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:YES], + // + [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:NO], + [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], + [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:YES], + [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], // [self fakeIncomingLargePngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingLargePngAction:thread isAttachmentDownloaded:YES hasCaption:YES], // + [self fakeIncomingTinyPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], + [self fakeIncomingTinyPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], + // [self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:NO hasCaption:YES], diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.h b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.h index a16ca58e9..d6ce5dbdb 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.h +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.h @@ -21,9 +21,12 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)gifInstance; + (instancetype)mp3Instance; + (instancetype)mp4Instance; -+ (instancetype)portraitPngInstance; -+ (instancetype)landscapePngInstance; ++ (instancetype)compactPortraitPngInstance; ++ (instancetype)compactLandscapePngInstance; ++ (instancetype)tallPortraitPngInstance; ++ (instancetype)wideLandscapePngInstance; + (instancetype)largePngInstance; ++ (instancetype)tinyPngInstance; + (instancetype)tinyPdfInstance; + (instancetype)largePdfInstance; + (instancetype)missingPngInstance; diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m index 03ce21a75..d16ced0ca 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessagesAssetLoader.m @@ -360,12 +360,12 @@ NS_ASSUME_NONNULL_BEGIN return instance; } -+ (instancetype)portraitPngInstance ++ (instancetype)compactPortraitPngInstance { static DebugUIMessagesAssetLoader *instance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(10, 100) + instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(60, 100) backgroundColor:[UIColor blueColor] textColor:[UIColor whiteColor] label:@"P"]; @@ -373,12 +373,12 @@ NS_ASSUME_NONNULL_BEGIN return instance; } -+ (instancetype)landscapePngInstance ++ (instancetype)compactLandscapePngInstance { static DebugUIMessagesAssetLoader *instance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ - instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(100, 10) + instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(100, 60) backgroundColor:[UIColor greenColor] textColor:[UIColor whiteColor] label:@"L"]; @@ -386,19 +386,58 @@ NS_ASSUME_NONNULL_BEGIN return instance; } ++ (instancetype)tallPortraitPngInstance +{ + static DebugUIMessagesAssetLoader *instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(10, 100) + backgroundColor:[UIColor yellowColor] + textColor:[UIColor whiteColor] + label:@"P"]; + }); + return instance; +} + ++ (instancetype)wideLandscapePngInstance +{ + static DebugUIMessagesAssetLoader *instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(100, 10) + backgroundColor:[UIColor purpleColor] + textColor:[UIColor whiteColor] + label:@"L"]; + }); + return instance; +} + + (instancetype)largePngInstance { static DebugUIMessagesAssetLoader *instance = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(4000, 4000) - backgroundColor:[UIColor redColor] + backgroundColor:[UIColor brownColor] textColor:[UIColor whiteColor] label:@"B"]; }); return instance; } ++ (instancetype)tinyPngInstance +{ + static DebugUIMessagesAssetLoader *instance = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + instance = [DebugUIMessagesAssetLoader fakePngAssetLoaderWithImageSize:CGSizeMake(2, 2) + backgroundColor:[UIColor cyanColor] + textColor:[UIColor whiteColor] + label:@"T"]; + }); + return instance; +} + + (instancetype)tinyPdfInstance { static DebugUIMessagesAssetLoader *instance = nil; diff --git a/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift b/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift index 6791a1a01..9a3907bce 100644 --- a/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift +++ b/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift @@ -5,7 +5,6 @@ import Foundation import JSQMessagesViewController import SignalServiceKit -import SignalMessaging @objc public class OWSMessagesBubbleImageFactory: NSObject {