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
@ -51,7 +51,7 @@ public class OWSFlatButton: UIView {
backgroundColor: UIColor,
width: CGFloat,
height: CGFloat,
target:Any,
target: Any,
selector: Selector) -> OWSFlatButton {
let button = OWSFlatButton()
button.setTitle(title:title,
@ -70,7 +70,7 @@ public class OWSFlatButton: UIView {
backgroundColor: UIColor,
width: CGFloat,
height: CGFloat,
target:Any,
target: Any,
selector: Selector) -> OWSFlatButton {
return OWSFlatButton.button(title:title,
font:fontForHeight(height),
@ -87,7 +87,7 @@ public class OWSFlatButton: UIView {
font: UIFont,
titleColor: UIColor,
backgroundColor: UIColor,
target:Any,
target: Any,
selector: Selector) -> OWSFlatButton {
let button = OWSFlatButton()
button.setTitle(title:title,
@ -104,7 +104,7 @@ public class OWSFlatButton: UIView {
// Cap the "button height" at 40pt or button text can look
// excessively large.
let fontPointSize = round(min(40, height) * 0.45)
return UIFont.ows_mediumFont(withSize:fontPointSize)!
return UIFont.ows_mediumFont(withSize:fontPointSize)
}
// MARK: Methods
@ -150,7 +150,7 @@ public class OWSFlatButton: UIView {
}
@objc
public func addTarget(target:Any,
public func addTarget(target: Any,
selector: Selector) {
button.addTarget(target, action:selector, for:.touchUpInside)
}

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

@ -183,6 +183,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
{
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
OWSAssertIsOnMainThread();
__block TSOutgoingMessage *outgoingMessage = nil;
outgoingMessage = [ThreadUtil sendMessageWithAttachment:attachment
inThread:self.thread
@ -190,6 +192,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
completion:^(NSError *_Nullable error) {
sendCompletion(error, outgoingMessage);
}];
// This is necessary to show progress.
self.outgoingMessage = outgoingMessage;
}
fromViewController:approvalViewController];
}
@ -209,6 +214,8 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
[ThreadUtil addThreadToProfileWhitelistIfEmptyContactThread:self.thread];
[self tryToSendMessageWithBlock:^(SendCompletionBlock sendCompletion) {
OWSAssertIsOnMainThread();
__block TSOutgoingMessage *outgoingMessage = nil;
outgoingMessage = [ThreadUtil sendMessageWithText:messageText
inThread:self.thread
@ -219,6 +226,9 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
failure:^(NSError *_Nonnull error) {
sendCompletion(error, outgoingMessage);
}];
// This is necessary to show progress.
self.outgoingMessage = outgoingMessage;
}
fromViewController:approvalViewController];
}
@ -229,7 +239,6 @@ typedef void (^SendMessageBlock)(SendCompletionBlock completion);
}
#pragma mark - Helpers
typedef void (^SendMessageBlock)(SendCompletionBlock completion);
- (void)tryToSendMessageWithBlock:(SendMessageBlock)sendMessageBlock
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>
NS_ASSUME_NONNULL_BEGIN
@interface UIFont (OWS)
+ (UIFont *)ows_thinFontWithSize:(CGFloat)size;
@ -31,3 +33,5 @@
+ (UIFont *)ows_footnoteFont;
@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"
NS_ASSUME_NONNULL_BEGIN
@implementation UIFont (OWS)
+ (UIFont *)ows_thinFontWithSize:(CGFloat)size
@ -105,3 +107,5 @@
}
@end
NS_ASSUME_NONNULL_END

@ -540,7 +540,7 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
}
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 isConvertibleToTextMessage = false
@ -576,7 +576,7 @@ public class ShareViewController: UINavigationController, ShareViewDelegate, SAE
return
}
let fileUrl = URL(fileURLWithPath:tempFilePath)
fulfill((fileUrl, srcUtiType))
fulfill((itemUrl: fileUrl, utiType: srcUtiType))
} else if let string = value as? String {
Logger.debug("\(self.logTag) string provider: \(string)")
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)
if UTTypeConformsTo(srcUtiType as CFString, kUTTypeText) {
fulfill((fileUrl, srcUtiType))
fulfill((itemUrl: fileUrl, utiType: srcUtiType))
} else {
fulfill((fileUrl, kUTTypeText as String))
fulfill((itemUrl: fileUrl, utiType: kUTTypeText as String))
}
} 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.
isConvertibleToTextMessage = (itemProvider.registeredTypeIdentifiers.contains(kUTTypeURL as String) &&
!itemProvider.registeredTypeIdentifiers.contains(kUTTypeFileURL as String))
if isConvertibleToTextMessage {
fulfill((url, kUTTypeURL as String))
fulfill((itemUrl: url, utiType: kUTTypeURL as String))
} else {
fulfill((url, srcUtiType))
fulfill((itemUrl: url, utiType: srcUtiType))
}
} else {
// 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)")
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")
}

Loading…
Cancel
Save