Support captions *and* independent message body

pull/1/head
Michael Kirk 7 years ago
parent cd88ef2bec
commit 4f0092615a

@ -2481,7 +2481,7 @@ typedef enum : NSUInteger {
{ {
OWSAssertDebug(attachment); OWSAssertDebug(attachment);
[self tryToSendAttachmentIfApproved:attachment]; [self showApprovalDialogForAttachment:attachment];
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self.conversationViewModel ensureDynamicInteractions]; [self.conversationViewModel ensureDynamicInteractions];
@ -2580,14 +2580,14 @@ typedef enum : NSUInteger {
// Although we want to be able to send higher quality attachments through the document picker // Although we want to be able to send higher quality attachments through the document picker
// it's more imporant that we ensure the sent format is one all clients can accept (e.g. *not* quicktime .mov) // it's more imporant that we ensure the sent format is one all clients can accept (e.g. *not* quicktime .mov)
if ([SignalAttachment isInvalidVideoWithDataSource:dataSource dataUTI:type]) { if ([SignalAttachment isInvalidVideoWithDataSource:dataSource dataUTI:type]) {
[self sendQualityAdjustedAttachmentForVideo:url filename:filename skipApprovalDialog:NO]; [self showApprovalDialogAfterProcessingVideoURL:url filename:filename];
return; return;
} }
// "Document picker" attachments _SHOULD NOT_ be resized, if possible. // "Document picker" attachments _SHOULD NOT_ be resized, if possible.
SignalAttachment *attachment = SignalAttachment *attachment =
[SignalAttachment attachmentWithDataSource:dataSource dataUTI:type imageQuality:TSImageQualityOriginal]; [SignalAttachment attachmentWithDataSource:dataSource dataUTI:type imageQuality:TSImageQualityOriginal];
[self tryToSendAttachmentIfApproved:attachment]; [self showApprovalDialogForAttachment:attachment];
} }
#pragma mark - UIImagePickerController #pragma mark - UIImagePickerController
@ -2673,12 +2673,17 @@ typedef enum : NSUInteger {
self.view.frame = frame; self.view.frame = frame;
} }
#pragma mark - OWSImagePickerControllerDelegate
- (void)imagePicker:(OWSImagePickerGridController *)imagePicker - (void)imagePicker:(OWSImagePickerGridController *)imagePicker
didPickImageAttachments:(NSArray<SignalAttachment *> *)attachments didPickImageAttachments:(NSArray<SignalAttachment *> *)attachments
messageText:(NSString *_Nullable)messageText
{ {
[self tryToSendAttachmentsIfApproved:attachments skipApprovalDialog:YES]; [self tryToSendAttachments:attachments messageText:messageText];
} }
#pragma mark - UIImagePickerControllerDelegate
/* /*
* Fetching data from UIImagePickerController * Fetching data from UIImagePickerController
*/ */
@ -2725,9 +2730,7 @@ typedef enum : NSUInteger {
NSURL *videoURL = info[UIImagePickerControllerMediaURL]; NSURL *videoURL = info[UIImagePickerControllerMediaURL];
[self dismissViewControllerAnimated:YES [self dismissViewControllerAnimated:YES
completion:^{ completion:^{
[self sendQualityAdjustedAttachmentForVideo:videoURL [self showApprovalDialogAfterProcessingVideoURL:videoURL filename:filename];
filename:filename
skipApprovalDialog:NO];
}]; }];
} else if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) { } else if (picker.sourceType == UIImagePickerControllerSourceTypeCamera) {
// Static Image captured from camera // Static Image captured from camera
@ -2751,7 +2754,7 @@ typedef enum : NSUInteger {
[self showErrorAlertForAttachment:attachment]; [self showErrorAlertForAttachment:attachment];
failedToPickAttachment(nil); failedToPickAttachment(nil);
} else { } else {
[self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:NO]; [self showApprovalDialogForAttachment:attachment];
} }
} else { } else {
failedToPickAttachment(nil); failedToPickAttachment(nil);
@ -2808,34 +2811,13 @@ typedef enum : NSUInteger {
[self showErrorAlertForAttachment:attachment]; [self showErrorAlertForAttachment:attachment];
failedToPickAttachment(nil); failedToPickAttachment(nil);
} else { } else {
[self tryToSendAttachmentIfApproved:attachment]; [self showApprovalDialogForAttachment:attachment];
} }
}]; }];
}]; }];
} }
} }
- (void)sendMessageAttachments:(NSArray<SignalAttachment *> *)attachments
{
OWSAssertIsOnMainThread();
for (SignalAttachment *attachment in attachments) {
OWSAssertDebug(![attachment hasError]);
OWSAssertDebug([attachment mimeType].length > 0);
}
BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
TSOutgoingMessage *message = [ThreadUtil enqueueMessageWithAttachments:attachments
messageBody:nil
inThread:self.thread
quotedReplyModel:self.inputToolbar.quotedReply];
[self messageWasSent:message];
if (didAddToProfileWhitelist) {
[self.conversationViewModel ensureDynamicInteractions];
}
}
- (void)sendContactShare:(ContactShareViewModel *)contactShare - (void)sendContactShare:(ContactShareViewModel *)contactShare
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
@ -2864,9 +2846,7 @@ typedef enum : NSUInteger {
}]; }];
} }
- (void)sendQualityAdjustedAttachmentForVideo:(NSURL *)movieURL - (void)showApprovalDialogAfterProcessingVideoURL:(NSURL *)movieURL filename:(nullable NSString *)filename
filename:(nullable NSString *)filename
skipApprovalDialog:(BOOL)skipApprovalDialog
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();
@ -2895,7 +2875,7 @@ typedef enum : NSUInteger {
attachment ? [attachment errorName] : @"Missing data"); attachment ? [attachment errorName] : @"Missing data");
[self showErrorAlertForAttachment:attachment]; [self showErrorAlertForAttachment:attachment];
} else { } else {
[self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:skipApprovalDialog]; [self showApprovalDialogForAttachment:attachment];
} }
}]; }];
}) retainUntilComplete]; }) retainUntilComplete];
@ -3086,7 +3066,7 @@ typedef enum : NSUInteger {
OWSLogWarn(@"Invalid attachment: %@.", attachment ? [attachment errorName] : @"Missing data"); OWSLogWarn(@"Invalid attachment: %@.", attachment ? [attachment errorName] : @"Missing data");
[self showErrorAlertForAttachment:attachment]; [self showErrorAlertForAttachment:attachment];
} else { } else {
[self tryToSendAttachmentIfApproved:attachment skipApprovalDialog:YES]; [self tryToSendAttachments:@[ attachment ] messageText:nil];
} }
} }
@ -3480,37 +3460,28 @@ typedef enum : NSUInteger {
{ {
OWSLogError(@""); OWSLogError(@"");
[self tryToSendAttachmentIfApproved:attachment]; [self showApprovalDialogForAttachment:attachment];
} }
- (void)tryToSendAttachmentIfApproved:(SignalAttachment *_Nullable)attachment - (void)showApprovalDialogForAttachment:(SignalAttachment *_Nullable)attachment
{ {
if (attachment == nil) { if (attachment == nil) {
OWSLogWarn(@"Missing attachment"); OWSFailDebug(@"attachment was unexpetedly nil");
[self showErrorAlertForAttachment:nil]; [self showErrorAlertForAttachment:nil];
return; return;
} }
[self tryToSendAttachmentsIfApproved:@[ attachment ]]; [self showApprovalDialogForAttachments:@[ attachment ]];
} }
- (void)tryToSendAttachmentIfApproved:(SignalAttachment *_Nullable)attachment - (void)showApprovalDialogForAttachments:(NSArray<SignalAttachment *> *)attachments
skipApprovalDialog:(BOOL)skipApprovalDialog
{ {
if (attachment == nil) { OWSNavigationController *modal =
OWSLogWarn(@"Missing attachment"); [AttachmentApprovalViewController wrappedInNavControllerWithAttachments:attachments approvalDelegate:self];
[self showErrorAlertForAttachment:nil];
return;
}
[self tryToSendAttachmentsIfApproved:@[ attachment ] skipApprovalDialog:skipApprovalDialog];
}
- (void)tryToSendAttachmentsIfApproved:(NSArray<SignalAttachment *> *)attachments [self presentViewController:modal animated:YES completion:nil];
{
[self tryToSendAttachmentsIfApproved:attachments skipApprovalDialog:NO];
} }
- (void)tryToSendAttachmentsIfApproved:(NSArray<SignalAttachment *> *)attachments - (void)tryToSendAttachments:(NSArray<SignalAttachment *> *)attachments messageText:(NSString *_Nullable)messageText
skipApprovalDialog:(BOOL)skipApprovalDialog
{ {
OWSLogError(@""); OWSLogError(@"");
@ -3519,7 +3490,7 @@ typedef enum : NSUInteger {
if ([self isBlockedConversation]) { if ([self isBlockedConversation]) {
[self showUnblockConversationUI:^(BOOL isBlocked) { [self showUnblockConversationUI:^(BOOL isBlocked) {
if (!isBlocked) { if (!isBlocked) {
[weakSelf tryToSendAttachmentsIfApproved:attachments]; [weakSelf tryToSendAttachments:attachments messageText:messageText];
} }
}]; }];
return; return;
@ -3529,8 +3500,8 @@ typedef enum : NSUInteger {
showSafetyNumberConfirmationIfNecessaryWithConfirmationText:[SafetyNumberStrings confirmSendButton] showSafetyNumberConfirmationIfNecessaryWithConfirmationText:[SafetyNumberStrings confirmSendButton]
completion:^(BOOL didConfirmIdentity) { completion:^(BOOL didConfirmIdentity) {
if (didConfirmIdentity) { if (didConfirmIdentity) {
[weakSelf [weakSelf tryToSendAttachments:attachments
tryToSendAttachmentsIfApproved:attachments]; messageText:messageText];
} }
}]; }];
if (didShowSNAlert) { if (didShowSNAlert) {
@ -3545,13 +3516,16 @@ typedef enum : NSUInteger {
} }
} }
if (skipApprovalDialog) { BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self sendMessageAttachments:attachments]; TSOutgoingMessage *message = [ThreadUtil enqueueMessageWithAttachments:attachments
} else { messageBody:messageText
OWSNavigationController *modal = inThread:self.thread
[AttachmentApprovalViewController wrappedInNavControllerWithAttachments:attachments quotedReplyModel:self.inputToolbar.quotedReply];
approvalDelegate:self];
[self presentViewController:modal animated:YES completion:nil]; [self messageWasSent:message];
if (didAddToProfileWhitelist) {
[self.conversationViewModel ensureDynamicInteractions];
} }
}); });
} }
@ -3660,10 +3634,13 @@ typedef enum : NSUInteger {
[self updateNavigationBarSubtitleLabel]; [self updateNavigationBarSubtitleLabel];
} }
#pragma mark - AttachmentApprovalViewControllerDelegate
- (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval - (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval
didApproveAttachments:(NSArray<SignalAttachment *> *)attachments didApproveAttachments:(NSArray<SignalAttachment *> *)attachments
messageText:(NSString *_Nullable)messageText
{ {
[self sendMessageAttachments:attachments]; [self tryToSendAttachments:attachments messageText:messageText];
[self dismissViewControllerAnimated:YES completion:nil]; [self dismissViewControllerAnimated:YES completion:nil];
// We always want to scroll to the bottom of the conversation after the local user // We always want to scroll to the bottom of the conversation after the local user
// sends a message. Normally, this is taken care of in yapDatabaseModified:, but // sends a message. Normally, this is taken care of in yapDatabaseModified:, but

@ -8,7 +8,7 @@ import PromiseKit
@objc(OWSImagePickerControllerDelegate) @objc(OWSImagePickerControllerDelegate)
protocol ImagePickerControllerDelegate { protocol ImagePickerControllerDelegate {
func imagePicker(_ imagePicker: ImagePickerGridController, didPickImageAttachments attachments: [SignalAttachment]) func imagePicker(_ imagePicker: ImagePickerGridController, didPickImageAttachments attachments: [SignalAttachment], messageText: String?)
} }
@objc(OWSImagePickerGridController) @objc(OWSImagePickerGridController)
@ -386,9 +386,9 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
// MARK: - AttachmentApprovalViewControllerDelegate // MARK: - AttachmentApprovalViewControllerDelegate
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment]) { func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], messageText: String?) {
self.dismiss(animated: true) { self.dismiss(animated: true) {
self.delegate?.imagePicker(self, didPickImageAttachments: attachments) self.delegate?.imagePicker(self, didPickImageAttachments: attachments, messageText: messageText)
} }
} }

@ -9,7 +9,7 @@ import PromiseKit
@objc @objc
public protocol AttachmentApprovalViewControllerDelegate: class { public protocol AttachmentApprovalViewControllerDelegate: class {
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment]) func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didApproveAttachments attachments: [SignalAttachment], messageText: String?)
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didCancelAttachments attachments: [SignalAttachment]) func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, didCancelAttachments attachments: [SignalAttachment])
@objc optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, addMoreToAttachments attachments: [SignalAttachment]) @objc optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, addMoreToAttachments attachments: [SignalAttachment])
@objc optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, changedCaptionOfAttachment attachment: SignalAttachment) @objc optional func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, changedCaptionOfAttachment attachment: SignalAttachment)
@ -62,6 +62,10 @@ class SignalAttachmentItem: Hashable {
// MARK: // MARK:
var captionText: String? {
return attachment.captionText
}
var imageSize: CGSize = .zero var imageSize: CGSize = .zero
func getThumbnailImage() -> Promise<UIImage> { func getThumbnailImage() -> Promise<UIImage> {
@ -100,7 +104,7 @@ public enum AttachmentApprovalViewControllerMode: UInt {
} }
@objc @objc
public class AttachmentApprovalViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate, MediaMessageTextToolbarDelegate { public class AttachmentApprovalViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
// MARK: - Properties // MARK: - Properties
@ -193,8 +197,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
} }
self.setCurrentItem(firstItem, direction: .forward, animated: false) self.setCurrentItem(firstItem, direction: .forward, animated: false)
mediaMessageTextToolbar.messageText = currentViewController.attachment.captionText
} }
override public func viewWillAppear(_ animated: Bool) { override public func viewWillAppear(_ animated: Bool) {
@ -335,13 +337,6 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
} }
if transitionCompleted { if transitionCompleted {
UIView.transition(with: self.mediaMessageTextToolbar,
duration: 0.1,
options: .transitionCrossDissolve,
animations: {
self.mediaMessageTextToolbar.messageText = self.currentViewController.attachment.captionText
},
completion: nil)
previousPage.zoomOut(animated: false) previousPage.zoomOut(animated: false)
updateMediaRail() updateMediaRail()
} }
@ -411,6 +406,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
Logger.debug("cache miss.") Logger.debug("cache miss.")
let viewController = AttachmentPrepViewController(attachmentItem: item) let viewController = AttachmentPrepViewController(attachmentItem: item)
viewController.prepDelegate = self
cachedPages[item] = viewController cachedPages[item] = viewController
return viewController return viewController
@ -483,9 +479,9 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
@objc func cancelPressed(sender: UIButton) { @objc func cancelPressed(sender: UIButton) {
self.approvalDelegate?.attachmentApproval(self, didCancelAttachments: attachments) self.approvalDelegate?.attachmentApproval(self, didCancelAttachments: attachments)
} }
}
// MARK: - MediaMessageTextToolbarDelegate extension AttachmentApprovalViewController: MediaMessageTextToolbarDelegate {
var currentPageController: AttachmentPrepViewController { var currentPageController: AttachmentPrepViewController {
return viewControllers!.first as! AttachmentPrepViewController return viewControllers!.first as! AttachmentPrepViewController
} }
@ -506,13 +502,7 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
mediaMessageTextToolbar.isUserInteractionEnabled = false mediaMessageTextToolbar.isUserInteractionEnabled = false
mediaMessageTextToolbar.isHidden = true mediaMessageTextToolbar.isHidden = true
approvalDelegate?.attachmentApproval(self, didApproveAttachments: attachments) approvalDelegate?.attachmentApproval(self, didApproveAttachments: attachments, messageText: mediaMessageTextToolbar.messageText)
}
func mediaMessageTextToolbar(_ mediaMessageTextToolbar: MediaMessageTextToolbar, textViewDidChange textView: UITextView) {
currentItem.attachment.captionText = textView.text
self.approvalDelegate?.attachmentApproval?(self, changedCaptionOfAttachment: currentItem.attachment)
} }
func mediaMessageTextToolbarDidAddMore(_ mediaMessageTextToolbar: MediaMessageTextToolbar) { func mediaMessageTextToolbarDidAddMore(_ mediaMessageTextToolbar: MediaMessageTextToolbar) {
@ -520,6 +510,12 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC
} }
} }
extension AttachmentApprovalViewController: AttachmentPrepViewControllerDelegate {
func prepViewController(_ prepViewController: AttachmentPrepViewController, didUpdateCaptionForAttachmentItem attachmentItem: SignalAttachmentItem) {
self.approvalDelegate?.attachmentApproval?(self, changedCaptionOfAttachment: attachmentItem.attachment)
}
}
// MARK: GalleryRail // MARK: GalleryRail
extension SignalAttachmentItem: GalleryRailItem { extension SignalAttachmentItem: GalleryRailItem {
@ -563,6 +559,10 @@ extension AttachmentApprovalViewController: GalleryRailViewDelegate {
// MARK: - Individual Page // MARK: - Individual Page
protocol AttachmentPrepViewControllerDelegate: class {
func prepViewController(_ prepViewController: AttachmentPrepViewController, didUpdateCaptionForAttachmentItem attachmentItem: SignalAttachmentItem)
}
public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarDelegate, OWSVideoPlayerDelegate { public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarDelegate, OWSVideoPlayerDelegate {
// We sometimes shrink the attachment view so that it remains somewhat visible // We sometimes shrink the attachment view so that it remains somewhat visible
// when the keyboard is presented. // when the keyboard is presented.
@ -572,6 +572,8 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
// MARK: - Properties // MARK: - Properties
weak var prepDelegate: AttachmentPrepViewControllerDelegate?
let attachmentItem: SignalAttachmentItem let attachmentItem: SignalAttachmentItem
var attachment: SignalAttachment { var attachment: SignalAttachment {
return attachmentItem.attachment return attachmentItem.attachment
@ -598,7 +600,9 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
// MARK: - View Lifecycle // MARK: - View Lifecycle
let captionView = CaptionView() lazy var captionView: CaptionView = {
return CaptionView(attachmentItem: attachmentItem)
}()
override public func loadView() { override public func loadView() {
self.view = UIView() self.view = UIView()
@ -703,9 +707,9 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
// Caption // Caption
captionView.captionText = attachment.captionText
view.addSubview(captionView) view.addSubview(captionView)
captionView.delegate = self
captionView.autoPinWidthToSuperview() captionView.autoPinWidthToSuperview()
// MJK TODO ideal CaptionView placement // MJK TODO ideal CaptionView placement
@ -880,6 +884,14 @@ public class AttachmentPrepViewController: OWSViewController, PlayerProgressBarD
} }
} }
extension AttachmentPrepViewController: CaptionViewDelegate {
func captionView(_ captionView: CaptionView, didChangeCaptionText captionText: String?, attachmentItem: SignalAttachmentItem) {
let attachment = attachmentItem.attachment
attachment.captionText = captionText
prepDelegate?.prepViewController(self, didUpdateCaptionForAttachmentItem: attachmentItem)
}
}
extension AttachmentPrepViewController: UIScrollViewDelegate { extension AttachmentPrepViewController: UIScrollViewDelegate {
public func viewForZooming(in scrollView: UIScrollView) -> UIView? { public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
@ -997,7 +1009,7 @@ class BottomToolView: UIView {
} }
protocol CaptionViewDelegate: class { protocol CaptionViewDelegate: class {
func captionViewDidChange(_ captionView: CaptionView) func captionView(_ captionView: CaptionView, didChangeCaptionText captionText: String?, attachmentItem: SignalAttachmentItem)
} }
class CaptionView: UIView { class CaptionView: UIView {
@ -1010,6 +1022,11 @@ class CaptionView: UIView {
} }
} }
let attachmentItem: SignalAttachmentItem
var attachment: SignalAttachment {
return attachmentItem.attachment
}
weak var delegate: CaptionViewDelegate? weak var delegate: CaptionViewDelegate?
private let kMinTextViewHeight: CGFloat = 38 private let kMinTextViewHeight: CGFloat = 38
@ -1020,8 +1037,12 @@ class CaptionView: UIView {
// MARK: Initializers // MARK: Initializers
override init(frame: CGRect) { init(attachmentItem: SignalAttachmentItem) {
super.init(frame: frame) self.attachmentItem = attachmentItem
super.init(frame: .zero)
self.captionText = attachmentItem.captionText
addSubview(placeholderTextView) addSubview(placeholderTextView)
placeholderTextView.autoPinEdgesToSuperviewMargins() placeholderTextView.autoPinEdgesToSuperviewMargins()
@ -1094,12 +1115,6 @@ class CaptionView: UIView {
} }
extension CaptionView: UITextViewDelegate { extension CaptionView: UITextViewDelegate {
// @available(iOS 2.0, *)
// optional public func textViewShouldBeginEditing(_ textView: UITextView) -> Bool
//
// @available(iOS 2.0, *)
// optional public func textViewShouldEndEditing(_ textView: UITextView) -> Bool
//
public func textViewDidBeginEditing(_ textView: UITextView) { public func textViewDidBeginEditing(_ textView: UITextView) {
updatePlaceholderTextViewVisibility() updatePlaceholderTextViewVisibility()
} }
@ -1143,33 +1158,14 @@ extension CaptionView: UITextViewDelegate {
} }
public func textViewDidChange(_ textView: UITextView) { public func textViewDidChange(_ textView: UITextView) {
self.delegate?.captionViewDidChange(self) self.delegate?.captionView(self, didChangeCaptionText: textView.text, attachmentItem: attachmentItem)
} }
//
//
// @available(iOS 2.0, *)
// optional public func textViewDidChangeSelection(_ textView: UITextView)
//
//
// @available(iOS 10.0, *)
// optional public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool
//
// @available(iOS 10.0, *)
// optional public func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool
//
//
// @available(iOS, introduced: 7.0, deprecated: 10.0, message: "Use textView:shouldInteractWithURL:inRange:forInteractionType: instead")
// optional public func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange) -> Bool
//
// @available(iOS, introduced: 7.0, deprecated: 10.0, message: "Use textView:shouldInteractWithTextAttachment:inRange:forInteractionType: instead")
// optional public func textView(_ textView: UITextView, shouldInteractWith textAttachment: NSTextAttachment, in characterRange: NSRange) -> Bool
} }
protocol MediaMessageTextToolbarDelegate: class { protocol MediaMessageTextToolbarDelegate: class {
func mediaMessageTextToolbarDidTapSend(_ mediaMessageTextToolbar: MediaMessageTextToolbar) func mediaMessageTextToolbarDidTapSend(_ mediaMessageTextToolbar: MediaMessageTextToolbar)
func mediaMessageTextToolbarDidBeginEditing(_ mediaMessageTextToolbar: MediaMessageTextToolbar) func mediaMessageTextToolbarDidBeginEditing(_ mediaMessageTextToolbar: MediaMessageTextToolbar)
func mediaMessageTextToolbarDidEndEditing(_ mediaMessageTextToolbar: MediaMessageTextToolbar) func mediaMessageTextToolbarDidEndEditing(_ mediaMessageTextToolbar: MediaMessageTextToolbar)
func mediaMessageTextToolbar(_ mediaMessageTextToolbar: MediaMessageTextToolbar, textViewDidChange: UITextView)
func mediaMessageTextToolbarDidAddMore(_ mediaMessageTextToolbar: MediaMessageTextToolbar) func mediaMessageTextToolbarDidAddMore(_ mediaMessageTextToolbar: MediaMessageTextToolbar)
} }
@ -1342,7 +1338,6 @@ class MediaMessageTextToolbar: UIView, UITextViewDelegate {
public func textViewDidChange(_ textView: UITextView) { public func textViewDidChange(_ textView: UITextView) {
updateHeight(textView: textView) updateHeight(textView: textView)
self.mediaMessageTextToolbarDelegate?.mediaMessageTextToolbar(self, textViewDidChange: textView)
} }
public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {

Loading…
Cancel
Save