From 0c6a42003fbffcb0aff14852134d940aa65aa124 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Tue, 16 Jan 2018 15:27:53 -0500 Subject: [PATCH] clang-format after RI // FREEBIE --- Signal/src/Signal-Bridging-Header.h | 2 +- .../ConversationViewController.m | 12 +- .../ConversationView/ConversationViewLayout.m | 2 +- .../MediaDetailViewController.m | 118 +++++++++--------- .../MessageDetailViewController.swift | 8 +- SignalMessaging/SignalMessaging.h | 2 +- .../attachments/MediaMessageView.swift | 6 +- SignalMessaging/categories/UIView+OWS.m | 6 +- 8 files changed, 77 insertions(+), 79 deletions(-) diff --git a/Signal/src/Signal-Bridging-Header.h b/Signal/src/Signal-Bridging-Header.h index 7c8bb2f93..82378ef00 100644 --- a/Signal/src/Signal-Bridging-Header.h +++ b/Signal/src/Signal-Bridging-Header.h @@ -11,8 +11,8 @@ #import "DateUtil.h" #import "DebugUIPage.h" #import "FingerprintViewController.h" -#import "MediaDetailViewController.h" #import "HomeViewController.h" +#import "MediaDetailViewController.h" #import "NotificationsManager.h" #import "OWSAnyTouchGestureRecognizer.h" #import "OWSAudioAttachmentPlayer.h" diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index c2b3e8f43..4d5b97089 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -1996,8 +1996,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { UIWindow *window = [UIApplication sharedApplication].keyWindow; CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window]; MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream - fromRect:convertedRect - viewItem:viewItem]; + fromRect:convertedRect + viewItem:viewItem]; [vc presentFromViewController:self replacingView:imageView]; } @@ -2014,8 +2014,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window]; MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream - fromRect:convertedRect - viewItem:viewItem]; + fromRect:convertedRect + viewItem:viewItem]; [vc presentFromViewController:self replacingView:imageView]; } @@ -3062,7 +3062,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { // content to fill the collection view at its current size. CGFloat contentOffsetYBottom = MAX(0.f, contentHeight + self.collectionView.contentInset.bottom - self.collectionView.bounds.size.height); - + CGFloat distanceFromBottom = contentOffsetYBottom - self.collectionView.contentOffset.y; BOOL isScrolledToBottom = distanceFromBottom <= kIsAtBottomTolerancePts; @@ -3770,7 +3770,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) { if (self.isUserScrolling) { return; } - + // Ensure the view is fully layed out before we try to scroll to the bottom, since // we use the collectionView bounds to determine where the "bottom" is. [self.view layoutIfNeeded]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m index f0dbdfb27..22a8eb9db 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewLayout.m @@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN [self clearState]; return; } - + if (self.collectionView.bounds.size.width <= 0.f || self.collectionView.bounds.size.height <= 0.f) { OWSFail( @"%@ Collection view has invalid size: %@", self.logTag, NSStringFromCGRect(self.collectionView.bounds)); diff --git a/Signal/src/ViewControllers/MediaDetailViewController.m b/Signal/src/ViewControllers/MediaDetailViewController.m index 70fb71e22..c8e987615 100644 --- a/Signal/src/ViewControllers/MediaDetailViewController.m +++ b/Signal/src/ViewControllers/MediaDetailViewController.m @@ -31,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN @implementation AttachmentMenuView -- (BOOL)canBecomeFirstResponder { +- (BOOL)canBecomeFirstResponder +{ return YES; } @@ -87,7 +88,7 @@ NS_ASSUME_NONNULL_BEGIN if (self) { self.attachmentStream = attachmentStream; - self.originRect = rect; + self.originRect = rect; self.viewItem = viewItem; } @@ -128,7 +129,8 @@ NS_ASSUME_NONNULL_BEGIN return _fileData; } -- (UIImage *)image { +- (UIImage *)image +{ if (self.attachmentStream) { return self.attachmentStream.image; } else if (self.attachment) { @@ -191,12 +193,12 @@ NS_ASSUME_NONNULL_BEGIN action:@selector(didTapDismissButton:)]; } -- (void)viewWillDisappear:(BOOL)animated { +- (void)viewWillDisappear:(BOOL)animated +{ [super viewWillDisappear:animated]; - + if ([UIMenuController sharedMenuController].isMenuVisible) { - [[UIMenuController sharedMenuController] setMenuVisible:NO - animated:NO]; + [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO]; } } @@ -289,7 +291,7 @@ NS_ASSUME_NONNULL_BEGIN // It's a static image of the media content. UIImageView *presentationView = [[UIImageView alloc] initWithImage:self.image]; self.presentationView = presentationView; - + [self.view addSubview:presentationView]; presentationView.hidden = YES; presentationView.clipsToBounds = YES; @@ -297,7 +299,7 @@ NS_ASSUME_NONNULL_BEGIN presentationView.layer.minificationFilter = kCAFilterTrilinear; presentationView.layer.magnificationFilter = kCAFilterTrilinear; presentationView.contentMode = UIViewContentModeScaleAspectFit; - + [self applyInitialMediaViewConstraints]; if (self.isVideo) { @@ -467,7 +469,7 @@ NS_ASSUME_NONNULL_BEGIN [[UIApplication sharedApplication] setStatusBarHidden:areToolbarsHidden withAnimation:UIStatusBarAnimationNone]; [self.navigationController setNavigationBarHidden:areToolbarsHidden animated:NO]; self.videoProgressBar.hidden = areToolbarsHidden; - + // We don't animate the background color change because the old color shows through momentarily // behind where the status bar "used to be". self.view.backgroundColor = areToolbarsHidden ? UIColor.blackColor : UIColor.whiteColor; @@ -495,20 +497,20 @@ NS_ASSUME_NONNULL_BEGIN // but in practice it works better if you use a separate GR for each // direction. for (NSNumber *direction in @[ - @(UISwipeGestureRecognizerDirectionRight), - @(UISwipeGestureRecognizerDirectionLeft), - @(UISwipeGestureRecognizerDirectionUp), - @(UISwipeGestureRecognizerDirectionDown), - ]) { + @(UISwipeGestureRecognizerDirectionRight), + @(UISwipeGestureRecognizerDirectionLeft), + @(UISwipeGestureRecognizerDirectionUp), + @(UISwipeGestureRecognizerDirectionDown), + ]) { UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeImage:)]; - swipe.direction = (UISwipeGestureRecognizerDirection) direction.integerValue; + swipe.direction = (UISwipeGestureRecognizerDirection)direction.integerValue; swipe.delegate = self; [self.view addGestureRecognizer:swipe]; } - UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self - action:@selector(longPressGesture:)]; + UILongPressGestureRecognizer *longPress = + [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGesture:)]; longPress.delegate = self; [self.view addGestureRecognizer:longPress]; } @@ -564,7 +566,8 @@ NS_ASSUME_NONNULL_BEGIN [self dismissSelfAnimated:YES completion:nil]; } -- (void)longPressGesture:(UIGestureRecognizer *)sender { +- (void)longPressGesture:(UIGestureRecognizer *)sender +{ // We "eagerly" respond when the long press begins, not when it ends. if (sender.state == UIGestureRecognizerStateBegan) { if (!self.viewItem) { @@ -572,22 +575,17 @@ NS_ASSUME_NONNULL_BEGIN } [self.view becomeFirstResponder]; - + if ([UIMenuController sharedMenuController].isMenuVisible) { - [[UIMenuController sharedMenuController] setMenuVisible:NO - animated:NO]; + [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO]; } NSArray *menuItems = self.viewItem.mediaMenuControllerItems; [UIMenuController sharedMenuController].menuItems = menuItems; CGPoint location = [sender locationInView:self.view]; - CGRect targetRect = CGRectMake(location.x, - location.y, - 1, 1); - [[UIMenuController sharedMenuController] setTargetRect:targetRect - inView:self.view]; - [[UIMenuController sharedMenuController] setMenuVisible:YES - animated:YES]; + CGRect targetRect = CGRectMake(location.x, location.y, 1, 1); + [[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self.view]; + [[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES]; } } @@ -784,11 +782,12 @@ NS_ASSUME_NONNULL_BEGIN } completion:^(BOOL finished) { // HACK: Setting the frame to itself *seems* like it should be a no-op, but - // it ensures the content is drawn at the right frame. In particular I was reproducibly - // some images squished (they were EXIF rotated, maybe relateed). - // similar to this report: https://stackoverflow.com/questions/27961884/swift-uiimageview-stretched-aspect + // it ensures the content is drawn at the right frame. In particular I was + // reproducibly some images squished (they were EXIF rotated, maybe + // relateed). similar to this report: + // https://stackoverflow.com/questions/27961884/swift-uiimageview-stretched-aspect self.mediaView.frame = self.mediaView.frame; - + // At this point our presentation view should be overlayed perfectly // with our media view. Swapping them out should be imperceptible. self.mediaView.hidden = NO; @@ -823,33 +822,33 @@ NS_ASSUME_NONNULL_BEGIN if (isAnimated) { [UIView animateWithDuration:0.18 - delay:0.0 - options:UIViewAnimationOptionCurveEaseOut - animations:^(void) { - [self.presentationView.superview layoutIfNeeded]; - self.presentationView.layer.cornerRadius = OWSMessageCellCornerRadius; + delay:0.0 + options:UIViewAnimationOptionCurveEaseOut + animations:^(void) { + [self.presentationView.superview layoutIfNeeded]; + self.presentationView.layer.cornerRadius = OWSMessageCellCornerRadius; - // In case user has hidden bars, which changes background to black. - self.view.backgroundColor = UIColor.whiteColor; + // In case user has hidden bars, which changes background to black. + self.view.backgroundColor = UIColor.whiteColor; - } + } completion:nil]; - + [UIView animateWithDuration:0.1 - delay:0.15 - options:UIViewAnimationOptionCurveEaseInOut - animations:^(void) { - - OWSAssert(self.replacingView); - self.replacingView.alpha = 1.0; - - // fade out content and toolbars - self.navigationController.view.alpha = 0.0; - } - completion:^(BOOL finished) { - [self.presentingViewController dismissViewControllerAnimated:NO completion:completion]; - }]; - + delay:0.15 + options:UIViewAnimationOptionCurveEaseInOut + animations:^(void) { + + OWSAssert(self.replacingView); + self.replacingView.alpha = 1.0; + + // fade out content and toolbars + self.navigationController.view.alpha = 0.0; + } + completion:^(BOOL finished) { + [self.presentingViewController dismissViewControllerAnimated:NO completion:completion]; + }]; + } else { self.replacingView.alpha = 1.0; [self.presentingViewController dismissViewControllerAnimated:NO completion:completion]; @@ -973,11 +972,12 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Saving images to Camera Roll -- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo { +- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo +{ if (error) { DDLogWarn(@"There was a problem saving <%@> to camera roll from %s ", - error.localizedDescription, - __PRETTY_FUNCTION__); + error.localizedDescription, + __PRETTY_FUNCTION__); } } diff --git a/Signal/src/ViewControllers/MessageDetailViewController.swift b/Signal/src/ViewControllers/MessageDetailViewController.swift index d5d328ff0..68cced685 100644 --- a/Signal/src/ViewControllers/MessageDetailViewController.swift +++ b/Signal/src/ViewControllers/MessageDetailViewController.swift @@ -414,7 +414,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate, Medi private func addAttachmentRows() -> [UIView] { var rows = [UIView]() - + guard let attachment = self.attachment else { Logger.warn("\(TAG) Missing attachment. Was it deleted?") return rows @@ -754,15 +754,15 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate, Medi } // MARK: MediaDetailPresenter - - public func presentDetails(mediaMessageView: MediaMessageView, fromView: UIView) { + + public func presentDetails(mediaMessageView: MediaMessageView, fromView: UIView) { let window = UIApplication.shared.keyWindow let convertedRect = fromView.convert(fromView.bounds, to:window) guard let attachmentStream = self.attachmentStream else { owsFail("attachment stream unexpectedly nil") return } - + let mediaDetailViewController = MediaDetailViewController(attachmentStream: attachmentStream, from: convertedRect, viewItem: self.viewItem) mediaDetailViewController.present(from: self, replacing: fromView) } diff --git a/SignalMessaging/SignalMessaging.h b/SignalMessaging/SignalMessaging.h index 613fd0b75..5122e313f 100644 --- a/SignalMessaging/SignalMessaging.h +++ b/SignalMessaging/SignalMessaging.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. // #import diff --git a/SignalMessaging/attachments/MediaMessageView.swift b/SignalMessaging/attachments/MediaMessageView.swift index 26658af65..7aeb3623f 100644 --- a/SignalMessaging/attachments/MediaMessageView.swift +++ b/SignalMessaging/attachments/MediaMessageView.swift @@ -61,7 +61,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { @objc public var contentView: UIView? - + private let mediaDetailPresenter: MediaDetailPresenter? // MARK: Initializers @@ -475,7 +475,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { guard let fromView = sender.view else { return } - + showMediaDetailViewController(fromView: fromView) } @@ -493,7 +493,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { guard let fromView = sender.view else { return } - + showMediaDetailViewController(fromView: fromView) } diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index bfa6aa319..6f11633d9 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -303,8 +303,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = - [self.bottomAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.bottomAnchor - constant:-margin]; + [self.bottomAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.bottomAnchor constant:-margin]; constraint.active = YES; return constraint; } else { @@ -316,8 +315,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) { if (@available(iOS 9.0, *)) { NSLayoutConstraint *constraint = - [self.topAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.topAnchor - constant:margin]; + [self.topAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.topAnchor constant:margin]; constraint.active = YES; return constraint; } else {