diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 69f3256a0..b136c856d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -457,7 +457,7 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]); TSMessage *message = (TSMessage *)self.viewItem.interaction; - return [self.bubbleFactory bubbleColorWithMessage:message]; + return [OWSMessagesBubbleColors bubbleColorWithMessage:message]; } - (BOOL)hasBodyMediaWithThumbnail @@ -1202,11 +1202,6 @@ NS_ASSUME_NONNULL_BEGIN return outgoingMessage.messageState == TSOutgoingMessageStateSending; } -- (OWSMessagesBubbleImageFactory *)bubbleFactory -{ - return [OWSMessagesBubbleImageFactory shared]; -} - - (void)prepareForReuse { [NSLayoutConstraint deactivateConstraints:self.viewConstraints]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index 46d793978..f34a207d7 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -104,7 +104,7 @@ NS_ASSUME_NONNULL_BEGIN - (UIColor *)highlightColor { BOOL isQuotingSelf = [NSObject isNullableObject:self.quotedMessage.authorId equalTo:TSAccountManager.localNumber]; - return (isQuotingSelf ? OWSMessagesBubbleImageFactory.bubbleColorOutgoingSent : [UIColor colorWithRGBHex:0xB5B5B5]); + return (isQuotingSelf ? OWSMessagesBubbleColors.bubbleColorOutgoingSent : [UIColor colorWithRGBHex:0xB5B5B5]); } #pragma mark - @@ -120,7 +120,7 @@ NS_ASSUME_NONNULL_BEGIN self.clipsToBounds = YES; self.boundsStrokeView = [OWSBubbleShapeView new]; - self.boundsStrokeView.strokeColor = OWSMessagesBubbleImageFactory.bubbleColorIncoming; + self.boundsStrokeView.strokeColor = OWSMessagesBubbleColors.bubbleColorIncoming; self.boundsStrokeView.strokeThickness = 1.f; [self addSubview:self.boundsStrokeView]; [self.boundsStrokeView autoPinToSuperviewEdges]; diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m index cc87772e4..a9fed819f 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIMessages.m @@ -1326,7 +1326,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingUnsent] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingUnsent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateFailed @@ -1334,7 +1334,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingUnsent] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingUnsent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSending @@ -1342,7 +1342,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Unsent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingUnsent] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingUnsent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSent @@ -1351,7 +1351,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sending' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingSending] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSending] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateFailed @@ -1359,7 +1359,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sending' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingSending] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSending] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSending @@ -1367,7 +1367,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sending' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingSending] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSending] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSent @@ -1376,7 +1376,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingSent] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateFailed @@ -1384,7 +1384,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingSent] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSending @@ -1392,7 +1392,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeOutgoingPngAction:thread actionLabel:@"Fake Outgoing 'Outgoing Sent' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorOutgoingSent] + backgroundColor:[OWSMessagesBubbleColors bubbleColorOutgoingSent] textColor:[UIColor whiteColor] imageLabel:@"W" messageState:TSOutgoingMessageStateSent @@ -1560,7 +1560,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeIncomingPngAction:thread actionLabel:@"Fake Incoming 'Incoming' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorIncoming] + backgroundColor:[OWSMessagesBubbleColors bubbleColorIncoming] textColor:[UIColor whiteColor] imageLabel:@"W" isAttachmentDownloaded:YES @@ -1568,7 +1568,7 @@ NS_ASSUME_NONNULL_BEGIN [self fakeIncomingPngAction:thread actionLabel:@"Fake Incoming 'Incoming' Png" imageSize:CGSizeMake(200.f, 200.f) - backgroundColor:[OWSMessagesBubbleImageFactory bubbleColorIncoming] + backgroundColor:[OWSMessagesBubbleColors bubbleColorIncoming] textColor:[UIColor whiteColor] imageLabel:@"W" isAttachmentDownloaded:NO diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift index b3fb85b30..784d3fd29 100644 --- a/Signal/src/ViewControllers/MessageDetailViewController.swift +++ b/Signal/src/ViewControllers/MessageDetailViewController.swift @@ -20,7 +20,6 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele let uiDatabaseConnection: YapDatabaseConnection - let bubbleFactory = OWSMessagesBubbleImageFactory() var bubbleView: UIView? let mode: MessageMetadataViewMode diff --git a/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift b/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift index 12f743c7a..1421581b4 100644 --- a/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift +++ b/SignalMessaging/utils/OWSMessagesBubbleImageFactory.swift @@ -6,16 +6,14 @@ import Foundation import SignalServiceKit @objc -public class OWSMessagesBubbleImageFactory: NSObject { +public class OWSMessagesBubbleColors: NSObject { - @objc - public static let shared = OWSMessagesBubbleImageFactory() + override private init() { + super.init() + } - // TODO: UIView is a little bit expensive to instantiate. - // Can we cache this value? - private lazy var isRTL: Bool = { - return UIView().isRTL() - }() + @objc + public static let shared = OWSMessagesBubbleColors() @objc public static let bubbleColorIncoming = UIColor.ows_messageBubbleLightGray @@ -27,20 +25,20 @@ public class OWSMessagesBubbleImageFactory: NSObject { public static let bubbleColorOutgoingSending = UIColor.ows_fadedBlue @objc - public static let bubbleColorOutgoingSent = UIColor.ows_materialBlue + public static let bubbleColorOutgoingSent = UIColor.ows_light10 @objc - public func bubbleColor(message: TSMessage) -> UIColor { + public static func bubbleColor(message: TSMessage) -> UIColor { if message is TSIncomingMessage { - return OWSMessagesBubbleImageFactory.bubbleColorIncoming + return OWSMessagesBubbleColors.bubbleColorIncoming } else if let outgoingMessage = message as? TSOutgoingMessage { switch outgoingMessage.messageState { case .failed: - return OWSMessagesBubbleImageFactory.bubbleColorOutgoingUnsent + return OWSMessagesBubbleColors.bubbleColorOutgoingUnsent case .sending: - return OWSMessagesBubbleImageFactory.bubbleColorOutgoingSending + return OWSMessagesBubbleColors.bubbleColorOutgoingSending default: - return OWSMessagesBubbleImageFactory.bubbleColorOutgoingSent + return OWSMessagesBubbleColors.bubbleColorOutgoingSent } } else { owsFail("Unexpected message type: \(message)")