clang-format after RI

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent a423fe8a0e
commit 0c6a42003f

@ -11,8 +11,8 @@
#import "DateUtil.h" #import "DateUtil.h"
#import "DebugUIPage.h" #import "DebugUIPage.h"
#import "FingerprintViewController.h" #import "FingerprintViewController.h"
#import "MediaDetailViewController.h"
#import "HomeViewController.h" #import "HomeViewController.h"
#import "MediaDetailViewController.h"
#import "NotificationsManager.h" #import "NotificationsManager.h"
#import "OWSAnyTouchGestureRecognizer.h" #import "OWSAnyTouchGestureRecognizer.h"
#import "OWSAudioAttachmentPlayer.h" #import "OWSAudioAttachmentPlayer.h"

@ -1996,8 +1996,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
UIWindow *window = [UIApplication sharedApplication].keyWindow; UIWindow *window = [UIApplication sharedApplication].keyWindow;
CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window]; CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window];
MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream
fromRect:convertedRect fromRect:convertedRect
viewItem:viewItem]; viewItem:viewItem];
[vc presentFromViewController:self replacingView:imageView]; [vc presentFromViewController:self replacingView:imageView];
} }
@ -2014,8 +2014,8 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window]; CGRect convertedRect = [imageView convertRect:imageView.bounds toView:window];
MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream MediaDetailViewController *vc = [[MediaDetailViewController alloc] initWithAttachmentStream:attachmentStream
fromRect:convertedRect fromRect:convertedRect
viewItem:viewItem]; viewItem:viewItem];
[vc presentFromViewController:self replacingView:imageView]; [vc presentFromViewController:self replacingView:imageView];
} }
@ -3062,7 +3062,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
// content to fill the collection view at its current size. // content to fill the collection view at its current size.
CGFloat contentOffsetYBottom CGFloat contentOffsetYBottom
= MAX(0.f, contentHeight + self.collectionView.contentInset.bottom - self.collectionView.bounds.size.height); = MAX(0.f, contentHeight + self.collectionView.contentInset.bottom - self.collectionView.bounds.size.height);
CGFloat distanceFromBottom = contentOffsetYBottom - self.collectionView.contentOffset.y; CGFloat distanceFromBottom = contentOffsetYBottom - self.collectionView.contentOffset.y;
BOOL isScrolledToBottom = distanceFromBottom <= kIsAtBottomTolerancePts; BOOL isScrolledToBottom = distanceFromBottom <= kIsAtBottomTolerancePts;
@ -3770,7 +3770,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
if (self.isUserScrolling) { if (self.isUserScrolling) {
return; return;
} }
// Ensure the view is fully layed out before we try to scroll to the bottom, since // 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. // we use the collectionView bounds to determine where the "bottom" is.
[self.view layoutIfNeeded]; [self.view layoutIfNeeded];

