From c6a3772a5e799fff5695cef6217a24c5c2dc45b2 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Mon, 25 Feb 2019 09:20:06 -0700 Subject: [PATCH] clearer constant names --- .../ColorPickerViewController.swift | 2 +- .../Cells/OWSMessageBubbleView.m | 22 +++++----- .../ConversationView/ConversationViewItem.h | 4 +- .../ConversationView/ConversationViewItem.m | 44 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Signal/src/ViewControllers/ColorPickerViewController.swift b/Signal/src/ViewControllers/ColorPickerViewController.swift index c72f2a14c..7c89d5b5f 100644 --- a/Signal/src/ViewControllers/ColorPickerViewController.swift +++ b/Signal/src/ViewControllers/ColorPickerViewController.swift @@ -325,7 +325,7 @@ private class MockConversationViewItem: NSObject, ConversationViewItem { var lastAudioMessageView: OWSAudioMessageView? var audioDurationSeconds: CGFloat = 0 var audioProgressSeconds: CGFloat = 0 - var messageCellType: OWSMessageCellType = .textMessage + var messageCellType: OWSMessageCellType = .textOnlyMessage var displayableBodyText: DisplayableText? var attachmentStream: TSAttachmentStream? var attachmentPointer: TSAttachmentPointer? diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index ad71ee1ab..72ce21c1b 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -273,7 +273,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes UIView *_Nullable bodyMediaView = nil; switch (self.cellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: break; case OWSMessageCellType_Audio: OWSAssertDebug(self.viewItem.attachmentStream); @@ -288,7 +288,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes case OWSMessageCellType_ContactShare: bodyMediaView = [self loadViewForContactShare]; break; - case OWSMessageCellType_MediaAlbum: + case OWSMessageCellType_MediaMessage: bodyMediaView = [self loadViewForMediaAlbum]; break; } @@ -569,13 +569,13 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes { switch (self.cellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_Audio: case OWSMessageCellType_GenericAttachment: case OWSMessageCellType_DownloadingAttachment: case OWSMessageCellType_ContactShare: return NO; - case OWSMessageCellType_MediaAlbum: + case OWSMessageCellType_MediaMessage: return YES; } } @@ -583,13 +583,13 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes - (BOOL)hasBodyMediaView { switch (self.cellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: return NO; case OWSMessageCellType_Audio: case OWSMessageCellType_GenericAttachment: case OWSMessageCellType_DownloadingAttachment: case OWSMessageCellType_ContactShare: - case OWSMessageCellType_MediaAlbum: + case OWSMessageCellType_MediaMessage: return YES; } } @@ -597,7 +597,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes - (BOOL)hasFullWidthMediaView { return (self.hasBodyMediaWithThumbnail || self.cellType == OWSMessageCellType_ContactShare - || self.cellType == OWSMessageCellType_MediaAlbum); + || self.cellType == OWSMessageCellType_MediaMessage); } - (BOOL)canFooterOverlayMedia @@ -975,7 +975,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes CGSize result = CGSizeZero; switch (self.cellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: { + case OWSMessageCellType_TextOnlyMessage: { return nil; } case OWSMessageCellType_Audio: @@ -997,7 +997,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes result = CGSizeMake(maxMessageWidth, [OWSContactShareView bubbleHeight]); break; - case OWSMessageCellType_MediaAlbum: + case OWSMessageCellType_MediaMessage: result = [OWSMediaAlbumCellView layoutSizeForMaxMessageWidth:maxMessageWidth items:self.viewItem.mediaAlbumItems]; @@ -1370,7 +1370,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes switch (self.cellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: break; case OWSMessageCellType_Audio: OWSAssertDebug(self.viewItem.attachmentStream); @@ -1394,7 +1394,7 @@ const UIDataDetectorTypes kOWSAllowedDataDetectorTypes case OWSMessageCellType_ContactShare: [self.delegate didTapContactShareViewItem:self.viewItem]; break; - case OWSMessageCellType_MediaAlbum: { + case OWSMessageCellType_MediaMessage: { OWSAssertDebug(self.bodyMediaView); OWSAssertDebug(self.viewItem.mediaAlbumItems.count > 0); diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h index 4a04b5133..3ec982aeb 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.h @@ -9,12 +9,12 @@ NS_ASSUME_NONNULL_BEGIN typedef NS_ENUM(NSInteger, OWSMessageCellType) { OWSMessageCellType_Unknown, - OWSMessageCellType_TextMessage, + OWSMessageCellType_TextOnlyMessage, OWSMessageCellType_Audio, OWSMessageCellType_GenericAttachment, OWSMessageCellType_DownloadingAttachment, OWSMessageCellType_ContactShare, - OWSMessageCellType_MediaAlbum, + OWSMessageCellType_MediaMessage, }; NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType); diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m index b1d5a3f04..33424a478 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewItem.m @@ -20,8 +20,8 @@ NS_ASSUME_NONNULL_BEGIN NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { switch (cellType) { - case OWSMessageCellType_TextMessage: - return @"OWSMessageCellType_TextMessage"; + case OWSMessageCellType_TextOnlyMessage: + return @"OWSMessageCellType_TextOnlyMessage"; case OWSMessageCellType_Audio: return @"OWSMessageCellType_Audio"; case OWSMessageCellType_GenericAttachment: @@ -32,8 +32,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) return @"OWSMessageCellType_Unknown"; case OWSMessageCellType_ContactShare: return @"OWSMessageCellType_ContactShare"; - case OWSMessageCellType_MediaAlbum: - return @"OWSMessageCellType_MediaAlbum"; + case OWSMessageCellType_MediaMessage: + return @"OWSMessageCellType_MediaMessage"; } } @@ -615,7 +615,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) } self.mediaAlbumItems = mediaAlbumItems; - self.messageCellType = OWSMessageCellType_MediaAlbum; + self.messageCellType = OWSMessageCellType_MediaMessage; return; } @@ -650,7 +650,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) OWSAssertDebug(message.attachmentIds.count == 0 || (message.attachmentIds.count == 1 && [message oversizeTextAttachmentWithTransaction:transaction] != nil)); - self.messageCellType = OWSMessageCellType_TextMessage; + self.messageCellType = OWSMessageCellType_TextOnlyMessage; } OWSAssertDebug(self.displayableBodyText); } @@ -681,7 +681,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) // Messages of unknown type (including messages with missing attachments) // are rendered like empty text messages, but without any interactivity. OWSLogWarn(@"Treating unknown message as empty text message: %@ %llu", message.class, message.timestamp); - self.messageCellType = OWSMessageCellType_TextMessage; + self.messageCellType = OWSMessageCellType_TextOnlyMessage; self.displayableBodyText = [[DisplayableText alloc] initWithFullText:@"" displayText:@"" isTextTruncated:NO]; } } @@ -843,9 +843,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) - (void)copyTextAction { switch (self.messageCellType) { - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_Audio: - case OWSMessageCellType_MediaAlbum: + case OWSMessageCellType_MediaMessage: case OWSMessageCellType_GenericAttachment: { OWSAssertDebug(self.displayableBodyText); [UIPasteboard.generalPasteboard setString:self.displayableBodyText.fullText]; @@ -871,7 +871,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { switch (self.messageCellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_ContactShare: { OWSFailDebug(@"No media to copy"); break; @@ -885,7 +885,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) OWSFailDebug(@"Can't copy not-yet-downloaded attachment"); break; } - case OWSMessageCellType_MediaAlbum: { + case OWSMessageCellType_MediaMessage: { if (self.mediaAlbumItems.count == 1) { ConversationMediaAlbumItem *mediaAlbumItem = self.mediaAlbumItems.firstObject; if (mediaAlbumItem.attachmentStream && mediaAlbumItem.attachmentStream.isValidVisualMedia) { @@ -921,7 +921,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { switch (self.messageCellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_ContactShare: OWSFailDebug(@"No media to share."); break; @@ -933,7 +933,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) OWSFailDebug(@"Can't share not-yet-downloaded attachment"); break; } - case OWSMessageCellType_MediaAlbum: { + case OWSMessageCellType_MediaMessage: { // TODO: We need a "canShareMediaAction" method. OWSAssertDebug(self.mediaAlbumItems); NSMutableArray *attachmentStreams = [NSMutableArray new]; @@ -956,14 +956,14 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { switch (self.messageCellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_ContactShare: return NO; case OWSMessageCellType_Audio: return NO; case OWSMessageCellType_GenericAttachment: case OWSMessageCellType_DownloadingAttachment: - case OWSMessageCellType_MediaAlbum: { + case OWSMessageCellType_MediaMessage: { if (self.mediaAlbumItems.count == 1) { ConversationMediaAlbumItem *mediaAlbumItem = self.mediaAlbumItems.firstObject; if (mediaAlbumItem.attachmentStream && mediaAlbumItem.attachmentStream.isValidVisualMedia) { @@ -979,7 +979,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { switch (self.messageCellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_ContactShare: return NO; case OWSMessageCellType_Audio: @@ -987,7 +987,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) case OWSMessageCellType_GenericAttachment: case OWSMessageCellType_DownloadingAttachment: return NO; - case OWSMessageCellType_MediaAlbum: { + case OWSMessageCellType_MediaMessage: { for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) { if (!mediaAlbumItem.attachmentStream) { continue; @@ -1014,7 +1014,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { switch (self.messageCellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_ContactShare: OWSFailDebug(@"Cannot save text data."); break; @@ -1028,7 +1028,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) OWSFailDebug(@"Can't save not-yet-downloaded attachment"); break; } - case OWSMessageCellType_MediaAlbum: { + case OWSMessageCellType_MediaMessage: { [self saveMediaAlbumItems]; break; } @@ -1096,7 +1096,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) { switch (self.messageCellType) { case OWSMessageCellType_Unknown: - case OWSMessageCellType_TextMessage: + case OWSMessageCellType_TextOnlyMessage: case OWSMessageCellType_ContactShare: return NO; case OWSMessageCellType_Audio: @@ -1105,14 +1105,14 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType) case OWSMessageCellType_DownloadingAttachment: { return NO; } - case OWSMessageCellType_MediaAlbum: + case OWSMessageCellType_MediaMessage: return self.firstValidAlbumAttachment != nil; } } - (BOOL)mediaAlbumHasFailedAttachment { - OWSAssertDebug(self.messageCellType == OWSMessageCellType_MediaAlbum); + OWSAssertDebug(self.messageCellType == OWSMessageCellType_MediaMessage); OWSAssertDebug(self.mediaAlbumItems.count > 0); for (ConversationMediaAlbumItem *mediaAlbumItem in self.mediaAlbumItems) {