Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 2bec1db541
commit f71ec9f7cb

@ -206,9 +206,7 @@ NS_ASSUME_NONNULL_BEGIN
[nonContactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
NewGroupViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (ContactTableViewCell *)nil;
}
OWSAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
@ -262,9 +260,7 @@ NS_ASSUME_NONNULL_BEGIN
[signalAccountSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{
NewGroupViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (ContactTableViewCell *)nil;
}
OWSAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
@ -439,7 +435,7 @@ NS_ASSUME_NONNULL_BEGIN
- (TSGroupModel *)makeGroup
{
NSString *title = self.groupNameTextField.text;
NSMutableArray *recipientIds = [self.memberRecipientIds.allObjects mutableCopy];
NSMutableArray<NSString *> *recipientIds = [self.memberRecipientIds.allObjects mutableCopy];
[recipientIds addObject:[self.contactsViewHelper localNumber]];
NSData *groupId = [SecurityUtils generateRandomBytes:16];

@ -4,6 +4,8 @@
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@class SignalAccount;
@protocol SelectRecipientViewControllerDelegate <NSObject>
@ -39,3 +41,5 @@
@property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper;
@end
NS_ASSUME_NONNULL_END

@ -11,6 +11,7 @@
#import "OWSContactsManager.h"
#import "OWSTableViewController.h"
#import "PhoneNumber.h"
#import "Signal-Swift.h"
#import "SignalAccount.h"
#import "StringUtil.h"
#import "UIFont+OWS.h"
@ -244,6 +245,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
OWSAssert(self.delegate);
if (![self hasValidPhoneNumber]) {
DDLogError(@"Invalid phone number was selected.");
OWSAssert(0);
return;
}
@ -257,6 +259,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
[possiblePhoneNumbers addObject:phoneNumber.toE164];
}
if ([possiblePhoneNumbers count] < 1) {
DDLogError(@"Couldn't parse phone number.");
OWSAssert(0);
return;
}
@ -278,7 +281,9 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
handler:^(UIAlertAction *_Nonnull action) {
wasCancelled = YES;
}]];
[ViewControllerUtils.topMostController presentViewController:activityAlert animated:YES completion:nil];
[[UIApplication sharedApplication].frontmostViewController presentViewController:activityAlert
animated:YES
completion:nil];
__weak SelectRecipientViewController *weakSelf = self;
[[ContactsUpdater sharedUpdater] lookupIdentifiers:possiblePhoneNumbers
@ -353,6 +358,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
[self updateCountryWithName:countryName callingCode:callingCode countryCode:countryCode];
// Trigger the formatting logic with a no-op edit.
[self textField:self.phoneNumberTextField shouldChangeCharactersInRange:NSMakeRange(0, 0) replacementString:@""];
}
@ -377,7 +383,9 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
[self tryToSelectPhoneNumber];
if ([self hasValidPhoneNumber]) {
[self tryToSelectPhoneNumber];
}
return NO;
}
@ -397,17 +405,14 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
const CGFloat kButtonRowHeight = 60;
[phoneNumberSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectRecipientViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (UITableViewCell *)nil;
}
OWSAssert(strongSelf);
UITableViewCell *cell = [UITableViewCell new];
// Country Row
UIView *countryRow = [self createRowWithHeight:kCountryRowHeight previousRow:nil superview:cell.contentView];
[countryRow
addGestureRecognizer:[[OWSAnyTouchGestureRecognizer alloc] initWithTarget:self
action:@selector(countryRowTouched:)]];
[countryRow addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(countryRowTouched:)]];
UILabel *countryCodeLabel = self.countryCodeLabel;
[countryRow addSubview:countryCodeLabel];
@ -421,9 +426,9 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
// Phone Number Row
UIView *phoneNumberRow =
[self createRowWithHeight:kPhoneNumberRowHeight previousRow:countryRow superview:cell.contentView];
[phoneNumberRow addGestureRecognizer:[[OWSAnyTouchGestureRecognizer alloc]
initWithTarget:self
action:@selector(phoneNumberRowTouched:)]];
[phoneNumberRow
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
action:@selector(phoneNumberRowTouched:)]];
UILabel *phoneNumberLabel = self.phoneNumberLabel;
[phoneNumberRow addSubview:phoneNumberLabel];
@ -476,9 +481,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
for (SignalAccount *signalAccount in signalAccounts) {
[contactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectRecipientViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (ContactTableViewCell *)nil;
}
OWSAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];