@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN
[self clearState]; [self clearState];
return; return;
} }
if (self.collectionView.bounds.size.width <= 0.f || self.collectionView.bounds.size.height <= 0.f) { if (self.collectionView.bounds.size.width <= 0.f || self.collectionView.bounds.size.height <= 0.f) {
OWSFail( OWSFail(
@"%@ Collection view has invalid size: %@", self.logTag, NSStringFromCGRect(self.collectionView.bounds)); @"%@ Collection view has invalid size: %@", self.logTag, NSStringFromCGRect(self.collectionView.bounds));

@ -31,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
@implementation AttachmentMenuView @implementation AttachmentMenuView
- (BOOL)canBecomeFirstResponder { - (BOOL)canBecomeFirstResponder
{
return YES; return YES;
} }
@ -87,7 +88,7 @@ NS_ASSUME_NONNULL_BEGIN
if (self) { if (self) {
self.attachmentStream = attachmentStream; self.attachmentStream = attachmentStream;
self.originRect = rect; self.originRect = rect;
self.viewItem = viewItem; self.viewItem = viewItem;
} }
@ -128,7 +129,8 @@ NS_ASSUME_NONNULL_BEGIN
return _fileData; return _fileData;
} }
- (UIImage *)image { - (UIImage *)image
{
if (self.attachmentStream) { if (self.attachmentStream) {
return self.attachmentStream.image; return self.attachmentStream.image;
} else if (self.attachment) { } else if (self.attachment) {
@ -191,12 +193,12 @@ NS_ASSUME_NONNULL_BEGIN
action:@selector(didTapDismissButton:)]; action:@selector(didTapDismissButton:)];
} }
- (void)viewWillDisappear:(BOOL)animated { - (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated]; [super viewWillDisappear:animated];
if ([UIMenuController sharedMenuController].isMenuVisible) { if ([UIMenuController sharedMenuController].isMenuVisible) {
[[UIMenuController sharedMenuController] setMenuVisible:NO [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
animated:NO];
} }
} }
@ -289,7 +291,7 @@ NS_ASSUME_NONNULL_BEGIN
// It's a static image of the media content. // It's a static image of the media content.
UIImageView *presentationView = [[UIImageView alloc] initWithImage:self.image]; UIImageView *presentationView = [[UIImageView alloc] initWithImage:self.image];
self.presentationView = presentationView; self.presentationView = presentationView;
[self.view addSubview:presentationView]; [self.view addSubview:presentationView];
presentationView.hidden = YES; presentationView.hidden = YES;
presentationView.clipsToBounds = YES; presentationView.clipsToBounds = YES;
@ -297,7 +299,7 @@ NS_ASSUME_NONNULL_BEGIN
presentationView.layer.minificationFilter = kCAFilterTrilinear; presentationView.layer.minificationFilter = kCAFilterTrilinear;
presentationView.layer.magnificationFilter = kCAFilterTrilinear; presentationView.layer.magnificationFilter = kCAFilterTrilinear;
presentationView.contentMode = UIViewContentModeScaleAspectFit; presentationView.contentMode = UIViewContentModeScaleAspectFit;
[self applyInitialMediaViewConstraints]; [self applyInitialMediaViewConstraints];
if (self.isVideo) { if (self.isVideo) {
@ -467,7 +469,7 @@ NS_ASSUME_NONNULL_BEGIN
[[UIApplication sharedApplication] setStatusBarHidden:areToolbarsHidden withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:areToolbarsHidden withAnimation:UIStatusBarAnimationNone];
[self.navigationController setNavigationBarHidden:areToolbarsHidden animated:NO]; [self.navigationController setNavigationBarHidden:areToolbarsHidden animated:NO];
self.videoProgressBar.hidden = areToolbarsHidden; self.videoProgressBar.hidden = areToolbarsHidden;
// We don't animate the background color change because the old color shows through momentarily // We don't animate the background color change because the old color shows through momentarily
// behind where the status bar "used to be". // behind where the status bar "used to be".
self.view.backgroundColor = areToolbarsHidden ? UIColor.blackColor : UIColor.whiteColor; 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 // but in practice it works better if you use a separate GR for each
// direction. // direction.
for (NSNumber *direction in @[ for (NSNumber *direction in @[
@(UISwipeGestureRecognizerDirectionRight), @(UISwipeGestureRecognizerDirectionRight),
@(UISwipeGestureRecognizerDirectionLeft), @(UISwipeGestureRecognizerDirectionLeft),
@(UISwipeGestureRecognizerDirectionUp), @(UISwipeGestureRecognizerDirectionUp),
@(UISwipeGestureRecognizerDirectionDown), @(UISwipeGestureRecognizerDirectionDown),
]) { ]) {
UISwipeGestureRecognizer *swipe = UISwipeGestureRecognizer *swipe =
[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeImage:)]; [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeImage:)];
swipe.direction = (UISwipeGestureRecognizerDirection) direction.integerValue; swipe.direction = (UISwipeGestureRecognizerDirection)direction.integerValue;
swipe.delegate = self; swipe.delegate = self;
[self.view addGestureRecognizer:swipe]; [self.view addGestureRecognizer:swipe];
} }
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self UILongPressGestureRecognizer *longPress =
action:@selector(longPressGesture:)]; [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPressGesture:)];
longPress.delegate = self; longPress.delegate = self;
[self.view addGestureRecognizer:longPress]; [self.view addGestureRecognizer:longPress];
} }
@ -564,7 +566,8 @@ NS_ASSUME_NONNULL_BEGIN
[self dismissSelfAnimated:YES completion:nil]; [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. // We "eagerly" respond when the long press begins, not when it ends.
if (sender.state == UIGestureRecognizerStateBegan) { if (sender.state == UIGestureRecognizerStateBegan) {
if (!self.viewItem) { if (!self.viewItem) {
@ -572,22 +575,17 @@ NS_ASSUME_NONNULL_BEGIN
} }
[self.view becomeFirstResponder]; [self.view becomeFirstResponder];
if ([UIMenuController sharedMenuController].isMenuVisible) { if ([UIMenuController sharedMenuController].isMenuVisible) {
[[UIMenuController sharedMenuController] setMenuVisible:NO [[UIMenuController sharedMenuController] setMenuVisible:NO animated:NO];
animated:NO];
} }
NSArray *menuItems = self.viewItem.mediaMenuControllerItems; NSArray *menuItems = self.viewItem.mediaMenuControllerItems;
[UIMenuController sharedMenuController].menuItems = menuItems; [UIMenuController sharedMenuController].menuItems = menuItems;
CGPoint location = [sender locationInView:self.view]; CGPoint location = [sender locationInView:self.view];
CGRect targetRect = CGRectMake(location.x, CGRect targetRect = CGRectMake(location.x, location.y, 1, 1);
location.y, [[UIMenuController sharedMenuController] setTargetRect:targetRect inView:self.view];
1, 1); [[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
[[UIMenuController sharedMenuController] setTargetRect:targetRect
inView:self.view];
[[UIMenuController sharedMenuController] setMenuVisible:YES
animated:YES];
} }
} }
@ -784,11 +782,12 @@ NS_ASSUME_NONNULL_BEGIN
} }
completion:^(BOOL finished) { completion:^(BOOL finished) {
// HACK: Setting the frame to itself *seems* like it should be a no-op, but // 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 // it ensures the content is drawn at the right frame. In particular I was
// some images squished (they were EXIF rotated, maybe relateed). // reproducibly some images squished (they were EXIF rotated, maybe
// similar to this report: https://stackoverflow.com/questions/27961884/swift-uiimageview-stretched-aspect // relateed). similar to this report:
// https://stackoverflow.com/questions/27961884/swift-uiimageview-stretched-aspect
self.mediaView.frame = self.mediaView.frame; self.mediaView.frame = self.mediaView.frame;
// At this point our presentation view should be overlayed perfectly // At this point our presentation view should be overlayed perfectly
// with our media view. Swapping them out should be imperceptible. // with our media view. Swapping them out should be imperceptible.
self.mediaView.hidden = NO; self.mediaView.hidden = NO;
@ -823,33 +822,33 @@ NS_ASSUME_NONNULL_BEGIN
if (isAnimated) { if (isAnimated) {
[UIView animateWithDuration:0.18 [UIView animateWithDuration:0.18
delay:0.0 delay:0.0
options:UIViewAnimationOptionCurveEaseOut options:UIViewAnimationOptionCurveEaseOut
animations:^(void) { animations:^(void) {
[self.presentationView.superview layoutIfNeeded]; [self.presentationView.superview layoutIfNeeded];
self.presentationView.layer.cornerRadius = OWSMessageCellCornerRadius; self.presentationView.layer.cornerRadius = OWSMessageCellCornerRadius;
// In case user has hidden bars, which changes background to black. // In case user has hidden bars, which changes background to black.
self.view.backgroundColor = UIColor.whiteColor; self.view.backgroundColor = UIColor.whiteColor;
} }
completion:nil]; completion:nil];
[UIView animateWithDuration:0.1 [UIView animateWithDuration:0.1
delay:0.15 delay:0.15
options:UIViewAnimationOptionCurveEaseInOut options:UIViewAnimationOptionCurveEaseInOut
animations:^(void) { animations:^(void) {
OWSAssert(self.replacingView); OWSAssert(self.replacingView);
self.replacingView.alpha = 1.0; self.replacingView.alpha = 1.0;
// fade out content and toolbars // fade out content and toolbars
self.navigationController.view.alpha = 0.0; self.navigationController.view.alpha = 0.0;
} }
completion:^(BOOL finished) { completion:^(BOOL finished) {
[self.presentingViewController dismissViewControllerAnimated:NO completion:completion]; [self.presentingViewController dismissViewControllerAnimated:NO completion:completion];
}]; }];
} else { } else {
self.replacingView.alpha = 1.0; self.replacingView.alpha = 1.0;
[self.presentingViewController dismissViewControllerAnimated:NO completion:completion]; [self.presentingViewController dismissViewControllerAnimated:NO completion:completion];
@ -973,11 +972,12 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Saving images to Camera Roll #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) { if (error) {
DDLogWarn(@"There was a problem saving <%@> to camera roll from %s ", DDLogWarn(@"There was a problem saving <%@> to camera roll from %s ",
error.localizedDescription, error.localizedDescription,
__PRETTY_FUNCTION__); __PRETTY_FUNCTION__);
} }
} }

