Merge branch 'charlesmchen/groupsVsNoLongerVerified'
This commit is contained in:
commit
6fa20d62ba
@ -844,6 +844,12 @@ typedef enum : NSUInteger {
|
||||
- (void)noLongerVerifiedBannerViewWasTapped:(UIGestureRecognizer *)sender
|
||||
{
|
||||
if (sender.state == UIGestureRecognizerStateRecognized) {
|
||||
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
|
||||
if (noLongerVerifiedRecipientIds.count < 1) {
|
||||
return;
|
||||
}
|
||||
BOOL hasMultiple = noLongerVerifiedRecipientIds.count > 1;
|
||||
|
||||
UIAlertController *actionSheetController =
|
||||
[UIAlertController alertControllerWithTitle:nil
|
||||
message:nil
|
||||
@ -851,12 +857,14 @@ typedef enum : NSUInteger {
|
||||
|
||||
__weak MessagesViewController *weakSelf = self;
|
||||
UIAlertAction *verifyAction = [UIAlertAction
|
||||
actionWithTitle:
|
||||
NSLocalizedString(@"VERIFY_PRIVACY",
|
||||
@"Label for button or row which allows users to verify the safety number of another user.")
|
||||
style:UIAlertActionStyleDefault
|
||||
actionWithTitle:(hasMultiple ? NSLocalizedString(@"VERIFY_PRIVACY_MULTIPLE",
|
||||
@"Label for button or row which allows users to verify the safety "
|
||||
@"numbers of multiple users.")
|
||||
: NSLocalizedString(@"VERIFY_PRIVACY",
|
||||
@"Label for button or row which allows users to verify the safety "
|
||||
@"number of another user."))style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *_Nonnull action) {
|
||||
[weakSelf showConversationSettingsAndShowVerification:YES];
|
||||
[weakSelf showNoLongerVerifiedUI];
|
||||
}];
|
||||
[actionSheetController addAction:verifyAction];
|
||||
|
||||
@ -1952,6 +1960,18 @@ typedef enum : NSUInteger {
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)showNoLongerVerifiedUI
|
||||
{
|
||||
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
|
||||
if (noLongerVerifiedRecipientIds.count > 1) {
|
||||
[self showConversationSettingsAndShowVerification:YES];
|
||||
} else if (noLongerVerifiedRecipientIds.count == 1) {
|
||||
// Pick one in an arbitrary but deterministic manner.
|
||||
NSString *recipientId = noLongerVerifiedRecipientIds.lastObject;
|
||||
[self showFingerprintWithRecipientId:recipientId];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showConversationSettings
|
||||
{
|
||||
[self showConversationSettingsAndShowVerification:NO];
|
||||
|
||||
@ -66,6 +66,10 @@ typedef UITableViewCell *_Nonnull (^OWSTableCustomCellBlock)();
|
||||
|
||||
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
||||
|
||||
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
|
||||
customRowHeight:(CGFloat)customRowHeight
|
||||
actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
||||
|
||||
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
|
||||
|
||||
+ (OWSTableItem *)labelItemWithText:(NSString *)text;
|
||||
|
||||
@ -169,6 +169,15 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
|
||||
return item;
|
||||
}
|
||||
|
||||
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
|
||||
customRowHeight:(CGFloat)customRowHeight
|
||||
actionBlock:(nullable OWSTableActionBlock)actionBlock
|
||||
{
|
||||
OWSTableItem *item = [self disclosureItemWithText:text actionBlock:actionBlock];
|
||||
item.customRowHeight = @(customRowHeight);
|
||||
return item;
|
||||
}
|
||||
|
||||
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock
|
||||
{
|
||||
OWSAssert(text.length > 0);
|
||||
|
||||
@ -124,21 +124,64 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
__weak ShowGroupMembersViewController *weakSelf = self;
|
||||
ContactsViewHelper *helper = self.contactsViewHelper;
|
||||
|
||||
OWSTableSection *membersSection = [OWSTableSection new];
|
||||
|
||||
// Group Members
|
||||
|
||||
OWSTableSection *section = [OWSTableSection new];
|
||||
// If there are "no longer verified" members of the group,
|
||||
// highlight them in a special section.
|
||||
NSArray<NSString *> *noLongerVerifiedRecipientIds = [self noLongerVerifiedRecipientIds];
|
||||
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.");
|
||||
[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.")
|
||||
customRowHeight:ContactTableViewCell.rowHeight
|
||||
actionBlock:^{
|
||||
[weakSelf offerResetAllNoLongerVerified];
|
||||
}]];
|
||||
[self addMembers:noLongerVerifiedRecipientIds toSection:noLongerVerifiedSection useVerifyAction:YES];
|
||||
[contents addSection:noLongerVerifiedSection];
|
||||
}
|
||||
|
||||
NSMutableSet *memberRecipientIds = [self.memberRecipientIds mutableCopy];
|
||||
[memberRecipientIds removeObject:[helper localNumber]];
|
||||
for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
|
||||
[self addMembers:memberRecipientIds.allObjects toSection:membersSection useVerifyAction:NO];
|
||||
[contents addSection:membersSection];
|
||||
|
||||
self.contents = contents;
|
||||
}
|
||||
|
||||
- (void)addMembers:(NSArray<NSString *> *)recipientIds
|
||||
toSection:(OWSTableSection *)section
|
||||
useVerifyAction:(BOOL)useVerifyAction
|
||||
{
|
||||
OWSAssert(recipientIds);
|
||||
OWSAssert(section);
|
||||
|
||||
__weak ShowGroupMembersViewController *weakSelf = self;
|
||||
ContactsViewHelper *helper = self.contactsViewHelper;
|
||||
for (NSString *recipientId in [recipientIds sortedArrayUsingSelector:@selector(compare:)]) {
|
||||
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
|
||||
ShowGroupMembersViewController *strongSelf = weakSelf;
|
||||
OWSAssert(strongSelf);
|
||||
|
||||
ContactTableViewCell *cell = [ContactTableViewCell new];
|
||||
SignalAccount *signalAccount = [helper signalAccountForRecipientId:recipientId];
|
||||
OWSVerificationState verificationState =
|
||||
[[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId];
|
||||
BOOL isVerified = verificationState == OWSVerificationStateVerified;
|
||||
BOOL isNoLongerVerified = verificationState == OWSVerificationStateNoLongerVerified;
|
||||
BOOL isBlocked = [helper isRecipientIdBlocked:recipientId];
|
||||
if (isBlocked) {
|
||||
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.");
|
||||
}
|
||||
@ -149,8 +192,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager];
|
||||
}
|
||||
|
||||
BOOL isVerified = [[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]
|
||||
== OWSVerificationStateVerified;
|
||||
if (isVerified) {
|
||||
[cell addVerifiedSubtitle];
|
||||
}
|
||||
@ -159,12 +200,77 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
}
|
||||
customRowHeight:[ContactTableViewCell rowHeight]
|
||||
actionBlock:^{
|
||||
[weakSelf didSelectRecipientId:recipientId];
|
||||
if (useVerifyAction) {
|
||||
[weakSelf showSafetyNumberView:recipientId];
|
||||
} else {
|
||||
[weakSelf didSelectRecipientId:recipientId];
|
||||
}
|
||||
}]];
|
||||
}
|
||||
[contents addSection:section];
|
||||
}
|
||||
|
||||
self.contents = contents;
|
||||
- (void)offerResetAllNoLongerVerified
|
||||
{
|
||||
OWSAssert([NSThread isMainThread]);
|
||||
|
||||
UIAlertController *actionSheetController = [UIAlertController
|
||||
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;
|
||||
UIAlertAction *verifyAction = [UIAlertAction
|
||||
actionWithTitle:NSLocalizedString(@"OK", nil)
|
||||
style:UIAlertActionStyleDestructive
|
||||
handler:^(UIAlertAction *_Nonnull action) {
|
||||
[weakSelf resetAllNoLongerVerified];
|
||||
}];
|
||||
[actionSheetController addAction:verifyAction];
|
||||
|
||||
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"TXT_CANCEL_TITLE", @"")
|
||||
style:UIAlertActionStyleCancel
|
||||
handler:nil];
|
||||
[actionSheetController addAction:cancelAction];
|
||||
|
||||
[self presentViewController:actionSheetController animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void)resetAllNoLongerVerified
|
||||
{
|
||||
OWSAssert([NSThread isMainThread]);
|
||||
|
||||
OWSIdentityManager *identityManger = [OWSIdentityManager sharedManager];
|
||||
NSArray<NSString *> *recipientIds = [self noLongerVerifiedRecipientIds];
|
||||
for (NSString *recipientId in recipientIds) {
|
||||
OWSVerificationState verificationState = [identityManger verificationStateForRecipientId:recipientId];
|
||||
if (verificationState == OWSVerificationStateNoLongerVerified) {
|
||||
NSData *identityKey = [identityManger identityKeyForRecipientId:recipientId];
|
||||
if (identityKey.length < 1) {
|
||||
OWSFail(@"Missing identity key for: %@", recipientId);
|
||||
continue;
|
||||
}
|
||||
[identityManger setVerificationState:OWSVerificationStateDefault
|
||||
identityKey:identityKey
|
||||
recipientId:recipientId
|
||||
isUserInitiatedChange:YES];
|
||||
}
|
||||
}
|
||||
|
||||
[self updateTableContents];
|
||||
}
|
||||
|
||||
// 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) {
|
||||
if ([[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]
|
||||
== OWSVerificationStateNoLongerVerified) {
|
||||
[result addObject:recipientId];
|
||||
}
|
||||
}
|
||||
return [result copy];
|
||||
}
|
||||
|
||||
- (void)didSelectRecipientId:(NSString *)recipientId
|
||||
@ -280,7 +386,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@"safety number of another user.")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction *_Nonnull action) {
|
||||
[self verifySafetyNumber:recipientId];
|
||||
[self showSafetyNumberView:recipientId];
|
||||
}]];
|
||||
}
|
||||
|
||||
@ -313,7 +419,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
[Environment callUserWithIdentifier:recipientId];
|
||||
}
|
||||
|
||||
- (void)verifySafetyNumber:(NSString *)recipientId
|
||||
- (void)showSafetyNumberView:(NSString *)recipientId
|
||||
{
|
||||
OWSAssert(recipientId.length > 0);
|
||||
|
||||
|
||||
@ -268,6 +268,9 @@
|
||||
/* An indicator that a contact has been blocked. */
|
||||
"CONTACT_CELL_IS_BLOCKED" = "Blocked";
|
||||
|
||||
/* An indicator that a contact is no longer verified. */
|
||||
"CONTACT_CELL_IS_NO_LONGER_VERIFIED" = "Not Verified";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"CONTACT_DETAIL_COMM_TYPE_INSECURE" = "Unregistered Number";
|
||||
|
||||
@ -577,6 +580,18 @@
|
||||
/* Button label for the 'call group member' button */
|
||||
"GROUP_MEMBERS_CALL" = "Call";
|
||||
|
||||
/* Label for the button that clears all verification errors in the 'group members' view. */
|
||||
"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED" = "Clear Verification For All";
|
||||
|
||||
/* Label for the 'reset all no-longer-verified group members' confirmation alert. */
|
||||
"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED_ALERT_MESSAGE" = "This will clear the verification of all group members whose safety numbers have changed since they were last verified.";
|
||||
|
||||
/* Title for the 'members' section of the 'group members' view. */
|
||||
"GROUP_MEMBERS_SECTION_TITLE_MEMBERS" = "Members";
|
||||
|
||||
/* Title for the 'no longer verified' section of the 'group members' view. */
|
||||
"GROUP_MEMBERS_SECTION_TITLE_NO_LONGER_VERIFIED" = "No Longer Marked as Verified";
|
||||
|
||||
/* Button label for the 'send message to group member' button */
|
||||
"GROUP_MEMBERS_SEND_MESSAGE" = "Send Message";
|
||||
|
||||
@ -974,7 +989,7 @@
|
||||
"PRIVACY_TAP_TO_SCAN" = "Tap to Scan";
|
||||
|
||||
/* Button that lets user mark another user's identity as unverified. */
|
||||
"PRIVACY_UNVERIFY_BUTTON" = "Mark as not Verified";
|
||||
"PRIVACY_UNVERIFY_BUTTON" = "Clear Verification";
|
||||
|
||||
/* Alert body when verifying with {{contact name}} */
|
||||
"PRIVACY_VERIFICATION_FAILED_I_HAVE_WRONG_KEY_FOR_THEM" = "This doesn't look like your safety number with %@. Are you verifying the correct contact?";
|
||||
@ -1441,6 +1456,9 @@
|
||||
/* Label for button or row which allows users to verify the safety number of another user. */
|
||||
"VERIFY_PRIVACY" = "Show Safety Number";
|
||||
|
||||
/* Label for button or row which allows users to verify the safety numbers of multiple users. */
|
||||
"VERIFY_PRIVACY_MULTIPLE" = "Review Safety Numbers";
|
||||
|
||||
/* Indicates how to cancel a voice message. */
|
||||
"VOICE_MESSAGE_CANCEL_INSTRUCTIONS" = "Slide to Cancel";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user