Clean up ahead of PR.

// FREEBIE
pull/1/head
Matthew Chen 7 years ago
parent fb408f980c
commit 5621fe893c

@ -219,8 +219,6 @@
45C0DC1C1E68FE9000E04C47 /* UIApplication+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C0DC1A1E68FE9000E04C47 /* UIApplication+OWS.swift */; };
45C0DC1E1E69011F00E04C47 /* UIStoryboard+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C0DC1D1E69011F00E04C47 /* UIStoryboard+OWS.swift */; };
45C0DC1F1E69011F00E04C47 /* UIStoryboard+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C0DC1D1E69011F00E04C47 /* UIStoryboard+OWS.swift */; };
45C681B71D305A580050903A /* OWSCall.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C681B61D305A580050903A /* OWSCall.m */; };
45C681B81D305A580050903A /* OWSCall.m in Sources */ = {isa = PBXBuildFile; fileRef = 45C681B61D305A580050903A /* OWSCall.m */; };
45C9DEB81DF4E35A0065CA84 /* WebRTCCallMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C9DEB71DF4E35A0065CA84 /* WebRTCCallMessageHandler.swift */; };
45C9DEB91DF4E35A0065CA84 /* WebRTCCallMessageHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 45C9DEB71DF4E35A0065CA84 /* WebRTCCallMessageHandler.swift */; };
45CB2FA81CB7146C00E1B343 /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 45CB2FA71CB7146C00E1B343 /* Launch Screen.storyboard */; };
@ -686,8 +684,6 @@
45BD60811DE9547E00A8F436 /* Contacts.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Contacts.framework; path = System/Library/Frameworks/Contacts.framework; sourceTree = SDKROOT; };
45C0DC1A1E68FE9000E04C47 /* UIApplication+OWS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIApplication+OWS.swift"; sourceTree = "<group>"; };
45C0DC1D1E69011F00E04C47 /* UIStoryboard+OWS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStoryboard+OWS.swift"; sourceTree = "<group>"; };
45C681B51D305A580050903A /* OWSCall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSCall.h; sourceTree = "<group>"; };
45C681B61D305A580050903A /* OWSCall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSCall.m; sourceTree = "<group>"; };
45C9DEB71DF4E35A0065CA84 /* WebRTCCallMessageHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebRTCCallMessageHandler.swift; sourceTree = "<group>"; };
45CB2FA71CB7146C00E1B343 /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = "Launch Screen.storyboard"; path = "Signal/src/util/Launch Screen.storyboard"; sourceTree = SOURCE_ROOT; };
45CD81EE1DC030E7004C9430 /* AccountManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AccountManager.swift; sourceTree = "<group>"; };
@ -1278,8 +1274,6 @@
45DF5DF11DDB843F00C936C7 /* CompareSafetyNumbersActivity.swift */,
45666EC41D99483D008FE134 /* OWSAvatarBuilder.h */,
45666EC51D99483D008FE134 /* OWSAvatarBuilder.m */,
45C681B51D305A580050903A /* OWSCall.h */,
45C681B61D305A580050903A /* OWSCall.m */,
45855F351D9498A40084F340 /* OWSContactAvatarBuilder.h */,
45855F361D9498A40084F340 /* OWSContactAvatarBuilder.m */,
34C42D621F4734ED0072EC04 /* OWSContactOffersInteraction.h */,
@ -2245,7 +2239,6 @@
76EB064218170B33006006FC /* StringUtil.m in Sources */,
452037D11EE84975004E4CDF /* DebugUISessionState.m in Sources */,
342FCE6B1EF9C375002690AD /* OWS105AttachmentFilePaths.m in Sources */,
45C681B71D305A580050903A /* OWSCall.m in Sources */,
D221A09A169C9E5E00537ABF /* main.m in Sources */,
345671011E89A5F1006EE662 /* ThreadUtil.m in Sources */,
4585C4601ED4FD0400896AEA /* OWS104CreateRecipientIdentities.m in Sources */,
@ -2420,7 +2413,6 @@
B660F7561C29988E00687D6E /* PushManager.m in Sources */,
45FBC5D21DF8592E00E9B410 /* SignalCall.swift in Sources */,
451A13B21E13DED2000A50FD /* CallNotificationsAdapter.swift in Sources */,
45C681B81D305A580050903A /* OWSCall.m in Sources */,
454EBAB31F2BC08800ACE0BB /* OWSSwiftUtils.swift in Sources */,
4542F0971EBB9E9A00C7EE92 /* Promise+retainUntilComplete.swift in Sources */,
451DA3C91F1489BE008E2423 /* OWSAlerts.swift in Sources */,