@ -414,7 +414,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate, Medi
private func addAttachmentRows() -> [UIView] { private func addAttachmentRows() -> [UIView] {
var rows = [UIView]() var rows = [UIView]()
guard let attachment = self.attachment else { guard let attachment = self.attachment else {
Logger.warn("\(TAG) Missing attachment. Was it deleted?") Logger.warn("\(TAG) Missing attachment. Was it deleted?")
return rows return rows
@ -754,15 +754,15 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate, Medi
} }
// MARK: MediaDetailPresenter // MARK: MediaDetailPresenter
public func presentDetails(mediaMessageView: MediaMessageView, fromView: UIView) { public func presentDetails(mediaMessageView: MediaMessageView, fromView: UIView) {
let window = UIApplication.shared.keyWindow let window = UIApplication.shared.keyWindow
let convertedRect = fromView.convert(fromView.bounds, to:window) let convertedRect = fromView.convert(fromView.bounds, to:window)
guard let attachmentStream = self.attachmentStream else { guard let attachmentStream = self.attachmentStream else {
owsFail("attachment stream unexpectedly nil") owsFail("attachment stream unexpectedly nil")
return return
} }
let mediaDetailViewController = MediaDetailViewController(attachmentStream: attachmentStream, from: convertedRect, viewItem: self.viewItem) let mediaDetailViewController = MediaDetailViewController(attachmentStream: attachmentStream, from: convertedRect, viewItem: self.viewItem)
mediaDetailViewController.present(from: self, replacing: fromView) mediaDetailViewController.present(from: self, replacing: fromView)
} }

@ -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> #import <UIKit/UIKit.h>

@ -61,7 +61,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
@objc @objc
public var contentView: UIView? public var contentView: UIView?
private let mediaDetailPresenter: MediaDetailPresenter? private let mediaDetailPresenter: MediaDetailPresenter?
// MARK: Initializers // MARK: Initializers
@ -475,7 +475,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
guard let fromView = sender.view else { guard let fromView = sender.view else {
return return
} }
showMediaDetailViewController(fromView: fromView) showMediaDetailViewController(fromView: fromView)
} }
@ -493,7 +493,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
guard let fromView = sender.view else { guard let fromView = sender.view else {
return return
} }
showMediaDetailViewController(fromView: fromView) showMediaDetailViewController(fromView: fromView)
} }

@ -303,8 +303,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
{ {
if (@available(iOS 9.0, *)) { if (@available(iOS 9.0, *)) {
NSLayoutConstraint *constraint = NSLayoutConstraint *constraint =
[self.bottomAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.bottomAnchor [self.bottomAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.bottomAnchor constant:-margin];
constant:-margin];
constraint.active = YES; constraint.active = YES;
return constraint; return constraint;
} else { } else {
@ -316,8 +315,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
{ {
if (@available(iOS 9.0, *)) { if (@available(iOS 9.0, *)) {
NSLayoutConstraint *constraint = NSLayoutConstraint *constraint =
[self.topAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.topAnchor [self.topAnchor constraintEqualToAnchor:self.superview.layoutMarginsGuide.topAnchor constant:margin];
constant:margin];
constraint.active = YES; constraint.active = YES;
return constraint; return constraint;
} else { } else {

Loading…
Cancel
Save