Respond to CR.

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

@ -5,6 +5,7 @@
#import "ContactsViewHelper.h"
#import "ContactTableViewCell.h"
#import "Environment.h"
#import "NSString+OWS.h"
#import "OWSProfileManager.h"
#import "Signal-Swift.h"
#import <SignalServiceKit/Contact.h>
@ -205,7 +206,7 @@ NS_ASSUME_NONNULL_BEGIN
- (NSArray<NSString *> *)searchTermsForSearchString:(NSString *)searchText
{
return [[[searchText stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
return [[[searchText ows_stripped]
componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSString *_Nullable searchTerm,
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
// cache their contents on their ConversationViewItem, but that cache may
// 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;
// The width of the collection view.

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

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

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

@ -20,6 +20,7 @@
#import "FingerprintViewController.h"
#import "FullImageViewController.h"
#import "NSAttributedString+OWS.h"
#import "NSString+OWS.h"
#import "NewGroupViewController.h"
#import "OWSAudioAttachmentPlayer.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.
const NSInteger kCellMediaCacheWindowSize = 24;
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.
//
// Always retain the cached cell media for any visible cells.
@ -3698,7 +3699,7 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
return;
}
text = [text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
text = [text ows_stripped];
if (text.length < 1) {
return;

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

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

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

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

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

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

@ -4,6 +4,7 @@
#import "SendExternalFileViewController.h"
#import "Environment.h"
#import "NSString+OWS.h"
#import "Signal-Swift.h"
#import "ThreadUtil.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",
// feature, this assumption would no longer apply.
OWSAssert(self.attachment);
NSString *filename =
[self.attachment.sourceFilename stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSString *filename = [self.attachment.sourceFilename ows_stripped];
OWSAssert(filename.length > 0);
const NSUInteger kMaxFilenameLength = 20;
if (filename.length > kMaxFilenameLength) {

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

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

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

Loading…
Cancel
Save