From 9df6b4bb784a6e19de2ad8bc6842edc2168e6cd6 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 13 Jul 2018 16:24:45 -0600 Subject: [PATCH 1/2] Fix "contact cell too close to edge" in detail view (iOS9/iOS10) Don't mix concepts of left/right with leading/trailing. --- Signal/src/ViewControllers/MessageDetailViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift index 1b21c2ebb7..b98c0163cb 100644 --- a/Signal/src/ViewControllers/MessageDetailViewController.swift +++ b/Signal/src/ViewControllers/MessageDetailViewController.swift @@ -261,7 +261,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele let wrapper = UIView() wrapper.layoutMargins = UIEdgeInsets(top: 8, left: 20, bottom: 8, right: 20) wrapper.addSubview(cellView) - cellView.autoPinToSuperviewMargins() + cellView.autoPinEdgesToSuperviewMargins() groupRows.append(wrapper) } From 8da47b64d9c9f88b2f92f27ae99ff7813095cdbe Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Fri, 13 Jul 2018 16:26:58 -0600 Subject: [PATCH 2/2] clarify different methods These method names were too similar to existing methods in PureLayout, which have slightly different behavior. ows_autoPinToSuperviewEdges uses left/right, whereas PureLayouts uses leading/trailing ows_autoPinToSuperviewMargins uses our own constraint adding logic, which behaves differently in some cases. --- .../AppSettings/OWSQRCodeScanningViewController.m | 2 +- .../ConversationView/Cells/OWSContactShareButtonsView.m | 2 +- .../ConversationView/Cells/OWSContactShareView.m | 2 +- .../ConversationView/Cells/OWSMessageBubbleView.m | 8 ++++---- .../ConversationView/Cells/OWSMessageTimerView.m | 2 +- .../ConversationView/Cells/OWSQuotedMessageView.m | 2 +- .../ConversationView/ConversationInputToolbar.m | 4 ++-- Signal/src/ViewControllers/GifPicker/GifPickerCell.swift | 2 +- Signal/src/ViewControllers/MediaDetailViewController.m | 2 +- .../src/ViewControllers/MenuActionsViewController.swift | 4 ++-- .../ThreadSettings/FingerprintViewController.m | 2 +- Signal/src/views/ReminderView.swift | 2 +- SignalMessaging/Views/OWSFlatButton.swift | 2 +- SignalMessaging/attachments/VideoPlayerView.swift | 2 +- SignalMessaging/categories/UIView+OWS.h | 4 ++-- SignalMessaging/categories/UIView+OWS.m | 4 ++-- 16 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m b/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m index 4cd7ba3e9d..8d6df66f18 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSQRCodeScanningViewController.m @@ -75,7 +75,7 @@ NS_ASSUME_NONNULL_BEGIN layer.opacity = 0.5f; }]; [self.view addSubview:maskingView]; - [maskingView autoPinToSuperviewEdges]; + [maskingView ows_autoPinToSuperviewEdges]; } - (void)viewWillAppear:(BOOL)animated diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m index d610189d90..bd6a718083 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareButtonsView.m @@ -132,7 +132,7 @@ NS_ASSUME_NONNULL_BEGIN label.textColor = UIColor.ows_materialBlueColor; label.textAlignment = NSTextAlignmentCenter; [self addSubview:label]; - [label autoPinToSuperviewEdges]; + [label ows_autoPinToSuperviewEdges]; [label autoSetDimension:ALDimensionHeight toSize:OWSContactShareButtonsView.buttonHeight]; self.userInteractionEnabled = YES; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m index a51bc035d0..077722987a 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSContactShareView.m @@ -157,7 +157,7 @@ NS_ASSUME_NONNULL_BEGIN [hStackView addArrangedSubview:labelsView]; [hStackView addArrangedSubview:disclosureImageView]; [self addSubview:hStackView]; - [hStackView autoPinToSuperviewEdges]; + [hStackView ows_autoPinToSuperviewEdges]; } @end diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 17fa9c6181..ff99305ae3 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -363,7 +363,7 @@ NS_ASSUME_NONNULL_BEGIN [self.viewConstraints addObjectsFromArray:[clipView autoPinToEdgesOfView:proxyView]]; [clipView addSubview:bodyMediaView]; - [self.viewConstraints addObjectsFromArray:[bodyMediaView autoPinToSuperviewEdges]]; + [self.viewConstraints addObjectsFromArray:[bodyMediaView ows_autoPinToSuperviewEdges]]; [self.bubbleView addPartnerView:shadowView1]; [self.bubbleView addPartnerView:shadowView2]; @@ -447,7 +447,7 @@ NS_ASSUME_NONNULL_BEGIN }]; [gradientView.layer addSublayer:gradientLayer]; [bodyMediaView addSubview:gradientView]; - [self.viewConstraints addObjectsFromArray:[gradientView autoPinToSuperviewEdges]]; + [self.viewConstraints addObjectsFromArray:[gradientView ows_autoPinToSuperviewEdges]]; [self.footerView configureWithConversationViewItem:self.viewItem isOverlayingMedia:YES @@ -528,7 +528,7 @@ NS_ASSUME_NONNULL_BEGIN [self.viewConstraints addObjectsFromArray:[clipView autoPinToEdgesOfView:proxyView]]; [clipView addSubview:buttonsView]; - [self.viewConstraints addObjectsFromArray:[buttonsView autoPinToSuperviewEdges]]; + [self.viewConstraints addObjectsFromArray:[buttonsView ows_autoPinToSuperviewEdges]]; [self.bubbleView addPartnerView:shadowView]; [self.bubbleView addPartnerView:clipView]; @@ -1091,7 +1091,7 @@ NS_ASSUME_NONNULL_BEGIN [[AttachmentUploadView alloc] initWithAttachment:self.attachmentStream attachmentStateCallback:attachmentStateCallback]; [self.bubbleView addSubview:attachmentUploadView]; - [attachmentUploadView autoPinToSuperviewEdges]; + [attachmentUploadView ows_autoPinToSuperviewEdges]; } } } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m index ed7096193c..5a8fc48fca 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageTimerView.m @@ -56,7 +56,7 @@ const CGFloat kDisappearingMessageIconSize = 12.f; { self.imageView = [UIImageView new]; [self addSubview:self.imageView]; - [self.imageView autoPinToSuperviewEdges]; + [self.imageView ows_autoPinToSuperviewEdges]; [self.imageView autoSetDimension:ALDimensionWidth toSize:kDisappearingMessageIconSize]; [self.imageView autoSetDimension:ALDimensionHeight toSize:kDisappearingMessageIconSize]; } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index 1f65657ab9..1c4038a8b4 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -190,7 +190,7 @@ NS_ASSUME_NONNULL_BEGIN hStackView.axis = UILayoutConstraintAxisHorizontal; hStackView.spacing = self.hSpacing; [innerBubbleView addSubview:hStackView]; - [hStackView autoPinToSuperviewEdges]; + [hStackView ows_autoPinToSuperviewEdges]; UIView *stripeView = [UIView new]; stripeView.backgroundColor = [self.conversationStyle quotedReplyStripeColorWithIsIncoming:!self.isOutgoing]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index 9b31d413fa..aeb2a92c69 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -248,7 +248,7 @@ const CGFloat kMaxTextViewHeight = 98; UIView *wrapper = [UIView containerView]; wrapper.layoutMargins = UIEdgeInsetsMake(self.quotedMessageTopMargin, 0, 0, 0); [wrapper addSubview:quotedMessagePreview]; - [quotedMessagePreview autoPinToSuperviewMargins]; + [quotedMessagePreview ows_autoPinToSuperviewMargins]; [self.contentRows insertArrangedSubview:wrapper atIndex:0]; @@ -386,7 +386,7 @@ const CGFloat kMaxTextViewHeight = 98; self.voiceMemoContentView = [UIView new]; [self.voiceMemoUI addSubview:self.voiceMemoContentView]; - [self.voiceMemoContentView autoPinToSuperviewEdges]; + [self.voiceMemoContentView ows_autoPinToSuperviewEdges]; self.recordingLabel = [UILabel new]; self.recordingLabel.textColor = [UIColor ows_destructiveRedColor]; diff --git a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift index 0dc4c3ee7c..6f2e44ae39 100644 --- a/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift +++ b/Signal/src/ViewControllers/GifPicker/GifPickerCell.swift @@ -206,7 +206,7 @@ class GifPickerCell: UICollectionViewCell { let imageView = YYAnimatedImageView() self.imageView = imageView self.contentView.addSubview(imageView) - imageView.autoPinToSuperviewEdges() + imageView.ows_autoPinToSuperviewEdges() } guard let imageView = imageView else { owsFail("\(TAG) missing imageview.") diff --git a/Signal/src/ViewControllers/MediaDetailViewController.m b/Signal/src/ViewControllers/MediaDetailViewController.m index e96f88a850..24fb2baa63 100644 --- a/Signal/src/ViewControllers/MediaDetailViewController.m +++ b/Signal/src/ViewControllers/MediaDetailViewController.m @@ -180,7 +180,7 @@ NS_ASSUME_NONNULL_BEGIN self.automaticallyAdjustsScrollViewInsets = NO; } - [scrollView autoPinToSuperviewEdges]; + [scrollView ows_autoPinToSuperviewEdges]; if (self.isAnimated) { if (self.attachmentStream.isValidImage) { diff --git a/Signal/src/ViewControllers/MenuActionsViewController.swift b/Signal/src/ViewControllers/MenuActionsViewController.swift index c4ad64f604..758009ee4d 100644 --- a/Signal/src/ViewControllers/MenuActionsViewController.swift +++ b/Signal/src/ViewControllers/MenuActionsViewController.swift @@ -293,7 +293,7 @@ class MenuActionSheetView: UIView, MenuActionViewDelegate { backgroundColor = UIColor.ows_light10 addSubview(actionStackView) - actionStackView.autoPinToSuperviewEdges() + actionStackView.ows_autoPinToSuperviewEdges() self.clipsToBounds = true @@ -378,7 +378,7 @@ class MenuActionView: UIButton { contentRow.isUserInteractionEnabled = false self.addSubview(contentRow) - contentRow.autoPinToSuperviewMargins() + contentRow.ows_autoPinToSuperviewMargins() contentRow.autoSetDimension(.height, toSize: 56, relation: .greaterThanOrEqual) self.addTarget(self, action: #selector(didPress(sender:)), for: .touchUpInside) diff --git a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m index 80cf20b1dd..f202bee290 100644 --- a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m @@ -289,7 +289,7 @@ typedef void (^CustomLayoutBlock)(void); layer.path = [UIBezierPath bezierPathWithOvalInRect:circle].CGPath; }]; [fingerprintView addSubview:fingerprintCircle]; - [fingerprintCircle autoPinToSuperviewEdges]; + [fingerprintCircle ows_autoPinToSuperviewEdges]; UIImageView *fingerprintImageView = [UIImageView new]; fingerprintImageView.image = self.fingerprint.image; diff --git a/Signal/src/views/ReminderView.swift b/Signal/src/views/ReminderView.swift index c84c3bb44a..5b8e4201fd 100644 --- a/Signal/src/views/ReminderView.swift +++ b/Signal/src/views/ReminderView.swift @@ -80,7 +80,7 @@ class ReminderView: UIView { self.addSubview(container) container.layoutMargins = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16) - container.autoPinToSuperviewEdges() + container.ows_autoPinToSuperviewEdges() // Label label.font = UIFont.ows_dynamicTypeSubheadline diff --git a/SignalMessaging/Views/OWSFlatButton.swift b/SignalMessaging/Views/OWSFlatButton.swift index f3e65715aa..12ed64e515 100644 --- a/SignalMessaging/Views/OWSFlatButton.swift +++ b/SignalMessaging/Views/OWSFlatButton.swift @@ -41,7 +41,7 @@ public class OWSFlatButton: UIView { private func createContent() { self.addSubview(button) button.addTarget(self, action: #selector(buttonPressed), for: .touchUpInside) - button.autoPinToSuperviewEdges() + button.ows_autoPinToSuperviewEdges() } @objc diff --git a/SignalMessaging/attachments/VideoPlayerView.swift b/SignalMessaging/attachments/VideoPlayerView.swift index 187802617e..c59aa5564b 100644 --- a/SignalMessaging/attachments/VideoPlayerView.swift +++ b/SignalMessaging/attachments/VideoPlayerView.swift @@ -109,7 +109,7 @@ public class PlayerProgressBar: UIView { backgroundColor = UIColor.lightGray.withAlphaComponent(0.5) if !UIAccessibilityIsReduceTransparencyEnabled() { addSubview(blurEffectView) - blurEffectView.autoPinToSuperviewEdges() + blurEffectView.ows_autoPinToSuperviewEdges() } // Configure controls diff --git a/SignalMessaging/categories/UIView+OWS.h b/SignalMessaging/categories/UIView+OWS.h index 1206a2e7bf..59f27e2680 100644 --- a/SignalMessaging/categories/UIView+OWS.h +++ b/SignalMessaging/categories/UIView+OWS.h @@ -27,8 +27,8 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value); - (NSArray *)autoPinHeightToSuperviewWithMargin:(CGFloat)margin; - (NSArray *)autoPinHeightToSuperview; -- (NSArray *)autoPinToSuperviewEdges; -- (NSArray *)autoPinToSuperviewMargins; +- (NSArray *)ows_autoPinToSuperviewEdges; +- (NSArray *)ows_autoPinToSuperviewMargins; - (NSLayoutConstraint *)autoHCenterInSuperview; - (NSLayoutConstraint *)autoVCenterInSuperview; diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index 5fa542ce9a..067e378101 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -79,7 +79,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) return result; } -- (NSArray *)autoPinToSuperviewEdges +- (NSArray *)ows_autoPinToSuperviewEdges { NSArray *result = @[ [self autoPinEdgeToSuperviewEdge:ALEdgeLeft], @@ -90,7 +90,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) return result; } -- (NSArray *)autoPinToSuperviewMargins +- (NSArray *)ows_autoPinToSuperviewMargins { NSArray *result = @[ [self autoPinTopToSuperviewMargin],