WIP: Support sending attachment captions

Looks fine on other clients, but locally we don't display the caption.

// FREEBIE
pull/1/head
Michael Kirk 7 years ago committed by sdkjfhsdkjhfsdlkjhfsdf
parent 0964c16417
commit e20f44024c

@ -1007,6 +1007,7 @@ NS_ASSUME_NONNULL_BEGIN
TSOutgoingMessage *message = TSOutgoingMessage *message =
[[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
messageBody:nil
isVoiceMessage:NO isVoiceMessage:NO
expiresInSeconds:0]; expiresInSeconds:0];
DDLogError(@"%@ sendFakeMessages outgoing attachment timestamp: %llu.", self.logTag, message.timestamp); DDLogError(@"%@ sendFakeMessages outgoing attachment timestamp: %llu.", self.logTag, message.timestamp);
@ -1043,6 +1044,7 @@ NS_ASSUME_NONNULL_BEGIN
[TSStorageManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { [TSStorageManager.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] TSOutgoingMessage *message = [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
messageBody:nil
isVoiceMessage:NO isVoiceMessage:NO
expiresInSeconds:0]; expiresInSeconds:0];
DDLogError(@"%@ sendFakeMessages outgoing attachment timestamp: %llu.", self.logTag, message.timestamp); DDLogError(@"%@ sendFakeMessages outgoing attachment timestamp: %llu.", self.logTag, message.timestamp);

@ -211,15 +211,15 @@ public class AttachmentApprovalViewController: OWSViewController, MessagingToolb
// MARK: MessagingToolbarDelegate // MARK: MessagingToolbarDelegate
func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar) { func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar, captionText: String?) {
self.sendAttachment() self.sendAttachment(captionText: captionText)
} }
func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat) { func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat) {
self.scrollView.contentInset.bottom = newHeight self.scrollView.contentInset.bottom = newHeight
} }
func sendAttachment() { func sendAttachment(captionText: String?) {
// disable controls after send was tapped. // disable controls after send was tapped.
self.bottomToolbar.isUserInteractionEnabled = false self.bottomToolbar.isUserInteractionEnabled = false
@ -231,6 +231,7 @@ public class AttachmentApprovalViewController: OWSViewController, MessagingToolb
activityIndicatorView.autoCenterInSuperview() activityIndicatorView.autoCenterInSuperview()
activityIndicatorView.startAnimating() activityIndicatorView.startAnimating()
attachment.captionText = captionText
self.delegate?.didApproveAttachment(attachment: attachment) self.delegate?.didApproveAttachment(attachment: attachment)
} }
} }
@ -325,7 +326,7 @@ private class GradientView: UIView {
} }
protocol MessagingToolbarDelegate: class { protocol MessagingToolbarDelegate: class {
func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar) func messagingToolbarDidTapSend(_ messagingToolbar: MessagingToolbar, captionText: String?)
func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat) func messagingToolbar(_ messagingToolbar: MessagingToolbar, didChangeHeight newHeight: CGFloat)
} }
@ -397,7 +398,7 @@ class MessagingToolbar: UIView, UITextViewDelegate {
} }
func didTapSend() { func didTapSend() {
self.messagingToolbarDelegate?.messagingToolbarDidTapSend(self) self.messagingToolbarDelegate?.messagingToolbarDidTapSend(self, captionText: self.textView.text)
} }
// MARK: - UITextViewDelegate // MARK: - UITextViewDelegate

@ -108,7 +108,10 @@ public class SignalAttachment: NSObject {
// MARK: Properties // MARK: Properties
@objc @objc
let dataSource: DataSource public let dataSource: DataSource
@objc
public var captionText: String?
@objc @objc
public var data: Data { public var data: Data {

@ -118,8 +118,10 @@ NS_ASSUME_NONNULL_BEGIN
TSOutgoingMessage *message = TSOutgoingMessage *message =
[[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp] [[TSOutgoingMessage alloc] initWithTimestamp:[NSDate ows_millisecondTimeStamp]
inThread:thread inThread:thread
messageBody:attachment.captionText
isVoiceMessage:[attachment isVoiceMessage] isVoiceMessage:[attachment isVoiceMessage]
expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)]; expiresInSeconds:(configuration.isEnabled ? configuration.durationSeconds : 0)];
[messageSender enqueueAttachment:attachment.dataSource [messageSender enqueueAttachment:attachment.dataSource
contentType:attachment.mimeType contentType:attachment.mimeType
sourceFilename:attachment.filenameOrDefault sourceFilename:attachment.filenameOrDefault

@ -62,6 +62,7 @@ typedef NS_ENUM(NSInteger, TSGroupMetaMessage) {
- (instancetype)initWithTimestamp:(uint64_t)timestamp - (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread inThread:(nullable TSThread *)thread
messageBody:(nullable NSString *)messageBody
isVoiceMessage:(BOOL)isVoiceMessage isVoiceMessage:(BOOL)isVoiceMessage
expiresInSeconds:(uint32_t)expiresInSeconds; expiresInSeconds:(uint32_t)expiresInSeconds;

@ -123,12 +123,13 @@ NSString *const kTSOutgoingMessageSentRecipientAll = @"kTSOutgoingMessageSentRec
- (instancetype)initWithTimestamp:(uint64_t)timestamp - (instancetype)initWithTimestamp:(uint64_t)timestamp
inThread:(nullable TSThread *)thread inThread:(nullable TSThread *)thread
messageBody:(nullable NSString *)messageBody
isVoiceMessage:(BOOL)isVoiceMessage isVoiceMessage:(BOOL)isVoiceMessage
expiresInSeconds:(uint32_t)expiresInSeconds expiresInSeconds:(uint32_t)expiresInSeconds
{ {
self = [self initWithTimestamp:timestamp self = [self initWithTimestamp:timestamp
inThread:thread inThread:thread
messageBody:nil messageBody:messageBody
attachmentIds:[NSMutableArray new] attachmentIds:[NSMutableArray new]
expiresInSeconds:expiresInSeconds expiresInSeconds:expiresInSeconds
expireStartedAt:0]; expireStartedAt:0];

Loading…
Cancel
Save