Respond to CR.

// FREEBIE
This commit is contained in:
Matthew Chen 2017-10-16 21:05:29 -07:00
parent 01691b7ade
commit 032ec59d1c
12 changed files with 122 additions and 210 deletions

View File

@ -92,9 +92,7 @@
34D1F0AA1F867BFC0066283D /* JSQMessagesCollectionViewCell+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0991F867BFC0066283D /* JSQMessagesCollectionViewCell+OWS.m */; }; 34D1F0AA1F867BFC0066283D /* JSQMessagesCollectionViewCell+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0991F867BFC0066283D /* JSQMessagesCollectionViewCell+OWS.m */; };
34D1F0AB1F867BFC0066283D /* OWSContactOffersCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F09B1F867BFC0066283D /* OWSContactOffersCell.m */; }; 34D1F0AB1F867BFC0066283D /* OWSContactOffersCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F09B1F867BFC0066283D /* OWSContactOffersCell.m */; };
34D1F0AC1F867BFC0066283D /* OWSExpirationTimerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F09E1F867BFC0066283D /* OWSExpirationTimerView.m */; }; 34D1F0AC1F867BFC0066283D /* OWSExpirationTimerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F09E1F867BFC0066283D /* OWSExpirationTimerView.m */; };
34D1F0AD1F867BFC0066283D /* OWSIncomingMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A01F867BFC0066283D /* OWSIncomingMessageCell.m */; };
34D1F0AE1F867BFC0066283D /* OWSMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A21F867BFC0066283D /* OWSMessageCell.m */; }; 34D1F0AE1F867BFC0066283D /* OWSMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A21F867BFC0066283D /* OWSMessageCell.m */; };
34D1F0AF1F867BFC0066283D /* OWSOutgoingMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A41F867BFC0066283D /* OWSOutgoingMessageCell.m */; };
34D1F0B01F867BFC0066283D /* OWSSystemMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A61F867BFC0066283D /* OWSSystemMessageCell.m */; }; 34D1F0B01F867BFC0066283D /* OWSSystemMessageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A61F867BFC0066283D /* OWSSystemMessageCell.m */; };
34D1F0B11F867BFC0066283D /* OWSUnreadIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A81F867BFC0066283D /* OWSUnreadIndicatorCell.m */; }; 34D1F0B11F867BFC0066283D /* OWSUnreadIndicatorCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0A81F867BFC0066283D /* OWSUnreadIndicatorCell.m */; };
34D1F0B41F86D31D0066283D /* ConversationCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0B31F86D31D0066283D /* ConversationCollectionView.m */; }; 34D1F0B41F86D31D0066283D /* ConversationCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0B31F86D31D0066283D /* ConversationCollectionView.m */; };
@ -157,7 +155,6 @@
452EA09E1EA7ABE00078744B /* AttachmentPointerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */; }; 452EA09E1EA7ABE00078744B /* AttachmentPointerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */; };
452ECA4D1E087E7200E2F016 /* MessageFetcherJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */; }; 452ECA4D1E087E7200E2F016 /* MessageFetcherJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */; };
452ECA4E1E087E7200E2F016 /* MessageFetcherJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */; }; 452ECA4E1E087E7200E2F016 /* MessageFetcherJob.swift in Sources */ = {isa = PBXBuildFile; fileRef = 452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */; };
4531C9C41DD8E6D800F08304 /* JSQMessagesCollectionViewCell+OWS.m in Sources */ = {isa = PBXBuildFile; fileRef = 4531C9C31DD8E6D800F08304 /* JSQMessagesCollectionViewCell+OWS.m */; };
45360B8D1F9521F800FA666C /* Searcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45360B8C1F9521F800FA666C /* Searcher.swift */; }; 45360B8D1F9521F800FA666C /* Searcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45360B8C1F9521F800FA666C /* Searcher.swift */; };
45360B8E1F9521F800FA666C /* Searcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45360B8C1F9521F800FA666C /* Searcher.swift */; }; 45360B8E1F9521F800FA666C /* Searcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45360B8C1F9521F800FA666C /* Searcher.swift */; };
45360B901F9527DA00FA666C /* SearcherTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45360B8F1F9527DA00FA666C /* SearcherTest.swift */; }; 45360B901F9527DA00FA666C /* SearcherTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45360B8F1F9527DA00FA666C /* SearcherTest.swift */; };
@ -551,12 +548,8 @@
34D1F09C1F867BFC0066283D /* OWSExpirableMessageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSExpirableMessageView.h; sourceTree = "<group>"; }; 34D1F09C1F867BFC0066283D /* OWSExpirableMessageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSExpirableMessageView.h; sourceTree = "<group>"; };
34D1F09D1F867BFC0066283D /* OWSExpirationTimerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSExpirationTimerView.h; sourceTree = "<group>"; }; 34D1F09D1F867BFC0066283D /* OWSExpirationTimerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSExpirationTimerView.h; sourceTree = "<group>"; };
34D1F09E1F867BFC0066283D /* OWSExpirationTimerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSExpirationTimerView.m; sourceTree = "<group>"; }; 34D1F09E1F867BFC0066283D /* OWSExpirationTimerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSExpirationTimerView.m; sourceTree = "<group>"; };
34D1F09F1F867BFC0066283D /* OWSIncomingMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSIncomingMessageCell.h; sourceTree = "<group>"; };
34D1F0A01F867BFC0066283D /* OWSIncomingMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSIncomingMessageCell.m; sourceTree = "<group>"; };
34D1F0A11F867BFC0066283D /* OWSMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageCell.h; sourceTree = "<group>"; }; 34D1F0A11F867BFC0066283D /* OWSMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSMessageCell.h; sourceTree = "<group>"; };
34D1F0A21F867BFC0066283D /* OWSMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSMessageCell.m; sourceTree = "<group>"; }; 34D1F0A21F867BFC0066283D /* OWSMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSMessageCell.m; sourceTree = "<group>"; };
34D1F0A31F867BFC0066283D /* OWSOutgoingMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSOutgoingMessageCell.h; sourceTree = "<group>"; };
34D1F0A41F867BFC0066283D /* OWSOutgoingMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSOutgoingMessageCell.m; sourceTree = "<group>"; };
34D1F0A51F867BFC0066283D /* OWSSystemMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSSystemMessageCell.h; sourceTree = "<group>"; }; 34D1F0A51F867BFC0066283D /* OWSSystemMessageCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSSystemMessageCell.h; sourceTree = "<group>"; };
34D1F0A61F867BFC0066283D /* OWSSystemMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSSystemMessageCell.m; sourceTree = "<group>"; }; 34D1F0A61F867BFC0066283D /* OWSSystemMessageCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSSystemMessageCell.m; sourceTree = "<group>"; };
34D1F0A71F867BFC0066283D /* OWSUnreadIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSUnreadIndicatorCell.h; sourceTree = "<group>"; }; 34D1F0A71F867BFC0066283D /* OWSUnreadIndicatorCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSUnreadIndicatorCell.h; sourceTree = "<group>"; };
@ -630,8 +623,6 @@
452D1EE71DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MesssagesBubblesSizeCalculatorTest.swift; path = Models/MesssagesBubblesSizeCalculatorTest.swift; sourceTree = "<group>"; }; 452D1EE71DCA90D100A57EC4 /* MesssagesBubblesSizeCalculatorTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MesssagesBubblesSizeCalculatorTest.swift; path = Models/MesssagesBubblesSizeCalculatorTest.swift; sourceTree = "<group>"; };
452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentPointerView.swift; sourceTree = "<group>"; }; 452EA09D1EA7ABE00078744B /* AttachmentPointerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AttachmentPointerView.swift; sourceTree = "<group>"; };
452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageFetcherJob.swift; path = Jobs/MessageFetcherJob.swift; sourceTree = "<group>"; }; 452ECA4C1E087E7200E2F016 /* MessageFetcherJob.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MessageFetcherJob.swift; path = Jobs/MessageFetcherJob.swift; sourceTree = "<group>"; };
4531C9C21DD8E6D800F08304 /* JSQMessagesCollectionViewCell+OWS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSQMessagesCollectionViewCell+OWS.h"; sourceTree = "<group>"; };
4531C9C31DD8E6D800F08304 /* JSQMessagesCollectionViewCell+OWS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSQMessagesCollectionViewCell+OWS.m"; sourceTree = "<group>"; };
45360B8C1F9521F800FA666C /* Searcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Searcher.swift; sourceTree = "<group>"; }; 45360B8C1F9521F800FA666C /* Searcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Searcher.swift; sourceTree = "<group>"; };
45360B8F1F9527DA00FA666C /* SearcherTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearcherTest.swift; sourceTree = "<group>"; }; 45360B8F1F9527DA00FA666C /* SearcherTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearcherTest.swift; sourceTree = "<group>"; };
45387B021E36D650005D00B3 /* OWS102MoveLoggingPreferenceToUserDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWS102MoveLoggingPreferenceToUserDefaults.h; path = Migrations/OWS102MoveLoggingPreferenceToUserDefaults.h; sourceTree = "<group>"; }; 45387B021E36D650005D00B3 /* OWS102MoveLoggingPreferenceToUserDefaults.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OWS102MoveLoggingPreferenceToUserDefaults.h; path = Migrations/OWS102MoveLoggingPreferenceToUserDefaults.h; sourceTree = "<group>"; };
@ -1165,12 +1156,8 @@
34D1F09E1F867BFC0066283D /* OWSExpirationTimerView.m */, 34D1F09E1F867BFC0066283D /* OWSExpirationTimerView.m */,
34D1F0B51F87F8850066283D /* OWSGenericAttachmentView.h */, 34D1F0B51F87F8850066283D /* OWSGenericAttachmentView.h */,
34D1F0B61F87F8850066283D /* OWSGenericAttachmentView.m */, 34D1F0B61F87F8850066283D /* OWSGenericAttachmentView.m */,
34D1F09F1F867BFC0066283D /* OWSIncomingMessageCell.h */,
34D1F0A01F867BFC0066283D /* OWSIncomingMessageCell.m */,
34D1F0A11F867BFC0066283D /* OWSMessageCell.h */, 34D1F0A11F867BFC0066283D /* OWSMessageCell.h */,
34D1F0A21F867BFC0066283D /* OWSMessageCell.m */, 34D1F0A21F867BFC0066283D /* OWSMessageCell.m */,
34D1F0A31F867BFC0066283D /* OWSOutgoingMessageCell.h */,
34D1F0A41F867BFC0066283D /* OWSOutgoingMessageCell.m */,
34D1F0A51F867BFC0066283D /* OWSSystemMessageCell.h */, 34D1F0A51F867BFC0066283D /* OWSSystemMessageCell.h */,
34D1F0A61F867BFC0066283D /* OWSSystemMessageCell.m */, 34D1F0A61F867BFC0066283D /* OWSSystemMessageCell.m */,
34D1F0A71F867BFC0066283D /* OWSUnreadIndicatorCell.h */, 34D1F0A71F867BFC0066283D /* OWSUnreadIndicatorCell.h */,
@ -2294,7 +2281,6 @@
4556FA681F54AA9500AF40DD /* DebugUIProfile.swift in Sources */, 4556FA681F54AA9500AF40DD /* DebugUIProfile.swift in Sources */,
34DFCB851E8E04B500053165 /* AddToBlockListViewController.m in Sources */, 34DFCB851E8E04B500053165 /* AddToBlockListViewController.m in Sources */,
45855F371D9498A40084F340 /* OWSContactAvatarBuilder.m in Sources */, 45855F371D9498A40084F340 /* OWSContactAvatarBuilder.m in Sources */,
34D1F0AD1F867BFC0066283D /* OWSIncomingMessageCell.m in Sources */,
45A6DAD61EBBF85500893231 /* ReminderView.swift in Sources */, 45A6DAD61EBBF85500893231 /* ReminderView.swift in Sources */,
45666EC61D99483D008FE134 /* OWSAvatarBuilder.m in Sources */, 45666EC61D99483D008FE134 /* OWSAvatarBuilder.m in Sources */,
45E615161E8C590B0018AD52 /* DisplayableTextFilter.swift in Sources */, 45E615161E8C590B0018AD52 /* DisplayableTextFilter.swift in Sources */,
@ -2328,7 +2314,6 @@
45F659821E1BE77000444429 /* NonCallKitCallUIAdaptee.swift in Sources */, 45F659821E1BE77000444429 /* NonCallKitCallUIAdaptee.swift in Sources */,
45AE48511E0732D6004D96C2 /* TurnServerInfo.swift in Sources */, 45AE48511E0732D6004D96C2 /* TurnServerInfo.swift in Sources */,
34B3F8771E8DF1700035BE1A /* ContactsPicker.swift in Sources */, 34B3F8771E8DF1700035BE1A /* ContactsPicker.swift in Sources */,
34D1F0AF1F867BFC0066283D /* OWSOutgoingMessageCell.m in Sources */,
45C0DC1B1E68FE9000E04C47 /* UIApplication+OWS.swift in Sources */, 45C0DC1B1E68FE9000E04C47 /* UIApplication+OWS.swift in Sources */,
45638BDF1F3DDB2200128435 /* MessageSender+Promise.swift in Sources */, 45638BDF1F3DDB2200128435 /* MessageSender+Promise.swift in Sources */,
34535D821E256BE9008A4747 /* UIView+OWS.m in Sources */, 34535D821E256BE9008A4747 /* UIView+OWS.m in Sources */,
@ -2440,8 +2425,6 @@
4504493A1F45EE7D002D1ADA /* NSString+OWS.m in Sources */, 4504493A1F45EE7D002D1ADA /* NSString+OWS.m in Sources */,
45843D201D2236B30013E85A /* OWSContactsSearcher.m in Sources */, 45843D201D2236B30013E85A /* OWSContactsSearcher.m in Sources */,
45AE48521E0732D6004D96C2 /* TurnServerInfo.swift in Sources */, 45AE48521E0732D6004D96C2 /* TurnServerInfo.swift in Sources */,
450873C41D9D5149006B54F2 /* OWSExpirationTimerView.m in Sources */,
453D28BB1D332DB100D523F0 /* OWSMessagesBubblesSizeCalculator.m in Sources */,
45360B901F9527DA00FA666C /* SearcherTest.swift in Sources */, 45360B901F9527DA00FA666C /* SearcherTest.swift in Sources */,
B660F7561C29988E00687D6E /* PushManager.m in Sources */, B660F7561C29988E00687D6E /* PushManager.m in Sources */,
45360B911F952AA900FA666C /* MarqueeLabel.swift in Sources */, 45360B911F952AA900FA666C /* MarqueeLabel.swift in Sources */,