@ -1,59 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
NS_ASSUME_NONNULL_BEGIN
//@class TSCall;
//@class TSInteraction;
//
// typedef enum : NSUInteger {
// kCallOutgoing = 1,
// kCallIncoming = 2,
// kCallMissed = 3,
// kCallOutgoingIncomplete = 4,
// kCallIncomingIncomplete = 5,
// // kGroupUpdateJoin = 6, has been deprecated.
// // kGroupUpdateLeft = 7, has been deprecated.
// // kGroupUpdate = 8, has been deprecated.
// kCallMissedBecauseOfChangedIdentity = 9,
//} CallStatus;
//
//@interface OWSCall : NSObject <OWSMessageData>
//
//#pragma mark - Initialization
//
//- (instancetype)initWithCallRecord:(TSCall *)callRecord;
//- (instancetype)init NS_UNAVAILABLE;
//
///*
// * Returns the string Id of the user who initiated the call
// */
//@property (copy, nonatomic, readonly) NSString *senderId;
//
///*
// * Returns the display name for user who initiated the call
// */
//@property (copy, nonatomic, readonly) NSString *senderDisplayName;
//
///*
// * Returns date of the call
// */
//@property (copy, nonatomic, readonly) NSDate *date;
//
///*
// * Returns the call status
// * @see CallStatus
// */
//@property (nonatomic) CallStatus status;
//
///**
// * String to be displayed
// */
//@property (nonatomic, copy) NSString *detailString;
//
//- (NSString *)dateText;
//
//@end
NS_ASSUME_NONNULL_END

