mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Restore message cell footers.
// FREEBIE
This commit is contained in:
parent
c2f07bb3d8
commit
3723a4845f
8 changed files with 96 additions and 63 deletions
|
@ -101,7 +101,7 @@
|
||||||
34D1F0B71F87F8850066283D /* OWSGenericAttachmentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0B61F87F8850066283D /* OWSGenericAttachmentView.m */; };
|
34D1F0B71F87F8850066283D /* OWSGenericAttachmentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0B61F87F8850066283D /* OWSGenericAttachmentView.m */; };
|
||||||
34D1F0BA1F8800D90066283D /* OWSAudioMessageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0B91F8800D90066283D /* OWSAudioMessageView.m */; };
|
34D1F0BA1F8800D90066283D /* OWSAudioMessageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0B91F8800D90066283D /* OWSAudioMessageView.m */; };
|
||||||
34D1F0BD1F8D108C0066283D /* AttachmentUploadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0BC1F8D108C0066283D /* AttachmentUploadView.m */; };
|
34D1F0BD1F8D108C0066283D /* AttachmentUploadView.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0BC1F8D108C0066283D /* AttachmentUploadView.m */; };
|
||||||
34D1F0C01F8EC1760066283D /* MessageRecipientState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0BF1F8EC1760066283D /* MessageRecipientState.swift */; };
|
34D1F0C01F8EC1760066283D /* MessageRecipientStatusUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34D1F0BF1F8EC1760066283D /* MessageRecipientStatusUtils.swift */; };
|
||||||
34D5CC961EA6AFAD005515DB /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */; };
|
34D5CC961EA6AFAD005515DB /* OWSContactsSyncing.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */; };
|
||||||
34D5CCA91EAE3D30005515DB /* AvatarViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCA81EAE3D30005515DB /* AvatarViewHelper.m */; };
|
34D5CCA91EAE3D30005515DB /* AvatarViewHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCA81EAE3D30005515DB /* AvatarViewHelper.m */; };
|
||||||
34D5CCB11EAE7E7F005515DB /* SelectRecipientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCB01EAE7E7F005515DB /* SelectRecipientViewController.m */; };
|
34D5CCB11EAE7E7F005515DB /* SelectRecipientViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34D5CCB01EAE7E7F005515DB /* SelectRecipientViewController.m */; };
|
||||||
|
@ -569,7 +569,7 @@
|
||||||
34D1F0B91F8800D90066283D /* OWSAudioMessageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSAudioMessageView.m; sourceTree = "<group>"; };
|
34D1F0B91F8800D90066283D /* OWSAudioMessageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSAudioMessageView.m; sourceTree = "<group>"; };
|
||||||
34D1F0BB1F8D108C0066283D /* AttachmentUploadView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttachmentUploadView.h; sourceTree = "<group>"; };
|
34D1F0BB1F8D108C0066283D /* AttachmentUploadView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttachmentUploadView.h; sourceTree = "<group>"; };
|
||||||
34D1F0BC1F8D108C0066283D /* AttachmentUploadView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttachmentUploadView.m; sourceTree = "<group>"; };
|
34D1F0BC1F8D108C0066283D /* AttachmentUploadView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttachmentUploadView.m; sourceTree = "<group>"; };
|
||||||
34D1F0BF1F8EC1760066283D /* MessageRecipientState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageRecipientState.swift; sourceTree = "<group>"; };
|
34D1F0BF1F8EC1760066283D /* MessageRecipientStatusUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageRecipientStatusUtils.swift; sourceTree = "<group>"; };
|
||||||
34D5CC941EA6AFAD005515DB /* OWSContactsSyncing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactsSyncing.h; sourceTree = "<group>"; };
|
34D5CC941EA6AFAD005515DB /* OWSContactsSyncing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSContactsSyncing.h; sourceTree = "<group>"; };
|
||||||
34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSyncing.m; sourceTree = "<group>"; };
|
34D5CC951EA6AFAD005515DB /* OWSContactsSyncing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OWSContactsSyncing.m; sourceTree = "<group>"; };
|
||||||
34D5CCA71EAE3D30005515DB /* AvatarViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AvatarViewHelper.h; sourceTree = "<group>"; };
|
34D5CCA71EAE3D30005515DB /* AvatarViewHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AvatarViewHelper.h; sourceTree = "<group>"; };
|
||||||
|
@ -1182,7 +1182,7 @@
|
||||||
34D1F0BE1F8EC1760066283D /* Utils */ = {
|
34D1F0BE1F8EC1760066283D /* Utils */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
34D1F0BF1F8EC1760066283D /* MessageRecipientState.swift */,
|
34D1F0BF1F8EC1760066283D /* MessageRecipientStatusUtils.swift */,
|
||||||
);
|
);
|
||||||
path = Utils;
|
path = Utils;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -2346,7 +2346,7 @@
|
||||||
34BECE2E1F7ABCE000D7438D /* GifPickerViewController.swift in Sources */,
|
34BECE2E1F7ABCE000D7438D /* GifPickerViewController.swift in Sources */,
|
||||||
34B3F8811E8DF1700035BE1A /* LockInteractionController.m in Sources */,
|
34B3F8811E8DF1700035BE1A /* LockInteractionController.m in Sources */,
|
||||||
34CCAF3B1F0C2748004084F4 /* OWSAddToContactViewController.m in Sources */,
|
34CCAF3B1F0C2748004084F4 /* OWSAddToContactViewController.m in Sources */,
|
||||||
34D1F0C01F8EC1760066283D /* MessageRecipientState.swift in Sources */,
|
34D1F0C01F8EC1760066283D /* MessageRecipientStatusUtils.swift in Sources */,
|
||||||
45F659731E1BD99C00444429 /* CallKitCallUIAdaptee.swift in Sources */,
|
45F659731E1BD99C00444429 /* CallKitCallUIAdaptee.swift in Sources */,
|
||||||
45BB93381E688E14001E3939 /* UIDevice+featureSupport.swift in Sources */,
|
45BB93381E688E14001E3939 /* UIDevice+featureSupport.swift in Sources */,
|
||||||
458DE9D61DEE3FD00071BB03 /* PeerConnectionClient.swift in Sources */,
|
458DE9D61DEE3FD00071BB03 /* PeerConnectionClient.swift in Sources */,
|
||||||
|
|
|
@ -276,7 +276,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
if (hasExpirationTimer) {
|
if (hasExpirationTimer) {
|
||||||
showFooter = YES;
|
showFooter = YES;
|
||||||
} else if (!self.isIncoming) {
|
} else if (!self.isIncoming) {
|
||||||
showFooter = YES;
|
showFooter = !self.viewItem.shouldHideRecipientStatus;
|
||||||
} else if (self.viewItem.isGroupThread) {
|
} else if (self.viewItem.isGroupThread) {
|
||||||
showFooter = YES;
|
showFooter = YES;
|
||||||
} else {
|
} else {
|
||||||
|
@ -297,10 +297,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
BOOL hasExpirationTimer = message.shouldStartExpireTimer;
|
BOOL hasExpirationTimer = message.shouldStartExpireTimer;
|
||||||
NSAttributedString *attributedText = nil;
|
NSAttributedString *attributedText = nil;
|
||||||
if (!self.isIncoming) {
|
if (!self.isIncoming) {
|
||||||
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)message;
|
if (!self.viewItem.shouldHideRecipientStatus || hasExpirationTimer) {
|
||||||
NSString *statusMessage =
|
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)message;
|
||||||
[MessageRecipientStatusUtils statusMessageWithOutgoingMessage:outgoingMessage referenceView:self];
|
NSString *statusMessage =
|
||||||
attributedText = [[NSAttributedString alloc] initWithString:statusMessage attributes:@{}];
|
[MessageRecipientStatusUtils statusMessageWithOutgoingMessage:outgoingMessage referenceView:self];
|
||||||
|
attributedText = [[NSAttributedString alloc] initWithString:statusMessage attributes:@{}];
|
||||||
|
}
|
||||||
} else if (self.viewItem.isGroupThread) {
|
} else if (self.viewItem.isGroupThread) {
|
||||||
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)self.viewItem.interaction;
|
TSIncomingMessage *incomingMessage = (TSIncomingMessage *)self.viewItem.interaction;
|
||||||
attributedText = [self.delegate attributedContactOrProfileNameForPhoneIdentifier:incomingMessage.authorId];
|
attributedText = [self.delegate attributedContactOrProfileNameForPhoneIdentifier:incomingMessage.authorId];
|
||||||
|
@ -633,6 +635,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
cellSize.height += self.dateHeaderHeight;
|
cellSize.height += self.dateHeaderHeight;
|
||||||
cellSize.height += self.footerHeight;
|
cellSize.height += self.footerHeight;
|
||||||
|
|
||||||
|
cellSize.width = ceil(cellSize.width);
|
||||||
|
cellSize.height = ceil(cellSize.height);
|
||||||
|
|
||||||
return cellSize;
|
return cellSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1138,6 +1138,18 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
[textView resignFirstResponder];
|
[textView resignFirstResponder];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
|
||||||
|
{
|
||||||
|
if (range.length > 0) {
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
if ([text isEqualToString:@"\n"]) {
|
||||||
|
[self sendButtonPressed];
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
|
@ -3885,67 +3885,42 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
|
||||||
}
|
}
|
||||||
shouldShowDateOnNextViewItem = NO;
|
shouldShowDateOnNextViewItem = NO;
|
||||||
}
|
}
|
||||||
if (viewItem.shouldShowDate != shouldShowDate) {
|
|
||||||
// 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.lastRow != NSNotFound) {
|
if (viewItem.shouldShowDate != shouldShowDate && viewItem.lastRow != NSNotFound) {
|
||||||
[rowsThatChangedSize addObject:@(viewItem.lastRow)];
|
[rowsThatChangedSize addObject:@(viewItem.lastRow)];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
viewItem.shouldShowDate = shouldShowDate;
|
viewItem.shouldShowDate = shouldShowDate;
|
||||||
|
|
||||||
previousViewItemTimestamp = viewItem.interaction.timestampForSorting;
|
previousViewItemTimestamp = viewItem.interaction.timestampForSorting;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the "shouldShowDate" property of the view items.
|
// Update the "shouldShowDate" property of the view items.
|
||||||
OWSInteractionType lastInteractionType = OWSInteractionType_Unknown;
|
OWSInteractionType lastInteractionType = OWSInteractionType_Unknown;
|
||||||
for (ConversationViewItem *viewItem in viewItems) {
|
MessageRecipientStatus lastRecipientStatus = MessageRecipientStatusUploading;
|
||||||
|
for (ConversationViewItem *viewItem in viewItems.reverseObjectEnumerator) {
|
||||||
|
BOOL shouldHideRecipientStatus = NO;
|
||||||
OWSInteractionType interactionType = viewItem.interaction.interactionType;
|
OWSInteractionType interactionType = viewItem.interaction.interactionType;
|
||||||
|
|
||||||
|
if (interactionType == OWSInteractionType_OutgoingMessage) {
|
||||||
|
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)viewItem.interaction;
|
||||||
|
MessageRecipientStatus recipientStatus =
|
||||||
|
[MessageRecipientStatusUtils recipientStatusWithOutgoingMessage:outgoingMessage];
|
||||||
|
shouldHideRecipientStatus
|
||||||
|
= (interactionType == lastInteractionType && recipientStatus == lastRecipientStatus);
|
||||||
|
lastRecipientStatus = recipientStatus;
|
||||||
|
}
|
||||||
lastInteractionType = interactionType;
|
lastInteractionType = interactionType;
|
||||||
// BOOL canShowDate = NO;
|
|
||||||
// switch (viewItem.interaction.interactionType) {
|
// If this is an existing view item and it has changed size,
|
||||||
// case OWSInteractionType_Unknown:
|
// note that so that we can reload this cell while doing
|
||||||
// case OWSInteractionType_UnreadIndicator:
|
// incremental updates.
|
||||||
// case OWSInteractionType_Offer:
|
if (viewItem.shouldHideRecipientStatus != shouldHideRecipientStatus && viewItem.lastRow != NSNotFound) {
|
||||||
// canShowDate = NO;
|
[rowsThatChangedSize addObject:@(viewItem.lastRow)];
|
||||||
// break;
|
}
|
||||||
// case OWSInteractionType_IncomingMessage:
|
viewItem.shouldHideRecipientStatus = shouldHideRecipientStatus;
|
||||||
// case OWSInteractionType_OutgoingMessage:
|
|
||||||
// case OWSInteractionType_Error:
|
|
||||||
// case OWSInteractionType_Info:
|
|
||||||
// case OWSInteractionType_Call:
|
|
||||||
// canShowDate = YES;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// BOOL shouldShowDate = NO;
|
|
||||||
// if (!canShowDate) {
|
|
||||||
// shouldShowDate = NO;
|
|
||||||
// shouldShowDateOnNextViewItem = YES;
|
|
||||||
// } else if (shouldShowDateOnNextViewItem) {
|
|
||||||
// shouldShowDate = YES;
|
|
||||||
// shouldShowDateOnNextViewItem = NO;
|
|
||||||
// } else {
|
|
||||||
// uint64_t viewItemTimestamp = viewItem.interaction.timestampForSorting;
|
|
||||||
// OWSAssert(viewItemTimestamp > 0);
|
|
||||||
// OWSAssert(previousViewItemTimestamp > 0);
|
|
||||||
// uint64_t timeDifferenceMs = viewItemTimestamp - previousViewItemTimestamp;
|
|
||||||
// static const uint64_t kShowTimeIntervalMs = 5 * kMinuteInMs;
|
|
||||||
// if (timeDifferenceMs > kShowTimeIntervalMs) {
|
|
||||||
// shouldShowDate = YES;
|
|
||||||
// }
|
|
||||||
// shouldShowDateOnNextViewItem = NO;
|
|
||||||
// }
|
|
||||||
// if (viewItem.shouldShowDate != shouldShowDate) {
|
|
||||||
// // If this is an existing view item and it has changed size,
|
|
||||||
// // note that so that we can reload this cell while doing
|
|
||||||
// // incremental updates.
|
|
||||||
// if (viewItem.lastRow != NSNotFound) {
|
|
||||||
// [rowsThatChangedSize addObject:@(viewItem.lastRow)];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// viewItem.shouldShowDate = shouldShowDate;
|
|
||||||
// previousViewItemTimestamp = viewItem.interaction.timestampForSorting;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.viewItems = viewItems;
|
self.viewItems = viewItems;
|
||||||
|
|
|
@ -42,6 +42,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType);
|
||||||
@property (nonatomic, readonly) BOOL isGroupThread;
|
@property (nonatomic, readonly) BOOL isGroupThread;
|
||||||
|
|
||||||
@property (nonatomic) BOOL shouldShowDate;
|
@property (nonatomic) BOOL shouldShowDate;
|
||||||
|
@property (nonatomic) BOOL shouldHideRecipientStatus;
|
||||||
|
|
||||||
@property (nonatomic) NSInteger row;
|
@property (nonatomic) NSInteger row;
|
||||||
@property (nonatomic) NSInteger lastRow;
|
@property (nonatomic) NSInteger lastRow;
|
||||||
|
|
|
@ -104,6 +104,17 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
||||||
[self clearCachedLayoutState];
|
[self clearCachedLayoutState];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setShouldHideRecipientStatus:(BOOL)shouldHideRecipientStatus
|
||||||
|
{
|
||||||
|
if (_shouldHideRecipientStatus == shouldHideRecipientStatus) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_shouldHideRecipientStatus = shouldHideRecipientStatus;
|
||||||
|
|
||||||
|
[self clearCachedLayoutState];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)clearCachedLayoutState
|
- (void)clearCachedLayoutState
|
||||||
{
|
{
|
||||||
self.cachedCellSize = nil;
|
self.cachedCellSize = nil;
|
||||||
|
|
|
@ -82,7 +82,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
// TODO: Remove this log statement after we've reduced the invalidation churn.
|
// TODO: Remove this log statement after we've reduced the invalidation churn.
|
||||||
DDLogVerbose(@"%@ prepareLayout", self.tag);
|
DDLogVerbose(@"%@ prepareLayout", self.tag);
|
||||||
|
|
||||||
const int vInset = 15;
|
const int vInset = 8;
|
||||||
const int hInset = 10;
|
const int hInset = 10;
|
||||||
const int vSpacing = 5;
|
const int vSpacing = 5;
|
||||||
const int viewWidth = (int)floor(self.collectionView.bounds.size.width);
|
const int viewWidth = (int)floor(self.collectionView.bounds.size.width);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
enum MessageRecipientStatus {
|
@objc enum MessageRecipientStatus: Int {
|
||||||
case uploading
|
case uploading
|
||||||
case sending
|
case sending
|
||||||
case sent
|
case sent
|
||||||
|
@ -132,4 +132,33 @@ class MessageRecipientStatusUtils: NSObject {
|
||||||
comment:"message status while message is sending.")
|
comment:"message status while message is sending.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class func recipientStatus(outgoingMessage: TSOutgoingMessage) -> MessageRecipientStatus {
|
||||||
|
let recipientReadMap = outgoingMessage.recipientReadMap
|
||||||
|
if recipientReadMap.count > 0 {
|
||||||
|
assert(outgoingMessage.messageState == .sentToService)
|
||||||
|
return .read
|
||||||
|
}
|
||||||
|
|
||||||
|
let recipientDeliveryMap = outgoingMessage.recipientDeliveryMap
|
||||||
|
if recipientDeliveryMap.count > 0 {
|
||||||
|
return .delivered
|
||||||
|
}
|
||||||
|
|
||||||
|
if outgoingMessage.wasDelivered {
|
||||||
|
return .delivered
|
||||||
|
}
|
||||||
|
|
||||||
|
if outgoingMessage.messageState == .unsent {
|
||||||
|
return .failed
|
||||||
|
} else if outgoingMessage.messageState == .sentToService {
|
||||||
|
return .sent
|
||||||
|
} else if outgoingMessage.hasAttachments() {
|
||||||
|
assert(outgoingMessage.messageState == .attemptingOut)
|
||||||
|
return .uploading
|
||||||
|
} else {
|
||||||
|
assert(outgoingMessage.messageState == .attemptingOut)
|
||||||
|
return .sending
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue