From cf48fb30769d9b38f6abd1be25441949e0743520 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 14 Dec 2018 11:03:54 -0700 Subject: [PATCH 1/3] Don't use caption field --- .../ConversationView/ConversationViewController.m | 10 ++++++---- .../AttachmentApprovalViewController.swift | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 44a494465..4a7981bd8 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -2815,7 +2815,7 @@ typedef enum : NSUInteger { } } -- (void)sendMessageAttachments:(NSArray *)attachments +- (void)sendMessageAttachments:(NSArray *)attachments messageText:(nullable NSString *)messageText { OWSAssertIsOnMainThread(); for (SignalAttachment *attachment in attachments) { @@ -2824,8 +2824,9 @@ typedef enum : NSUInteger { } BOOL didAddToProfileWhitelist = [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; + TSOutgoingMessage *message = [ThreadUtil enqueueMessageWithAttachments:attachments - messageBody:nil + messageBody:messageText inThread:self.thread quotedReplyModel:self.inputToolbar.quotedReply]; @@ -3546,7 +3547,7 @@ typedef enum : NSUInteger { } if (skipApprovalDialog) { - [self sendMessageAttachments:attachments]; + [self sendMessageAttachments:attachments messageText:nil]; } else { OWSNavigationController *modal = [AttachmentApprovalViewController wrappedInNavControllerWithAttachments:attachments @@ -3662,8 +3663,9 @@ typedef enum : NSUInteger { - (void)attachmentApproval:(AttachmentApprovalViewController *)attachmentApproval didApproveAttachments:(NSArray *)attachments + messageText:(nullable NSString *)messageText { - [self sendMessageAttachments:attachments]; + [self sendMessageAttachments:attachments messageText:messageText]; [self dismissViewControllerAnimated:YES completion:nil]; // 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 diff --git a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift index e12babbc8..06e76d7e2 100644 --- a/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift +++ b/SignalMessaging/ViewControllers/AttachmentApprovalViewController.swift @@ -8,7 +8,7 @@ import MediaPlayer @objc 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]) } @@ -326,11 +326,14 @@ public class AttachmentApprovalViewController: UIPageViewController, UIPageViewC captioningToolbar.isUserInteractionEnabled = false captioningToolbar.isHidden = true - approvalDelegate?.attachmentApproval(self, didApproveAttachments: attachments) + approvalDelegate?.attachmentApproval(self, didApproveAttachments: attachments, messageText: captioningToolbar.captionText) } func captioningToolbar(_ captioningToolbar: CaptioningToolbar, textViewDidChange textView: UITextView) { - currentItem.attachment.captionText = textView.text + // For 2.32.0 we only have one input bar - and it's for mesageBody text, not for caption text. + // For 2.33.0 there are potentially two input bars - one for message body and one for caption text. + // Commenting this out for now, but we'll have to resolve this merge conflict when RI'ing to 2.33 + // currentItem.attachment.captionText = textView.text } } From 31a1fe10c7cbbb636233c86bfd7a08e1d33d9e6b Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 14 Dec 2018 11:13:09 -0700 Subject: [PATCH 2/3] "Bump build to 2.32.1.0." --- Signal/Signal-Info.plist | 4 ++-- SignalShareExtension/Info.plist | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 0dcf5b4aa..595f3376c 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -32,7 +32,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 2.32.0 + 2.32.1 CFBundleSignature ???? CFBundleURLTypes @@ -49,7 +49,7 @@ CFBundleVersion - 2.32.0.23 + 2.32.1.0 ITSAppUsesNonExemptEncryption LOGS_EMAIL diff --git a/SignalShareExtension/Info.plist b/SignalShareExtension/Info.plist index 223f2664b..98e2b1301 100644 --- a/SignalShareExtension/Info.plist +++ b/SignalShareExtension/Info.plist @@ -17,9 +17,9 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 2.32.0 + 2.32.1 CFBundleVersion - 2.32.0.23 + 2.32.1.0 ITSAppUsesNonExemptEncryption NSAppTransportSecurity From fcea9f07b0d51a0ae6b327e0170a9a53b89f5572 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 14 Dec 2018 14:54:08 -0700 Subject: [PATCH 3/3] Fix hang on iOS10. Offsetting by a large number was a work-around to the late assignment of safeAreaInsets. Before iOS11, safeAreaInsets didn't exist, and contentInsets are set *before* viewDidAppear, so this workaround wasn't relevant. --- .../PhotoLibrary/ImagePickerController.swift | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift index c9cc525d6..a4694441a 100644 --- a/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift +++ b/Signal/src/ViewControllers/PhotoLibrary/ImagePickerController.swift @@ -155,20 +155,32 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat return } - // We could try to be more precise by doing something like - // - // let botomOffset = collectionView.contentSize + collectionView.contentInset.top - collectionView.bounds.height - // - // But `collectionView.contentInset` is based on `safeAreaInsets`, which isn't accurate - // until `viewDidAppear` at the earliest. - // - // from https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area - // > Make your modifications in [viewDidAppear] because the safe area insets for a view are - // > not accurate until the view is added to a view hierarchy. - // - // Overshooting like this works without visible animation glitch. - let bottomOffset = CGFloat.greatestFiniteMagnitude - collectionView.setContentOffset(CGPoint(x: 0, y: bottomOffset), animated: animated) + let verticalOffset: CGFloat + if #available(iOS 11, *) { + // On iOS10 and earlier, we can be precise, but as of iOS11 `collectionView.contentInset` + // is based on `safeAreaInsets`, which isn't accurate until `viewDidAppear` at the earliest. + // + // from https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area + // > Make your modifications in [viewDidAppear] because the safe area insets for a view are + // > not accurate until the view is added to a view hierarchy. + // + // Overshooting like this works without visible animation glitch. on iOS11+ + // However, before iOS11, "overshooting" the contentOffset like this produces a broken + // layout or hanging. Luckily for those versions, before the safeAreaInset feature + // existed, we can accurately accesse colletionView.contentInset before `viewDidAppear` + // and calculate a precise content offset. + verticalOffset = CGFloat.greatestFiniteMagnitude + } else { + let visibleHeight = collectionView.bounds.height - collectionView.contentInset.top + let contentHeight = collectionView.contentSize.height + if contentHeight <= visibleHeight { + verticalOffset = -collectionView.contentInset.top + } else { + let topOfLastPage = contentHeight - collectionView.bounds.height + verticalOffset = topOfLastPage + } + } + collectionView.setContentOffset(CGPoint(x: 0, y: verticalOffset), animated: animated) } private func reloadDataAndRestoreSelection() {