Remove distinction between TS and RP users

* Ensure we're always showing call button for non-group threads.
* search phone strings directly rather than precomputing field

// FREEBIE
This commit is contained in:
Michael Kirk 2016-06-27 19:51:57 -07:00
parent 62633ff7f4
commit 26f5418500
7 changed files with 22 additions and 31 deletions

View File

@ -137,7 +137,7 @@ CHECKOUT OPTIONS:
:commit: 225b1baa11125ea84d4b960d700834b5b0a40ee1 :commit: 225b1baa11125ea84d4b960d700834b5b0a40ee1
:git: https://github.com/WhisperSystems/JSQMessagesViewController :git: https://github.com/WhisperSystems/JSQMessagesViewController
SignalServiceKit: SignalServiceKit:
:commit: 8058951b08a9fb0c610c56bdb50c403132da2089 :commit: f5aac9610c274dad33c071fcdd9d2ab6b3d85f0d
:git: https://github.com/WhisperSystems/SignalServiceKit.git :git: https://github.com/WhisperSystems/SignalServiceKit.git
SocketRocket: SocketRocket:
:commit: 587ad297eb63eb0d64d4caeb32a7da646ad1132b :commit: 587ad297eb63eb0d64d4caeb32a7da646ad1132b

View File

@ -28,7 +28,7 @@ typedef void (^ABReloadRequestCompletionBlock)(NSArray *contacts);
- (void)verifyABPermission; - (void)verifyABPermission;
- (NSArray<Contact *> *)allContacts; - (NSArray<Contact *> *)allContacts;
- (NSArray *)signalContacts; - (NSArray<Contact *> *)signalContacts;
- (NSArray *)textSecureContacts; - (NSArray *)textSecureContacts;
- (void)doAfterEnvironmentInitSetup; - (void)doAfterEnvironmentInitSetup;

View File

@ -374,7 +374,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
- (NSArray *)getSignalUsersFromContactsArray:(NSArray *)contacts { - (NSArray *)getSignalUsersFromContactsArray:(NSArray *)contacts {
return [[contacts filter:^int(Contact *contact) { return [[contacts filter:^int(Contact *contact) {
return contact.isRedPhoneContact || contact.isTextSecureContact; return [contact isSignalContact];
}] sortedArrayUsingComparator:[[self class] contactComparator]]; }] sortedArrayUsingComparator:[[self class] contactComparator]];
} }
@ -393,13 +393,13 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
}; };
} }
- (NSArray *)signalContacts { - (NSArray<Contact *> *)signalContacts {
return [self getSignalUsersFromContactsArray:[self allContacts]]; return [self getSignalUsersFromContactsArray:[self allContacts]];
} }
- (NSArray *)textSecureContacts { - (NSArray *)textSecureContacts {
return [[self.allContacts filter:^int(Contact *contact) { return [[self.allContacts filter:^int(Contact *contact) {
return [contact isTextSecureContact]; return [contact isSignalContact];
}] sortedArrayUsingComparator:[[self class] contactComparator]]; }] sortedArrayUsingComparator:[[self class] contactComparator]];
} }

View File

