From 3ce3f9faaaf450685e2cdc323ea9c2cfc0bda4bb Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 22 Mar 2019 16:13:40 -0400 Subject: [PATCH] Add accessibilityIdentifiers to conversation settings view. --- .../FingerprintViewController.m | 17 +++++++++---- .../OWSAddToContactViewController.m | 5 +++- .../ShowGroupMembersViewController.m | 25 +++++++++++++++---- .../UpdateGroupViewController.m | 13 +++++++++- Signal/src/util/MainAppContext.m | 1 + SignalMessaging/Views/ContactsViewHelper.m | 1 + SignalMessaging/profiles/OWSProfileManager.m | 1 + 7 files changed, 51 insertions(+), 12 deletions(-) diff --git a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m index c2a9f5f1a..aa4638690 100644 --- a/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/FingerprintViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "FingerprintViewController.h" @@ -169,10 +169,13 @@ typedef void (^CustomLayoutBlock)(void); self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self - action:@selector(closeButton)]; - self.shareButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction - target:self - action:@selector(didTapShareButton)]; + action:@selector(closeButton) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"stop")]; + self.shareButton = + [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction + target:self + action:@selector(didTapShareButton) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"share")]; self.navigationItem.rightBarButtonItem = self.shareButton; [self createViews]; @@ -190,6 +193,7 @@ typedef void (^CustomLayoutBlock)(void); [self.view addSubview:verifyUnverifyButton]; [verifyUnverifyButton autoPinWidthToSuperview]; [verifyUnverifyButton autoPinToBottomLayoutGuideOfViewController:self withInset:0]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, verifyUnverifyButton); UIView *verifyUnverifyPillbox = [UIView new]; verifyUnverifyPillbox.backgroundColor = [UIColor ows_materialBlueColor]; @@ -217,6 +221,7 @@ typedef void (^CustomLayoutBlock)(void); [self.view addSubview:learnMoreButton]; [learnMoreButton autoPinWidthToSuperview]; [learnMoreButton autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:verifyUnverifyButton withOffset:0]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, learnMoreButton); UILabel *learnMoreLabel = [UILabel new]; learnMoreLabel.attributedText = [[NSAttributedString alloc] @@ -265,6 +270,7 @@ typedef void (^CustomLayoutBlock)(void); toEdge:ALEdgeTop ofView:instructionsLabel withOffset:-ScaleFromIPhone5To7Plus(8.f, 15.f)]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, fingerprintLabel); // Fingerprint Image CustomLayoutView *fingerprintView = [CustomLayoutView new]; @@ -278,6 +284,7 @@ typedef void (^CustomLayoutBlock)(void); addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(fingerprintViewTapped:)]]; fingerprintView.userInteractionEnabled = YES; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, fingerprintView); OWSBezierPathView *fingerprintCircle = [OWSBezierPathView new]; [fingerprintCircle setConfigureShapeLayerBlock:^(CAShapeLayer *layer, CGRect bounds) { diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSAddToContactViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSAddToContactViewController.m index d80dcaab1..842149951 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSAddToContactViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSAddToContactViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSAddToContactViewController.h" @@ -166,7 +166,10 @@ NS_ASSUME_NONNULL_BEGIN continue; } + // TODO: Confirm with nancy if this will work. + NSString *cellName = [NSString stringWithFormat:@"contact.%@", NSUUID.UUID.UUIDString]; [section addItem:[OWSTableItem disclosureItemWithText:displayName + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, cellName) actionBlock:^{ [weakSelf presentContactViewControllerForContact:contact]; }]]; diff --git a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m index a3f87b950..4de3f3d24 100644 --- a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m @@ -136,6 +136,7 @@ NS_ASSUME_NONNULL_BEGIN addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED", @"Label for the button that clears all verification " @"errors in the 'group members' view.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"no_longer_verified") customRowHeight:UITableViewAutomaticDimension actionBlock:^{ [weakSelf offerResetAllNoLongerVerified]; @@ -196,6 +197,10 @@ NS_ASSUME_NONNULL_BEGIN [cell setAttributedSubtitle:nil]; } + NSString *cellName = [NSString stringWithFormat:@"user.%@", recipientId]; + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(ShowGroupMembersViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -221,6 +226,7 @@ NS_ASSUME_NONNULL_BEGIN __weak ShowGroupMembersViewController *weakSelf = self; UIAlertAction *verifyAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"ok") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull action) { [weakSelf resetAllNoLongerVerified]; @@ -283,11 +289,13 @@ NS_ASSUME_NONNULL_BEGIN ? 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"); - [actionSheet addAction:[UIAlertAction actionWithTitle:contactInfoTitle - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *_Nonnull action) { - [self showContactInfoViewForRecipientId:recipientId]; - }]]; + [actionSheet + addAction:[UIAlertAction actionWithTitle:contactInfoTitle + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"show_contact_info") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *_Nonnull action) { + [self showContactInfoViewForRecipientId:recipientId]; + }]]; } BOOL isBlocked; @@ -297,6 +305,7 @@ NS_ASSUME_NONNULL_BEGIN [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"unblock") style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) { [BlockListUIUtils @@ -312,6 +321,7 @@ NS_ASSUME_NONNULL_BEGIN [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"block") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull action) { [BlockListUIUtils @@ -330,6 +340,7 @@ NS_ASSUME_NONNULL_BEGIN [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"unblock") style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) { [BlockListUIUtils @@ -345,6 +356,7 @@ NS_ASSUME_NONNULL_BEGIN [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"block") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull action) { [BlockListUIUtils @@ -363,12 +375,14 @@ NS_ASSUME_NONNULL_BEGIN [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_SEND_MESSAGE", @"Button label for the 'send message to group member' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_message") style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) { [self showConversationViewForRecipientId:recipientId]; }]]; [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"GROUP_MEMBERS_CALL", @"Button label for the 'call group member' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"call") style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) { [self callMember:recipientId]; @@ -377,6 +391,7 @@ NS_ASSUME_NONNULL_BEGIN addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"VERIFY_PRIVACY", @"Label for button or row which allows users to verify the " @"safety number of another user.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"safety_numbers") style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) { [self showSafetyNumberView:recipientId]; diff --git a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m index 40e80dbd7..f2624d178 100644 --- a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m @@ -143,7 +143,8 @@ NS_ASSUME_NONNULL_BEGIN @"The title for the 'update group' button.") style:UIBarButtonItemStylePlain target:self - action:@selector(updateGroupPressed)] + action:@selector(updateGroupPressed) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"update")] : nil); } @@ -206,10 +207,12 @@ NS_ASSUME_NONNULL_BEGIN [groupNameTextField autoVCenterInSuperview]; [groupNameTextField autoPinTrailingToSuperviewMargin]; [groupNameTextField autoPinLeadingToTrailingEdgeOfView:avatarView offset:16.f]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, groupNameTextField); [avatarView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTouched:)]]; avatarView.userInteractionEnabled = YES; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, avatarView); return firstSectionHeader; } @@ -285,6 +288,12 @@ NS_ASSUME_NONNULL_BEGIN } [cell configureWithRecipientId:recipientId]; + + // TODO: Confirm with nancy if this will work. + NSString *cellName = [NSString stringWithFormat:@"member.%@", recipientId]; + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(UpdateGroupViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -424,6 +433,7 @@ NS_ASSUME_NONNULL_BEGIN preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_SAVE", @"The label for the 'save' button in action sheets.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"save") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { OWSAssertDebug(self.conversationSettingsViewDelegate); @@ -435,6 +445,7 @@ NS_ASSUME_NONNULL_BEGIN }]]; [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DONT_SAVE", @"The label for the 'don't save' button in action sheets.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dont_save") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { [self.navigationController popViewControllerAnimated:YES]; diff --git a/Signal/src/util/MainAppContext.m b/Signal/src/util/MainAppContext.m index 8631e9291..c808a9160 100644 --- a/Signal/src/util/MainAppContext.m +++ b/Signal/src/util/MainAppContext.m @@ -230,6 +230,7 @@ NSString *const ReportedApplicationStateDidChangeNotification = @"ReportedApplic - (nullable UIAlertAction *)openSystemSettingsAction { return [UIAlertAction actionWithTitle:CommonStrings.openSettingsButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"system_settings") style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) { [UIApplication.sharedApplication openSystemSettings]; diff --git a/SignalMessaging/Views/ContactsViewHelper.m b/SignalMessaging/Views/ContactsViewHelper.m index e8d958d61..7d5950c65 100644 --- a/SignalMessaging/Views/ContactsViewHelper.m +++ b/SignalMessaging/Views/ContactsViewHelper.m @@ -334,6 +334,7 @@ NS_ASSUME_NONNULL_BEGIN [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"AB_PERMISSION_MISSING_ACTION_NOT_NOW", @"Button text to dismiss missing contacts permission alert") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"not_now") style:UIAlertActionStyleCancel handler:nil]]; diff --git a/SignalMessaging/profiles/OWSProfileManager.m b/SignalMessaging/profiles/OWSProfileManager.m index 0219e8ac9..7eb698855 100644 --- a/SignalMessaging/profiles/OWSProfileManager.m +++ b/SignalMessaging/profiles/OWSProfileManager.m @@ -1473,6 +1473,7 @@ typedef void (^ProfileManagerFailureBlock)(NSError *error); NSString *shareTitle = NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE", @"Button to confirm that user wants to share their profile with a user or group."); [alert addAction:[UIAlertAction actionWithTitle:shareTitle + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"share_profile") style:UIAlertActionStyleDefault handler:^(UIAlertAction *_Nonnull action) { [self userAddedThreadToProfileWhitelist:thread];