Respond to CR.

pull/1/head
Matthew Chen 7 years ago
parent 74cd37dd7c
commit 6a7f06f940

@ -1,5 +1,5 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
import Foundation import Foundation
@ -51,7 +51,7 @@ public class OWSFlatButton: UIView {
backgroundColor: UIColor, backgroundColor: UIColor,
width: CGFloat, width: CGFloat,
height: CGFloat, height: CGFloat,
target:Any, target: Any,
selector: Selector) -> OWSFlatButton { selector: Selector) -> OWSFlatButton {
let button = OWSFlatButton() let button = OWSFlatButton()
button.setTitle(title:title, button.setTitle(title:title,
@ -70,7 +70,7 @@ public class OWSFlatButton: UIView {
backgroundColor: UIColor, backgroundColor: UIColor,
width: CGFloat, width: CGFloat,
height: CGFloat, height: CGFloat,
target:Any, target: Any,
selector: Selector) -> OWSFlatButton { selector: Selector) -> OWSFlatButton {
return OWSFlatButton.button(title:title, return OWSFlatButton.button(title:title,
font:fontForHeight(height), font:fontForHeight(height),
@ -87,7 +87,7 @@ public class OWSFlatButton: UIView {
font: UIFont, font: UIFont,
titleColor: UIColor, titleColor: UIColor,
backgroundColor: UIColor, backgroundColor: UIColor,
target:Any, target: Any,
selector: Selector) -> OWSFlatButton { selector: Selector) -> OWSFlatButton {
let button = OWSFlatButton() let button = OWSFlatButton()
button.setTitle(title:title, button.setTitle(title:title,
@ -104,7 +104,7 @@ public class OWSFlatButton: UIView {
// Cap the "button height" at 40pt or button text can look // Cap the "button height" at 40pt or button text can look
// excessively large. // excessively large.
let fontPointSize = round(min(40, height) * 0.45) let fontPointSize = round(min(40, height) * 0.45)
return UIFont.ows_mediumFont(withSize:fontPointSize)! return UIFont.ows_mediumFont(withSize:fontPointSize)
} }
// MARK: Methods // MARK: Methods
@ -150,7 +150,7 @@ public class OWSFlatButton: UIView {
} }
@objc @objc
public func addTarget(target:Any, public func addTarget(target: Any,
selector: Selector) { selector: Selector) {
button.addTarget(target, action:selector, for:.touchUpInside) button.addTarget(target, action:selector, for:.touchUpInside)
} }

@ -131,10 +131,7 @@ public class MessageApprovalViewController: OWSViewController, UITextViewDelegat
bottomBorder.autoPinBottomToSuperview() bottomBorder.autoPinBottomToSuperview()
bottomBorder.autoSetDimension(.height, toSize: borderThickness) bottomBorder.autoSetDimension(.height, toSize: borderThickness)
guard let font = UIFont.ows_regularFont(withSize:ScaleFromIPhone5To7Plus(14.0, 18.0)) else { let font = UIFont.ows_regularFont(withSize:ScaleFromIPhone5To7Plus(14.0, 18.0))
owsFail("Can't load font")
return recipientRow
}
let hSpacing = CGFloat(10) let hSpacing = CGFloat(10)
let hMargin = CGFloat(15) let hMargin = CGFloat(15)
let vSpacing = CGFloat(5) let vSpacing = CGFloat(5)

@ -183,6 +183,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
{ {
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) { [self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
OWSAssertIsOnMainThread();
__block TSOutgoingMessage *outgoingMessage = nil; __block TSOutgoingMessage *outgoingMessage = nil;
outgoingMessage = [ThreadUtil sendMessageWithAttachment:attachment outgoingMessage = [ThreadUtil sendMessageWithAttachment:attachment
inThread:self.thread inThread:self.thread
@ -190,6 +192,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
completion:^(NSError *_Nullable error) { completion:^(NSError *_Nullable error) {
sendCompletion(error, outgoingMessage); sendCompletion(error, outgoingMessage);
}]; }];
// This is necessary to show progress.
self.outgoingMessage = outgoingMessage;
} }
fromViewController:approvalViewController]; fromViewController:approvalViewController];
} }
@ -209,6 +214,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread]; [ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) { [self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
OWSAssertIsOnMainThread();
__block TSOutgoingMessage *outgoingMessage = nil; __block TSOutgoingMessage *outgoingMessage = nil;
outgoingMessage = [ThreadUtil sendMessageWithText:messageText outgoingMessage = [ThreadUtil sendMessageWithText:messageText
inThread:self.thread inThread:self.thread
@ -219,6 +226,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
failure:^(NSError *_Nonnull error) { failure:^(NSError *_Nonnull error) {
sendCompletion(error, outgoingMessage); sendCompletion(error, outgoingMessage);
}]; }];
// This is necessary to show progress.
self.outgoingMessage = outgoingMessage;
} }
fromViewController:approvalViewController]; fromViewController:approvalViewController];
} }
@ -229,7 +239,6 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
} }
#pragma mark - Helpers #pragma mark - Helpers
typedef void (^SendMessageBlock)(SendCompletionBlock completion);
- (void)tryToSendMessageWithBlock:(SendMessageBlock)sendMessageBlock - (void)tryToSendMessageWithBlock:(SendMessageBlock)sendMessageBlock
fromViewController:(UIViewController *)fromViewController fromViewController:(UIViewController *)fromViewController