@ -169,7 +169,7 @@
__block BOOL success; __block BOOL success;
TSUpdateAttributesRequest *request = [[TSUpdateAttributesRequest alloc] initWithUpdatedAttributesWithVoice:YES]; TSUpdateAttributesRequest *request = [[TSUpdateAttributesRequest alloc] initWithUpdatedAttributesWithVoice];
[[TSNetworkManager sharedManager] makeRequest:request [[TSNetworkManager sharedManager] makeRequest:request
success:^(NSURLSessionDataTask *task, id responseObject) { success:^(NSURLSessionDataTask *task, id responseObject) {
success = YES; success = YES;

View File

@ -132,7 +132,6 @@
[TSAccountManager verifyAccountWithCode:[self validationCodeFromTextField] [TSAccountManager verifyAccountWithCode:[self validationCodeFromTextField]
pushToken:pushTokens[0] pushToken:pushTokens[0]
voipToken:([pushTokens count] == 2) ? pushTokens.lastObject : nil voipToken:([pushTokens count] == 2) ? pushTokens.lastObject : nil
supportsVoice:YES
success:^{ success:^{
[textsecureRegistration trySetResult:@YES]; [textsecureRegistration trySetResult:@YES];
} }

View File

@ -21,8 +21,8 @@
MFMessageComposeViewControllerDelegate> { MFMessageComposeViewControllerDelegate> {
UIButton *sendTextButton; UIButton *sendTextButton;
NSString *currentSearchTerm; NSString *currentSearchTerm;
NSArray *contacts; NSArray<Contact *> *contacts;
NSArray *searchResults; NSArray<Contact *> *searchResults;
} }
@property (nonatomic, strong) UISearchController *searchController; @property (nonatomic, strong) UISearchController *searchController;
@ -39,7 +39,7 @@
[super viewDidLoad]; [super viewDidLoad];
[self.navigationController.navigationBar setTranslucent:NO]; [self.navigationController.navigationBar setTranslucent:NO];
contacts = [[Environment getCurrent] contactsManager].signalContacts; contacts = [[[Environment getCurrent] contactsManager] signalContacts];
searchResults = contacts; searchResults = contacts;
[self initializeSearch]; [self initializeSearch];
@ -266,7 +266,7 @@
- (void)filterContentForSearchText:(NSString *)searchText scope:(NSString *)scope { - (void)filterContentForSearchText:(NSString *)searchText scope:(NSString *)scope {
// search by contact name or number // search by contact name or number
NSPredicate *resultPredicate = [NSPredicate NSPredicate *resultPredicate = [NSPredicate
predicateWithFormat:@"(fullName contains[c] %@) OR (allPhoneNumbers contains[c] %@)", searchText, searchText]; predicateWithFormat:@"(fullName contains[c] %@) OR (ANY parsedPhoneNumbers.toE164 contains[c] %@)", searchText, searchText];
searchResults = [contacts filteredArrayUsingPredicate:resultPredicate]; searchResults = [contacts filteredArrayUsingPredicate:resultPredicate];
if (!searchResults.count && _searchController.searchBar.text.length == 0) { if (!searchResults.count && _searchController.searchBar.text.length == 0) {
searchResults = contacts; searchResults = contacts;
@ -427,8 +427,9 @@
#pragma mark - Table View delegate #pragma mark - Table View delegate
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Contact *person = [self contactForIndexPath:indexPath]; Contact *contact = [self contactForIndexPath:indexPath];
return person.isTextSecureContact ? indexPath : nil; // TODO what does it mean to have non Signal contacts here?
return contact.isSignalContact ? indexPath : nil;
} }
@ -476,7 +477,7 @@
[[ContactsUpdater sharedUpdater] [[ContactsUpdater sharedUpdater]
updateSignalContactIntersectionWithABContacts:[Environment getCurrent].contactsManager.allContacts updateSignalContactIntersectionWithABContacts:[Environment getCurrent].contactsManager.allContacts
success:^{ success:^{
contacts = [[Environment getCurrent] contactsManager].signalContacts; contacts = [[[Environment getCurrent] contactsManager] signalContacts];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[self updateSearchResultsForSearchController:self.searchController]; [self updateSearchResultsForSearchController:self.searchController];
[self.tableView reloadData]; [self.tableView reloadData];

View File

@ -437,9 +437,7 @@ typedef enum : NSUInteger {
target:self target:self
action:@selector(callAction)]; action:@selector(callAction)];
self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(0, -10, 0, 10); self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(0, -10, 0, 10);
} else if (!_thread.isGroupThread) { } else if ([self.thread isGroupThread]) {
self.navigationItem.rightBarButtonItem = nil;
} else {
self.navigationItem.rightBarButtonItem = self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"contact-options-action"] [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"contact-options-action"]
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
@ -447,6 +445,9 @@ typedef enum : NSUInteger {
target:self target:self
action:@selector(didSelectShow:)]; action:@selector(didSelectShow:)];
self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(10, 20, 10, 0); self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(10, 20, 10, 0);
} else {
self.navigationItem.rightBarButtonItem = nil;
DDLogError(@"Thread was neither group thread nor callable");
} }
[self hideInputIfNeeded]; [self hideInputIfNeeded];
@ -627,17 +628,8 @@ typedef enum : NSUInteger {
return recipient; return recipient;
} }
- (BOOL)isRedPhoneReachable {
return [self signalRecipient].supportsVoice;
}
- (BOOL)isTextSecureReachable { - (BOOL)isTextSecureReachable {
if (isGroupConversation) { return isGroupConversation || [self signalRecipient];
return YES;
} else {
return [self signalRecipient];
}
} }
- (PhoneNumber *)phoneNumberForThread { - (PhoneNumber *)phoneNumberForThread {
@ -646,18 +638,17 @@ typedef enum : NSUInteger {
} }
- (void)callAction { - (void)callAction {
if ([self isRedPhoneReachable]) { if ([self canCall]) {
PhoneNumber *number = [self phoneNumberForThread]; PhoneNumber *number = [self phoneNumberForThread];
Contact *contact = [[Environment.getCurrent contactsManager] latestContactForPhoneNumber:number]; Contact *contact = [[Environment.getCurrent contactsManager] latestContactForPhoneNumber:number];
[Environment.phoneManager initiateOutgoingCallToContact:contact atRemoteNumber:number]; [Environment.phoneManager initiateOutgoingCallToContact:contact atRemoteNumber:number];
} else { } else {
DDLogWarn(@"Tried to initiate a call but contact has no RedPhone identifier"); DDLogWarn(@"Tried to initiate a call but thread is not callable.");
} }
} }
- (BOOL)canCall { - (BOOL)canCall {
return !isGroupConversation && [self isRedPhoneReachable] && return !(isGroupConversation || [((TSContactThread *)self.thread).contactIdentifier isEqualToString:[TSAccountManager localNumber]]);
![((TSContactThread *)_thread).contactIdentifier isEqualToString:[TSAccountManager localNumber]];
} }
- (void)textViewDidChange:(UITextView *)textView { - (void)textViewDidChange:(UITextView *)textView {