View File

@ -337,7 +337,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
constraint.active = YES; constraint.active = YES;
return constraint; return constraint;
} else { } else {
return [self autoPinEdge:ALEdgeTrailing toEdge:ALEdgeLeading ofView:view withOffset:-margin]; return [self autoPinEdge:ALEdgeTrailing toEdge:ALEdgeLeading ofView:view withOffset:margin];
} }
} }

View File

@ -1,16 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageCell.h"
NS_ASSUME_NONNULL_BEGIN
// TODO: Remove this class.
@interface OWSIncomingMessageCell : OWSMessageCell
+ (NSString *)cellReuseIdentifier;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,25 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSIncomingMessageCell.h"
#import "ConversationViewItem.h"
#import <SignalServiceKit/TSIncomingMessage.h>
NS_ASSUME_NONNULL_BEGIN
@implementation OWSIncomingMessageCell
+ (NSString *)cellReuseIdentifier
{
return NSStringFromClass([self class]);
}
- (BOOL)isIncoming
{
return YES;
}
@end
NS_ASSUME_NONNULL_END

View File

@ -8,6 +8,8 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSMessageCell : ConversationViewCell @interface OWSMessageCell : ConversationViewCell
+ (NSString *)cellReuseIdentifier;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@ -143,7 +143,6 @@ NS_ASSUME_NONNULL_BEGIN
self.dateHeaderLabel.hidden = YES; self.dateHeaderLabel.hidden = YES;
self.footerLabel.hidden = YES; self.footerLabel.hidden = YES;
[self.dateHeaderLabel autoPinEdgeToSuperviewEdge:ALEdgeTop];
[self.payloadView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.dateHeaderLabel]; [self.payloadView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.dateHeaderLabel];
[self.payloadView autoPinWidthToSuperview]; [self.payloadView autoPinWidthToSuperview];
[self.footerView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.payloadView]; [self.footerView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.payloadView];
@ -159,6 +158,11 @@ NS_ASSUME_NONNULL_BEGIN
[self addGestureRecognizer:longPress]; [self addGestureRecognizer:longPress];
} }
+ (NSString *)cellReuseIdentifier
{
return NSStringFromClass([self class]);
}
- (OWSMessageCellType)cellType - (OWSMessageCellType)cellType
{ {
return self.viewItem.messageCellType; return self.viewItem.messageCellType;
@ -196,6 +200,13 @@ NS_ASSUME_NONNULL_BEGIN
return self.viewItem.contentSize; return self.viewItem.contentSize;
} }
- (TSMessage *)message
{
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
return (TSMessage *)self.viewItem.interaction;
}
- (void)loadForDisplay:(int)contentWidth - (void)loadForDisplay:(int)contentWidth
{ {
OWSAssert(self.viewItem); OWSAssert(self.viewItem);
@ -304,6 +315,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.dateHeaderLabel autoSetDimension:ALDimensionWidth toSize:contentWidth], [self.dateHeaderLabel autoSetDimension:ALDimensionWidth toSize:contentWidth],
(self.isIncoming ? [self.dateHeaderLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading] (self.isIncoming ? [self.dateHeaderLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading]
: [self.dateHeaderLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing]), : [self.dateHeaderLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing]),
[self.dateHeaderLabel autoPinEdgeToSuperviewEdge:ALEdgeTop],
[self.dateHeaderLabel autoSetDimension:ALDimensionHeight toSize:self.dateHeaderHeight], [self.dateHeaderLabel autoSetDimension:ALDimensionHeight toSize:self.dateHeaderHeight],
]; ];
} else { } else {
@ -318,12 +330,11 @@ NS_ASSUME_NONNULL_BEGIN
{ {
BOOL showFooter = NO; BOOL showFooter = NO;
TSMessage *message = (TSMessage *)self.viewItem.interaction; BOOL hasExpirationTimer = self.message.shouldStartExpireTimer;
BOOL hasExpirationTimer = message.shouldStartExpireTimer;
if (hasExpirationTimer) { if (hasExpirationTimer) {
showFooter = YES; showFooter = YES;
} else if (!self.isIncoming) { } else if (self.isOutgoing) {
showFooter = !self.viewItem.shouldHideRecipientStatus; showFooter = !self.viewItem.shouldHideRecipientStatus;
} else if (self.viewItem.isGroupThread) { } else if (self.viewItem.isGroupThread) {
showFooter = YES; showFooter = YES;
@ -341,10 +352,10 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(self.viewItem.interaction.interactionType == OWSInteractionType_IncomingMessage OWSAssert(self.viewItem.interaction.interactionType == OWSInteractionType_IncomingMessage
|| self.viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage); || self.viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage);
TSMessage *message = (TSMessage *)self.viewItem.interaction; TSMessage *message = self.message;
BOOL hasExpirationTimer = message.shouldStartExpireTimer; BOOL hasExpirationTimer = message.shouldStartExpireTimer;
NSAttributedString *attributedText = nil; NSAttributedString *attributedText = nil;
if (!self.isIncoming) { if (self.isOutgoing) {
if (!self.viewItem.shouldHideRecipientStatus || hasExpirationTimer) { if (!self.viewItem.shouldHideRecipientStatus || hasExpirationTimer) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)message; TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)message;
NSString *statusMessage = NSString *statusMessage =
@ -365,8 +376,7 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
if (hasExpirationTimer) if (hasExpirationTimer) {
{
uint64_t expirationTimestamp = message.expiresAt; uint64_t expirationTimestamp = message.expiresAt;
uint32_t expiresInSeconds = message.expiresInSeconds; uint32_t expiresInSeconds = message.expiresInSeconds;
self.expirationTimerView = [[OWSExpirationTimerView alloc] initWithExpiration:expirationTimestamp self.expirationTimerView = [[OWSExpirationTimerView alloc] initWithExpiration:expirationTimestamp
@ -587,7 +597,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(attachmentView); OWSAssert(attachmentView);
OWSAssert(attachmentStateCallback); OWSAssert(attachmentStateCallback);
if (!self.isIncoming) { if (self.isOutgoing) {
self.attachmentUploadView = [[AttachmentUploadView alloc] initWithAttachment:self.attachmentStream self.attachmentUploadView = [[AttachmentUploadView alloc] initWithAttachment:self.attachmentStream
superview:attachmentView superview:attachmentView
attachmentStateCallback:attachmentStateCallback]; attachmentStateCallback:attachmentStateCallback];
@ -599,7 +609,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(view); OWSAssert(view);
OWSAssert(view.superview == self.payloadView); OWSAssert(view.superview == self.payloadView);
self.payloadView.isOutgoing = !self.isIncoming; self.payloadView.isOutgoing = self.isOutgoing;
self.payloadView.maskedSubview = view; self.payloadView.maskedSubview = view;
[self.payloadView updateMask]; [self.payloadView updateMask];
} }
@ -715,7 +725,12 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isIncoming - (BOOL)isIncoming
{ {
return YES; return self.viewItem.interaction.interactionType == OWSInteractionType_IncomingMessage;
}
- (BOOL)isOutgoing
{
return self.viewItem.interaction.interactionType == OWSInteractionType_OutgoingMessage;
} }
- (CGFloat)textLeadingMargin - (CGFloat)textLeadingMargin
@ -837,15 +852,16 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Notifications #pragma mark - Notifications
- (void)setIsCellVisible:(BOOL)isCellVisible { - (void)setIsCellVisible:(BOOL)isCellVisible {
if (self.isCellVisible == isCellVisible) { BOOL didChange = self.isCellVisible != isCellVisible;
return;
}
[super setIsCellVisible:isCellVisible]; [super setIsCellVisible:isCellVisible];
if (!didChange) {
return;
}
if (isCellVisible) { if (isCellVisible) {
TSMessage *message = (TSMessage *)self.viewItem.interaction; if (self.message.shouldStartExpireTimer) {
if (message.shouldStartExpireTimer) {
[self.expirationTimerView ensureAnimations]; [self.expirationTimerView ensureAnimations];
} else { } else {
[self.expirationTimerView clearAnimations]; [self.expirationTimerView clearAnimations];
@ -985,7 +1001,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]); OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
[self.delegate showMetadataViewForMessage:(TSMessage *)self.viewItem.interaction]; [self.delegate showMetadataViewForMessage:self.message];
} }
- (BOOL)canBecomeFirstResponder - (BOOL)canBecomeFirstResponder

View File

@ -1,16 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSMessageCell.h"
NS_ASSUME_NONNULL_BEGIN
// TODO: Remove this class.
@interface OWSOutgoingMessageCell : OWSMessageCell
+ (NSString *)cellReuseIdentifier;
@end
NS_ASSUME_NONNULL_END

View File

@ -1,26 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSOutgoingMessageCell.h"
#import "ConversationViewItem.h"
#import "UIView+OWS.h"
#import <SignalServiceKit/TSOutgoingMessage.h>
NS_ASSUME_NONNULL_BEGIN
@implementation OWSOutgoingMessageCell
+ (NSString *)cellReuseIdentifier
{
return NSStringFromClass([self class]);
}
- (BOOL)isIncoming
{
return NO;
}
@end
NS_ASSUME_NONNULL_END

View File

@ -28,8 +28,7 @@
#import "OWSConversationSettingsViewController.h" #import "OWSConversationSettingsViewController.h"
#import "OWSConversationSettingsViewDelegate.h" #import "OWSConversationSettingsViewDelegate.h"
#import "OWSDisappearingMessagesJob.h" #import "OWSDisappearingMessagesJob.h"
#import "OWSIncomingMessageCell.h" #import "OWSMessageCell.h"
#import "OWSOutgoingMessageCell.h"
#import "OWSSystemMessageCell.h" #import "OWSSystemMessageCell.h"
#import "OWSUnreadIndicatorCell.h" #import "OWSUnreadIndicatorCell.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
@ -494,10 +493,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
forCellWithReuseIdentifier:[OWSUnreadIndicatorCell cellReuseIdentifier]]; forCellWithReuseIdentifier:[OWSUnreadIndicatorCell cellReuseIdentifier]];
[self.collectionView registerClass:[OWSContactOffersCell class] [self.collectionView registerClass:[OWSContactOffersCell class]
forCellWithReuseIdentifier:[OWSContactOffersCell cellReuseIdentifier]]; forCellWithReuseIdentifier:[OWSContactOffersCell cellReuseIdentifier]];
[self.collectionView registerClass:[OWSOutgoingMessageCell class] [self.collectionView registerClass:[OWSMessageCell class]
forCellWithReuseIdentifier:[OWSOutgoingMessageCell cellReuseIdentifier]]; forCellWithReuseIdentifier:[OWSMessageCell cellReuseIdentifier]];
[self.collectionView registerClass:[OWSIncomingMessageCell class]
forCellWithReuseIdentifier:[OWSIncomingMessageCell cellReuseIdentifier]];
} }
- (void)applicationWillEnterForeground:(NSNotification *)notification - (void)applicationWillEnterForeground:(NSNotification *)notification
@ -3846,7 +3843,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
ConversationViewItem *_Nullable viewItem = self.viewItemMap[interaction.uniqueId]; ConversationViewItem *_Nullable viewItem = self.viewItemMap[interaction.uniqueId];
if (viewItem) { if (viewItem) {
viewItem.lastRow = viewItem.row; viewItem.previousRow = viewItem.row;
} else { } else {
viewItem = [[ConversationViewItem alloc] initWithTSInteraction:interaction isGroupThread:isGroupThread]; viewItem = [[ConversationViewItem alloc] initWithTSInteraction:interaction isGroupThread:isGroupThread];
} }
@ -3901,8 +3898,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
// If this is an existing view item and it has changed size, // If this is an existing view item and it has changed size,
// note that so that we can reload this cell while doing // note that so that we can reload this cell while doing
// incremental updates. // incremental updates.
if (viewItem.shouldShowDate != shouldShowDate && viewItem.lastRow != NSNotFound) { if (viewItem.shouldShowDate != shouldShowDate && viewItem.previousRow != NSNotFound) {
[rowsThatChangedSize addObject:@(viewItem.lastRow)]; [rowsThatChangedSize addObject:@(viewItem.previousRow)];
} }
viewItem.shouldShowDate = shouldShowDate; viewItem.shouldShowDate = shouldShowDate;
@ -3929,8 +3926,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
// If this is an existing view item and it has changed size, // If this is an existing view item and it has changed size,
// note that so that we can reload this cell while doing // note that so that we can reload this cell while doing
// incremental updates. // incremental updates.
if (viewItem.shouldHideRecipientStatus != shouldHideRecipientStatus && viewItem.lastRow != NSNotFound) { if (viewItem.shouldHideRecipientStatus != shouldHideRecipientStatus && viewItem.previousRow != NSNotFound) {
[rowsThatChangedSize addObject:@(viewItem.lastRow)]; [rowsThatChangedSize addObject:@(viewItem.previousRow)];
} }
viewItem.shouldHideRecipientStatus = shouldHideRecipientStatus; viewItem.shouldHideRecipientStatus = shouldHideRecipientStatus;
} }

View File

@ -45,7 +45,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
@property (nonatomic) BOOL shouldHideRecipientStatus; @property (nonatomic) BOOL shouldHideRecipientStatus;
@property (nonatomic) NSInteger row; @property (nonatomic) NSInteger row;
@property (nonatomic) NSInteger lastRow; // During updates, we sometimes need the previous row index
// (before this update) of this item.
@property (nonatomic) NSInteger previousRow;
//@property (nonatomic, weak) ConversationViewCell *lastCell; //@property (nonatomic, weak) ConversationViewCell *lastCell;

View File

@ -5,8 +5,7 @@
#import "ConversationViewItem.h" #import "ConversationViewItem.h"
#import "OWSAudioMessageView.h" #import "OWSAudioMessageView.h"
#import "OWSContactOffersCell.h" #import "OWSContactOffersCell.h"
#import "OWSIncomingMessageCell.h" #import "OWSMessageCell.h"
#import "OWSOutgoingMessageCell.h"
#import "OWSSystemMessageCell.h" #import "OWSSystemMessageCell.h"
#import "OWSUnreadIndicatorCell.h" #import "OWSUnreadIndicatorCell.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
@ -72,7 +71,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
_interaction = interaction; _interaction = interaction;
_isGroupThread = isGroupThread; _isGroupThread = isGroupThread;
self.row = NSNotFound; self.row = NSNotFound;
self.lastRow = NSNotFound; self.previousRow = NSNotFound;
return self; return self;
} }
@ -176,10 +175,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
OWSFail(@"%@ Unknown interaction type.", self.tag); OWSFail(@"%@ Unknown interaction type.", self.tag);
return nil; return nil;
case OWSInteractionType_IncomingMessage: case OWSInteractionType_IncomingMessage:
measurementCell = [OWSIncomingMessageCell new];
break;
case OWSInteractionType_OutgoingMessage: case OWSInteractionType_OutgoingMessage:
measurementCell = [OWSOutgoingMessageCell new]; measurementCell = [OWSMessageCell new];
break; break;
case OWSInteractionType_Error: case OWSInteractionType_Error:
case OWSInteractionType_Info: case OWSInteractionType_Info:
@ -214,10 +211,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
OWSFail(@"%@ Unknown interaction type.", self.tag); OWSFail(@"%@ Unknown interaction type.", self.tag);
return nil; return nil;
case OWSInteractionType_IncomingMessage: case OWSInteractionType_IncomingMessage:
return [collectionView dequeueReusableCellWithReuseIdentifier:[OWSIncomingMessageCell cellReuseIdentifier]
forIndexPath:indexPath];
case OWSInteractionType_OutgoingMessage: case OWSInteractionType_OutgoingMessage:
return [collectionView dequeueReusableCellWithReuseIdentifier:[OWSOutgoingMessageCell cellReuseIdentifier] return [collectionView dequeueReusableCellWithReuseIdentifier:[OWSMessageCell cellReuseIdentifier]
forIndexPath:indexPath]; forIndexPath:indexPath];
case OWSInteractionType_Error: case OWSInteractionType_Error:
case OWSInteractionType_Info: case OWSInteractionType_Info:

View File

@ -71,9 +71,9 @@ class MessageMetadataViewController: OWSViewController {
} }
NotificationCenter.default.addObserver(self, NotificationCenter.default.addObserver(self,
selector:#selector(yapDatabaseModified), selector: #selector(yapDatabaseModified),
name:NSNotification.Name.YapDatabaseModified, name: NSNotification.Name.YapDatabaseModified,
object:nil) object: nil)
} }
override func viewWillAppear(_ animated: Bool) { override func viewWillAppear(_ animated: Bool) {
@ -96,8 +96,8 @@ class MessageMetadataViewController: OWSViewController {
let scrollView = UIScrollView() let scrollView = UIScrollView()
self.scrollView = scrollView self.scrollView = scrollView
view.addSubview(scrollView) view.addSubview(scrollView)
scrollView.autoPinWidthToSuperview(withMargin:0) scrollView.autoPinWidthToSuperview(withMargin: 0)
scrollView.autoPin(toTopLayoutGuideOf: self, withInset:0) scrollView.autoPin(toTopLayoutGuideOf: self, withInset: 0)
// See notes on how to use UIScrollView with iOS Auto Layout: // See notes on how to use UIScrollView with iOS Auto Layout:
// //
@ -107,8 +107,8 @@ class MessageMetadataViewController: OWSViewController {
scrollView.addSubview(contentView) scrollView.addSubview(contentView)
contentView.autoPinLeadingToSuperview() contentView.autoPinLeadingToSuperview()
contentView.autoPinTrailingToSuperview() contentView.autoPinTrailingToSuperview()
contentView.autoPinEdge(toSuperviewEdge:.top) contentView.autoPinEdge(toSuperviewEdge: .top)
contentView.autoPinEdge(toSuperviewEdge:.bottom) contentView.autoPinEdge(toSuperviewEdge: .bottom)
scrollView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) scrollView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
let hasAttachment = message.attachmentIds.count > 0 let hasAttachment = message.attachmentIds.count > 0
@ -117,9 +117,9 @@ class MessageMetadataViewController: OWSViewController {
let footer = UIToolbar() let footer = UIToolbar()
footer.barTintColor = UIColor.ows_materialBlue() footer.barTintColor = UIColor.ows_materialBlue()
view.addSubview(footer) view.addSubview(footer)
footer.autoPinWidthToSuperview(withMargin:0) footer.autoPinWidthToSuperview(withMargin: 0)
footer.autoPinEdge(.top, to:.bottom, of:scrollView) footer.autoPinEdge(.top, to: .bottom, of: scrollView)
footer.autoPin(toBottomLayoutGuideOf: self, withInset:0) footer.autoPin(toBottomLayoutGuideOf: self, withInset: 0)
footer.items = [ footer.items = [
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil), UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil),
@ -127,7 +127,7 @@ class MessageMetadataViewController: OWSViewController {
UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
] ]
} else { } else {
scrollView.autoPin(toBottomLayoutGuideOf: self, withInset:0) scrollView.autoPin(toBottomLayoutGuideOf: self, withInset: 0)
} }
updateContent() updateContent()
@ -154,10 +154,10 @@ class MessageMetadataViewController: OWSViewController {
// Sender? // Sender?
if let incomingMessage = message as? TSIncomingMessage { if let incomingMessage = message as? TSIncomingMessage {
let senderId = incomingMessage.authorId let senderId = incomingMessage.authorId
let senderName = contactsManager.contactOrProfileName(forPhoneIdentifier:senderId) let senderName = contactsManager.contactOrProfileName(forPhoneIdentifier: senderId)
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SENDER", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SENDER",
comment: "Label for the 'sender' field of the 'message metadata' view."), comment: "Label for the 'sender' field of the 'message metadata' view."),
value:senderName)) value: senderName))
} }
// Recipient(s) // Recipient(s)
@ -179,13 +179,13 @@ class MessageMetadataViewController: OWSViewController {
// TODO: It'd be nice to inset these dividers from the edge of the screen. // TODO: It'd be nice to inset these dividers from the edge of the screen.
let addDivider = { let addDivider = {
let divider = UIView() let divider = UIView()
divider.backgroundColor = UIColor(white:0.9, alpha:1.0) divider.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
divider.autoSetDimension(.height, toSize:0.5) divider.autoSetDimension(.height, toSize: 0.5)
groupRows.append(divider) groupRows.append(divider)
} }
for recipientId in thread.recipientIdentifiers { for recipientId in thread.recipientIdentifiers {
let (recipientStatus, statusMessage) = MessageRecipientStatusUtils.recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage, recipientId: recipientId, referenceView:self.view) let (recipientStatus, statusMessage) = MessageRecipientStatusUtils.recipientStatusAndStatusMessage(outgoingMessage: outgoingMessage, recipientId: recipientId, referenceView: self.view)
guard recipientStatus == recipientStatusGroup else { guard recipientStatus == recipientStatusGroup else {
continue continue
@ -193,8 +193,8 @@ class MessageMetadataViewController: OWSViewController {
if groupRows.count < 1 { if groupRows.count < 1 {
if isGroupThread { if isGroupThread {
groupRows.append(valueRow(name: MessageRecipientStatusName(recipientStatusGroup), groupRows.append(valueRow(name: string(for: recipientStatusGroup),
value:"")) value: ""))
} }
addDivider() addDivider()
@ -208,7 +208,7 @@ class MessageMetadataViewController: OWSViewController {
statusLabel.font = UIFont.ows_footnote() statusLabel.font = UIFont.ows_footnote()
statusLabel.sizeToFit() statusLabel.sizeToFit()
cell.accessoryView = statusLabel cell.accessoryView = statusLabel
cell.autoSetDimension(.height, toSize:ContactTableViewCell.rowHeight()) cell.autoSetDimension(.height, toSize: ContactTableViewCell.rowHeight())
cell.setContentHuggingLow() cell.setContentHuggingLow()
cell.isUserInteractionEnabled = false cell.isUserInteractionEnabled = false
groupRows.append(cell) groupRows.append(cell)
@ -218,7 +218,7 @@ class MessageMetadataViewController: OWSViewController {
addDivider() addDivider()
let spacer = UIView() let spacer = UIView()
spacer.autoSetDimension(.height, toSize:10) spacer.autoSetDimension(.height, toSize: 10)
groupRows.append(spacer) groupRows.append(spacer)
} }
@ -232,12 +232,12 @@ class MessageMetadataViewController: OWSViewController {
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SENT_DATE_TIME", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SENT_DATE_TIME",
comment: "Label for the 'sent date & time' field of the 'message metadata' view."), comment: "Label for the 'sent date & time' field of the 'message metadata' view."),
value:DateUtil.formatPastTimestampRelativeToNow(message.timestamp))) value: DateUtil.formatPastTimestampRelativeToNow(message.timestamp)))
if message as? TSIncomingMessage != nil { if message as? TSIncomingMessage != nil {
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_RECEIVED_DATE_TIME", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_RECEIVED_DATE_TIME",
comment: "Label for the 'received date & time' field of the 'message metadata' view."), comment: "Label for the 'received date & time' field of the 'message metadata' view."),
value:DateUtil.formatPastTimestampRelativeToNow(message.timestampForSorting()))) value: DateUtil.formatPastTimestampRelativeToNow(message.timestampForSorting())))
} }
rows += addAttachmentMetadataRows() rows += addAttachmentMetadataRows()
@ -251,15 +251,15 @@ class MessageMetadataViewController: OWSViewController {
row.autoPinTrailingToSuperview() row.autoPinTrailingToSuperview()
if let lastRow = lastRow { if let lastRow = lastRow {
row.autoPinEdge(.top, to:.bottom, of:lastRow, withOffset:5) row.autoPinEdge(.top, to: .bottom, of: lastRow, withOffset: 5)
} else { } else {
row.autoPinEdge(toSuperviewEdge:.top, withInset:20) row.autoPinEdge(toSuperviewEdge: .top, withInset: 20)
} }
lastRow = row lastRow = row
} }
if let lastRow = lastRow { if let lastRow = lastRow {
lastRow.autoPinEdge(toSuperviewEdge:.bottom, withInset:20) lastRow.autoPinEdge(toSuperviewEdge: .bottom, withInset: 20)
} }
if let mediaMessageView = mediaMessageView { if let mediaMessageView = mediaMessageView {
@ -282,7 +282,7 @@ class MessageMetadataViewController: OWSViewController {
let bodyLabel = UILabel() let bodyLabel = UILabel()
bodyLabel.textColor = isIncoming ? UIColor.black : UIColor.white bodyLabel.textColor = isIncoming ? UIColor.black : UIColor.white
bodyLabel.font = UIFont.ows_regularFont(withSize:16) bodyLabel.font = UIFont.ows_regularFont(withSize: 16)
bodyLabel.text = messageBody bodyLabel.text = messageBody
bodyLabel.numberOfLines = 0 bodyLabel.numberOfLines = 0
bodyLabel.lineBreakMode = .byWordWrapping bodyLabel.lineBreakMode = .byWordWrapping
@ -307,7 +307,7 @@ class MessageMetadataViewController: OWSViewController {
bodyLabel.setContentHuggingPriority(UILayoutPriorityDefaultLow, for: .horizontal) bodyLabel.setContentHuggingPriority(UILayoutPriorityDefaultLow, for: .horizontal)
bodyLabel.setContentHuggingPriority(UILayoutPriorityDefaultHigh, for: .vertical) bodyLabel.setContentHuggingPriority(UILayoutPriorityDefaultHigh, for: .vertical)
bodyLabel.setContentCompressionResistancePriority(UILayoutPriorityRequired, for: .vertical) bodyLabel.setContentCompressionResistancePriority(UILayoutPriorityRequired, for: .vertical)
bodyLabel.autoSetDimension(.width, toSize:ScaleFromIPhone5(210), relation:.lessThanOrEqual) bodyLabel.autoSetDimension(.width, toSize: ScaleFromIPhone5(210), relation: .lessThanOrEqual)
let bubbleSpacer = UIView() let bubbleSpacer = UIView()
@ -320,13 +320,13 @@ class MessageMetadataViewController: OWSViewController {
bubbleSpacer.setContentHuggingLow() bubbleSpacer.setContentHuggingLow()
if isIncoming { if isIncoming {
bubbleView.autoPinLeadingToSuperview(withMargin:10) bubbleView.autoPinLeadingToSuperview(withMargin: 10)
bubbleSpacer.autoPinLeading(toTrailingOf:bubbleView) bubbleSpacer.autoPinLeading(toTrailingOf: bubbleView)
bubbleSpacer.autoPinTrailingToSuperview(withMargin:10) bubbleSpacer.autoPinTrailingToSuperview(withMargin: 10)
} else { } else {
bubbleSpacer.autoPinLeadingToSuperview(withMargin:10) bubbleSpacer.autoPinLeadingToSuperview(withMargin: 10)
bubbleView.autoPinLeading(toTrailingOf:bubbleSpacer) bubbleView.autoPinLeading(toTrailingOf: bubbleSpacer)
bubbleView.autoPinTrailingToSuperview(withMargin:10) bubbleView.autoPinTrailingToSuperview(withMargin: 10)
} }
rows.append(row) rows.append(row)
@ -335,12 +335,12 @@ class MessageMetadataViewController: OWSViewController {
owsFail("\(self.TAG) Message has neither attachment nor body.") owsFail("\(self.TAG) Message has neither attachment nor body.")
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_NO_ATTACHMENT_OR_BODY", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_NO_ATTACHMENT_OR_BODY",
comment: "Label for messages without a body or attachment in the 'message metadata' view."), comment: "Label for messages without a body or attachment in the 'message metadata' view."),
value:"")) value: ""))
} }
} }
let spacer = UIView() let spacer = UIView()
spacer.autoSetDimension(.height, toSize:15) spacer.autoSetDimension(.height, toSize: 15)
rows.append(spacer) rows.append(spacer)
return rows return rows
@ -354,7 +354,7 @@ class MessageMetadataViewController: OWSViewController {
return rows return rows
} }
guard let attachment = TSAttachment.fetch(uniqueId:attachmentId) else { guard let attachment = TSAttachment.fetch(uniqueId: attachmentId) else {
owsFail("Missing attachment") owsFail("Missing attachment")
return rows return rows
} }
@ -363,26 +363,26 @@ class MessageMetadataViewController: OWSViewController {
guard let attachmentStream = attachment as? TSAttachmentStream else { guard let attachmentStream = attachment as? TSAttachmentStream else {
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_NOT_YET_DOWNLOADED", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_NOT_YET_DOWNLOADED",
comment: "Label for 'not yet downloaded' attachments in the 'message metadata' view."), comment: "Label for 'not yet downloaded' attachments in the 'message metadata' view."),
value:"")) value: ""))
return rows return rows
} }
self.attachmentStream = attachmentStream self.attachmentStream = attachmentStream
if let filePath = attachmentStream.filePath() { if let filePath = attachmentStream.filePath() {
dataSource = DataSourcePath.dataSource(withFilePath:filePath) dataSource = DataSourcePath.dataSource(withFilePath: filePath)
} }
guard let dataSource = dataSource else { guard let dataSource = dataSource else {
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_MISSING_FILE", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_MISSING_FILE",
comment: "Label for 'missing' attachments in the 'message metadata' view."), comment: "Label for 'missing' attachments in the 'message metadata' view."),
value:"")) value: ""))
return rows return rows
} }
let contentType = attachment.contentType let contentType = attachment.contentType
if let dataUTI = MIMETypeUtil.utiType(forMIMEType:contentType) { if let dataUTI = MIMETypeUtil.utiType(forMIMEType: contentType) {
let attachment = SignalAttachment(dataSource : dataSource, dataUTI: dataUTI) let attachment = SignalAttachment(dataSource: dataSource, dataUTI: dataUTI)
let mediaMessageView = MediaMessageView(attachment:attachment) let mediaMessageView = MediaMessageView(attachment: attachment)
self.mediaMessageView = mediaMessageView self.mediaMessageView = mediaMessageView
rows.append(mediaMessageView) rows.append(mediaMessageView)
} }
@ -396,12 +396,12 @@ class MessageMetadataViewController: OWSViewController {
let contentType = attachment.contentType let contentType = attachment.contentType
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_MIME_TYPE", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_MIME_TYPE",
comment: "Label for the MIME type of attachments in the 'message metadata' view."), comment: "Label for the MIME type of attachments in the 'message metadata' view."),
value:contentType)) value: contentType))
if let sourceFilename = attachment.sourceFilename { if let sourceFilename = attachment.sourceFilename {
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SOURCE_FILENAME", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_SOURCE_FILENAME",
comment: "Label for the original filename of any attachment in the 'message metadata' view."), comment: "Label for the original filename of any attachment in the 'message metadata' view."),
value:sourceFilename)) value: sourceFilename))
} }
} }
@ -409,7 +409,7 @@ class MessageMetadataViewController: OWSViewController {
let fileSize = dataSource.dataLength() let fileSize = dataSource.dataLength()
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_FILE_SIZE", rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_ATTACHMENT_FILE_SIZE",
comment: "Label for file size of attachments in the 'message metadata' view."), comment: "Label for file size of attachments in the 'message metadata' view."),
value:ViewControllerUtils.formatFileSize(UInt(fileSize)))) value: ViewControllerUtils.formatFileSize(UInt(fileSize))))
} }
return rows return rows
@ -418,7 +418,7 @@ class MessageMetadataViewController: OWSViewController {
private func nameLabel(text: String) -> UILabel { private func nameLabel(text: String) -> UILabel {
let label = UILabel() let label = UILabel()
label.textColor = UIColor.black label.textColor = UIColor.black
label.font = UIFont.ows_mediumFont(withSize:14) label.font = UIFont.ows_mediumFont(withSize: 14)
label.text = text label.text = text
label.setContentHuggingHorizontalHigh() label.setContentHuggingHorizontalHigh()
return label return label
@ -427,7 +427,7 @@ class MessageMetadataViewController: OWSViewController {
private func valueLabel(text: String) -> UILabel { private func valueLabel(text: String) -> UILabel {
let label = UILabel() let label = UILabel()
label.textColor = UIColor.black label.textColor = UIColor.black
label.font = UIFont.ows_regularFont(withSize:14) label.font = UIFont.ows_regularFont(withSize: 14)
label.text = text label.text = text
label.setContentHuggingHorizontalLow() label.setContentHuggingHorizontalLow()
return label return label
@ -435,28 +435,28 @@ class MessageMetadataViewController: OWSViewController {
private func valueRow(name: String, value: String, subtitle: String = "") -> UIView { private func valueRow(name: String, value: String, subtitle: String = "") -> UIView {
let row = UIView.container() let row = UIView.container()
let nameLabel = self.nameLabel(text:name) let nameLabel = self.nameLabel(text: name)
let valueLabel = self.valueLabel(text:value) let valueLabel = self.valueLabel(text: value)
row.addSubview(nameLabel) row.addSubview(nameLabel)
row.addSubview(valueLabel) row.addSubview(valueLabel)
nameLabel.autoPinLeadingToSuperview(withMargin:20) nameLabel.autoPinLeadingToSuperview(withMargin: 20)
valueLabel.autoPinTrailingToSuperview(withMargin:20) valueLabel.autoPinTrailingToSuperview(withMargin: 20)
valueLabel.autoPinLeading(toTrailingOf:nameLabel, margin: 10) valueLabel.autoPinLeading(toTrailingOf: nameLabel, margin: 10)
nameLabel.autoPinEdge(toSuperviewEdge:.top) nameLabel.autoPinEdge(toSuperviewEdge: .top)
valueLabel.autoPinEdge(toSuperviewEdge:.top) valueLabel.autoPinEdge(toSuperviewEdge: .top)
if subtitle.characters.count > 0 { if subtitle.characters.count > 0 {
let subtitleLabel = self.valueLabel(text:subtitle) let subtitleLabel = self.valueLabel(text: subtitle)
subtitleLabel.textColor = UIColor.ows_darkGray() subtitleLabel.textColor = UIColor.ows_darkGray()
row.addSubview(subtitleLabel) row.addSubview(subtitleLabel)
subtitleLabel.autoPinTrailingToSuperview() subtitleLabel.autoPinTrailingToSuperview()
subtitleLabel.autoPinLeading(toTrailingOf:nameLabel, margin: 10) subtitleLabel.autoPinLeading(toTrailingOf: nameLabel, margin: 10)
subtitleLabel.autoPinEdge(.top, to:.bottom, of:valueLabel, withOffset:1) subtitleLabel.autoPinEdge(.top, to: .bottom, of: valueLabel, withOffset: 1)
subtitleLabel.autoPinEdge(toSuperviewEdge:.bottom) subtitleLabel.autoPinEdge(toSuperviewEdge: .bottom)
} else if value.characters.count > 0 { } else if value.characters.count > 0 {
valueLabel.autoPinEdge(toSuperviewEdge:.bottom) valueLabel.autoPinEdge(toSuperviewEdge: .bottom)
} else { } else {
nameLabel.autoPinEdge(toSuperviewEdge:.bottom) nameLabel.autoPinEdge(toSuperviewEdge: .bottom)
} }
return row return row
@ -474,7 +474,7 @@ class MessageMetadataViewController: OWSViewController {
Logger.error("\(TAG) Message has neither attachment nor message body.") Logger.error("\(TAG) Message has neither attachment nor message body.")
return return
} }
AttachmentSharing.showShareUI(forAttachment:attachmentStream) AttachmentSharing.showShareUI(forAttachment: attachmentStream)
} }
func copyToPasteboard() { func copyToPasteboard() {
@ -487,7 +487,7 @@ class MessageMetadataViewController: OWSViewController {
Logger.error("\(TAG) Message has neither attachment nor message body.") Logger.error("\(TAG) Message has neither attachment nor message body.")
return return
} }
guard let utiType = MIMETypeUtil.utiType(forMIMEType:attachmentStream.contentType) else { guard let utiType = MIMETypeUtil.utiType(forMIMEType: attachmentStream.contentType) else {
Logger.error("\(TAG) Attachment has invalid MIME type: \(attachmentStream.contentType).") Logger.error("\(TAG) Attachment has invalid MIME type: \(attachmentStream.contentType).")
return return
} }
@ -496,7 +496,7 @@ class MessageMetadataViewController: OWSViewController {
return return
} }
let data = dataSource.data() let data = dataSource.data()
UIPasteboard.general.setData(data, forPasteboardType:utiType) UIPasteboard.general.setData(data, forPasteboardType: utiType)
} }
// MARK: - Actions // MARK: - Actions
@ -507,7 +507,7 @@ class MessageMetadataViewController: OWSViewController {
AssertIsOnMainThread() AssertIsOnMainThread()
self.databaseConnection.read { transaction in self.databaseConnection.read { transaction in
guard let newMessage = TSInteraction.fetch(uniqueId:self.message.uniqueId, transaction:transaction) as? TSMessage else { guard let newMessage = TSInteraction.fetch(uniqueId: self.message.uniqueId, transaction: transaction) as? TSMessage else {
Logger.error("\(self.TAG) Couldn't reload message.") Logger.error("\(self.TAG) Couldn't reload message.")
return return
} }
@ -520,9 +520,9 @@ class MessageMetadataViewController: OWSViewController {
let notifications = self.databaseConnection.beginLongLivedReadTransaction() let notifications = self.databaseConnection.beginLongLivedReadTransaction()
guard self.databaseConnection.hasChange(forKey:message.uniqueId, guard self.databaseConnection.hasChange(forKey: message.uniqueId,
inCollection:TSInteraction.collection(), inCollection: TSInteraction.collection(),
in:notifications) else { in: notifications) else {
Logger.debug("\(TAG) No relevant changes.") Logger.debug("\(TAG) No relevant changes.")
return return
} }
@ -532,8 +532,8 @@ class MessageMetadataViewController: OWSViewController {
updateContent() updateContent()
} }
private func MessageRecipientStatusName(_ value: MessageRecipientStatus) -> String { private func string(for messageRecipientStatus: MessageRecipientStatus) -> String {
switch value { switch messageRecipientStatus {
case .uploading: case .uploading:
return NSLocalizedString("MESSAGE_METADATA_VIEW_MESSAGE_STATUS_UPLOADING", return NSLocalizedString("MESSAGE_METADATA_VIEW_MESSAGE_STATUS_UPLOADING",
comment: "Status label for messages which are uploading.") comment: "Status label for messages which are uploading.")