clang-format after RI

// FREEBIE
This commit is contained in:
Michael Kirk 2018-01-16 15:27:53 -05:00
parent a423fe8a0e
commit 0c6a42003f
8 changed files with 79 additions and 81 deletions

View File

@ -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"

View File

@ -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];

View File

@ -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));

View File

@ -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;
// 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
delay:0.0
options:UIViewAnimationOptionCurveEaseOut
animations:^(void) {
OWSAssert(self.replacingView);
self.replacingView.alpha = 1.0;
// fade out content and toolbars
self.navigationController.view.alpha = 0.0;
[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;
}
completion:^(BOOL finished) {
[self.presentingViewController dismissViewControllerAnimated:NO completion:completion];
}];
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];
}];
} 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__);
}
}

View File

@ -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)
}

View File

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import <UIKit/UIKit.h>

View File

@ -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)
}

View File

@ -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 {