diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 252ad9923..77874febc 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2858,7 +2858,8 @@ typedef enum : NSUInteger { UIViewController *pickerModal; if (SSKFeatureFlags.useCustomPhotoCapture) { - SendMediaNavigationController *navController = [SendMediaNavigationController showingCameraFirst]; + SendMediaNavigationController *navController = + [SendMediaNavigationController showingCameraFirstWithMessageText:self.inputToolbar.messageText]; navController.sendMediaNavDelegate = self; pickerModal = navController; } else { @@ -2903,7 +2904,8 @@ typedef enum : NSUInteger { return; } - SendMediaNavigationController *pickerModal = [SendMediaNavigationController showingMediaLibraryFirst]; + SendMediaNavigationController *pickerModal = + [SendMediaNavigationController showingMediaLibraryFirstWithMessageText:self.inputToolbar.messageText]; pickerModal.sendMediaNavDelegate = self; [self dismissKeyBoard]; @@ -3921,6 +3923,14 @@ typedef enum : NSUInteger { [self dismissViewControllerAnimated:YES completion:nil]; } +- (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval + didChangeMessageText:(nullable NSString *)newMessageText +{ + [self.inputToolbar setMessageText:newMessageText animated:NO]; +} + +#pragma mark - + - (void)showErrorAlertForAttachment:(SignalAttachment *_Nullable)attachment { OWSAssertDebug(attachment == nil || [attachment hasError]); diff --git a/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift b/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift index cb234fe22..08002d79b 100644 --- a/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift +++ b/Signal/src/ViewControllers/Photos/SendMediaNavigationController.swift @@ -19,6 +19,8 @@ class SendMediaNavigationController: OWSNavigationController { override var prefersStatusBarHidden: Bool { return true } + var messageText: String? + override func viewDidLoad() { super.viewDidLoad() @@ -51,19 +53,21 @@ class SendMediaNavigationController: OWSNavigationController { public weak var sendMediaNavDelegate: SendMediaNavDelegate? @objc - public class func showingCameraFirst() -> SendMediaNavigationController { + public class func showingCameraFirst(messageText: String) -> SendMediaNavigationController { let navController = SendMediaNavigationController() navController.setViewControllers([navController.captureViewController], animated: false) navController.updateButtons() + navController.messageText = messageText return navController } @objc - public class func showingMediaLibraryFirst() -> SendMediaNavigationController { + public class func showingMediaLibraryFirst(messageText: String) -> SendMediaNavigationController { let navController = SendMediaNavigationController() navController.setViewControllers([navController.mediaLibraryViewController], animated: false) navController.updateButtons() + navController.messageText = messageText return navController } @@ -210,6 +214,7 @@ class SendMediaNavigationController: OWSNavigationController { private func pushApprovalViewController() { let approvalViewController = AttachmentApprovalViewController(mode: .sharedNavigation, attachments: self.attachments) approvalViewController.approvalDelegate = self + approvalViewController.messageText = messageText pushViewController(approvalViewController, animated: true) updateButtons() @@ -361,6 +366,10 @@ extension SendMediaNavigationController: ImagePickerGridControllerDelegate { } extension SendMediaNavigationController: AttachmentApprovalViewControllerDelegate { + func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didChangeMessageText newMessageText: String?) { + self.messageText = newMessageText + } + func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didRemoveAttachment attachment: SignalAttachment) { guard let removedDraft = attachmentDraftCollection.attachmentDrafts.first(where: { $0.attachment == attachment}) else { owsFailDebug("removedDraft was unexpectedly nil") diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift index 7017c122e..3f1f4ab68 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentApprovalViewController.swift @@ -9,17 +9,19 @@ import PromiseKit @objc public protocol AttachmentApprovalViewControllerDelegate: class { - func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], messageText: String?) + func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, + didApproveAttachments attachments: [SignalAttachment], messageText: String?) + func attachmentApprovalDidCancel(_ attachmentApproval: AttachmentApprovalViewController) + func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, + didChangeMessageText newMessageText: String?) + @objc optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didRemoveAttachment attachment: SignalAttachment) @objc optional func attachmentApprovalDidTapAddMore(_ attachmentApproval: AttachmentApprovalViewController) - - @objc - optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, changedCaptionOfAttachment attachment: SignalAttachment) } // MARK: - @@ -216,6 +218,15 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC bottomToolView.update(isEditingCaptions: isEditingCaptions, currentAttachmentItem: currentAttachmentItem) } + public var messageText: String? { + get { + return attachmentTextToolbar.messageText + } + set { + attachmentTextToolbar.messageText = newValue + } + } + // MARK: - Navigation Bar public func updateNavigationBar() { @@ -678,6 +689,10 @@ extension AttachmentApprovalViewController: AttachmentTextToolbarDelegate { func attachmentTextToolbarDidAddMore(_ attachmentTextToolbar: AttachmentTextToolbar) { self.approvalDelegate?.attachmentApprovalDidTapAddMore?(self) } + + func attachmentTextToolbarDidChange(_ attachmentTextToolbar: AttachmentTextToolbar) { + approvalDelegate?.attachmentApproval(self, didChangeMessageText: attachmentTextToolbar.messageText) + } } // MARK: - diff --git a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift index 078893bdd..d475d2a0b 100644 --- a/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift +++ b/SignalMessaging/ViewControllers/AttachmentApproval/AttachmentTextToolbar.swift @@ -13,6 +13,7 @@ protocol AttachmentTextToolbarDelegate: class { func attachmentTextToolbarDidBeginEditing(_ attachmentTextToolbar: AttachmentTextToolbar) func attachmentTextToolbarDidEndEditing(_ attachmentTextToolbar: AttachmentTextToolbar) func attachmentTextToolbarDidAddMore(_ attachmentTextToolbar: AttachmentTextToolbar) + func attachmentTextToolbarDidChange(_ attachmentTextToolbar: AttachmentTextToolbar) } // MARK: - @@ -228,6 +229,7 @@ class AttachmentTextToolbar: UIView, UITextViewDelegate { public func textViewDidChange(_ textView: UITextView) { updateHeight(textView: textView) + attachmentTextToolbarDelegate?.attachmentTextToolbarDidChange(self) } public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { diff --git a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m index 0097efa37..bf6dbbc37 100644 --- a/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m +++ b/SignalMessaging/ViewControllers/SharingThreadPickerViewController.m @@ -310,6 +310,12 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion); [self cancelShareExperience]; } +- (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval + didChangeMessageText:(nullable NSString *)newMessageText +{ + // no-op +} + #pragma mark - MessageApprovalViewControllerDelegate - (void)messageApproval:(MessageApprovalViewController *)approvalViewController