@ -1,9 +1,11 @@
// //
// 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>
NS_ASSUME_NONNULL_BEGIN
@interface UIFont (OWS) @interface UIFont (OWS)
+ (UIFont *)ows_thinFontWithSize:(CGFloat)size; + (UIFont *)ows_thinFontWithSize:(CGFloat)size;
@ -31,3 +33,5 @@
+ (UIFont *)ows_footnoteFont; + (UIFont *)ows_footnoteFont;
@end @end
NS_ASSUME_NONNULL_END

@ -1,9 +1,11 @@
// //
// Copyright (c) 2017 Open Whisper Systems. All rights reserved. // Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// //
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
NS_ASSUME_NONNULL_BEGIN
@implementation UIFont (OWS) @implementation UIFont (OWS)
+ (UIFont *)ows_thinFontWithSize:(CGFloat)size + (UIFont *)ows_thinFontWithSize:(CGFloat)size
@ -105,3 +107,5 @@
} }
@end @end
NS_ASSUME_NONNULL_END

@ -540,7 +540,7 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
} }
Logger.debug("\(logTag) matched utiType: \(srcUtiType)") Logger.debug("\(logTag) matched utiType: \(srcUtiType)")
let (promise, fulfill, reject) = Promise<(URL, String)>.pending() let (promise, fulfill, reject) = Promise<(itemUrl: URL, utiType: String)>.pending()
var customFileName: String? var customFileName: String?
var isConvertibleToTextMessage = false var isConvertibleToTextMessage = false
@ -576,7 +576,7 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
return return
} }
let fileUrl = URL(fileURLWithPath:tempFilePath) let fileUrl = URL(fileURLWithPath:tempFilePath)
fulfill((fileUrl, srcUtiType)) fulfill((itemUrl: fileUrl, utiType: srcUtiType))
} else if let string = value as? String { } else if let string = value as? String {
Logger.debug("\(self.logTag) string provider: \(string)") Logger.debug("\(self.logTag) string provider: \(string)")
guard let data = string.data(using: String.Encoding.utf8) else { guard let data = string.data(using: String.Encoding.utf8) else {
@ -595,18 +595,18 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
isConvertibleToTextMessage = !itemProvider.registeredTypeIdentifiers.contains(kUTTypeFileURL as String) isConvertibleToTextMessage = !itemProvider.registeredTypeIdentifiers.contains(kUTTypeFileURL as String)
if UTTypeConformsTo(srcUtiType as CFString, kUTTypeText) { if UTTypeConformsTo(srcUtiType as CFString, kUTTypeText) {
fulfill((fileUrl, srcUtiType)) fulfill((itemUrl: fileUrl, utiType: srcUtiType))
} else { } else {
fulfill((fileUrl, kUTTypeText as String)) fulfill((itemUrl: fileUrl, utiType: kUTTypeText as String))
} }
} else if let url = value as? URL { } else if let url = value as? URL {
// If the share itself is a URL (e.g. a link from Safari), try to send this as a text message. // If the share itself is a URL (e.g. a link from Safari), try to send this as a text message.
isConvertibleToTextMessage = (itemProvider.registeredTypeIdentifiers.contains(kUTTypeURL as String) && isConvertibleToTextMessage = (itemProvider.registeredTypeIdentifiers.contains(kUTTypeURL as String) &&
!itemProvider.registeredTypeIdentifiers.contains(kUTTypeFileURL as String)) !itemProvider.registeredTypeIdentifiers.contains(kUTTypeFileURL as String))
if isConvertibleToTextMessage { if isConvertibleToTextMessage {
fulfill((url, kUTTypeURL as String)) fulfill((itemUrl: url, utiType: kUTTypeURL as String))
} else { } else {
fulfill((url, srcUtiType)) fulfill((itemUrl: url, utiType: srcUtiType))
} }
} else { } else {
// It's unavoidable that we may sometimes receives data types that we // It's unavoidable that we may sometimes receives data types that we
@ -633,7 +633,7 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
Logger.debug("\(self.logTag) building DataSource with url: \(url), utiType: \(utiType)") Logger.debug("\(self.logTag) building DataSource with url: \(url), utiType: \(utiType)")
guard let dataSource = ShareViewController.createDataSource(utiType : utiType, url : url, customFileName : customFileName) else { guard let dataSource = ShareViewController.createDataSource(utiType: utiType, url: url, customFileName: customFileName) else {
throw ShareViewControllerError.assertionError(description: "Unable to read attachment data") throw ShareViewControllerError.assertionError(description: "Unable to read attachment data")
} }

Loading…
Cancel
Save