@ -136,9 +136,7 @@ NS_ASSUME_NONNULL_BEGIN
for (TSThread *thread in [self filteredThreadsWithSearchText]) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (ContactTableViewCell *)nil;
}
OWSAssert(strongSelf);
// To be consistent with the threads (above), we use ContactTableViewCell
// instead of InboxTableViewCell to present contacts and threads.
@ -157,9 +155,7 @@ NS_ASSUME_NONNULL_BEGIN
for (SignalAccount *signalAccount in filteredSignalAccounts) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (ContactTableViewCell *)nil;
}
OWSAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];

@ -103,9 +103,7 @@ NS_ASSUME_NONNULL_BEGIN
for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
ShowGroupMembersViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (ContactTableViewCell *)nil;
}
OWSAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [helper signalAccountForRecipientId:recipientId];
@ -165,7 +163,9 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController:self
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
completionBlock:nil];
completionBlock:^(BOOL ignore) {
[self updateTableContents];
}];
}]];
} else {
[actionSheetController
@ -178,7 +178,9 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController:self
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
completionBlock:nil];
completionBlock:^(BOOL ignore) {
[self updateTableContents];
}];
}]];
}
} else {
@ -194,7 +196,9 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController:self
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
completionBlock:nil];
completionBlock:^(BOOL ignore) {
[self updateTableContents];
}];
}]];
} else {
[actionSheetController
@ -207,7 +211,9 @@ NS_ASSUME_NONNULL_BEGIN
fromViewController:self
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
completionBlock:nil];
completionBlock:^(BOOL ignore) {
[self updateTableContents];
}];
}]];
}
}

@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
// non-contact account.
@property (nonatomic, nullable) Contact *contact;
@property (nonatomic) BOOL isMultipleAccountContact;
@property (nonatomic) BOOL hasMultipleAccountContact;
// For contacts with more than one signal account,
// this is a label for the account.

@ -246,9 +246,7 @@ NS_ASSUME_NONNULL_BEGIN
[section
addItem:[OWSTableItem itemWithCustomCellBlock:^{
UpdateGroupViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (ContactTableViewCell *)nil;
}
OWSAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];

@ -28,6 +28,4 @@
message:(NSString *)message
buttonLabel:(NSString *)buttonLabel;
+ (UIViewController *)topMostController;
@end

@ -5,6 +5,7 @@
#import "ViewControllerUtils.h"
#import "Environment.h"
#import "PhoneNumber.h"
#import "Signal-Swift.h"
#import "SignalsViewController.h"
#import "StringUtil.h"
#import <AVFoundation/AVFoundation.h>
@ -117,23 +118,11 @@ NS_ASSUME_NONNULL_BEGIN
[alert addAction:[UIAlertAction actionWithTitle:buttonLabel style:UIAlertActionStyleDefault handler:nil]];
[self.topMostController presentViewController:alert animated:YES completion:nil];
[[UIApplication sharedApplication].frontmostViewController presentViewController:alert animated:YES completion:nil];
return alert;
}
+ (UIViewController *)topMostController
{
UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController;
while (topController.presentedViewController) {
topController = topController.presentedViewController;
}
OWSAssert(topController);
return topController;
}
#pragma mark - Logging
+ (NSString *)tag

@ -214,7 +214,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
SignalAccount *signalAccount = [[SignalAccount alloc] initWithSignalRecipient:signalRecipient];
signalAccount.contact = contact;
if (signalRecipients.count > 1) {
signalAccount.isMultipleAccountContact = YES;
signalAccount.hasMultipleAccountContact = YES;
signalAccount.multipleAccountLabel =
[[self class] accountLabelForContact:contact recipientId:signalRecipient.recipientId];
}
@ -562,7 +562,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
NSString *baseName = (signalAccount.contact ? [self displayNameForContact:signalAccount.contact]
: [self displayNameForPhoneIdentifier:signalAccount.recipientId]);
OWSAssert(signalAccount.isMultipleAccountContact == (signalAccount.multipleAccountLabel != nil));
OWSAssert(signalAccount.hasMultipleAccountContact == (signalAccount.multipleAccountLabel != nil));
if (signalAccount.multipleAccountLabel) {
return [NSString stringWithFormat:@"%@ (%@)", baseName, signalAccount.multipleAccountLabel];
} else {
@ -577,7 +577,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
OWSAssert(font);
NSAttributedString *baseName = [self formattedFullNameForContact:signalAccount.contact font:font];
OWSAssert(signalAccount.isMultipleAccountContact == (signalAccount.multipleAccountLabel != nil));
OWSAssert(signalAccount.hasMultipleAccountContact == (signalAccount.multipleAccountLabel != nil));
if (signalAccount.multipleAccountLabel) {
NSMutableAttributedString *result = [NSMutableAttributedString new];
[result appendAttributedString:baseName];

Loading…
Cancel
Save