2014-12-24 02:25:10 +01:00
|
|
|
//
|
2019-03-21 15:55:04 +01:00
|
|
|
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
|
2014-12-24 02:25:10 +01:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "ShowGroupMembersViewController.h"
|
2019-05-02 23:58:48 +02:00
|
|
|
#import "Session-Swift.h"
|
2017-12-01 21:17:29 +01:00
|
|
|
#import "SignalApp.h"
|
2017-05-03 23:03:26 +02:00
|
|
|
#import "ViewControllerUtils.h"
|
2017-12-08 17:50:35 +01:00
|
|
|
#import <SignalMessaging/BlockListUIUtils.h>
|
|
|
|
#import <SignalMessaging/ContactTableViewCell.h>
|
|
|
|
#import <SignalMessaging/ContactsViewHelper.h>
|
2017-12-19 03:50:51 +01:00
|
|
|
#import <SignalMessaging/Environment.h>
|
2017-12-08 17:50:35 +01:00
|
|
|
#import <SignalMessaging/OWSContactsManager.h>
|
|
|
|
#import <SignalMessaging/UIUtil.h>
|
2017-04-18 22:08:01 +02:00
|
|
|
#import <SignalServiceKit/OWSBlockingManager.h>
|
2017-05-05 18:33:10 +02:00
|
|
|
#import <SignalServiceKit/SignalAccount.h>
|
2017-04-28 18:18:42 +02:00
|
|
|
#import <SignalServiceKit/TSGroupModel.h>
|
|
|
|
#import <SignalServiceKit/TSGroupThread.h>
|
2014-12-24 02:25:10 +01:00
|
|
|
|
2017-05-09 19:58:49 +02:00
|
|
|
@import ContactsUI;
|
|
|
|
|
2016-12-05 04:51:31 +01:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2017-05-09 23:55:18 +02:00
|
|
|
@interface ShowGroupMembersViewController () <ContactsViewHelperDelegate, ContactEditingDelegate>
|
2014-12-24 02:25:10 +01:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
@property (nonatomic, readonly) TSGroupThread *thread;
|
|
|
|
@property (nonatomic, readonly) ContactsViewHelper *contactsViewHelper;
|
2015-02-17 00:14:50 +01:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
@property (nonatomic, nullable) NSSet<NSString *> *memberRecipientIds;
|
2017-04-18 22:08:01 +02:00
|
|
|
|
2014-12-24 02:25:10 +01:00
|
|
|
@end
|
2015-02-17 00:14:50 +01:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
#pragma mark -
|
|
|
|
|
2014-12-24 02:25:10 +01:00
|
|
|
@implementation ShowGroupMembersViewController
|
|
|
|
|
2016-12-05 04:51:31 +01:00
|
|
|
- (instancetype)init
|
|
|
|
{
|
|
|
|
self = [super init];
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2017-04-18 22:08:01 +02:00
|
|
|
[self commonInit];
|
2016-12-05 04:51:31 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder
|
|
|
|
{
|
|
|
|
self = [super initWithCoder:aDecoder];
|
|
|
|
if (!self) {
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2017-04-18 22:08:01 +02:00
|
|
|
[self commonInit];
|
2016-12-05 04:51:31 +01:00
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2017-04-18 22:08:01 +02:00
|
|
|
|
|
|
|
- (void)commonInit
|
|
|
|
{
|
2017-05-12 17:09:25 +02:00
|
|
|
_contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self];
|
2017-06-09 22:21:59 +02:00
|
|
|
|
2018-06-15 17:15:21 +02:00
|
|
|
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
|
|
|
self.tableView.estimatedRowHeight = 60;
|
|
|
|
|
2017-06-09 22:21:59 +02:00
|
|
|
[self observeNotifications];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)observeNotifications
|
|
|
|
{
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
|
|
selector:@selector(identityStateDidChange:)
|
|
|
|
name:kNSNotificationName_IdentityStateDidChange
|
|
|
|
object:nil];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (void)configWithThread:(TSGroupThread *)thread
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
_thread = thread;
|
2017-04-18 22:08:01 +02:00
|
|
|
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(self.thread);
|
|
|
|
OWSAssertDebug(self.thread.groupModel);
|
|
|
|
OWSAssertDebug(self.thread.groupModel.groupMemberIds);
|
2017-04-18 22:08:01 +02:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
self.memberRecipientIds = [NSSet setWithArray:self.thread.groupModel.groupMemberIds];
|
2014-12-24 02:25:10 +01:00
|
|
|
}
|
|
|
|
|
2018-03-05 17:57:12 +01:00
|
|
|
- (void)viewDidLoad
|
|
|
|
{
|
2014-12-24 02:25:10 +01:00
|
|
|
[super viewDidLoad];
|
2017-05-09 19:58:49 +02:00
|
|
|
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug([self.navigationController isKindOfClass:[OWSNavigationController class]]);
|
2017-09-07 17:03:54 +02:00
|
|
|
|
2014-12-24 02:25:10 +01:00
|
|
|
self.title = _thread.groupModel.groupName;
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2018-07-17 20:24:21 +02:00
|
|
|
self.tableView.rowHeight = UITableViewAutomaticDimension;
|
|
|
|
self.tableView.estimatedRowHeight = 45;
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
[self updateTableContents];
|
2014-12-24 02:25:10 +01:00
|
|
|
}
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
#pragma mark - Table Contents
|
2014-12-24 02:25:10 +01:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (void)updateTableContents
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(self.thread);
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
OWSTableContents *contents = [OWSTableContents new];
|
2017-04-18 22:08:01 +02:00
|
|
|
|
2017-06-20 16:53:30 +02:00
|
|
|
__weak ShowGroupMembersViewController *weakSelf = self;
|
2017-04-28 18:18:42 +02:00
|
|
|
ContactsViewHelper *helper = self.contactsViewHelper;
|
|
|
|
|
2017-06-20 16:24:29 +02:00
|
|
|
OWSTableSection *membersSection = [OWSTableSection new];
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
// Group Members
|
|
|
|
|
2017-06-20 16:24:29 +02:00
|
|
|
// If there are "no longer verified" members of the group,
|
|
|
|
// highlight them in a special section.
|
2017-06-20 16:27:27 +02:00
|
|
|
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
|
2017-06-20 16:24:29 +02:00
|
|
|
if (noLongerVerifiedRecipientIds.count > 0) {
|
|
|
|
OWSTableSection *noLongerVerifiedSection = [OWSTableSection new];
|
|
|
|
noLongerVerifiedSection.headerTitle = NSLocalizedString(@"GROUP_MEMBERS_SECTION_TITLE_NO_LONGER_VERIFIED",
|
|
|
|
@"Title for the 'no longer verified' section of the 'group members' view.");
|
|
|
|
membersSection.headerTitle = NSLocalizedString(
|
|
|
|
@"GROUP_MEMBERS_SECTION_TITLE_MEMBERS", @"Title for the 'members' section of the 'group members' view.");
|
2017-06-20 16:53:30 +02:00
|
|
|
[noLongerVerifiedSection
|
|
|
|
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED",
|
|
|
|
@"Label for the button that clears all verification "
|
|
|
|
@"errors in the 'group members' view.")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"no_longer_verified")
|
2018-06-13 22:22:03 +02:00
|
|
|
customRowHeight:UITableViewAutomaticDimension
|
2017-06-20 16:53:30 +02:00
|
|
|
actionBlock:^{
|
|
|
|
[weakSelf offerResetAllNoLongerVerified];
|
|
|
|
}]];
|
2017-06-20 16:30:05 +02:00
|
|
|
[self addMembers:noLongerVerifiedRecipientIds toSection:noLongerVerifiedSection useVerifyAction:YES];
|
2017-06-20 16:24:29 +02:00
|
|
|
[contents addSection:noLongerVerifiedSection];
|
|
|
|
}
|
2017-04-28 18:18:42 +02:00
|
|
|
|
|
|
|
NSMutableSet *memberRecipientIds = [self.memberRecipientIds mutableCopy];
|
|
|
|
[memberRecipientIds removeObject:[helper localNumber]];
|
2017-06-20 16:30:05 +02:00
|
|
|
[self addMembers:memberRecipientIds.allObjects toSection:membersSection useVerifyAction:NO];
|
2017-06-20 16:24:29 +02:00
|
|
|
[contents addSection:membersSection];
|
|
|
|
|
|
|
|
self.contents = contents;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)addMembers:(NSArray<NSString *> *)recipientIds
|
2017-06-20 16:30:05 +02:00
|
|
|
toSection:(OWSTableSection *)section
|
|
|
|
useVerifyAction:(BOOL)useVerifyAction
|
2017-06-20 16:24:29 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(recipientIds);
|
|
|
|
OWSAssertDebug(section);
|
2017-06-20 16:24:29 +02:00
|
|
|
|
|
|
|
__weak ShowGroupMembersViewController *weakSelf = self;
|
|
|
|
ContactsViewHelper *helper = self.contactsViewHelper;
|
2018-05-16 22:12:13 +02:00
|
|
|
// Sort the group members using contacts manager.
|
2018-07-27 20:19:11 +02:00
|
|
|
NSArray<NSString *> *sortedRecipientIds = [recipientIds sortedArrayUsingComparator:^NSComparisonResult(
|
|
|
|
NSString *recipientIdA, NSString *recipientIdB) {
|
|
|
|
SignalAccount *signalAccountA = [helper.contactsManager fetchOrBuildSignalAccountForRecipientId:recipientIdA];
|
|
|
|
SignalAccount *signalAccountB = [helper.contactsManager fetchOrBuildSignalAccountForRecipientId:recipientIdB];
|
|
|
|
return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB];
|
|
|
|
}];
|
2018-05-16 22:12:13 +02:00
|
|
|
for (NSString *recipientId in sortedRecipientIds) {
|
2018-06-13 22:22:03 +02:00
|
|
|
[section addItem:[OWSTableItem
|
|
|
|
itemWithCustomCellBlock:^{
|
|
|
|
ShowGroupMembersViewController *strongSelf = weakSelf;
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSCAssertDebug(strongSelf);
|
2018-06-13 22:22:03 +02:00
|
|
|
|
|
|
|
ContactTableViewCell *cell = [ContactTableViewCell new];
|
|
|
|
OWSVerificationState verificationState =
|
|
|
|
[[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId];
|
|
|
|
BOOL isVerified = verificationState == OWSVerificationStateVerified;
|
|
|
|
BOOL isNoLongerVerified = verificationState == OWSVerificationStateNoLongerVerified;
|
|
|
|
BOOL isBlocked = [helper isRecipientIdBlocked:recipientId];
|
|
|
|
if (isNoLongerVerified) {
|
|
|
|
cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_NO_LONGER_VERIFIED",
|
|
|
|
@"An indicator that a contact is no longer verified.");
|
|
|
|
} else if (isBlocked) {
|
|
|
|
cell.accessoryMessage = NSLocalizedString(
|
|
|
|
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
|
|
|
}
|
|
|
|
|
2018-10-25 15:35:08 +02:00
|
|
|
[cell configureWithRecipientId:recipientId];
|
2018-06-13 22:22:03 +02:00
|
|
|
|
|
|
|
if (isVerified) {
|
2018-06-21 20:49:19 +02:00
|
|
|
[cell setAttributedSubtitle:cell.verifiedSubtitle];
|
2018-06-13 22:22:03 +02:00
|
|
|
} else {
|
2018-06-21 20:49:19 +02:00
|
|
|
[cell setAttributedSubtitle:nil];
|
2018-06-13 22:22:03 +02:00
|
|
|
}
|
|
|
|
|
2019-03-22 21:13:40 +01:00
|
|
|
NSString *cellName = [NSString stringWithFormat:@"user.%@", recipientId];
|
|
|
|
cell.accessibilityIdentifier
|
|
|
|
= ACCESSIBILITY_IDENTIFIER_WITH_NAME(ShowGroupMembersViewController, cellName);
|
|
|
|
|
2018-06-13 22:22:03 +02:00
|
|
|
return cell;
|
|
|
|
}
|
|
|
|
customRowHeight:UITableViewAutomaticDimension
|
2017-04-28 18:18:42 +02:00
|
|
|
actionBlock:^{
|
2017-06-20 16:30:05 +02:00
|
|
|
if (useVerifyAction) {
|
2017-06-21 21:06:48 +02:00
|
|
|
[weakSelf showSafetyNumberView:recipientId];
|
2017-06-20 16:30:05 +02:00
|
|
|
} else {
|
|
|
|
[weakSelf didSelectRecipientId:recipientId];
|
|
|
|
}
|
2017-04-28 18:18:42 +02:00
|
|
|
}]];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
2017-06-20 16:24:29 +02:00
|
|
|
}
|
2014-12-24 02:25:10 +01:00
|
|
|
|
2017-06-20 16:53:30 +02:00
|
|
|
- (void)offerResetAllNoLongerVerified
|
|
|
|
{
|
2017-12-19 17:38:25 +01:00
|
|
|
OWSAssertIsOnMainThread();
|
2017-06-20 16:53:30 +02:00
|
|
|
|
2019-03-21 15:55:04 +01:00
|
|
|
UIAlertController *actionSheet = [UIAlertController
|
2017-06-20 16:53:30 +02:00
|
|
|
alertControllerWithTitle:nil
|
|
|
|
message:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED_ALERT_MESSAGE",
|
|
|
|
@"Label for the 'reset all no-longer-verified group members' confirmation alert.")
|
|
|
|
preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
|
|
__weak ShowGroupMembersViewController *weakSelf = self;
|
2018-03-05 17:57:12 +01:00
|
|
|
UIAlertAction *verifyAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"ok")
|
2018-03-05 17:57:12 +01:00
|
|
|
style:UIAlertActionStyleDestructive
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
[weakSelf resetAllNoLongerVerified];
|
|
|
|
}];
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet addAction:verifyAction];
|
|
|
|
[actionSheet addAction:[OWSAlerts cancelAction]];
|
2017-06-20 16:53:30 +02:00
|
|
|
|
2019-03-21 15:55:04 +01:00
|
|
|
[self presentAlert:actionSheet];
|
2017-06-20 16:53:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)resetAllNoLongerVerified
|
|
|
|
{
|
2017-12-19 17:38:25 +01:00
|
|
|
OWSAssertIsOnMainThread();
|
2017-06-20 16:53:30 +02:00
|
|
|
|
|
|
|
OWSIdentityManager *identityManger = [OWSIdentityManager sharedManager];
|
|
|
|
NSArray<NSString *> *recipientIds = [self noLongerVerifiedRecipientIds];
|
|
|
|
for (NSString *recipientId in recipientIds) {
|
2018-01-30 22:41:25 +01:00
|
|
|
OWSVerificationState verificationState = [identityManger verificationStateForRecipientId:recipientId];
|
2017-06-20 16:53:30 +02:00
|
|
|
if (verificationState == OWSVerificationStateNoLongerVerified) {
|
2018-01-30 22:41:25 +01:00
|
|
|
NSData *identityKey = [identityManger identityKeyForRecipientId:recipientId];
|
2017-06-20 16:53:30 +02:00
|
|
|
if (identityKey.length < 1) {
|
2018-08-27 16:29:51 +02:00
|
|
|
OWSFailDebug(@"Missing identity key for: %@", recipientId);
|
2017-06-20 16:53:30 +02:00
|
|
|
continue;
|
|
|
|
}
|
2018-02-02 20:07:13 +01:00
|
|
|
[identityManger setVerificationState:OWSVerificationStateDefault
|
|
|
|
identityKey:identityKey
|
|
|
|
recipientId:recipientId
|
|
|
|
isUserInitiatedChange:YES];
|
2017-06-20 16:53:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[self updateTableContents];
|
|
|
|
}
|
|
|
|
|
2017-06-20 16:24:29 +02:00
|
|
|
// Returns a collection of the group members who are "no longer verified".
|
|
|
|
- (NSArray<NSString *> *)noLongerVerifiedRecipientIds
|
|
|
|
{
|
|
|
|
NSMutableArray<NSString *> *result = [NSMutableArray new];
|
|
|
|
for (NSString *recipientId in self.thread.recipientIdentifiers) {
|
2018-01-30 22:41:25 +01:00
|
|
|
if ([[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]
|
2017-06-20 16:24:29 +02:00
|
|
|
== OWSVerificationStateNoLongerVerified) {
|
|
|
|
[result addObject:recipientId];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return [result copy];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (void)didSelectRecipientId:(NSString *)recipientId
|
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(recipientId.length > 0);
|
2017-04-18 22:08:01 +02:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
ContactsViewHelper *helper = self.contactsViewHelper;
|
2018-07-27 20:19:11 +02:00
|
|
|
SignalAccount *_Nullable signalAccount = [helper fetchSignalAccountForRecipientId:recipientId];
|
2017-04-18 22:08:01 +02:00
|
|
|
|
2019-03-21 15:55:04 +01:00
|
|
|
UIAlertController *actionSheet =
|
2017-04-18 22:08:01 +02:00
|
|
|
[UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
|
|
|
|
|
2017-05-18 14:41:28 +02:00
|
|
|
if (self.contactsViewHelper.contactsManager.supportsContactEditing) {
|
|
|
|
NSString *contactInfoTitle = signalAccount
|
|
|
|
? NSLocalizedString(@"GROUP_MEMBERS_VIEW_CONTACT_INFO", @"Button label for the 'show contact info' button")
|
|
|
|
: NSLocalizedString(
|
|
|
|
@"GROUP_MEMBERS_ADD_CONTACT_INFO", @"Button label to add information to an unknown contact");
|
2019-03-22 21:13:40 +01:00
|
|
|
[actionSheet
|
|
|
|
addAction:[UIAlertAction actionWithTitle:contactInfoTitle
|
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"show_contact_info")
|
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
[self showContactInfoViewForRecipientId:recipientId];
|
|
|
|
}]];
|
2017-05-18 14:41:28 +02:00
|
|
|
}
|
2017-04-18 22:08:01 +02:00
|
|
|
|
|
|
|
BOOL isBlocked;
|
2017-05-01 18:51:59 +02:00
|
|
|
if (signalAccount) {
|
|
|
|
isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
|
2017-04-18 22:08:01 +02:00
|
|
|
if (isBlocked) {
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet
|
2017-04-18 22:08:01 +02:00
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON",
|
|
|
|
@"Button label for the 'unblock' button")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"unblock")
|
2017-04-19 17:39:13 +02:00
|
|
|
style:UIAlertActionStyleDefault
|
2017-04-18 22:08:01 +02:00
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
[BlockListUIUtils
|
2017-05-01 18:51:59 +02:00
|
|
|
showUnblockSignalAccountActionSheet:signalAccount
|
|
|
|
fromViewController:self
|
|
|
|
blockingManager:helper.blockingManager
|
|
|
|
contactsManager:helper.contactsManager
|
2017-05-02 17:16:34 +02:00
|
|
|
completionBlock:^(BOOL ignore) {
|
|
|
|
[self updateTableContents];
|
|
|
|
}];
|
2017-04-18 22:08:01 +02:00
|
|
|
}]];
|
|
|
|
} else {
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet
|
2017-04-18 22:08:01 +02:00
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON",
|
|
|
|
@"Button label for the 'block' button")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"block")
|
2017-04-18 22:08:01 +02:00
|
|
|
style:UIAlertActionStyleDestructive
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
2017-04-28 18:18:42 +02:00
|
|
|
[BlockListUIUtils
|
2017-05-01 18:51:59 +02:00
|
|
|
showBlockSignalAccountActionSheet:signalAccount
|
|
|
|
fromViewController:self
|
|
|
|
blockingManager:helper.blockingManager
|
|
|
|
contactsManager:helper.contactsManager
|
2017-05-02 17:16:34 +02:00
|
|
|
completionBlock:^(BOOL ignore) {
|
|
|
|
[self updateTableContents];
|
|
|
|
}];
|
2017-04-18 22:08:01 +02:00
|
|
|
}]];
|
|
|
|
}
|
|
|
|
} else {
|
2017-04-28 18:18:42 +02:00
|
|
|
isBlocked = [helper isRecipientIdBlocked:recipientId];
|
2017-04-18 22:08:01 +02:00
|
|
|
if (isBlocked) {
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet
|
2017-04-18 22:08:01 +02:00
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON",
|
|
|
|
@"Button label for the 'unblock' button")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"unblock")
|
2017-04-19 17:39:13 +02:00
|
|
|
style:UIAlertActionStyleDefault
|
2017-04-18 22:08:01 +02:00
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
[BlockListUIUtils
|
|
|
|
showUnblockPhoneNumberActionSheet:recipientId
|
|
|
|
fromViewController:self
|
2017-04-28 18:18:42 +02:00
|
|
|
blockingManager:helper.blockingManager
|
|
|
|
contactsManager:helper.contactsManager
|
2017-05-02 17:16:34 +02:00
|
|
|
completionBlock:^(BOOL ignore) {
|
|
|
|
[self updateTableContents];
|
|
|
|
}];
|
2017-04-18 22:08:01 +02:00
|
|
|
}]];
|
|
|
|
} else {
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet
|
2017-04-18 22:08:01 +02:00
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON",
|
|
|
|
@"Button label for the 'block' button")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"block")
|
2017-04-18 22:08:01 +02:00
|
|
|
style:UIAlertActionStyleDestructive
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
[BlockListUIUtils
|
|
|
|
showBlockPhoneNumberActionSheet:recipientId
|
|
|
|
fromViewController:self
|
2017-04-28 18:18:42 +02:00
|
|
|
blockingManager:helper.blockingManager
|
|
|
|
contactsManager:helper.contactsManager
|
2017-05-02 17:16:34 +02:00
|
|
|
completionBlock:^(BOOL ignore) {
|
|
|
|
[self updateTableContents];
|
|
|
|
}];
|
2017-04-18 22:08:01 +02:00
|
|
|
}]];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isBlocked) {
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet
|
2017-04-18 22:08:01 +02:00
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_SEND_MESSAGE",
|
|
|
|
@"Button label for the 'send message to group member' button")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_message")
|
2017-04-19 17:39:13 +02:00
|
|
|
style:UIAlertActionStyleDefault
|
2017-04-18 22:08:01 +02:00
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
2017-04-28 18:18:42 +02:00
|
|
|
[self showConversationViewForRecipientId:recipientId];
|
2017-04-18 22:08:01 +02:00
|
|
|
}]];
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_CALL",
|
|
|
|
@"Button label for the 'call group member' button")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"call")
|
2019-03-21 15:55:04 +01:00
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
|
|
|
[self callMember:recipientId];
|
|
|
|
}]];
|
|
|
|
[actionSheet
|
2017-06-09 22:58:00 +02:00
|
|
|
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"VERIFY_PRIVACY",
|
|
|
|
@"Label for button or row which allows users to verify the "
|
|
|
|
@"safety number of another user.")
|
2019-03-22 21:13:40 +01:00
|
|
|
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"safety_numbers")
|
2017-06-09 22:58:00 +02:00
|
|
|
style:UIAlertActionStyleDefault
|
|
|
|
handler:^(UIAlertAction *_Nonnull action) {
|
2017-06-21 21:06:48 +02:00
|
|
|
[self showSafetyNumberView:recipientId];
|
2017-06-09 22:58:00 +02:00
|
|
|
}]];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
|
|
|
|
2019-03-21 15:55:04 +01:00
|
|
|
[actionSheet addAction:[OWSAlerts cancelAction]];
|
2017-04-18 22:08:01 +02:00
|
|
|
|
2019-03-21 15:55:04 +01:00
|
|
|
[self presentAlert:actionSheet];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (void)showContactInfoViewForRecipientId:(NSString *)recipientId
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(recipientId.length > 0);
|
2017-04-28 18:18:42 +02:00
|
|
|
|
2017-05-09 23:55:18 +02:00
|
|
|
[self.contactsViewHelper presentContactViewControllerForRecipientId:recipientId
|
|
|
|
fromViewController:self
|
|
|
|
editImmediately:NO];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
2015-12-22 12:45:09 +01:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (void)showConversationViewForRecipientId:(NSString *)recipientId
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(recipientId.length > 0);
|
2017-04-28 18:18:42 +02:00
|
|
|
|
Faster conversation presentation.
There are multiple places in the codebase we present a conversation.
We used to have some very conservative machinery around how this was done, for
fear of failing to present the call view controller, which would have left a
hidden call in the background. We've since addressed that concern more
thoroughly via the separate calling UIWindow.
As such, the remaining presentation machinery is overly complex and inflexible
for what we need.
Sometimes we want to animate-push the conversation. (tap on home, tap on "send message" in contact card/group members)
Sometimes we want to dismiss a modal, to reveal the conversation behind it (contact picker, group creation)
Sometimes we want to present the conversation with no animation (becoming active from a notification)
We also want to ensure that we're never pushing more than one conversation view
controller, which was previously a problem since we were "pushing" a newly
constructed VC in response to these myriad actions. It turned out there were
certain code paths that caused multiple actions to be fired in rapid succession
which pushed multiple ConversationVC's.
The built-in method: `setViewControllers:animated` easily ensures we only have
one ConversationVC on the stack, while being composable enough to faciliate the
various more efficient animations we desire.
The only thing lost with the complex methods is that the naive
`presentViewController:` can fail, e.g. if another view is already presented.
E.g. if an alert appears *just* before the user taps compose, the contact
picker will fail to present.
Since we no longer depend on this for presenting the CallViewController, this
isn't catostrophic, and in fact, arguable preferable, since we want the user to
read and dismiss any alert explicitly.
// FREEBIE
2018-08-18 22:54:35 +02:00
|
|
|
[SignalApp.sharedApp presentConversationForRecipientId:recipientId
|
|
|
|
action:ConversationViewActionCompose
|
|
|
|
animated:YES];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (void)callMember:(NSString *)recipientId
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
Faster conversation presentation.
There are multiple places in the codebase we present a conversation.
We used to have some very conservative machinery around how this was done, for
fear of failing to present the call view controller, which would have left a
hidden call in the background. We've since addressed that concern more
thoroughly via the separate calling UIWindow.
As such, the remaining presentation machinery is overly complex and inflexible
for what we need.
Sometimes we want to animate-push the conversation. (tap on home, tap on "send message" in contact card/group members)
Sometimes we want to dismiss a modal, to reveal the conversation behind it (contact picker, group creation)
Sometimes we want to present the conversation with no animation (becoming active from a notification)
We also want to ensure that we're never pushing more than one conversation view
controller, which was previously a problem since we were "pushing" a newly
constructed VC in response to these myriad actions. It turned out there were
certain code paths that caused multiple actions to be fired in rapid succession
which pushed multiple ConversationVC's.
The built-in method: `setViewControllers:animated` easily ensures we only have
one ConversationVC on the stack, while being composable enough to faciliate the
various more efficient animations we desire.
The only thing lost with the complex methods is that the naive
`presentViewController:` can fail, e.g. if another view is already presented.
E.g. if an alert appears *just* before the user taps compose, the contact
picker will fail to present.
Since we no longer depend on this for presenting the CallViewController, this
isn't catostrophic, and in fact, arguable preferable, since we want the user to
read and dismiss any alert explicitly.
// FREEBIE
2018-08-18 22:54:35 +02:00
|
|
|
[SignalApp.sharedApp presentConversationForRecipientId:recipientId
|
|
|
|
action:ConversationViewActionAudioCall
|
|
|
|
animated:YES];
|
2015-01-04 18:47:12 +01:00
|
|
|
}
|
|
|
|
|
2017-06-21 21:06:48 +02:00
|
|
|
- (void)showSafetyNumberView:(NSString *)recipientId
|
2017-06-09 22:58:00 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(recipientId.length > 0);
|
2017-06-09 22:58:00 +02:00
|
|
|
|
2017-06-15 22:20:33 +02:00
|
|
|
[FingerprintViewController presentFromViewController:self recipientId:recipientId];
|
2017-06-09 22:58:00 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
#pragma mark - ContactsViewHelperDelegate
|
2015-01-04 18:47:12 +01:00
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (void)contactsViewHelperDidUpdateContacts
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
2017-04-28 18:18:42 +02:00
|
|
|
[self updateTableContents];
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
|
|
|
|
2017-04-28 18:18:42 +02:00
|
|
|
- (BOOL)shouldHideLocalNumber
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
2017-04-28 18:18:42 +02:00
|
|
|
return YES;
|
2017-04-18 22:08:01 +02:00
|
|
|
}
|
|
|
|
|
2017-05-09 23:55:18 +02:00
|
|
|
#pragma mark - ContactEditingDelegate
|
|
|
|
|
|
|
|
- (void)didFinishEditingContact
|
|
|
|
{
|
2018-08-27 18:09:39 +02:00
|
|
|
OWSLogDebug(@"");
|
2017-05-09 23:55:18 +02:00
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
2017-05-09 19:58:49 +02:00
|
|
|
#pragma mark - CNContactViewControllerDelegate
|
|
|
|
|
|
|
|
- (void)contactViewController:(CNContactViewController *)viewController
|
|
|
|
didCompleteWithContact:(nullable CNContact *)contact
|
|
|
|
{
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSLogDebug(@"done editing contact.");
|
2017-05-09 19:58:49 +02:00
|
|
|
[self dismissViewControllerAnimated:YES completion:nil];
|
|
|
|
}
|
|
|
|
|
2017-06-09 22:21:59 +02:00
|
|
|
#pragma mark - Notifications
|
|
|
|
|
|
|
|
- (void)identityStateDidChange:(NSNotification *)notification
|
|
|
|
{
|
2017-12-19 17:38:25 +01:00
|
|
|
OWSAssertIsOnMainThread();
|
2017-06-09 22:21:59 +02:00
|
|
|
|
|
|
|
[self updateTableContents];
|
|
|
|
}
|
|
|
|
|
2014-12-24 02:25:10 +01:00
|
|
|
@end
|
2016-12-05 04:51:31 +01:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|