|
|
@ -3,12 +3,15 @@
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "ShowGroupMembersViewController.h"
|
|
|
|
#import "ShowGroupMembersViewController.h"
|
|
|
|
#import "SignalsViewController.h"
|
|
|
|
#import "BlockListUIUtils.h"
|
|
|
|
#import "OWSContactsManager.h"
|
|
|
|
#import "ContactTableViewCell.h"
|
|
|
|
#import "Environment.h"
|
|
|
|
#import "Environment.h"
|
|
|
|
#import "GroupContactsResult.h"
|
|
|
|
#import "GroupContactsResult.h"
|
|
|
|
|
|
|
|
#import "OWSContactsManager.h"
|
|
|
|
|
|
|
|
#import "SignalsViewController.h"
|
|
|
|
#import "UIUtil.h"
|
|
|
|
#import "UIUtil.h"
|
|
|
|
#import <AddressBookUI/AddressBookUI.h>
|
|
|
|
#import <AddressBookUI/AddressBookUI.h>
|
|
|
|
|
|
|
|
#import <SignalServiceKit/OWSBlockingManager.h>
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
|
@ -20,6 +23,9 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
@property TSGroupThread *thread;
|
|
|
|
@property TSGroupThread *thread;
|
|
|
|
@property (nonatomic, readonly) OWSContactsManager *_Nonnull contactsManager;
|
|
|
|
@property (nonatomic, readonly) OWSContactsManager *_Nonnull contactsManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) OWSBlockingManager *blockingManager;
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) NSArray<NSString *> *blockedPhoneNumbers;
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation ShowGroupMembersViewController
|
|
|
|
@implementation ShowGroupMembersViewController
|
|
|
@ -31,7 +37,7 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_contactsManager = [Environment getCurrent].contactsManager;
|
|
|
|
[self commonInit];
|
|
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -43,11 +49,43 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_contactsManager = [Environment getCurrent].contactsManager;
|
|
|
|
[self commonInit];
|
|
|
|
|
|
|
|
|
|
|
|
return self;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)commonInit
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_blockingManager = [OWSBlockingManager sharedManager];
|
|
|
|
|
|
|
|
_blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers];
|
|
|
|
|
|
|
|
_contactsManager = [Environment getCurrent].contactsManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self addNotificationListeners];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)addNotificationListeners
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
|
|
|
|
selector:@selector(blockedPhoneNumbersDidChange:)
|
|
|
|
|
|
|
|
name:kNSNotificationName_BlockedPhoneNumbersDidChange
|
|
|
|
|
|
|
|
object:nil];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)blockedPhoneNumbersDidChange:(id)notification
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
|
|
|
|
_blockedPhoneNumbers = [_blockingManager blockedPhoneNumbers];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self.tableView reloadData];
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)configWithThread:(TSGroupThread *)gThread {
|
|
|
|
- (void)configWithThread:(TSGroupThread *)gThread {
|
|
|
|
_thread = gThread;
|
|
|
|
_thread = gThread;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -62,11 +100,15 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
|
|
|
|
|
|
|
|
self.groupContacts =
|
|
|
|
self.groupContacts =
|
|
|
|
[[GroupContactsResult alloc] initWithMembersId:self.thread.groupModel.groupMemberIds without:nil];
|
|
|
|
[[GroupContactsResult alloc] initWithMembersId:self.thread.groupModel.groupMemberIds without:nil];
|
|
|
|
|
|
|
|
__weak ShowGroupMembersViewController *weakSelf = self;
|
|
|
|
[self.contactsManager.getObservableContacts watchLatestValue:^(id latestValue) {
|
|
|
|
[self.contactsManager.getObservableContacts watchLatestValue:^(id latestValue) {
|
|
|
|
self.groupContacts =
|
|
|
|
ShowGroupMembersViewController *strongSelf = weakSelf;
|
|
|
|
[[GroupContactsResult alloc] initWithMembersId:self.thread.groupModel.groupMemberIds without:nil];
|
|
|
|
if (!strongSelf) {
|
|
|
|
[self.tableView reloadData];
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
strongSelf.groupContacts =
|
|
|
|
|
|
|
|
[[GroupContactsResult alloc] initWithMembersId:strongSelf.thread.groupModel.groupMemberIds without:nil];
|
|
|
|
|
|
|
|
[strongSelf.tableView reloadData];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onThread:[NSThread mainThread]
|
|
|
|
onThread:[NSThread mainThread]
|
|
|
|
untilCancelled:nil];
|
|
|
|
untilCancelled:nil];
|
|
|
@ -76,6 +118,8 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
|
|
|
|
|
|
|
|
- (void)initializeTableView {
|
|
|
|
- (void)initializeTableView {
|
|
|
|
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
|
|
|
|
[self.tableView registerClass:[ContactTableViewCell class]
|
|
|
|
|
|
|
|
forCellReuseIdentifier:kContactsTable_CellReuseIdentifier];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Actions
|
|
|
|
#pragma mark - Actions
|
|
|
@ -90,44 +134,176 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
return (NSInteger)[self.groupContacts numberOfMembers] + 1;
|
|
|
|
return (NSInteger)[self.groupContacts numberOfMembers] + 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SearchCell"];
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
if (cell == nil) {
|
|
|
|
if (indexPath.row == 0) {
|
|
|
|
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
|
|
|
|
UITableViewCell *cell = [UITableViewCell new];
|
|
|
|
reuseIdentifier:indexPath.row == 0 ? @"HeaderCell" : @"GroupSearchCell"];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (indexPath.row > 0) {
|
|
|
|
|
|
|
|
NSIndexPath *relativeIndexPath = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
|
|
|
|
|
|
|
|
if ([self.groupContacts isContactAtIndexPath:relativeIndexPath]) {
|
|
|
|
|
|
|
|
Contact *contact = [self contactForIndexPath:relativeIndexPath];
|
|
|
|
|
|
|
|
cell.textLabel.attributedText =
|
|
|
|
|
|
|
|
[self.contactsManager formattedFullNameForContact:contact font:cell.textLabel.font];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cell.textLabel.text = [self.groupContacts identifierForIndexPath:relativeIndexPath];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
cell.textLabel.text = NSLocalizedString(@"GROUP_MEMBERS_HEADER", @"header for table which lists the members of this group thread");
|
|
|
|
cell.textLabel.text = NSLocalizedString(@"GROUP_MEMBERS_HEADER", @"header for table which lists the members of this group thread");
|
|
|
|
cell.textLabel.textColor = [UIColor lightGrayColor];
|
|
|
|
cell.textLabel.textColor = [UIColor lightGrayColor];
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
|
|
|
cell.userInteractionEnabled = NO;
|
|
|
|
cell.userInteractionEnabled = NO;
|
|
|
|
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
|
|
|
|
// Adjust index path for the header row.
|
|
|
|
|
|
|
|
indexPath = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ContactTableViewCell *cell = [ContactTableViewCell new];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ([self.groupContacts isContactAtIndexPath:indexPath]) {
|
|
|
|
|
|
|
|
Contact *contact = [self contactForIndexPath:indexPath];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL isBlocked = [self isContactBlocked:contact];
|
|
|
|
|
|
|
|
if (isBlocked) {
|
|
|
|
|
|
|
|
cell.accessoryMessage
|
|
|
|
|
|
|
|
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
OWSAssert(cell.accessoryMessage == nil);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[cell configureWithContact:contact contactsManager:self.contactsManager];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
NSString *recipientId = [self.groupContacts identifierForIndexPath:indexPath];
|
|
|
|
|
|
|
|
BOOL isBlocked = [self isRecipientIdBlocked:recipientId];
|
|
|
|
|
|
|
|
if (isBlocked) {
|
|
|
|
|
|
|
|
cell.accessoryMessage
|
|
|
|
|
|
|
|
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
OWSAssert(cell.accessoryMessage == nil);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[cell configureWithRecipientId:recipientId contactsManager:self.contactsManager];
|
|
|
|
|
|
|
|
}
|
|
|
|
return cell;
|
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (indexPath.row == 0) {
|
|
|
|
|
|
|
|
return 45.f;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return [ContactTableViewCell rowHeight];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
NSIndexPath *relativeIndexPath = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
|
|
|
|
if (indexPath.row == 0) {
|
|
|
|
|
|
|
|
OWSAssert(0);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Adjust index path for the header row.
|
|
|
|
|
|
|
|
indexPath = [NSIndexPath indexPathForRow:indexPath.row - 1 inSection:indexPath.section];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIAlertController *actionSheetController =
|
|
|
|
|
|
|
|
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[actionSheetController
|
|
|
|
|
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_VIEW_CONTACT_INFO",
|
|
|
|
|
|
|
|
@"Button label for the 'show contact info' button")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
|
|
|
|
[self showContactInfoViewForMember:indexPath];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL isBlocked;
|
|
|
|
|
|
|
|
if ([self.groupContacts isContactAtIndexPath:indexPath]) {
|
|
|
|
|
|
|
|
Contact *contact = [self contactForIndexPath:indexPath];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
isBlocked = [self isContactBlocked:contact];
|
|
|
|
|
|
|
|
if (isBlocked) {
|
|
|
|
|
|
|
|
[actionSheetController
|
|
|
|
|
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON",
|
|
|
|
|
|
|
|
@"Button label for the 'unblock' button")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
|
|
|
|
[BlockListUIUtils
|
|
|
|
|
|
|
|
showUnblockContactActionSheet:contact
|
|
|
|
|
|
|
|
fromViewController:self
|
|
|
|
|
|
|
|
blockingManager:self.blockingManager
|
|
|
|
|
|
|
|
contactsManager:self.contactsManager
|
|
|
|
|
|
|
|
completionBlock:nil];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
[actionSheetController
|
|
|
|
|
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON",
|
|
|
|
|
|
|
|
@"Button label for the 'block' button")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleDestructive
|
|
|
|
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
|
|
|
|
[BlockListUIUtils showBlockContactActionSheet:contact
|
|
|
|
|
|
|
|
fromViewController:self
|
|
|
|
|
|
|
|
blockingManager:self.blockingManager
|
|
|
|
|
|
|
|
contactsManager:self.contactsManager
|
|
|
|
|
|
|
|
completionBlock:nil];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
NSString *recipientId = [self.groupContacts identifierForIndexPath:indexPath];
|
|
|
|
|
|
|
|
isBlocked = [self isRecipientIdBlocked:recipientId];
|
|
|
|
|
|
|
|
if (isBlocked) {
|
|
|
|
|
|
|
|
[actionSheetController
|
|
|
|
|
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON",
|
|
|
|
|
|
|
|
@"Button label for the 'unblock' button")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
|
|
|
|
[BlockListUIUtils
|
|
|
|
|
|
|
|
showUnblockPhoneNumberActionSheet:recipientId
|
|
|
|
|
|
|
|
fromViewController:self
|
|
|
|
|
|
|
|
blockingManager:self.blockingManager
|
|
|
|
|
|
|
|
contactsManager:self.contactsManager
|
|
|
|
|
|
|
|
completionBlock:nil];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
[actionSheetController
|
|
|
|
|
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON",
|
|
|
|
|
|
|
|
@"Button label for the 'block' button")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleDestructive
|
|
|
|
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
|
|
|
|
[BlockListUIUtils
|
|
|
|
|
|
|
|
showBlockPhoneNumberActionSheet:recipientId
|
|
|
|
|
|
|
|
fromViewController:self
|
|
|
|
|
|
|
|
blockingManager:self.blockingManager
|
|
|
|
|
|
|
|
contactsManager:self.contactsManager
|
|
|
|
|
|
|
|
completionBlock:nil];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isBlocked) {
|
|
|
|
|
|
|
|
[actionSheetController
|
|
|
|
|
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_SEND_MESSAGE",
|
|
|
|
|
|
|
|
@"Button label for the 'send message to group member' button")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
|
|
|
|
[self showConversationViewForMember:indexPath];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
[actionSheetController
|
|
|
|
|
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_CALL",
|
|
|
|
|
|
|
|
@"Button label for the 'call group member' button")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
|
|
|
|
[self callMember:indexPath];
|
|
|
|
|
|
|
|
}]];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"")
|
|
|
|
|
|
|
|
style:UIAlertActionStyleCancel
|
|
|
|
|
|
|
|
handler:nil];
|
|
|
|
|
|
|
|
[actionSheetController addAction:dismissAction];
|
|
|
|
|
|
|
|
|
|
|
|
if (indexPath.row > 0 && [self.groupContacts isContactAtIndexPath:relativeIndexPath]) {
|
|
|
|
[self presentViewController:actionSheetController animated:YES completion:nil];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)showContactInfoViewForMember:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ([self.groupContacts isContactAtIndexPath:indexPath]) {
|
|
|
|
ABPersonViewController *view = [[ABPersonViewController alloc] init];
|
|
|
|
ABPersonViewController *view = [[ABPersonViewController alloc] init];
|
|
|
|
|
|
|
|
|
|
|
|
Contact *contact = [self.groupContacts contactForIndexPath:relativeIndexPath];
|
|
|
|
Contact *contact = [self.groupContacts contactForIndexPath:indexPath];
|
|
|
|
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, nil);
|
|
|
|
ABAddressBookRef addressBookRef = ABAddressBookCreateWithOptions(NULL, nil);
|
|
|
|
view.displayedPerson =
|
|
|
|
view.displayedPerson
|
|
|
|
ABAddressBookGetPersonWithRecordID(addressBookRef, contact.recordID); // Assume person is already defined.
|
|
|
|
= ABAddressBookGetPersonWithRecordID(addressBookRef, contact.recordID); // Assume person is already defined.
|
|
|
|
view.allowsActions = NO;
|
|
|
|
view.allowsActions = NO;
|
|
|
|
view.allowsEditing = YES;
|
|
|
|
view.allowsEditing = YES;
|
|
|
|
|
|
|
|
|
|
|
@ -139,8 +315,7 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
CFErrorRef anError = NULL;
|
|
|
|
CFErrorRef anError = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
ABMultiValueRef phone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
|
|
|
|
ABMultiValueRef phone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
|
|
|
|
ABMultiValueAddValueAndLabel(
|
|
|
|
ABMultiValueAddValueAndLabel(phone,
|
|
|
|
phone,
|
|
|
|
|
|
|
|
(__bridge CFTypeRef)[self.tableView cellForRowAtIndexPath:indexPath].textLabel.text,
|
|
|
|
(__bridge CFTypeRef)[self.tableView cellForRowAtIndexPath:indexPath].textLabel.text,
|
|
|
|
kABPersonPhoneMainLabel,
|
|
|
|
kABPersonPhoneMainLabel,
|
|
|
|
NULL);
|
|
|
|
NULL);
|
|
|
@ -154,8 +329,30 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
[self.navigationController pushViewController:view animated:YES];
|
|
|
|
[self.navigationController pushViewController:view animated:YES];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)showConversationViewForMember:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NSString *recipientId;
|
|
|
|
|
|
|
|
if ([self.groupContacts isContactAtIndexPath:indexPath]) {
|
|
|
|
|
|
|
|
Contact *contact = [self.groupContacts contactForIndexPath:indexPath];
|
|
|
|
|
|
|
|
recipientId = [[contact textSecureIdentifiers] firstObject];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
recipientId = [self.groupContacts identifierForIndexPath:indexPath];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[Environment messageIdentifier:recipientId withCompose:YES];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
|
|
|
- (void)callMember:(NSIndexPath *)indexPath
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
NSString *recipientId;
|
|
|
|
|
|
|
|
if ([self.groupContacts isContactAtIndexPath:indexPath]) {
|
|
|
|
|
|
|
|
Contact *contact = [self.groupContacts contactForIndexPath:indexPath];
|
|
|
|
|
|
|
|
recipientId = [[contact textSecureIdentifiers] firstObject];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
recipientId = [self.groupContacts identifierForIndexPath:indexPath];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[Environment callUserWithIdentifier:recipientId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (Contact *)contactForIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
- (Contact *)contactForIndexPath:(NSIndexPath *)indexPath {
|
|
|
@ -163,6 +360,27 @@ static NSString *const kUnwindToMessagesViewSegue = @"UnwindToMessagesViewSegue"
|
|
|
|
return contact;
|
|
|
|
return contact;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)isContactBlocked:(Contact *)contact
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (contact.parsedPhoneNumbers.count < 1) {
|
|
|
|
|
|
|
|
// Do not consider contacts without any valid phone numbers to be blocked.
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (PhoneNumber *phoneNumber in contact.parsedPhoneNumbers) {
|
|
|
|
|
|
|
|
if ([_blockedPhoneNumbers containsObject:phoneNumber.toE164]) {
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NO;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (BOOL)isRecipientIdBlocked:(NSString *)recipientId
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return [_blockedPhoneNumbers containsObject:recipientId];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|
NS_ASSUME_NONNULL_END
|
|
|
|