@ -1,224 +0,0 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "OWSCall.h"
#import "TSCall.h"
#import "TSContactThread.h"
#import <JSQMessagesViewController/JSQMessagesTimestampFormatter.h>
#import <JSQMessagesViewController/UIImage+JSQMessages.h>
#import <SignalServiceKit/TSCall.h>
NS_ASSUME_NONNULL_BEGIN
//@interface OWSCall ()
//
//// -- Redeclaring properties from OWSMessageData protocol to synthesize variables
//@property (nonatomic) TSMessageAdapterType messageType;
//@property (nonatomic) BOOL isExpiringMessage;
//@property (nonatomic) BOOL shouldStartExpireTimer;
//@property (nonatomic) double expiresAtSeconds;
//@property (nonatomic) uint32_t expiresInSeconds;
//@property (nonatomic) TSInteraction *interaction;
//
//@end
//
//@implementation OWSCall
//
//#pragma mark - Initialzation
//
//- (instancetype)initWithCallRecord:(TSCall *)callRecord
//{
// TSThread *thread = callRecord.thread;
// TSContactThread *contactThread;
// if ([thread isKindOfClass:[TSContactThread class]]) {
// contactThread = (TSContactThread *)thread;
// } else {
// DDLogError(@"%@ Unexpected thread type: %@", self.tag, thread);
// }
//
// CallStatus status = 0;
// switch (callRecord.callType) {
// case RPRecentCallTypeOutgoing:
// status = kCallOutgoing;
// break;
// case RPRecentCallTypeOutgoingIncomplete:
// status = kCallOutgoingIncomplete;
// break;
// case RPRecentCallTypeMissed:
// status = kCallMissed;
// break;
// case RPRecentCallTypeIncoming:
// status = kCallIncoming;
// break;
// case RPRecentCallTypeIncomingIncomplete:
// status = kCallIncomingIncomplete;
// break;
// case RPRecentCallTypeMissedBecauseOfChangedIdentity:
// status = kCallMissedBecauseOfChangedIdentity;
// break;
// default:
// status = kCallIncoming;
// break;
// }
//
// NSString *name = contactThread.name;
// NSString *detailString;
// switch (status) {
// case kCallMissed:
// detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_MISSED_CALL_WITH_NAME", nil), name];
// break;
// case kCallIncoming:
// detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_RECEIVED_CALL", nil), name];
// break;
// case kCallIncomingIncomplete:
// detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_THEY_TRIED_TO_CALL_YOU", nil),
// name]; break;
// case kCallOutgoing:
// detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_YOU_CALLED", nil), name];
// break;
// case kCallOutgoingIncomplete:
// detailString = [NSString stringWithFormat:NSLocalizedString(@"MSGVIEW_YOU_TRIED_TO_CALL", nil), name];
// break;
// case kCallMissedBecauseOfChangedIdentity:
// detailString = [NSString
// stringWithFormat:NSLocalizedString(@"MSGVIEW_MISSED_CALL_BECAUSE_OF_CHANGED_IDENTITY", nil), name];
// default:
// detailString = @"";
// break;
// }
//
// return [self initWithInteraction:callRecord
// callerId:contactThread.contactIdentifier
// callerDisplayName:name
// date:callRecord.dateForSorting
// status:status
// displayString:detailString];
//}
//
//- (instancetype)initWithInteraction:(TSInteraction *)interaction
// callerId:(NSString *)senderId
// callerDisplayName:(NSString *)senderDisplayName
// date:(nullable NSDate *)date
// status:(CallStatus)status
// displayString:(NSString *)detailString
//{
// NSParameterAssert(senderId != nil);
// NSParameterAssert(senderDisplayName != nil);
//
// self = [super init];
// if (!self) {
// return self;
// }
//
// _interaction = interaction;
// _senderId = [senderId copy];
// _senderDisplayName = [senderDisplayName copy];
// _date = [date copy];
// _status = status;
// _isExpiringMessage = NO; // TODO - call notifications should expire too.
// _shouldStartExpireTimer = NO; // TODO - call notifications should expire too.
// _messageType = TSCallAdapter;
//
// // TODO interpret detailString from status. make sure it works for calls and
// // our re-use of calls as group update display
// _detailString = [detailString stringByAppendingFormat:@" "];
//
// return self;
//}
//
//- (NSString *)dateText
//{
// NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// dateFormatter.timeStyle = NSDateFormatterShortStyle;
// dateFormatter.dateStyle = NSDateFormatterMediumStyle;
// dateFormatter.doesRelativeDateFormatting = YES;
// return [dateFormatter stringFromDate:_date];
//}
//
//#pragma mark - NSObject
//
//- (BOOL)isEqual:(id)object
//{
// if (self == object) {
// return YES;
// }
//
// if (![object isKindOfClass:[self class]]) {
// return NO;
// }
//
// OWSCall *aCall = (OWSCall *)object;
//
// return [self.senderId isEqualToString:aCall.senderId] &&
// [self.senderDisplayName isEqualToString:aCall.senderDisplayName]
// && ([self.date compare:aCall.date] == NSOrderedSame) && self.status == aCall.status;
//}
//
//- (NSUInteger)hash
//{
// return self.senderId.hash ^ self.date.hash;
//}
//
//- (NSString *)description
//{
// return [NSString stringWithFormat:@"<%@: senderId=%@, senderDisplayName=%@, date=%@>",
// [self class],
// self.senderId,
// self.senderDisplayName,
// self.date];
//}
//
//#pragma mark - OWSMessageEditing
//
//- (BOOL)canPerformEditingAction:(SEL)action
//{
// return action == @selector(delete:);
//}
//
//- (void)performEditingAction:(SEL)action
//{
// // Deletes are always handled by TSMessageAdapter
// if (action == @selector(delete:)) {
// DDLogDebug(@"%@ Deleting interaction with uniqueId: %@", self.tag, self.interaction.uniqueId);
// [self.interaction remove];
// return;
// }
//
// // Shouldn't get here, as only supported actions should be exposed via canPerformEditingAction
// NSString *actionString = NSStringFromSelector(action);
// DDLogError(@"%@ '%@' action unsupported", self.tag, actionString);
//}
//
//#pragma mark - JSQMessageData
//
//- (BOOL)isMediaMessage
//{
// return NO;
//}
//
//- (NSUInteger)messageHash
//{
// return self.interaction.hash;
//}
//
//- (NSString *)text
//{
// return _detailString;
//}
//
//#pragma mark - Logging
//
//+ (NSString *)tag
//{
// return [NSString stringWithFormat:@"[%@]", self.class];
//}
//
//- (NSString *)tag
//{
// return self.class.tag;
//}
//
//@end
NS_ASSUME_NONNULL_END

