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:
parent
62633ff7f4
commit
26f5418500
|
@ -137,7 +137,7 @@ CHECKOUT OPTIONS:
|
|||
:commit: 225b1baa11125ea84d4b960d700834b5b0a40ee1
|
||||
:git: https://github.com/WhisperSystems/JSQMessagesViewController
|
||||
SignalServiceKit:
|
||||
:commit: 8058951b08a9fb0c610c56bdb50c403132da2089
|
||||
:commit: f5aac9610c274dad33c071fcdd9d2ab6b3d85f0d
|
||||
:git: https://github.com/WhisperSystems/SignalServiceKit.git
|
||||
SocketRocket:
|
||||
:commit: 587ad297eb63eb0d64d4caeb32a7da646ad1132b
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef void (^ABReloadRequestCompletionBlock)(NSArray *contacts);
|
|||
- (void)verifyABPermission;
|
||||
|
||||
- (NSArray<Contact *> *)allContacts;
|
||||
- (NSArray *)signalContacts;
|
||||
- (NSArray<Contact *> *)signalContacts;
|
||||
- (NSArray *)textSecureContacts;
|
||||
|
||||
- (void)doAfterEnvironmentInitSetup;
|
||||
|
|
|
@ -374,7 +374,7 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
|
|||
|
||||
- (NSArray *)getSignalUsersFromContactsArray:(NSArray *)contacts {
|
||||
return [[contacts filter:^int(Contact *contact) {
|
||||
return contact.isRedPhoneContact || contact.isTextSecureContact;
|
||||
return [contact isSignalContact];
|
||||
}] sortedArrayUsingComparator:[[self class] contactComparator]];
|
||||
}
|
||||
|
||||
|
@ -393,13 +393,13 @@ void onAddressBookChanged(ABAddressBookRef notifyAddressBook, CFDictionaryRef in
|
|||
};
|
||||
}
|
||||
|
||||
- (NSArray *)signalContacts {
|
||||
- (NSArray<Contact *> *)signalContacts {
|
||||
return [self getSignalUsersFromContactsArray:[self allContacts]];
|
||||
}
|
||||
|
||||
- (NSArray *)textSecureContacts {
|
||||
return [[self.allContacts filter:^int(Contact *contact) {
|
||||
return [contact isTextSecureContact];
|
||||
return [contact isSignalContact];
|
||||
}] sortedArrayUsingComparator:[[self class] contactComparator]];
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@
|
|||
|
||||
__block BOOL success;
|
||||
|
||||
TSUpdateAttributesRequest *request = [[TSUpdateAttributesRequest alloc] initWithUpdatedAttributesWithVoice:YES];
|
||||
TSUpdateAttributesRequest *request = [[TSUpdateAttributesRequest alloc] initWithUpdatedAttributesWithVoice];
|
||||
[[TSNetworkManager sharedManager] makeRequest:request
|
||||
success:^(NSURLSessionDataTask *task, id responseObject) {
|
||||
success = YES;
|
||||
|
|
|
@ -132,7 +132,6 @@
|
|||
[TSAccountManager verifyAccountWithCode:[self validationCodeFromTextField]
|
||||
pushToken:pushTokens[0]
|
||||
voipToken:([pushTokens count] == 2) ? pushTokens.lastObject : nil
|
||||
supportsVoice:YES
|
||||
success:^{
|
||||
[textsecureRegistration trySetResult:@YES];
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
MFMessageComposeViewControllerDelegate> {
|
||||
UIButton *sendTextButton;
|
||||
NSString *currentSearchTerm;
|
||||
NSArray *contacts;
|
||||
NSArray *searchResults;
|
||||
NSArray<Contact *> *contacts;
|
||||
NSArray<Contact *> *searchResults;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) UISearchController *searchController;
|
||||
|
@ -39,7 +39,7 @@
|
|||
[super viewDidLoad];
|
||||
[self.navigationController.navigationBar setTranslucent:NO];
|
||||
|
||||
contacts = [[Environment getCurrent] contactsManager].signalContacts;
|
||||
contacts = [[[Environment getCurrent] contactsManager] signalContacts];
|
||||
searchResults = contacts;
|
||||
[self initializeSearch];
|
||||
|
||||
|
@ -266,7 +266,7 @@
|
|||
- (void)filterContentForSearchText:(NSString *)searchText scope:(NSString *)scope {
|
||||
// search by contact name or number
|
||||
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];
|
||||
if (!searchResults.count && _searchController.searchBar.text.length == 0) {
|
||||
searchResults = contacts;
|
||||
|
@ -427,8 +427,9 @@
|
|||
|
||||
#pragma mark - Table View delegate
|
||||
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
Contact *person = [self contactForIndexPath:indexPath];
|
||||
return person.isTextSecureContact ? indexPath : nil;
|
||||
Contact *contact = [self contactForIndexPath:indexPath];
|
||||
// TODO what does it mean to have non Signal contacts here?
|
||||
return contact.isSignalContact ? indexPath : nil;
|
||||
}
|
||||
|
||||
|
||||
|
@ -476,7 +477,7 @@
|
|||
[[ContactsUpdater sharedUpdater]
|
||||
updateSignalContactIntersectionWithABContacts:[Environment getCurrent].contactsManager.allContacts
|
||||
success:^{
|
||||
contacts = [[Environment getCurrent] contactsManager].signalContacts;
|
||||
contacts = [[[Environment getCurrent] contactsManager] signalContacts];
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self updateSearchResultsForSearchController:self.searchController];
|
||||
[self.tableView reloadData];
|
||||
|
|
|
@ -437,9 +437,7 @@ typedef enum : NSUInteger {
|
|||
target:self
|
||||
action:@selector(callAction)];
|
||||
self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(0, -10, 0, 10);
|
||||
} else if (!_thread.isGroupThread) {
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
} else {
|
||||
} else if ([self.thread isGroupThread]) {
|
||||
self.navigationItem.rightBarButtonItem =
|
||||
[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"contact-options-action"]
|
||||
imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]
|
||||
|
@ -447,6 +445,9 @@ typedef enum : NSUInteger {
|
|||
target:self
|
||||
action:@selector(didSelectShow:)];
|
||||
self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(10, 20, 10, 0);
|
||||
} else {
|
||||
self.navigationItem.rightBarButtonItem = nil;
|
||||
DDLogError(@"Thread was neither group thread nor callable");
|
||||
}
|
||||
|
||||
[self hideInputIfNeeded];
|
||||
|
@ -627,17 +628,8 @@ typedef enum : NSUInteger {
|
|||
return recipient;
|
||||
}
|
||||
|
||||
- (BOOL)isRedPhoneReachable {
|
||||
return [self signalRecipient].supportsVoice;
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)isTextSecureReachable {
|
||||
if (isGroupConversation) {
|
||||
return YES;
|
||||
} else {
|
||||
return [self signalRecipient];
|
||||
}
|
||||
return isGroupConversation || [self signalRecipient];
|
||||
}
|
||||
|
||||
- (PhoneNumber *)phoneNumberForThread {
|
||||
|
@ -646,18 +638,17 @@ typedef enum : NSUInteger {
|
|||
}
|
||||
|
||||
- (void)callAction {
|
||||
if ([self isRedPhoneReachable]) {
|
||||
if ([self canCall]) {
|
||||
PhoneNumber *number = [self phoneNumberForThread];
|
||||
Contact *contact = [[Environment.getCurrent contactsManager] latestContactForPhoneNumber:number];
|
||||
[Environment.phoneManager initiateOutgoingCallToContact:contact atRemoteNumber:number];
|
||||
} 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 {
|
||||
return !isGroupConversation && [self isRedPhoneReachable] &&
|
||||
![((TSContactThread *)_thread).contactIdentifier isEqualToString:[TSAccountManager localNumber]];
|
||||
return !(isGroupConversation || [((TSContactThread *)self.thread).contactIdentifier isEqualToString:[TSAccountManager localNumber]]);
|
||||
}
|
||||
|
||||
- (void)textViewDidChange:(UITextView *)textView {
|
||||
|
|
Loading…
Reference in New Issue