Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 88c874e4e6
commit 3b945a9da2

@ -5,6 +5,7 @@
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h"
#import "OWSProfileManager.h" #import "OWSProfileManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import <SignalServiceKit/Contact.h> #import <SignalServiceKit/Contact.h>
@ -205,7 +206,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<NSString *> *)searchTermsForSearchString:(NSString *)searchText - (NSArray<NSString *> *)searchTermsForSearchString:(NSString *)searchText
{ {
return [[[searchText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] return [[[searchText ows_stripped]
componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString *_Nullable searchTerm, filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString *_Nullable searchTerm,
NSDictionary<NSString *, id> *_Nullable bindings) { NSDictionary<NSString *, id> *_Nullable bindings) {

@ -58,6 +58,12 @@ NS_ASSUME_NONNULL_BEGIN
// when visible and unload when no longer visible. Non-visible cells can // when visible and unload when no longer visible. Non-visible cells can
// cache their contents on their ConversationViewItem, but that cache may // cache their contents on their ConversationViewItem, but that cache may
// be evacuated before the cell becomes visible again. // be evacuated before the cell becomes visible again.
//
// ConversationViewController also uses this property to evacuate the cell's
// meda views when:
//
// * App enters background.
// * Users enters another view (e.g. conversation settings view, call screen, etc.).
@property (nonatomic) BOOL isCellVisible; @property (nonatomic) BOOL isCellVisible;
// The width of the collection view. // The width of the collection view.

@ -231,8 +231,7 @@ NS_ASSUME_NONNULL_BEGIN
if (!filename) { if (!filename) {
filename = [[self.attachmentStream filePath] lastPathComponent]; filename = [[self.attachmentStream filePath] lastPathComponent];
} }
NSString *topText = [[filename stringByDeletingPathExtension] NSString *topText = [[filename stringByDeletingPathExtension] ows_stripped];
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if (topText.length < 1) { if (topText.length < 1) {
topText = [MIMETypeUtil fileExtensionForMIMEType:self.attachmentStream.contentType].uppercaseString; topText = [MIMETypeUtil fileExtensionForMIMEType:self.attachmentStream.contentType].uppercaseString;
} }
@ -247,7 +246,6 @@ NS_ASSUME_NONNULL_BEGIN
topLabel.textColor = [textColor colorWithAlphaComponent:0.85f]; topLabel.textColor = [textColor colorWithAlphaComponent:0.85f];
topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
topLabel.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(11.f, 13.f)]; topLabel.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(11.f, 13.f)];
topLabel.textAlignment = NSTextAlignmentLeft;
[labelsView addSubview:topLabel]; [labelsView addSubview:topLabel];
[topLabel autoPinEdgeToSuperviewEdge:ALEdgeTop]; [topLabel autoPinEdgeToSuperviewEdge:ALEdgeTop];
[topLabel autoPinWidthToSuperview]; [topLabel autoPinWidthToSuperview];
@ -267,7 +265,6 @@ NS_ASSUME_NONNULL_BEGIN
bottomLabel.textColor = [textColor colorWithAlphaComponent:0.85f]; bottomLabel.textColor = [textColor colorWithAlphaComponent:0.85f];
bottomLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; bottomLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
bottomLabel.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(11.f, 13.f)]; bottomLabel.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(11.f, 13.f)];
bottomLabel.textAlignment = NSTextAlignmentLeft;
[labelsView addSubview:bottomLabel]; [labelsView addSubview:bottomLabel];
[bottomLabel autoPinWidthToSuperview]; [bottomLabel autoPinWidthToSuperview];
[bottomLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:audioProgressView withOffset:kLabelVSpacing]; [bottomLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:audioProgressView withOffset:kLabelVSpacing];

@ -3,6 +3,7 @@
// //
#import "OWSGenericAttachmentView.h" #import "OWSGenericAttachmentView.h"
#import "NSString+OWS.h"
#import "UIColor+JSQMessages.h" #import "UIColor+JSQMessages.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
@ -162,8 +163,7 @@ NS_ASSUME_NONNULL_BEGIN
[imageView autoSetDimension:ALDimensionWidth toSize:15.f]; [imageView autoSetDimension:ALDimensionWidth toSize:15.f];
const CGFloat kLabelVSpacing = 2; const CGFloat kLabelVSpacing = 2;
NSString *topText = NSString *topText = [self.attachmentStream.sourceFilename ows_stripped];
[self.attachmentStream.sourceFilename stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if (topText.length < 1) { if (topText.length < 1) {
topText = [MIMETypeUtil fileExtensionForMIMEType:self.attachmentStream.contentType].uppercaseString; topText = [MIMETypeUtil fileExtensionForMIMEType:self.attachmentStream.contentType].uppercaseString;
} }
@ -175,7 +175,6 @@ NS_ASSUME_NONNULL_BEGIN
topLabel.textColor = textColor; topLabel.textColor = textColor;
topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle; topLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
topLabel.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(13.f, 15.f)]; topLabel.font = [UIFont ows_regularFontWithSize:ScaleFromIPhone5To7Plus(13.f, 15.f)];
topLabel.textAlignment = NSTextAlignmentLeft;
[labelsView addSubview:topLabel]; [labelsView addSubview:topLabel];
[topLabel autoPinEdgeToSuperviewEdge:ALEdgeTop]; [topLabel autoPinEdgeToSuperviewEdge:ALEdgeTop];
[topLabel autoPinWidthToSuperview]; [topLabel autoPinWidthToSuperview];

@ -3,6 +3,7 @@
// //
#import "ConversationInputTextView.h" #import "ConversationInputTextView.h"
#import "NSString+OWS.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -121,7 +122,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString *)trimmedText - (NSString *)trimmedText
{ {
return [self.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; return [self.text ows_stripped];
} }
// TODO: // TODO:

@ -20,6 +20,7 @@
#import "FingerprintViewController.h" #import "FingerprintViewController.h"
#import "FullImageViewController.h" #import "FullImageViewController.h"
#import "NSAttributedString+OWS.h" #import "NSAttributedString+OWS.h"
#import "NSString+OWS.h"
#import "NewGroupViewController.h" #import "NewGroupViewController.h"
#import "OWSAudioAttachmentPlayer.h" #import "OWSAudioAttachmentPlayer.h"
#import "OWSContactOffersCell.h" #import "OWSContactOffersCell.h"
@ -985,7 +986,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
// Only retain the cached cell media for N cells at a time. // Only retain the cached cell media for N cells at a time.
const NSInteger kCellMediaCacheWindowSize = 24; const NSInteger kCellMediaCacheWindowSize = 24;
NSInteger centerRow = (firstVisibleIndexPath.row + lastVisibleIndexPath.row) / 2; NSInteger centerRow = (firstVisibleIndexPath.row + lastVisibleIndexPath.row) / 2;
// Determine the first and law rows (inclusive) of the cached cell media load window. // Determine the first and last rows (inclusive) of the cached cell media load window.
// Note these row values may not correspond to actual rows in the collection view. // Note these row values may not correspond to actual rows in the collection view.
// //
// Always retain the cached cell media for any visible cells. // Always retain the cached cell media for any visible cells.
@ -3698,7 +3699,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
return; return;
} }
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; text = [text ows_stripped];
if (text.length < 1) { if (text.length < 1) {
return; return;

@ -3,6 +3,7 @@
// //
#import "ConversationViewItem.h" #import "ConversationViewItem.h"
#import "NSString+OWS.h"
#import "OWSAudioMessageView.h" #import "OWSAudioMessageView.h"
#import "OWSContactOffersCell.h" #import "OWSContactOffersCell.h"
#import "OWSMessageCell.h" #import "OWSMessageCell.h"
@ -274,14 +275,12 @@ NSString *NSStringForOWSMessageCellType(OWSMessageCellType cellType)
if (!displayableText) { if (!displayableText) {
// Only show up to 2kb of text. // Only show up to 2kb of text.
const NSUInteger kMaxTextDisplayLength = 2 * 1024; const NSUInteger kMaxTextDisplayLength = 2 * 1024;
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; text = [text ows_stripped];
displayableText = [[DisplayableTextFilter new] displayableText:text]; displayableText = [[DisplayableTextFilter new] displayableText:text];
if (displayableText.length > kMaxTextDisplayLength) { if (displayableText.length > kMaxTextDisplayLength) {
// Trim whitespace before _AND_ after slicing the snipper from the string. // Trim whitespace before _AND_ after slicing the snipper from the string.
NSString *snippet = NSString *snippet = [
[[[displayableText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] [[displayableText ows_stripped] substringWithRange:NSMakeRange(0, kMaxTextDisplayLength)] ows_stripped];
substringWithRange:NSMakeRange(0, kMaxTextDisplayLength)]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
displayableText = [NSString stringWithFormat:NSLocalizedString(@"OVERSIZE_TEXT_DISPLAY_FORMAT", displayableText = [NSString stringWithFormat:NSLocalizedString(@"OVERSIZE_TEXT_DISPLAY_FORMAT",
@"A display format for oversize text messages."), @"A display format for oversize text messages."),
snippet]; snippet];

@ -3,6 +3,7 @@
// //
#import "CountryCodeViewController.h" #import "CountryCodeViewController.h"
#import "NSString+OWS.h"
#import "PhoneNumberUtil.h" #import "PhoneNumberUtil.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
#import "UIFont+OWS.h" #import "UIFont+OWS.h"
@ -142,8 +143,7 @@
- (void)searchTextDidChange - (void)searchTextDidChange
{ {
NSString *searchText = NSString *searchText = [self.searchBar.text ows_stripped];
[self.searchBar.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
self.countryCodes = [PhoneNumberUtil countryCodesForSearchTerm:searchText]; self.countryCodes = [PhoneNumberUtil countryCodesForSearchTerm:searchText];

@ -9,6 +9,7 @@
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
@ -515,8 +516,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
- (TSGroupModel *)makeGroup - (TSGroupModel *)makeGroup
{ {
NSString *groupName = [self.groupNameTextField.text NSString *groupName = [self.groupNameTextField.text ows_stripped];
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSMutableArray<NSString *> *recipientIds = [self.memberRecipientIds.allObjects mutableCopy]; NSMutableArray<NSString *> *recipientIds = [self.memberRecipientIds.allObjects mutableCopy];
[recipientIds addObject:[self.contactsViewHelper localNumber]]; [recipientIds addObject:[self.contactsViewHelper localNumber]];
NSData *groupId = [SecurityUtils generateRandomBytes:16]; NSData *groupId = [SecurityUtils generateRandomBytes:16];

@ -6,6 +6,7 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "AvatarViewHelper.h" #import "AvatarViewHelper.h"
#import "HomeViewController.h" #import "HomeViewController.h"
#import "NSString+OWS.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "OWSProfileManager.h" #import "OWSProfileManager.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
@ -410,7 +411,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
- (NSString *)normalizedProfileName - (NSString *)normalizedProfileName
{ {
return [self.nameTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; return [self.nameTextField.text ows_stripped];
} }
- (void)updateProfileCompleted - (void)updateProfileCompleted

@ -6,6 +6,7 @@
#import "CodeVerificationViewController.h" #import "CodeVerificationViewController.h"
#import "CountryCodeViewController.h" #import "CountryCodeViewController.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h"
#import "PhoneNumber.h" #import "PhoneNumber.h"
#import "PhoneNumberUtil.h" #import "PhoneNumberUtil.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
@ -280,8 +281,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi
- (void)sendCodeAction - (void)sendCodeAction
{ {
NSString *phoneNumberText = NSString *phoneNumberText = [_phoneNumberTextField.text ows_stripped];
[_phoneNumberTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (phoneNumberText.length < 1) { if (phoneNumberText.length < 1) {
[OWSAlerts [OWSAlerts
showAlertWithTitle:NSLocalizedString(@"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_TITLE", showAlertWithTitle:NSLocalizedString(@"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_TITLE",

@ -7,6 +7,7 @@
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSContactsSearcher.h" #import "OWSContactsSearcher.h"
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
@ -223,8 +224,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
NSArray<TSThread *> *threads = self.threadViewHelper.threads; NSArray<TSThread *> *threads = self.threadViewHelper.threads;
NSString *searchTerm = NSString *searchTerm = [[self.searchBar text] ows_stripped];
[[self.searchBar text] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([searchTerm isEqualToString:@""]) { if ([searchTerm isEqualToString:@""]) {
return threads; return threads;

@ -4,6 +4,7 @@
#import "SendExternalFileViewController.h" #import "SendExternalFileViewController.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h"
#import "Signal-Swift.h" #import "Signal-Swift.h"
#import "ThreadUtil.h" #import "ThreadUtil.h"
#import "UIColor+OWS.h" #import "UIColor+OWS.h"
@ -141,8 +142,7 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: If we reuse this VC, for example to offer a "forward attachment to other thread", // TODO: If we reuse this VC, for example to offer a "forward attachment to other thread",
// feature, this assumption would no longer apply. // feature, this assumption would no longer apply.
OWSAssert(self.attachment); OWSAssert(self.attachment);
NSString *filename = NSString *filename = [self.attachment.sourceFilename ows_stripped];
[self.attachment.sourceFilename stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
OWSAssert(filename.length > 0); OWSAssert(filename.length > 0);
const NSUInteger kMaxFilenameLength = 20; const NSUInteger kMaxFilenameLength = 20;
if (filename.length > kMaxFilenameLength) { if (filename.length > kMaxFilenameLength) {

@ -9,6 +9,7 @@
#import "ContactTableViewCell.h" #import "ContactTableViewCell.h"
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "OWSTableViewController.h" #import "OWSTableViewController.h"
@ -196,8 +197,7 @@ NS_ASSUME_NONNULL_BEGIN
UITextField *groupNameTextField = [UITextField new]; UITextField *groupNameTextField = [UITextField new];
_groupNameTextField = groupNameTextField; _groupNameTextField = groupNameTextField;
self.groupNameTextField.text = [self.thread.groupModel.groupName self.groupNameTextField.text = [self.thread.groupModel.groupName ows_stripped];
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
groupNameTextField.textColor = [UIColor blackColor]; groupNameTextField.textColor = [UIColor blackColor];
groupNameTextField.font = [UIFont ows_dynamicTypeTitle2Font]; groupNameTextField.font = [UIFont ows_dynamicTypeTitle2Font];
groupNameTextField.placeholder groupNameTextField.placeholder
@ -373,8 +373,7 @@ NS_ASSUME_NONNULL_BEGIN
{ {
OWSAssert(self.conversationSettingsViewDelegate); OWSAssert(self.conversationSettingsViewDelegate);
NSString *groupName = [self.groupNameTextField.text NSString *groupName = [self.groupNameTextField.text ows_stripped];
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
TSGroupModel *groupModel = [[TSGroupModel alloc] initWithTitle:groupName TSGroupModel *groupModel = [[TSGroupModel alloc] initWithTitle:groupName
memberIds:[self.memberRecipientIds.allObjects mutableCopy] memberIds:[self.memberRecipientIds.allObjects mutableCopy]
image:self.groupAvatar image:self.groupAvatar

@ -3,6 +3,7 @@
// //
#import "OWSContactsSearcher.h" #import "OWSContactsSearcher.h"
#import "NSString+OWS.h"
#import <SignalServiceKit/PhoneNumber.h> #import <SignalServiceKit/PhoneNumber.h>
@interface OWSContactsSearcher () @interface OWSContactsSearcher ()
@ -22,7 +23,7 @@
} }
- (NSArray<Contact *> *)filterWithString:(NSString *)string { - (NSArray<Contact *> *)filterWithString:(NSString *)string {
NSString *searchTerm = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSString *searchTerm = [string ows_stripped];
if ([searchTerm isEqualToString:@""]) { if ([searchTerm isEqualToString:@""]) {
return self.contacts; return self.contacts;

@ -4,6 +4,7 @@
#import "NotificationsManager.h" #import "NotificationsManager.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h"
#import "OWSContactsManager.h" #import "OWSContactsManager.h"
#import "OWSPreferences.h" #import "OWSPreferences.h"
#import "PushManager.h" #import "PushManager.h"
@ -272,8 +273,7 @@ NSString *const kNotificationsManagerNewMesssageSoundName = @"NewMessage.aifc";
BOOL shouldPlaySound = [self shouldPlaySoundForNotification]; BOOL shouldPlaySound = [self shouldPlaySoundForNotification];
NSString *senderName = [contactsManager displayNameForPhoneIdentifier:message.authorId]; NSString *senderName = [contactsManager displayNameForPhoneIdentifier:message.authorId];
NSString *groupName = NSString *groupName = [thread.name ows_stripped];
[thread.name stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (groupName.length < 1) { if (groupName.length < 1) {
groupName = [MessageStrings newGroupDefaultTitle]; groupName = [MessageStrings newGroupDefaultTitle];
} }

Loading…
Cancel
Save