Bubble collapse.

pull/1/head
Matthew Chen 8 years ago
parent e0e8eafb5d
commit 8a74e10208

@ -114,15 +114,15 @@ CG_INLINE CGSize CGSizeCeil(CGSize size)
[self.footerView autoPinEdgeToSuperviewEdge:ALEdgeBottom]; [self.footerView autoPinEdgeToSuperviewEdge:ALEdgeBottom];
[self.footerView autoPinWidthToSuperview]; [self.footerView autoPinWidthToSuperview];
self.bubbleView.userInteractionEnabled = YES; self.contentView.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = UITapGestureRecognizer *tap =
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)]; [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapGesture:)];
[self.bubbleView addGestureRecognizer:tap]; [self.contentView addGestureRecognizer:tap];
UILongPressGestureRecognizer *longPress = UILongPressGestureRecognizer *longPress =
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)]; [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)];
[self.bubbleView addGestureRecognizer:longPress]; [self.contentView addGestureRecognizer:longPress];
PanDirectionGestureRecognizer *panGesture = [[PanDirectionGestureRecognizer alloc] PanDirectionGestureRecognizer *panGesture = [[PanDirectionGestureRecognizer alloc]
initWithDirection:(self.isRTL ? PanDirectionLeft : PanDirectionRight)target:self initWithDirection:(self.isRTL ? PanDirectionLeft : PanDirectionRight)target:self

@ -1106,35 +1106,66 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Fake Media #pragma mark - Fake Media
+ (NSArray<DebugUIMessagesAction *> *)allFakeMediaActions:(TSThread *)thread + (NSArray<DebugUIMessagesAction *> *)allFakeMediaActions:(TSThread *)thread includeLabels:(BOOL)includeLabels
{ {
OWSAssert(thread); OWSAssert(thread);
NSArray<DebugUIMessagesAction *> *actions = @[ NSMutableArray<DebugUIMessagesAction *> *actions = [NSMutableArray new];
// Outgoing
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Jpeg ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
[self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], [self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES],
[self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO],
[self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], [self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES],
[self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
[self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], [self fakeOutgoingJpegAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES],
]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Gif ⚠️"]];
}
[actions addObjectsFromArray:@[
// Don't bother with multiple GIF states. // Don't bother with multiple GIF states.
[self fakeOutgoingGifAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingGifAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Mp3 ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], [self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES],
[self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO],
[self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
[self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], [self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES],
[self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
[self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], [self fakeOutgoingMp3Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Mp4 ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO],
[self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES],
[self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
[self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES],
[self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
[self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], [self fakeOutgoingMp4Action:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Compact Landscape Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingCompactLandscapePngAction:thread [self fakeOutgoingCompactLandscapePngAction:thread
messageState:TSOutgoingMessageStateAttemptingOut messageState:TSOutgoingMessageStateAttemptingOut
hasCaption:NO], hasCaption:NO],
@ -1149,7 +1180,13 @@ NS_ASSUME_NONNULL_BEGIN
[self fakeOutgoingCompactLandscapePngAction:thread [self fakeOutgoingCompactLandscapePngAction:thread
messageState:TSOutgoingMessageStateSentToService messageState:TSOutgoingMessageStateSentToService
hasCaption:YES], hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Compact Portrait Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingCompactPortraitPngAction:thread [self fakeOutgoingCompactPortraitPngAction:thread
messageState:TSOutgoingMessageStateAttemptingOut messageState:TSOutgoingMessageStateAttemptingOut
hasCaption:NO], hasCaption:NO],
@ -1164,7 +1201,13 @@ NS_ASSUME_NONNULL_BEGIN
[self fakeOutgoingCompactPortraitPngAction:thread [self fakeOutgoingCompactPortraitPngAction:thread
messageState:TSOutgoingMessageStateSentToService messageState:TSOutgoingMessageStateSentToService
hasCaption:YES], hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Wide Landscape Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingWideLandscapePngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingWideLandscapePngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO],
[self fakeOutgoingWideLandscapePngAction:thread [self fakeOutgoingWideLandscapePngAction:thread
messageState:TSOutgoingMessageStateAttemptingOut messageState:TSOutgoingMessageStateAttemptingOut
@ -1175,97 +1218,211 @@ NS_ASSUME_NONNULL_BEGIN
[self fakeOutgoingWideLandscapePngAction:thread [self fakeOutgoingWideLandscapePngAction:thread
messageState:TSOutgoingMessageStateSentToService messageState:TSOutgoingMessageStateSentToService
hasCaption:YES], hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Tall Portrait Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO],
[self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES],
[self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
[self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES],
[self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
[self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], [self fakeOutgoingTallPortraitPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Large Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingLargePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingLargePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
[self fakeOutgoingLargePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], [self fakeOutgoingLargePngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Tiny Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingTinyPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingTinyPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
[self fakeOutgoingTinyPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], [self fakeOutgoingTinyPngAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Tiny Pdf ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO],
[self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:YES],
[self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
[self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:YES],
[self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
[self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES], [self fakeOutgoingTinyPdfAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Large Pdf ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingLargePdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingLargePdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Missing Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingMissingPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingMissingPngAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Large Pdf ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingMissingPdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingMissingPdfAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
// ]];
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Oversize Text ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeOutgoingOversizeTextAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO], [self fakeOutgoingOversizeTextAction:thread messageState:TSOutgoingMessageStateUnsent hasCaption:NO],
[self fakeOutgoingOversizeTextAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO], [self fakeOutgoingOversizeTextAction:thread messageState:TSOutgoingMessageStateAttemptingOut hasCaption:NO],
[self fakeOutgoingOversizeTextAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO], [self fakeOutgoingOversizeTextAction:thread messageState:TSOutgoingMessageStateSentToService hasCaption:NO],
]];
// Incoming // Incoming
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Jpg ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingJpegAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingJpegAction:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingJpegAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingJpegAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingJpegAction:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingJpegAction:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingJpegAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingJpegAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// Don't bother with multiple GIF states. ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Gif ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingGifAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingGifAction:thread isAttachmentDownloaded:YES hasCaption:NO],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Mp3 ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingMp3Action:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingMp3Action:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingMp3Action:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingMp3Action:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingMp3Action:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingMp3Action:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingMp3Action:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingMp3Action:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Mp4 ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingMp4Action:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingMp4Action:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingMp4Action:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingMp4Action:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingMp4Action:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingMp4Action:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingMp4Action:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingMp4Action:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions
addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Compact Landscape Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingCompactLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions
addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Compact Portrait Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingCompactPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions
addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Wide Landscape Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingWideLandscapePngAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions
addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Tall Portrait Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingTallPortraitPngAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Large Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingLargePngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingLargePngAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingLargePngAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingLargePngAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Tiny Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingTinyPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingTinyPngAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingTinyPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingTinyPngAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Tiny Pdf ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:NO hasCaption:YES], [self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:NO hasCaption:YES],
[self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingTinyPdfAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Large Pdf ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingLargePdfAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingLargePdfAction:thread isAttachmentDownloaded:YES hasCaption:NO],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Missing Png ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingMissingPngAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingMissingPngAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingMissingPngAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingMissingPngAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Missing Pdf ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingMissingPdfAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingMissingPdfAction:thread isAttachmentDownloaded:YES hasCaption:NO],
[self fakeIncomingMissingPdfAction:thread isAttachmentDownloaded:YES hasCaption:YES], [self fakeIncomingMissingPdfAction:thread isAttachmentDownloaded:YES hasCaption:YES],
// ]];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Oversize Text ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeIncomingOversizeTextAction:thread isAttachmentDownloaded:NO hasCaption:NO], [self fakeIncomingOversizeTextAction:thread isAttachmentDownloaded:NO hasCaption:NO],
[self fakeIncomingOversizeTextAction:thread isAttachmentDownloaded:YES hasCaption:NO], [self fakeIncomingOversizeTextAction:thread isAttachmentDownloaded:YES hasCaption:NO],
]; ]];
return actions; return actions;
} }
@ -1274,7 +1431,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(thread); OWSAssert(thread);
return [DebugUIMessagesGroupAction allGroupActionWithLabel:@"Fake All Media" return [DebugUIMessagesGroupAction allGroupActionWithLabel:@"Fake All Media"
subactions:[self allFakeMediaActions:thread]]; subactions:[self allFakeMediaActions:thread includeLabels:YES]];
} }
+ (DebugUIMessagesAction *)fakeRandomMediaAction:(TSThread *)thread + (DebugUIMessagesAction *)fakeRandomMediaAction:(TSThread *)thread
@ -1282,7 +1439,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(thread); OWSAssert(thread);
return [DebugUIMessagesGroupAction randomGroupActionWithLabel:@"Fake Random Media" return [DebugUIMessagesGroupAction randomGroupActionWithLabel:@"Fake Random Media"
subactions:[self allFakeMediaActions:thread]]; subactions:[self allFakeMediaActions:thread includeLabels:NO]];
} }
#pragma mark - Send Text Messages #pragma mark - Send Text Messages
@ -1439,19 +1596,35 @@ NS_ASSUME_NONNULL_BEGIN
}]; }];
} }
+ (NSArray<DebugUIMessagesAction *> *)allFakeTextActions:(TSThread *)thread + (NSArray<DebugUIMessagesAction *> *)allFakeTextActions:(TSThread *)thread includeLabels:(BOOL)includeLabels
{ {
OWSAssert(thread); OWSAssert(thread);
NSArray<DebugUIMessagesAction *> *actions = @[ NSArray<NSString *> *messageBodies = @[
[self fakeShortIncomingTextMessageAction:thread], @"Hi",
[self fakeIncomingTextMessageAction:thread text:@"Hi"], @"1️⃣",
[self fakeIncomingTextMessageAction:thread text:@"1️⃣"], @"1️⃣2️⃣",
[self fakeIncomingTextMessageAction:thread text:@"1️⃣2️⃣"], @"1️⃣2️⃣3️⃣",
[self fakeIncomingTextMessageAction:thread text:@"1️⃣2️⃣3️⃣"], @"落",
[self fakeIncomingTextMessageAction:thread text:@"落"], @"﷽",
[self fakeIncomingTextMessageAction:thread text:@"﷽"], ];
NSMutableArray<DebugUIMessagesAction *> *actions = [NSMutableArray new];
if (includeLabels) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:@"⚠️ Incoming Message Bodies ⚠️"]];
}
[actions addObject:[self fakeShortIncomingTextMessageAction:thread]];
for (NSString *messageBody in messageBodies) {
[actions addObject:[self fakeIncomingTextMessageAction:thread text:messageBody]];
}
if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService
text:@"⚠️ Outgoing Statuses ⚠️"]];
}
[actions addObjectsFromArray:@[
[self fakeShortOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateUnsent], [self fakeShortOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateUnsent],
[self fakeShortOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateAttemptingOut], [self fakeShortOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateAttemptingOut],
[self fakeShortOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateSentToService], [self fakeShortOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateSentToService],
@ -1463,18 +1636,18 @@ NS_ASSUME_NONNULL_BEGIN
messageState:TSOutgoingMessageStateSentToService messageState:TSOutgoingMessageStateSentToService
isDelivered:YES isDelivered:YES
isRead:YES], isRead:YES],
[self fakeOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateSentToService text:@"Hi"], ]];
[self fakeOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateSentToService text:@"1️⃣"],
[self fakeOutgoingTextMessageAction:thread if (includeLabels) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService messageState:TSOutgoingMessageStateSentToService
text:@"1️⃣2️⃣"], text:@"⚠️ Outgoing Message Bodies ⚠️"]];
[self fakeOutgoingTextMessageAction:thread }
for (NSString *messageBody in messageBodies) {
[actions addObject:[self fakeOutgoingTextMessageAction:thread
messageState:TSOutgoingMessageStateSentToService messageState:TSOutgoingMessageStateSentToService
text:@"1️⃣2️⃣3️⃣"], text:messageBody]];
[self fakeOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateSentToService text:@"1️⃣"], }
[self fakeOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateSentToService text:@"落"],
[self fakeOutgoingTextMessageAction:thread messageState:TSOutgoingMessageStateSentToService text:@"﷽"],
];
return actions; return actions;
} }
@ -1483,7 +1656,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(thread); OWSAssert(thread);
return [DebugUIMessagesGroupAction allGroupActionWithLabel:@"Fake All Text" return [DebugUIMessagesGroupAction allGroupActionWithLabel:@"Fake All Text"
subactions:[self allFakeTextActions:thread]]; subactions:[self allFakeTextActions:thread includeLabels:YES]];
} }
+ (DebugUIMessagesAction *)fakeRandomTextAction:(TSThread *)thread + (DebugUIMessagesAction *)fakeRandomTextAction:(TSThread *)thread
@ -1491,18 +1664,18 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(thread); OWSAssert(thread);
return [DebugUIMessagesGroupAction randomGroupActionWithLabel:@"Fake Random Text" return [DebugUIMessagesGroupAction randomGroupActionWithLabel:@"Fake Random Text"
subactions:[self allFakeTextActions:thread]]; subactions:[self allFakeTextActions:thread includeLabels:NO]];
} }
#pragma mark - Exemplary #pragma mark - Exemplary
+ (NSArray<DebugUIMessagesAction *> *)allExemplaryActions:(TSThread *)thread + (NSArray<DebugUIMessagesAction *> *)allExemplaryActions:(TSThread *)thread includeLabels:(BOOL)includeLabels
{ {
OWSAssert(thread); OWSAssert(thread);
NSMutableArray<DebugUIMessagesAction *> *actions = [NSMutableArray new]; NSMutableArray<DebugUIMessagesAction *> *actions = [NSMutableArray new];
[actions addObjectsFromArray:[self allFakeMediaActions:thread]]; [actions addObjectsFromArray:[self allFakeMediaActions:thread includeLabels:includeLabels]];
[actions addObjectsFromArray:[self allFakeTextActions:thread]]; [actions addObjectsFromArray:[self allFakeTextActions:thread includeLabels:includeLabels]];
return actions; return actions;
} }
@ -1511,7 +1684,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(thread); OWSAssert(thread);
return [DebugUIMessagesGroupAction allGroupActionWithLabel:@"Exemplary Permutations" return [DebugUIMessagesGroupAction allGroupActionWithLabel:@"Exemplary Permutations"
subactions:[self allExemplaryActions:thread]]; subactions:[self allExemplaryActions:thread includeLabels:YES]];
} }
+ (void)selectExemplaryAction:(TSThread *)thread + (void)selectExemplaryAction:(TSThread *)thread
@ -1520,7 +1693,7 @@ NS_ASSUME_NONNULL_BEGIN
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Select Action" UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Select Action"
message:nil message:nil
preferredStyle:UIAlertControllerStyleActionSheet]; preferredStyle:UIAlertControllerStyleActionSheet];
for (DebugUIMessagesAction *action in [self allExemplaryActions:thread]) { for (DebugUIMessagesAction *action in [self allExemplaryActions:thread includeLabels:NO]) {
[alert addAction:[UIAlertAction actionWithTitle:action.label [alert addAction:[UIAlertAction actionWithTitle:action.label
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *ignore) { handler:^(UIAlertAction *ignore) {

@ -122,6 +122,7 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
@autoreleasepool {
NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:@"png"]; NSString *filePath = [OWSFileSystem temporaryFilePathWithFileExtension:@"png"];
UIImage *image = UIImage *image =
[self createRandomPngWithSize:imageSize backgroundColor:backgroundColor textColor:textColor label:label]; [self createRandomPngWithSize:imageSize backgroundColor:backgroundColor textColor:textColor label:label];
@ -130,6 +131,7 @@ NS_ASSUME_NONNULL_BEGIN
self.filePath = filePath; self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]); OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
success(); success();
}
} }
- (nullable UIImage *)createRandomPngWithSize:(CGSize)imageSize - (nullable UIImage *)createRandomPngWithSize:(CGSize)imageSize
@ -142,6 +144,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(textColor); OWSAssert(textColor);
OWSAssert(label.length > 0); OWSAssert(label.length > 0);
@autoreleasepool {
CGRect frame = CGRectZero; CGRect frame = CGRectZero;
frame.size = imageSize; frame.size = imageSize;
CGFloat smallDimension = MIN(imageSize.width, imageSize.height); CGFloat smallDimension = MIN(imageSize.width, imageSize.height);
@ -167,6 +170,7 @@ NS_ASSUME_NONNULL_BEGIN
UIGraphicsEndImageContext(); UIGraphicsEndImageContext();
return image; return image;
}
} }
#pragma mark - #pragma mark -
@ -203,6 +207,7 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
@autoreleasepool {
NSString *fileExtension = [MIMETypeUtil fileExtensionForMIMEType:self.mimeType]; NSString *fileExtension = [MIMETypeUtil fileExtensionForMIMEType:self.mimeType];
OWSAssert(fileExtension.length > 0); OWSAssert(fileExtension.length > 0);
NSData *data = [Randomness generateRandomBytes:(int)dataLength]; NSData *data = [Randomness generateRandomBytes:(int)dataLength];
@ -212,6 +217,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(didWrite); OWSAssert(didWrite);
self.filePath = filePath; self.filePath = filePath;
OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]); OWSAssert([NSFileManager.defaultManager fileExistsAtPath:filePath]);
}
success(); success();
} }
@ -453,7 +459,8 @@ NS_ASSUME_NONNULL_BEGIN
static DebugUIMessagesAssetLoader *instance = nil; static DebugUIMessagesAssetLoader *instance = nil;
static dispatch_once_t onceToken; static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
instance = [DebugUIMessagesAssetLoader fakeRandomAssetLoaderWithLength:256 mimeType:@"application/pdf"]; instance =
[DebugUIMessagesAssetLoader fakeRandomAssetLoaderWithLength:4 * 1024 * 1024 mimeType:@"application/pdf"];
}); });
return instance; return instance;
} }

Loading…
Cancel
Save