mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Bubble collapse.
This commit is contained in:
parent
d0cddfd22c
commit
75177ef00f
5 changed files with 1542 additions and 410 deletions
File diff suppressed because it is too large
Load diff
|
@ -55,11 +55,13 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
@property (nonatomic) BOOL hasViewState;
|
||||
@property (nonatomic) OWSMessageCellType messageCellType;
|
||||
// TODO: Rename to displayableBodyText.
|
||||
@property (nonatomic, nullable) DisplayableText *displayableText;
|
||||
@property (nonatomic, nullable) TSAttachmentStream *attachmentStream;
|
||||
@property (nonatomic, nullable) TSAttachmentPointer *attachmentPointer;
|
||||
@property (nonatomic) CGSize mediaSize;
|
||||
@property (nonatomic) BOOL hasText;
|
||||
// TODO: Remove in favor of displayableBodyText nil test.
|
||||
//@property (nonatomic) BOOL hasText;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -84,6 +86,8 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
[self ensureViewState:transaction];
|
||||
|
||||
// OWSAssert(self.hasViewState);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -103,6 +107,13 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
[self clearCachedLayoutState];
|
||||
|
||||
[self ensureViewState:transaction];
|
||||
|
||||
// OWSAssert(self.hasViewState);
|
||||
}
|
||||
|
||||
- (BOOL)hasText
|
||||
{
|
||||
return _displayableText != nil;
|
||||
}
|
||||
|
||||
- (void)setShouldShowDate:(BOOL)shouldShowDate
|
||||
|
@ -287,7 +298,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
}];
|
||||
}
|
||||
|
||||
- (DisplayableText *)displayableTextForAttachmentStream:(TSAttachmentStream *)attachmentStream
|
||||
- (DisplayableText *)displayableTextForOversizeTextAttachment:(TSAttachmentStream *)attachmentStream
|
||||
interactionId:(NSString *)interactionId
|
||||
{
|
||||
OWSAssert(attachmentStream);
|
||||
|
@ -353,9 +364,9 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
|
||||
if ([attachment.contentType isEqualToString:OWSMimeTypeOversizeTextMessage]) {
|
||||
self.messageCellType = OWSMessageCellType_OversizeTextMessage;
|
||||
self.displayableText =
|
||||
[self displayableTextForAttachmentStream:self.attachmentStream interactionId:message.uniqueId];
|
||||
self.hasText = YES;
|
||||
self.displayableText = [self displayableTextForOversizeTextAttachment:self.attachmentStream
|
||||
interactionId:message.uniqueId];
|
||||
// self.hasText = YES;
|
||||
} else if ([self.attachmentStream isAnimated] || [self.attachmentStream isImage] ||
|
||||
[self.attachmentStream isVideo]) {
|
||||
if ([self.attachmentStream isAnimated]) {
|
||||
|
@ -392,8 +403,13 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
}
|
||||
}
|
||||
|
||||
// Ignore message body for oversize text attachments.
|
||||
if (message.body.length > 0) {
|
||||
self.hasText = YES;
|
||||
if (self.hasText) {
|
||||
OWSFail(@"%@ oversize text message has unexpected caption.", self.logTag);
|
||||
}
|
||||
|
||||
// self.hasText = YES;
|
||||
// If we haven't already assigned an attachment type at this point, message.body isn't a caption,
|
||||
// it's a stand-alone text message.
|
||||
if (self.messageCellType == OWSMessageCellType_Unknown) {
|
||||
|
@ -409,7 +425,7 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
|
|||
// are rendered like empty text messages, but without any interactivity.
|
||||
DDLogWarn(@"%@ Treating unknown message as empty text message: %@", self.logTag, message.description);
|
||||
self.messageCellType = OWSMessageCellType_TextMessage;
|
||||
self.hasText = YES;
|
||||
// self.hasText = YES;
|
||||
self.displayableText = [[DisplayableText alloc] initWithFullText:@"" displayText:@"" isTextTruncated:NO];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -284,6 +284,11 @@ typedef NS_ENUM(NSInteger, CellState) { kArchiveState, kInboxState };
|
|||
}
|
||||
|
||||
[self updateBarButtonItems];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
TSThread *thread = [self threadForIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
|
||||
[self presentThread:thread keyboardOnViewAppearing:NO callOnViewAppearing:NO];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated
|
||||
|
|
|
@ -58,6 +58,24 @@ public class OWSMessagesBubbleImageFactory: NSObject {
|
|||
}
|
||||
}
|
||||
|
||||
public func bubbleColor(message: TSMessage) -> UIColor {
|
||||
if message is TSIncomingMessage {
|
||||
return UIColor.jsq_messageBubbleLightGray()!
|
||||
} else if let outgoingMessage = message as? TSOutgoingMessage {
|
||||
switch outgoingMessage.messageState {
|
||||
case .unsent:
|
||||
return UIColor.gray
|
||||
case .attemptingOut:
|
||||
return UIColor.ows_fadedBlue
|
||||
default:
|
||||
return UIColor.ows_materialBlue
|
||||
}
|
||||
} else {
|
||||
owsFail("Unexpected message type: \(message)")
|
||||
return UIColor.ows_materialBlue
|
||||
}
|
||||
}
|
||||
|
||||
private func outgoing(color: UIColor) -> JSQMessagesBubbleImage {
|
||||
if isRTL {
|
||||
return jsqFactory.incomingMessagesBubbleImage(with: color)
|
||||
|
|
|
@ -572,19 +572,21 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
OWSAssertIsOnMainThread();
|
||||
OWSAssert([self isAudio]);
|
||||
|
||||
NSError *error;
|
||||
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:self.mediaURL error:&error];
|
||||
if (error && [error.domain isEqualToString:NSOSStatusErrorDomain]
|
||||
&& (error.code == kAudioFileInvalidFileError || error.code == kAudioFileStreamError_InvalidFile)) {
|
||||
// Ignore "invalid audio file" errors.
|
||||
return 0.f;
|
||||
}
|
||||
if (!error) {
|
||||
return (CGFloat)[audioPlayer duration];
|
||||
} else {
|
||||
OWSFail(@"Could not find audio duration: %@", self.mediaURL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// NSError *error;
|
||||
// AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:self.mediaURL error:&error];
|
||||
// if (error && [error.domain isEqualToString:NSOSStatusErrorDomain]
|
||||
// && (error.code == kAudioFileInvalidFileError || error.code == kAudioFileStreamError_InvalidFile)) {
|
||||
// // Ignore "invalid audio file" errors.
|
||||
// return 0.f;
|
||||
// }
|
||||
// if (!error) {
|
||||
// return (CGFloat)[audioPlayer duration];
|
||||
// } else {
|
||||
// OWSFail(@"Could not find audio duration: %@", self.mediaURL);
|
||||
// return 0;
|
||||
// }
|
||||
}
|
||||
|
||||
- (CGFloat)audioDurationSeconds
|
||||
|
|
Loading…
Reference in a new issue