@ -294,7 +294,6 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
constraint.active = YES;
return constraint;
} else {
// CGFloat oldMargin = margin;
margin += (self.isRTL ? self.superview.layoutMargins.left : self.superview.layoutMargins.right);
return [self autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:margin];
}

@ -56,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)loadForDisplay;
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth;
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth;
@end

@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN
OWSFail(@"%@ This method should be overridden.", self.logTag);
}
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth
{
OWSFail(@"%@ This method should be overridden.", self.logTag);
return CGSizeZero;

@ -87,7 +87,7 @@ NS_ASSUME_NONNULL_BEGIN
return NSStringFromClass([self class]);
}
- (void)configure
- (void)loadForDisplay
{
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]);
@ -173,7 +173,7 @@ NS_ASSUME_NONNULL_BEGIN
layoutButton(self.blockButton, interaction.hasBlockOffer);
}
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth
{
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[OWSContactOffersInteraction class]]);

@ -387,11 +387,13 @@ NS_ASSUME_NONNULL_BEGIN
[self cropViewToBubbbleShape:self.customView];
}
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth
{
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[TSMessage class]]);
const int maxMessageWidth = (int)floor(contentWidth * 0.7f);
switch (self.cellType) {
case OWSMessageCellType_TextMessage:
case OWSMessageCellType_OversizeTextMessage: {
@ -399,16 +401,12 @@ NS_ASSUME_NONNULL_BEGIN
CGFloat leftMargin = isRTL ? self.textTrailingMargin : self.textLeadingMargin;
CGFloat rightMargin = isRTL ? self.textLeadingMargin : self.textTrailingMargin;
CGFloat textVMargin = self.textVMargin;
CGFloat maxTextWidth = maxMessageWidth - (leftMargin + rightMargin);
const int maxTextWidth = (int)floor(maxMessageWidth - (leftMargin + rightMargin));
self.textLabel.text = self.textMessage;
CGSize textSize = [self.textLabel sizeThatFits:CGSizeMake(maxTextWidth, CGFLOAT_MAX)];
CGSize result = CGSizeMake((CGFloat)ceil(textSize.width + leftMargin + rightMargin),
(CGFloat)ceil(textSize.height + textVMargin * 2));
// NSLog(@"???? %@", self.viewItem.interaction.debugDescription);
// NSLog(@"\t %@", messageBody);
// NSLog(@"textSize: %@", NSStringFromCGSize(textSize));
// NSLog(@"result: %@", NSStringFromCGSize(result));
return result;
}
case OWSMessageCellType_StillImage:
@ -420,19 +418,15 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: Adjust this behavior.
// TODO: This behavior is a bit different than the old behavior defined
// in JSQMediaItem+OWS.h. Let's discuss.
const CGFloat maxContentWidth = maxMessageWidth;
const CGFloat maxContentHeight = maxMessageWidth;
CGFloat contentWidth = (CGFloat)round(maxContentWidth);
CGFloat contentHeight = (CGFloat)round(maxContentWidth * self.contentSize.height / self.contentSize.width);
if (contentHeight > maxContentHeight) {
contentWidth = (CGFloat)round(maxContentHeight * self.contentSize.width / self.contentSize.height);
contentHeight = (CGFloat)round(maxContentHeight);
const CGFloat maxMediaWidth = maxMessageWidth;
const CGFloat maxMediaHeight = maxMessageWidth;
CGFloat mediaWidth = (CGFloat)round(maxMediaWidth);
CGFloat mediaHeight = (CGFloat)round(maxMediaWidth * self.contentSize.height / self.contentSize.width);
if (mediaHeight > maxMediaHeight) {
mediaWidth = (CGFloat)round(maxMediaHeight * self.contentSize.width / self.contentSize.height);
mediaHeight = (CGFloat)round(maxMediaHeight);
}
CGSize result = CGSizeMake(contentWidth, contentHeight);
// DDLogError(@"measuring: %@ %@ %@", self.viewItem.interaction.uniqueId,
// self.viewItem.interaction.description, self.attachmentStream.contentType); DDLogError(@"\t
// contentSize: %@", NSStringFromCGSize(self.contentSize)); DDLogError(@"\t result: %@",
// NSStringFromCGSize(result));
CGSize result = CGSizeMake(mediaWidth, mediaHeight);
return result;
}
case OWSMessageCellType_Audio:

@ -274,29 +274,19 @@ NS_ASSUME_NONNULL_BEGIN
[self iconSize],
[self iconSize]);
// DDLogError(@"system: %@", self.viewItem.interaction.description);
// DDLogError(@"\t cell: %@", NSStringFromCGRect(self.frame));
// DDLogError(@"\t self.contentView: %@", NSStringFromCGRect(self.contentView.frame));
// DDLogError(@"\t imageView: %@", NSStringFromCGRect(self.imageView.frame));
// DDLogError(@"\t titleLabel: %@", NSStringFromCGRect(self.titleLabel.frame));
// [DDLog flushLog];
self.titleLabel.frame = CGRectMake(titleLeft,
round((self.contentView.height - titleSize.height + topLabelSpacing) * 0.5f),
ceil(titleSize.width + 1.f),
ceil(titleSize.height + 1.f));
// [self addRedBorder];
}
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth
{
OWSAssert(self.viewItem);
TSInteraction *interaction = self.viewItem.interaction;
// TODO: Should we use maxMessageWidth?
CGSize result = CGSizeMake(viewWidth, 0);
CGSize result = CGSizeMake(contentWidth, 0);
result.height += self.topVMargin;
result.height += self.bottomVMargin;
@ -307,10 +297,6 @@ NS_ASSUME_NONNULL_BEGIN
CGFloat contentHeight = ceil(MAX([self iconSize], titleSize.height));
result.height += contentHeight;
// DDLogError(@"system?: %@", self.viewItem.interaction.description);
// DDLogError(@"\t result: %@", NSStringFromCGSize(result));
// [DDLog flushLog];
return result;
}

@ -10,9 +10,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface OWSUnreadIndicatorCell : ConversationViewCell
//- (CGSize)bubbleSizeForInteraction:(TSUnreadIndicatorInteraction *)interaction
// collectionViewWidth:(CGFloat)collectionViewWidth;
+ (NSString *)cellReuseIdentifier;
@end

@ -202,7 +202,7 @@ NS_ASSUME_NONNULL_BEGIN
}
}
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth
{
OWSAssert(self.viewItem);
OWSAssert([self.viewItem.interaction isKindOfClass:[TSUnreadIndicatorInteraction class]]);

@ -22,7 +22,6 @@
#import "NSAttributedString+OWS.h"
#import "NewGroupViewController.h"
#import "OWSAudioAttachmentPlayer.h"
#import "OWSCall.h"
#import "OWSContactOffersCell.h"
#import "OWSContactOffersInteraction.h"
#import "OWSContactsManager.h"
@ -3826,6 +3825,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
#pragma mark - View Items
// This is a key method. It builds or rebuilds the list of
// cell view models.
- (void)reloadViewItems
{
NSMutableArray<ConversationViewItem *> *viewItems = [NSMutableArray new];
@ -3887,6 +3888,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
self.viewItemMap = viewItemMap;
}
// Whenever an interaction is modified, we need to reload it from the DB
// and update the corresponding view item.
- (void)reloadViewItem:(ConversationViewItem *)viewItem
{
OWSAssert([NSThread isMainThread]);

@ -26,6 +26,13 @@ typedef NS_ENUM(NSInteger, OWSMessageCellType) {
@class TSAttachmentStream;
@class TSInteraction;
// This is a ViewModel for cells in the conversation view.
//
// The lifetime of this class is the lifetime of that cell
// in the load window of the conversation view.
//
// Critically, this class implements ConversationViewLayoutItem
// and does caching of the cell's size.
@interface ConversationViewItem : NSObject <ConversationViewLayoutItem, OWSAudioAttachmentPlayerDelegate>
@property (nonatomic, readonly) TSInteraction *interaction;
@ -52,11 +59,6 @@ typedef NS_ENUM(NSInteger, OWSMessageCellType) {
- (CGFloat)audioProgressSeconds;
//#pragma mark - Menu Actions
//
//- (BOOL)canPerformEditingAction:(SEL)selector;
//- (void)performEditingAction:(SEL)selector;
#pragma mark - Expiration
// TODO:

@ -77,7 +77,7 @@ NS_ASSUME_NONNULL_BEGIN
self.cachedCellSize = nil;
}
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth
{
OWSAssert([NSThread isMainThread]);
@ -85,16 +85,11 @@ NS_ASSUME_NONNULL_BEGIN
if (!self.cachedCellSize) {
ConversationViewCell *_Nullable measurementCell = [self measurementCell];
measurementCell.viewItem = self;
cellSize = [measurementCell cellSizeForViewWidth:viewWidth maxMessageWidth:maxMessageWidth];
cellSize = [measurementCell cellSizeForViewWidth:viewWidth contentWidth:contentWidth];
self.cachedCellSize = [NSValue valueWithCGSize:cellSize];
[measurementCell prepareForReuse];
// DDLogError(@"cellSizeForViewWidth: %@ %@", self.interaction.uniqueId, self.interaction.description);
// DDLogError(@"\t fresh cellSize: %@", NSStringFromCGSize(cellSize));
} else {
cellSize = [self.cachedCellSize CGSizeValue];
// DDLogError(@"cellSizeForViewWidth: %@ %@", self.interaction.uniqueId, self.interaction.description);
// DDLogError(@"\t cached cellSize: %@", NSStringFromCGSize(cellSize));
}
return cellSize;
}

@ -13,9 +13,7 @@ typedef NS_ENUM(NSInteger, ConversationViewLayoutAlignment) {
@protocol ConversationViewLayoutItem <NSObject>
// TODO: Perhaps maxMessageWidth should be an implementation detail of the
// message cells.
- (CGSize)cellSizeForViewWidth:(int)viewWidth maxMessageWidth:(int)maxMessageWidth;
- (CGSize)cellSizeForViewWidth:(int)viewWidth contentWidth:(int)contentWidth;
- (ConversationViewLayoutAlignment)layoutAlignment;

@ -83,7 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
const int hInset = 10;
const int vSpacing = 5;
const int viewWidth = (int)floor(self.collectionView.bounds.size.width);
const int maxMessageWidth = (int)floor((viewWidth - 2 * hInset) * 0.7f);
const int contentWidth = (int)floor(viewWidth - 2 * hInset);
NSArray<id<ConversationViewLayoutItem>> *layoutItems = self.delegate.layoutItems;
@ -93,7 +93,7 @@ NS_ASSUME_NONNULL_BEGIN
NSInteger row = 0;
for (id<ConversationViewLayoutItem> layoutItem in layoutItems) {
CGSize layoutSize = [layoutItem cellSizeForViewWidth:viewWidth maxMessageWidth:maxMessageWidth];
CGSize layoutSize = [layoutItem cellSizeForViewWidth:viewWidth contentWidth:contentWidth];
layoutSize.width = MIN(viewWidth, floor(layoutSize.width));
layoutSize.height = floor(layoutSize.height);

Loading…
Cancel
Save