diff --git a/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m b/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m index 2b2bdf672..4a592b66e 100644 --- a/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m @@ -58,7 +58,7 @@ [informationSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_LEGAL_TERMS_CELL", @"table cell label") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"terms") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"terms") actionBlock:^{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:kLegalTermsUrlString]]; @@ -69,7 +69,7 @@ OWSTableSection *helpSection = [OWSTableSection new]; helpSection.headerTitle = NSLocalizedString(@"SETTINGS_HELP_HEADER", @""); [helpSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_SUPPORT", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"support") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"support") actionBlock:^{ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://support.signal.org"]]; diff --git a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m index 7369ffa93..8c7654ac2 100644 --- a/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AdvancedSettingsTableViewController.m @@ -89,7 +89,7 @@ NS_ASSUME_NONNULL_BEGIN OWSTableSection *loggingSection = [OWSTableSection new]; loggingSection.headerTitle = NSLocalizedString(@"LOGGING_SECTION", nil); [loggingSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_DEBUGLOG", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"enable_debug_log") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"enable_debug_log") isOnBlock:^{ return [OWSPreferences isLoggingEnabled]; } @@ -103,7 +103,7 @@ NS_ASSUME_NONNULL_BEGIN if ([OWSPreferences isLoggingEnabled]) { [loggingSection addItem:[OWSTableItem actionItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_SUBMIT_DEBUGLOG", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"submit_debug_log") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"submit_debug_log") actionBlock:^{ OWSLogInfo(@"Submitting debug logs"); [DDLog flushLog]; @@ -117,7 +117,7 @@ NS_ASSUME_NONNULL_BEGIN pushNotificationsSection.headerTitle = NSLocalizedString(@"PUSH_REGISTER_TITLE", @"Used in table section header and alert view title contexts"); [pushNotificationsSection addItem:[OWSTableItem actionItemWithText:NSLocalizedString(@"REREGISTER_FOR_PUSH", nil) - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER( + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( self, @"reregister_push_notifications") actionBlock:^{ [weakSelf syncPushTokens]; @@ -187,7 +187,7 @@ NS_ASSUME_NONNULL_BEGIN [censorshipSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_CENSORSHIP_CIRCUMVENTION", @"Label for the 'manual censorship circumvention' switch.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"censorship_circumvention") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"censorship_circumvention") isOnBlock:isCensorshipCircumventionOnBlock isEnabledBlock:isManualCensorshipCircumventionOnEnabledBlock target:weakSelf diff --git a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m index 6350714c4..1dc3e958a 100644 --- a/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AppSettingsViewController.m @@ -165,7 +165,7 @@ [accessoryLabel sizeToFit]; cell.accessoryView = accessoryLabel; cell.accessibilityIdentifier - = SUBVIEW_ACCESSIBILITY_IDENTIFIER(AppSettingsViewController, @"network_status"); + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(AppSettingsViewController, @"network_status"); return cell; } actionBlock:nil]]; @@ -173,29 +173,29 @@ [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_INVITE_TITLE", @"Settings table view cell label") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"invite") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"invite") actionBlock:^{ [weakSelf showInviteFlow]; }]]; [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_TITLE", @"Settings table view cell label") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"privacy") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"privacy") actionBlock:^{ [weakSelf showPrivacy]; }]]; [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_NOTIFICATIONS", nil) - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"notifications") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"notifications") actionBlock:^{ [weakSelf showNotifications]; }]]; [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"LINKED_DEVICES_TITLE", @"Menu item and navbar title for the device manager") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"linked_devices") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"linked_devices") actionBlock:^{ [weakSelf showLinkedDevices]; }]]; [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_ADVANCED_TITLE", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"advanced") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"advanced") actionBlock:^{ [weakSelf showAdvanced]; }]]; @@ -204,20 +204,20 @@ if (showBackup) { [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BACKUP", @"Label for the backup view in app settings.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"backup") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"backup") actionBlock:^{ [weakSelf showBackup]; }]]; } [section addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_ABOUT", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"about") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"about") actionBlock:^{ [weakSelf showAbout]; }]]; #ifdef USE_DEBUG_UI [section addItem:[OWSTableItem disclosureItemWithText:@"Debug UI" - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"debugui") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"debugui") actionBlock:^{ [weakSelf showDebugUI]; }]]; @@ -226,19 +226,20 @@ if (TSAccountManager.sharedInstance.isDeregistered) { [section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_REREGISTER_BUTTON", @"Label for re-registration button.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"reregister") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"reregister") selector:@selector(reregisterUser) color:[UIColor ows_materialBlueColor]]]; [section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_DATA_BUTTON", @"Label for 'delete data' button.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"delete_data") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_data") selector:@selector(deleteUnregisterUserData) color:[UIColor ows_destructiveRedColor]]]; } else { - [section addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"delete_account") - selector:@selector(unregisterUser) - color:[UIColor ows_destructiveRedColor]]]; + [section + addItem:[self destructiveButtonItemWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete_account") + selector:@selector(unregisterUser) + color:[UIColor ows_destructiveRedColor]]]; } [contents addSection:section]; @@ -352,7 +353,7 @@ [disclosureButton setContentCompressionResistancePriority:(UILayoutPriorityDefaultHigh + 1) forAxis:UILayoutConstraintAxisHorizontal]; - cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"profile"); + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"profile"); return cell; } @@ -490,7 +491,7 @@ target:self action:@selector(didPressEnableDarkTheme:)]; } - barButtonItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dark_theme"); + barButtonItem.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dark_theme"); return barButtonItem; } diff --git a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m index 549ca71cf..2a02ff318 100644 --- a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m +++ b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m @@ -74,7 +74,7 @@ NS_ASSUME_NONNULL_BEGIN addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BLOCK_LIST_ADD_BUTTON", @"A label for the 'add phone number' button in the block list table.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"add") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"add") actionBlock:^{ AddToBlockListViewController *vc = [[AddToBlockListViewController alloc] init]; [weakSelf.navigationController pushViewController:vc animated:YES]; @@ -96,7 +96,7 @@ NS_ASSUME_NONNULL_BEGIN itemWithCustomCellBlock:^{ ContactTableViewCell *cell = [ContactTableViewCell new]; [cell configureWithRecipientId:phoneNumber]; - cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER( + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME( BlockListViewController, @"user"); return cell; } diff --git a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m index 02b099a94..280c7d48a 100644 --- a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m @@ -41,7 +41,7 @@ cell.accessoryType = UITableViewCellAccessoryCheckmark; } cell.accessibilityIdentifier - = SUBVIEW_ACCESSIBILITY_IDENTIFIER(NotificationSettingsOptionsViewController, + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(NotificationSettingsOptionsViewController, NSStringForNotificationType(notificationType)); return cell; } diff --git a/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m index 5ac5722c7..42c6dc393 100644 --- a/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m @@ -48,7 +48,7 @@ NSLocalizedString(@"SETTINGS_ITEM_NOTIFICATION_SOUND", @"Label for settings view that allows user to change the notification sound.") detailText:[OWSSounds displayNameForSound:[OWSSounds globalNotificationSound]] - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"message_sound") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"message_sound") actionBlock:^{ OWSSoundSettingsViewController *vc = [OWSSoundSettingsViewController new]; [weakSelf.navigationController pushViewController:vc animated:YES]; @@ -58,7 +58,7 @@ @"Table cell switch label. When disabled, Signal will not play notification sounds while the app is in the " @"foreground."); [soundsSection addItem:[OWSTableItem switchItemWithText:inAppSoundsLabelText - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"in_app_sounds") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"in_app_sounds") isOnBlock:^{ return [prefs soundInForeground]; } @@ -75,7 +75,7 @@ addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NOTIFICATIONS_SHOW", nil) detailText:[prefs nameForNotificationPreviewType:[prefs notificationPreviewType]] - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"options") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"options") actionBlock:^{ NotificationSettingsOptionsViewController *vc = [NotificationSettingsOptionsViewController new]; diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m index 0e5adbfb7..d3285b495 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m @@ -329,7 +329,7 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; cell.detailTextLabel.text = NSLocalizedString(@"LINK_NEW_DEVICE_SUBTITLE", @"Subheading for 'Link New Device' navigation"); cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(OWSLinkedDevicesTableViewController, @"add"); + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(OWSLinkedDevicesTableViewController, @"add"); return cell; } else if (indexPath.section == OWSLinkedDevicesTableViewControllerSectionExistingDevices) { OWSDeviceTableViewCell *cell = diff --git a/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m index b327efd96..49c5649b2 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m @@ -6,6 +6,7 @@ #import #import #import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -46,17 +47,19 @@ NS_ASSUME_NONNULL_BEGIN - (void)updateNavigationItems { - UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel - target:self - action:@selector(cancelWasPressed:)]; - cancelItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"cancel"); + UIBarButtonItem *cancelItem = + [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel + target:self + action:@selector(cancelWasPressed:) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"cancel")]; self.navigationItem.leftBarButtonItem = cancelItem; if (self.isDirty) { - UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave - target:self - action:@selector(saveWasPressed:)]; - saveItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"save"); + UIBarButtonItem *saveItem = + [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave + target:self + action:@selector(saveWasPressed:) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"save")]; self.navigationItem.rightBarButtonItem = saveItem; } else { self.navigationItem.rightBarButtonItem = nil; @@ -94,14 +97,14 @@ NS_ASSUME_NONNULL_BEGIN if (sound == self.currentSound) { item = [OWSTableItem checkmarkItemWithText:soundLabelText - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, [OWSSounds displayNameForSound:sound]) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, [OWSSounds displayNameForSound:sound]) actionBlock:^{ [weakSelf soundWasSelected:sound]; }]; } else { item = [OWSTableItem actionItemWithText:soundLabelText - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, [OWSSounds displayNameForSound:sound]) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, [OWSSounds displayNameForSound:sound]) actionBlock:^{ [weakSelf soundWasSelected:sound]; }]; diff --git a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m index 061796827..0004f12f3 100644 --- a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m @@ -425,7 +425,7 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s [UIAlertAction actionWithTitle: NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION_BUTTON", @"Confirmation text for button which deletes all message, calling, attachments, etc.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"delete") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"delete") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull action) { [self deleteThreadsAndMessages]; @@ -561,11 +561,11 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s UIAlertAction *action = [UIAlertAction actionWithTitle:screenLockTimeoutString + accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.timeout.%@", timeoutValue] style:UIAlertActionStyleDefault handler:^(UIAlertAction *ignore) { [OWSScreenLock.sharedManager setScreenLockTimeout:screenLockTimeout]; }]; - action.accessibilityIdentifier = [NSString stringWithFormat:@"settings.privacy.timeout.%@", timeoutValue]; [alert addAction:action]; } [alert addAction:[OWSAlerts cancelAction]]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index b351b4d54..fd34c1cd4 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -136,6 +136,7 @@ const CGFloat kMaxTextViewHeight = 98; self.inputTextView.backgroundColor = Theme.toolbarBackgroundColor; [self.inputTextView setContentHuggingLow]; [self.inputTextView setCompressionResistanceLow]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _inputTextView); _textViewHeightConstraint = [self.inputTextView autoSetDimension:ALDimensionHeight toSize:kMinTextViewHeight]; @@ -152,6 +153,7 @@ const CGFloat kMaxTextViewHeight = 98; forState:UIControlStateNormal]; self.attachmentButton.tintColor = Theme.navbarIconColor; [self.attachmentButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _attachmentButton); _sendButton = [UIButton buttonWithType:UIButtonTypeCustom]; [self.sendButton setTitle:MessageStrings.sendButton forState:UIControlStateNormal]; @@ -161,6 +163,7 @@ const CGFloat kMaxTextViewHeight = 98; self.sendButton.contentEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 4); [self.sendButton autoSetDimension:ALDimensionHeight toSize:kMinTextViewHeight]; [self.sendButton addTarget:self action:@selector(sendButtonPressed) forControlEvents:UIControlEventTouchUpInside]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _sendButton); UIImage *voiceMemoIcon = [UIImage imageNamed:@"voice-memo-button"]; OWSAssertDebug(voiceMemoIcon); @@ -169,6 +172,7 @@ const CGFloat kMaxTextViewHeight = 98; forState:UIControlStateNormal]; self.voiceMemoButton.imageView.tintColor = Theme.navbarIconColor; [self.voiceMemoButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _voiceMemoButton); // We want to be permissive about the voice message gesture, so we hang // the long press GR on the button's wrapper, not the button itself. @@ -184,11 +188,13 @@ const CGFloat kMaxTextViewHeight = 98; self.quotedReplyWrapper.hidden = YES; [self.quotedReplyWrapper setContentHuggingHorizontalLow]; [self.quotedReplyWrapper setCompressionResistanceHorizontalLow]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _quotedReplyWrapper); _linkPreviewWrapper = [UIView containerView]; self.linkPreviewWrapper.hidden = YES; [self.linkPreviewWrapper setContentHuggingHorizontalLow]; [self.linkPreviewWrapper setCompressionResistanceHorizontalLow]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _linkPreviewWrapper); // V Stack UIStackView *vStack = [[UIStackView alloc] @@ -346,6 +352,7 @@ const CGFloat kMaxTextViewHeight = 98; self.quotedReplyWrapper.layoutMargins = UIEdgeInsetsZero; [self.quotedReplyWrapper addSubview:quotedMessagePreview]; [quotedMessagePreview ows_autoPinToSuperviewMargins]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, quotedMessagePreview); self.linkPreviewView.hasAsymmetricalRounding = !self.quotedReply; } @@ -563,6 +570,7 @@ const CGFloat kMaxTextViewHeight = 98; self.voiceMemoUI.backgroundColor = Theme.toolbarBackgroundColor; [self addSubview:self.voiceMemoUI]; self.voiceMemoUI.frame = CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height); + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _voiceMemoUI); self.voiceMemoContentView = [UIView new]; [self.voiceMemoUI addSubview:self.voiceMemoContentView]; @@ -572,6 +580,7 @@ const CGFloat kMaxTextViewHeight = 98; self.recordingLabel.textColor = [UIColor ows_destructiveRedColor]; self.recordingLabel.font = [UIFont ows_mediumFontWithSize:14.f]; [self.voiceMemoContentView addSubview:self.recordingLabel]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _recordingLabel); VoiceMemoLockView *voiceMemoLockView = [VoiceMemoLockView new]; self.voiceMemoLockView = voiceMemoLockView; @@ -773,6 +782,7 @@ const CGFloat kMaxTextViewHeight = 98; [sendVoiceMemoButton autoVCenterInSuperview]; [sendVoiceMemoButton setCompressionResistanceHigh]; [sendVoiceMemoButton setContentHuggingHigh]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, sendVoiceMemoButton); UIButton *cancelButton = [[OWSButton alloc] initWithBlock:^{ [weakSelf.inputToolbarDelegate voiceMemoGestureDidCancel]; @@ -781,6 +791,7 @@ const CGFloat kMaxTextViewHeight = 98; [cancelButton setTitleColor:UIColor.ows_destructiveRedColor forState:UIControlStateNormal]; cancelButton.alpha = 0; cancelButton.titleLabel.textAlignment = NSTextAlignmentCenter; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, cancelButton); [self.voiceMemoContentView addSubview:cancelButton]; OWSAssert(self.recordingLabel != nil); diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index 25d0806d4..98d94289d 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -619,10 +619,12 @@ typedef enum : NSUInteger { [self.collectionView autoPinEdgeToSuperviewSafeArea:ALEdgeTrailing]; [self.collectionView applyScrollViewInsetsFix]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _collectionView); _inputToolbar = [[ConversationInputToolbar alloc] initWithConversationStyle:self.conversationStyle]; self.inputToolbar.inputToolbarDelegate = self; self.inputToolbar.inputTextViewDelegate = self; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _inputToolbar); self.loadMoreHeader = [UILabel new]; self.loadMoreHeader.text = NSLocalizedString(@"CONVERSATION_VIEW_LOADING_MORE_MESSAGES", @@ -634,6 +636,7 @@ typedef enum : NSUInteger { [self.loadMoreHeader autoPinWidthToWidthOfView:self.view]; [self.loadMoreHeader autoPinEdgeToSuperviewEdge:ALEdgeTop]; [self.loadMoreHeader autoSetDimension:ALDimensionHeight toSize:kLoadMoreHeaderHeight]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _loadMoreHeader); [self updateShowLoadMoreHeader]; } @@ -1006,6 +1009,7 @@ typedef enum : NSUInteger { [closeButton autoPinLeadingToTrailingEdgeOfView:label offset:kBannerHSpacing]; [bannerView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:tapSelector]]; + bannerView.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"banner_close"); [self.view addSubview:bannerView]; [bannerView autoPinToTopLayoutGuideOfViewController:self withInset:10]; @@ -1083,11 +1087,13 @@ typedef enum : NSUInteger { }]; [actionSheet addAction:verifyAction]; - UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.dismissButton - style:UIAlertActionStyleCancel - handler:^(UIAlertAction *action) { - [weakSelf resetVerificationStateToDefault]; - }]; + UIAlertAction *dismissAction = + [UIAlertAction actionWithTitle:CommonStrings.dismissButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dismiss") + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *action) { + [weakSelf resetVerificationStateToDefault]; + }]; [actionSheet addAction:dismissAction]; [self dismissKeyBoard]; @@ -1358,6 +1364,7 @@ typedef enum : NSUInteger { ConversationHeaderView *headerView = [[ConversationHeaderView alloc] initWithThread:self.thread contactsManager:self.contactsManager]; self.headerView = headerView; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, headerView); headerView.delegate = self; self.navigationItem.titleView = headerView; @@ -1483,7 +1490,9 @@ typedef enum : NSUInteger { 0, round(image.size.width + imageEdgeInsets.left + imageEdgeInsets.right), round(image.size.height + imageEdgeInsets.top + imageEdgeInsets.bottom)); - [barButtons addObject:[[UIBarButtonItem alloc] initWithCustomView:callButton]]; + [barButtons + addObject:[[UIBarButtonItem alloc] initWithCustomView:callButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"call")]]; } if (self.disappearingMessagesConfiguration.isEnabled) { @@ -1502,7 +1511,9 @@ typedef enum : NSUInteger { timerView.frame = CGRectMake(0, 0, 36, 44); } - [barButtons addObject:[[UIBarButtonItem alloc] initWithCustomView:timerView]]; + [barButtons + addObject:[[UIBarButtonItem alloc] initWithCustomView:timerView + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"timer")]]; } self.navigationItem.rightBarButtonItems = [barButtons copy]; @@ -1804,14 +1815,15 @@ typedef enum : NSUInteger { [actionSheet addAction:deleteMessageAction]; UIAlertAction *resendMessageAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"SEND_AGAIN_BUTTON", @"") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self.editingDatabaseConnection - asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - [self.messageSenderJobQueue addMessage:message transaction:transaction]; + actionWithTitle:NSLocalizedString(@"SEND_AGAIN_BUTTON", @"") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_again") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [self.editingDatabaseConnection + asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + [self.messageSenderJobQueue addMessage:message transaction:transaction]; + }]; }]; - }]; [actionSheet addAction:resendMessageAction]; @@ -1851,20 +1863,21 @@ typedef enum : NSUInteger { [alert addAction:[OWSAlerts cancelAction]]; UIAlertAction *resetSessionAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON", @"") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - if (![self.thread isKindOfClass:[TSContactThread class]]) { - // Corrupt Message errors only appear in contact threads. - OWSLogError(@"Unexpected request to reset session in group thread. Refusing"); - return; - } - TSContactThread *contactThread = (TSContactThread *)self.thread; - [self.editingDatabaseConnection - asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { - [self.sessionResetJobQueue addContactThread:contactThread transaction:transaction]; + actionWithTitle:NSLocalizedString(@"FINGERPRINT_SHRED_KEYMATERIAL_BUTTON", @"") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"reset_session") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + if (![self.thread isKindOfClass:[TSContactThread class]]) { + // Corrupt Message errors only appear in contact threads. + OWSLogError(@"Unexpected request to reset session in group thread. Refusing"); + return; + } + TSContactThread *contactThread = (TSContactThread *)self.thread; + [self.editingDatabaseConnection + asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { + [self.sessionResetJobQueue addContactThread:contactThread transaction:transaction]; + }]; }]; - }]; [alert addAction:resetSessionAction]; [self dismissKeyBoard]; @@ -1885,6 +1898,7 @@ typedef enum : NSUInteger { UIAlertAction *showSafteyNumberAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"SHOW_SAFETY_NUMBER_ACTION", @"Action sheet item") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"show_safety_number") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { OWSLogInfo(@"Remote Key Changed actions: Show fingerprint display"); @@ -1894,13 +1908,14 @@ typedef enum : NSUInteger { UIAlertAction *acceptSafetyNumberAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"ACCEPT_NEW_IDENTITY_ACTION", @"Action sheet item") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"accept_safety_number") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { OWSLogInfo(@"Remote Key Changed actions: Accepted new identity key"); - // DEPRECATED: we're no longer creating these incoming SN error's per message, - // but there will be some legacy ones in the wild, behind which await - // as-of-yet-undecrypted messages + // DEPRECATED: we're no longer creating these incoming SN error's per message, + // but there will be some legacy ones in the wild, behind which await + // as-of-yet-undecrypted messages #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" if ([errorMessage isKindOfClass:[TSInvalidIdentityKeyReceivingErrorMessage class]]) { @@ -1936,6 +1951,7 @@ typedef enum : NSUInteger { __weak ConversationViewController *weakSelf = self; UIAlertAction *callAction = [UIAlertAction actionWithTitle:[CallStrings callBackAlertCallButton] + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"call_back") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [weakSelf startAudioCall]; @@ -2207,20 +2223,22 @@ typedef enum : NSUInteger { [actionSheet addAction:[OWSAlerts cancelAction]]; - UIAlertAction *blockAction = [UIAlertAction - actionWithTitle:NSLocalizedString( - @"BLOCK_OFFER_ACTIONSHEET_BLOCK_ACTION", @"Action sheet that will block an unknown user.") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *action) { - OWSLogInfo(@"Blocking an unknown user."); - [self.blockingManager addBlockedPhoneNumber:interaction.recipientId]; - // Delete the offers. - [self.editingDatabaseConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { - contactThread.hasDismissedOffers = YES; - [contactThread saveWithTransaction:transaction]; - [interaction removeWithTransaction:transaction]; - }]; - }]; + UIAlertAction *blockAction = + [UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_OFFER_ACTIONSHEET_BLOCK_ACTION", + @"Action sheet that will block an unknown user.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"block_user") + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction *action) { + OWSLogInfo(@"Blocking an unknown user."); + [self.blockingManager addBlockedPhoneNumber:interaction.recipientId]; + // Delete the offers. + [self.editingDatabaseConnection + readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { + contactThread.hasDismissedOffers = YES; + [contactThread saveWithTransaction:transaction]; + [interaction removeWithTransaction:transaction]; + }]; + }]; [actionSheet addAction:blockAction]; [self dismissKeyBoard]; @@ -2566,6 +2584,7 @@ typedef enum : NSUInteger { [self.view addSubview:self.scrollDownButton]; [self.scrollDownButton autoSetDimension:ALDimensionWidth toSize:ConversationScrollButton.buttonSize]; [self.scrollDownButton autoSetDimension:ALDimensionHeight toSize:ConversationScrollButton.buttonSize]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _scrollDownButton); // The "scroll down" button layout tracks the content inset of the collection view, // so pin to the edge of the collection view. @@ -2584,6 +2603,7 @@ typedef enum : NSUInteger { [self.scrollUpButton autoPinToTopLayoutGuideOfViewController:self withInset:0]; [self.scrollUpButton autoPinEdgeToSuperviewSafeArea:ALEdgeTrailing]; #endif + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _scrollUpButton); [self updateScrollDownButtonLayout]; } @@ -3409,34 +3429,40 @@ typedef enum : NSUInteger { [actionSheet addAction:[OWSAlerts cancelAction]]; - UIAlertAction *takeMediaAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"MEDIA_FROM_CAMERA_BUTTON", @"media picker option to take photo or video") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self takePictureOrVideo]; - }]; + UIAlertAction *takeMediaAction = + [UIAlertAction actionWithTitle:NSLocalizedString( + @"MEDIA_FROM_CAMERA_BUTTON", @"media picker option to take photo or video") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_camera") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [self takePictureOrVideo]; + }]; UIImage *takeMediaImage = [UIImage imageNamed:@"actionsheet_camera_black"]; OWSAssertDebug(takeMediaImage); [takeMediaAction setValue:takeMediaImage forKey:@"image"]; [actionSheet addAction:takeMediaAction]; - UIAlertAction *chooseMediaAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"MEDIA_FROM_LIBRARY_BUTTON", @"media picker option to choose from library") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self chooseFromLibraryAsMedia]; - }]; + UIAlertAction *chooseMediaAction = + [UIAlertAction actionWithTitle:NSLocalizedString( + @"MEDIA_FROM_LIBRARY_BUTTON", @"media picker option to choose from library") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_choose_media") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [self chooseFromLibraryAsMedia]; + }]; UIImage *chooseMediaImage = [UIImage imageNamed:@"actionsheet_camera_roll_black"]; OWSAssertDebug(chooseMediaImage); [chooseMediaAction setValue:chooseMediaImage forKey:@"image"]; [actionSheet addAction:chooseMediaAction]; - UIAlertAction *gifAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"SELECT_GIF_BUTTON", @"Label for 'select GIF to attach' action sheet button") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self showGifPicker]; - }]; + UIAlertAction *gifAction = + [UIAlertAction actionWithTitle:NSLocalizedString(@"SELECT_GIF_BUTTON", + @"Label for 'select GIF to attach' action sheet button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_gif") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [self showGifPicker]; + }]; UIImage *gifImage = [UIImage imageNamed:@"actionsheet_gif_black"]; OWSAssertDebug(gifImage); [gifAction setValue:gifImage forKey:@"image"]; @@ -3445,6 +3471,7 @@ typedef enum : NSUInteger { UIAlertAction *chooseDocumentAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"MEDIA_FROM_DOCUMENT_PICKER_BUTTON", @"action sheet button title when choosing attachment type") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_document") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self showAttachmentDocumentPickerMenu]; @@ -3458,6 +3485,7 @@ typedef enum : NSUInteger { UIAlertAction *chooseContactAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"ATTACHMENT_MENU_CONTACT_BUTTON", @"attachment menu option to send contact") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_contact") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self chooseContactForSending]; @@ -4543,6 +4571,10 @@ typedef enum : NSUInteger { [cell loadForDisplay]; + // TODO: Confirm with nancy if this will work. + NSString *cellName = [NSString stringWithFormat:@"interaction.%@", NSUUID.UUID.UUIDString]; + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, cellName); + return cell; } diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index f3aa5301f..3806974b9 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -287,6 +287,8 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { self.reminderViewCell.selectionStyle = UITableViewCellSelectionStyleNone; [self.reminderViewCell.contentView addSubview:reminderStackView]; [reminderStackView autoPinEdgesToSuperviewEdges]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _reminderViewCell); + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, reminderStackView); __weak HomeViewController *weakSelf = self; ReminderView *deregisteredView = @@ -301,18 +303,21 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { }]; _deregisteredView = deregisteredView; [reminderStackView addArrangedSubview:deregisteredView]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, deregisteredView); ReminderView *outageView = [ReminderView nagWithText:NSLocalizedString(@"OUTAGE_WARNING", @"Label warning the user that the Signal service may be down.") tapAction:nil]; _outageView = outageView; [reminderStackView addArrangedSubview:outageView]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, outageView); ReminderView *archiveReminderView = [ReminderView explanationWithText:NSLocalizedString(@"INBOX_VIEW_ARCHIVE_MODE_REMINDER", @"Label reminding the user that they are in archive mode.")]; _archiveReminderView = archiveReminderView; [reminderStackView addArrangedSubview:archiveReminderView]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, archiveReminderView); ReminderView *missingContactsPermissionView = [ReminderView nagWithText:NSLocalizedString(@"INBOX_VIEW_MISSING_CONTACTS_PERMISSION", @@ -322,6 +327,7 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { }]; _missingContactsPermissionView = missingContactsPermissionView; [reminderStackView addArrangedSubview:missingContactsPermissionView]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, missingContactsPermissionView); self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; self.tableView.delegate = self; @@ -332,6 +338,8 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:kArchivedConversationsReuseIdentifier]; [self.view addSubview:self.tableView]; [self.tableView autoPinEdgesToSuperviewEdges]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _tableView); + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _searchBar); self.tableView.rowHeight = UITableViewAutomaticDimension; self.tableView.estimatedRowHeight = 60; @@ -340,6 +348,7 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { [self.view addSubview:self.emptyInboxView]; [self.emptyInboxView autoPinWidthToSuperviewMargins]; [self.emptyInboxView autoVCenterInSuperview]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _emptyInboxView); [self createFirstConversationCueView]; [self.view addSubview:self.firstConversationCueView]; @@ -353,6 +362,8 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { relation:NSLayoutRelationGreaterThanOrEqual]; [self.firstConversationCueView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _firstConversationCueView); + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _firstConversationLabel); UIRefreshControl *pullToRefreshView = [UIRefreshControl new]; pullToRefreshView.tintColor = [UIColor grayColor]; @@ -360,13 +371,7 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { action:@selector(pullToRefreshPerformed:) forControlEvents:UIControlEventValueChanged]; [self.tableView insertSubview:pullToRefreshView atIndex:0]; - - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _tableView); - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _emptyInboxView); - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _firstConversationCueView); - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _firstConversationLabel); - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _searchBar); - SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _reminderStackView); + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, pullToRefreshView); } - (UIView *)createEmptyInboxView @@ -744,15 +749,18 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { settingsButton = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self - action:@selector(settingsButtonPressed:)]; + action:@selector(settingsButtonPressed:) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"settings")]; } settingsButton.accessibilityLabel = CommonStrings.openSettingsButton; self.navigationItem.leftBarButtonItem = settingsButton; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, settingsButton); self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self - action:@selector(showNewConversationView)]; + action:@selector(showNewConversationView) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"compose")]; } - (void)settingsButtonPressed:(id)sender @@ -1098,6 +1106,10 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { BOOL isBlocked = [self.blocklistCache isThreadBlocked:thread.threadRecord]; [cell configureWithThread:thread isBlocked:isBlocked]; + // TODO: Work with Nancy to confirm that this is accessible via Appium. + NSString *cellName = [NSString stringWithFormat:@"conversation-%@", NSUUID.UUID.UUIDString]; + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, cellName); + return cell; } @@ -1141,6 +1153,8 @@ typedef NS_ENUM(NSInteger, HomeViewControllerSection) { [stackView autoPinEdgeToSuperviewMargin:ALEdgeTop]; [stackView autoPinEdgeToSuperviewMargin:ALEdgeBottom]; + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"archived_conversations"); + return cell; } diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index ee9eb2228..e41d5530e 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -104,14 +104,17 @@ NS_ASSUME_NONNULL_BEGIN self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self - action:@selector(dismissPressed)]; + action:@selector(dismissPressed) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"stop")]; // TODO: We should use separate RTL and LTR flavors of this asset. UIImage *newGroupImage = [UIImage imageNamed:@"btnGroup--white"]; OWSAssertDebug(newGroupImage); - UIBarButtonItem *newGroupButton = [[UIBarButtonItem alloc] initWithImage:newGroupImage - style:UIBarButtonItemStylePlain - target:self - action:@selector(showNewGroupView:)]; + UIBarButtonItem *newGroupButton = + [[UIBarButtonItem alloc] initWithImage:newGroupImage + style:UIBarButtonItemStylePlain + target:self + action:@selector(showNewGroupView:) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"new_group")]; newGroupButton.accessibilityLabel = NSLocalizedString(@"CREATE_NEW_GROUP", @"Accessibility label for the create group new group button"); self.navigationItem.rightBarButtonItem = newGroupButton; @@ -122,6 +125,7 @@ NS_ASSUME_NONNULL_BEGIN searchBar.delegate = self; searchBar.placeholder = NSLocalizedString(@"SEARCH_BYNAMEORNUMBER_PLACEHOLDER_TEXT", @""); [searchBar sizeToFit]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, searchBar); _tableViewController = [OWSTableViewController new]; _tableViewController.delegate = self; @@ -149,6 +153,7 @@ NS_ASSUME_NONNULL_BEGIN [self.noSignalContactsView autoPinWidthToSuperview]; [self.noSignalContactsView autoPinEdgeToSuperviewEdge:ALEdgeTop]; [self.noSignalContactsView autoPinToBottomLayoutGuideOfViewController:self withInset:0]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _noSignalContactsView); UIRefreshControl *pullToRefreshView = [UIRefreshControl new]; pullToRefreshView.tintColor = [UIColor grayColor]; @@ -156,6 +161,7 @@ NS_ASSUME_NONNULL_BEGIN action:@selector(pullToRefreshPerformed:) forControlEvents:UIControlEventValueChanged]; [self.tableViewController.tableView insertSubview:pullToRefreshView atIndex:0]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, pullToRefreshView); [self updateTableContents]; @@ -254,6 +260,7 @@ NS_ASSUME_NONNULL_BEGIN action:@selector(presentInviteFlow) forControlEvents:UIControlEventTouchUpInside]; lastSubview = inviteContactsButton; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, inviteContactsButton); UIButton *searchByPhoneNumberButton = [UIButton buttonWithType:UIButtonTypeCustom]; [searchByPhoneNumberButton setTitle:NSLocalizedString(@"NO_CONTACTS_SEARCH_BY_PHONE_NUMBER", @@ -268,6 +275,7 @@ NS_ASSUME_NONNULL_BEGIN action:@selector(hideBackgroundView) forControlEvents:UIControlEventTouchUpInside]; lastSubview = searchByPhoneNumberButton; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, searchByPhoneNumberButton); [lastSubview autoPinEdgeToSuperviewMargin:ALEdgeBottom]; @@ -320,7 +328,7 @@ NS_ASSUME_NONNULL_BEGIN if (self.contactsManager.isSystemContactsDenied) { OWSTableItem *contactReminderItem = [OWSTableItem itemWithCustomCellBlock:^{ - UITableViewCell *newCell = [OWSTableItem newCell]; + UITableViewCell *cell = [OWSTableItem newCell]; ReminderView *reminderView = [ReminderView nagWithText:NSLocalizedString(@"COMPOSE_SCREEN_MISSING_CONTACTS_PERMISSION", @@ -328,10 +336,13 @@ NS_ASSUME_NONNULL_BEGIN tapAction:^{ [[UIApplication sharedApplication] openSystemSettings]; }]; - [newCell.contentView addSubview:reminderView]; + [cell.contentView addSubview:reminderView]; [reminderView autoPinEdgesToSuperviewEdges]; - return newCell; + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(NewContactThreadViewController, @"missing_contacts"); + + return cell; } customRowHeight:UITableViewAutomaticDimension actionBlock:nil]; @@ -347,6 +358,8 @@ NS_ASSUME_NONNULL_BEGIN [staticSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER", @"A label the cell that lets you add a new member to a group.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + NewContactThreadViewController, @"find_by_phone") customRowHeight:UITableViewAutomaticDimension actionBlock:^{ NewNonContactConversationViewController *viewController = @@ -360,12 +373,14 @@ NS_ASSUME_NONNULL_BEGIN // Invite Contacts [staticSection addItem:[OWSTableItem - disclosureItemWithText:NSLocalizedString(@"INVITE_FRIENDS_CONTACT_TABLE_BUTTON", - @"Label for the cell that presents the 'invite contacts' workflow.") - customRowHeight:UITableViewAutomaticDimension - actionBlock:^{ - [weakSelf presentInviteFlow]; - }]]; + disclosureItemWithText:NSLocalizedString(@"INVITE_FRIENDS_CONTACT_TABLE_BUTTON", + @"Label for the cell that presents the 'invite contacts' workflow.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + NewContactThreadViewController, @"invite_contacts") + customRowHeight:UITableViewAutomaticDimension + actionBlock:^{ + [weakSelf presentInviteFlow]; + }]]; } [contents addSection:staticSection]; @@ -450,6 +465,9 @@ NS_ASSUME_NONNULL_BEGIN // hide separator for loading cell. The loading cell doesn't really feel like a cell loadingCell.backgroundView = [UIView new]; + loadingCell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(NewContactThreadViewController, @"loading"); + OWSTableItem *loadingItem = [OWSTableItem itemWithCustomCell:loadingCell customRowHeight:40 actionBlock:nil]; [contactsSection addItem:loadingItem]; @@ -495,6 +513,11 @@ NS_ASSUME_NONNULL_BEGIN [cell configureWithRecipientId:signalAccount.recipientId]; + NSString *cellName = [NSString + stringWithFormat:@"signal_contact.%@", signalAccount.recipientId]; + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME( + NewContactThreadViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -541,6 +564,11 @@ NS_ASSUME_NONNULL_BEGIN @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } [cell configureWithRecipientId:phoneNumber]; + + NSString *cellName = [NSString stringWithFormat:@"non_signal_contact.%@", phoneNumber]; + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(NewContactThreadViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -552,11 +580,13 @@ NS_ASSUME_NONNULL_BEGIN @"Text for button to send a Signal invite via SMS. %@ is " @"placeholder for the recipient's phone number."), phoneNumber]; - [phoneNumbersSection addItem:[OWSTableItem disclosureItemWithText:text - customRowHeight:UITableViewAutomaticDimension - actionBlock:^{ - [weakSelf sendTextToPhoneNumber:phoneNumber]; - }]]; + [phoneNumbersSection + addItem:[OWSTableItem disclosureItemWithText:text + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"invite_via_sms") + customRowHeight:UITableViewAutomaticDimension + actionBlock:^{ + [weakSelf sendTextToPhoneNumber:phoneNumber]; + }]]; } } if (searchPhoneNumbers.count > 0) { @@ -590,6 +620,11 @@ NS_ASSUME_NONNULL_BEGIN [cell configureWithRecipientId:signalAccount.recipientId]; + NSString *cellName = + [NSString stringWithFormat:@"signal_contact.%@", signalAccount.recipientId]; + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(NewContactThreadViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -613,6 +648,13 @@ NS_ASSUME_NONNULL_BEGIN itemWithCustomCellBlock:^{ GroupTableViewCell *cell = [GroupTableViewCell new]; [cell configureWithThread:thread]; + + // TODO: We need to verify that UUIDs will work for Nancy. + NSString *cellName = + [NSString stringWithFormat:@"group.%@", NSUUID.UUID.UUIDString]; + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME( + NewContactThreadViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -644,7 +686,9 @@ NS_ASSUME_NONNULL_BEGIN @"Text for button to send a Signal invite via SMS. %@ is " @"placeholder for the recipient's phone number."), displayName]; + NSString *accessibilityIdentifier = [NSString stringWithFormat:@"invite_via_sms.%@", phoneNumber.toE164]; [inviteeSection addItem:[OWSTableItem disclosureItemWithText:text + accessibilityIdentifier:accessibilityIdentifier customRowHeight:UITableViewAutomaticDimension actionBlock:^{ [weakSelf sendTextToPhoneNumber:phoneNumber.toE164]; @@ -738,7 +782,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)sendTextToPhoneNumber:(NSString *)phoneNumber { - OWSInviteFlow *inviteFlow = [[OWSInviteFlow alloc] initWithPresentingViewController:self]; OWSAssertDebug([phoneNumber length] > 0); @@ -753,16 +796,18 @@ NS_ASSUME_NONNULL_BEGIN preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"OK", @"") - style:UIAlertActionStyleDefault - handler:^(UIAlertAction *action) { - [self.searchBar resignFirstResponder]; - if ([MFMessageComposeViewController canSendText]) { - [inviteFlow sendSMSToPhoneNumbers:@[ phoneNumber ]]; - } else { - [OWSAlerts showErrorAlertWithMessage:NSLocalizedString(@"UNSUPPORTED_FEATURE_ERROR", @"")]; - } - }]; + actionWithTitle:NSLocalizedString(@"OK", @"") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"ok") + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + [self.searchBar resignFirstResponder]; + if ([MFMessageComposeViewController canSendText]) { + [inviteFlow sendSMSToPhoneNumbers:@[ phoneNumber ]]; + } else { + [OWSAlerts + showErrorAlertWithMessage:NSLocalizedString(@"UNSUPPORTED_FEATURE_ERROR", @"")]; + } + }]; [alert addAction:[OWSAlerts cancelAction]]; [alert addAction:okAction]; diff --git a/Signal/src/ViewControllers/NewGroupViewController.m b/Signal/src/ViewControllers/NewGroupViewController.m index 90de0b8a5..fbe7b3926 100644 --- a/Signal/src/ViewControllers/NewGroupViewController.m +++ b/Signal/src/ViewControllers/NewGroupViewController.m @@ -106,11 +106,13 @@ NS_ASSUME_NONNULL_BEGIN self.view.backgroundColor = Theme.backgroundColor; - self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] - initWithTitle:NSLocalizedString(@"NEW_GROUP_CREATE_BUTTON", @"The title for the 'create group' button.") - style:UIBarButtonItemStylePlain - target:self - action:@selector(createGroup)]; + self.navigationItem.rightBarButtonItem = + [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"NEW_GROUP_CREATE_BUTTON", + @"The title for the 'create group' button.") + style:UIBarButtonItemStylePlain + target:self + action:@selector(createGroup) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"create")]; self.navigationItem.rightBarButtonItem.imageInsets = UIEdgeInsetsMake(0, -10, 0, 10); self.navigationItem.rightBarButtonItem.accessibilityLabel = NSLocalizedString(@"FINISH_GROUP_CREATION_LABEL", @"Accessibility label for finishing new group"); @@ -158,6 +160,11 @@ NS_ASSUME_NONNULL_BEGIN [avatarView autoSetDimension:ALDimensionHeight toSize:kLargeAvatarSize]; [self updateAvatarView]; + [avatarView + addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTouched:)]]; + avatarView.userInteractionEnabled = YES; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, avatarView); + UITextField *groupNameTextField = [OWSTextField new]; _groupNameTextField = groupNameTextField; groupNameTextField.textColor = Theme.primaryColor; @@ -176,10 +183,7 @@ NS_ASSUME_NONNULL_BEGIN [groupNameTextField autoVCenterInSuperview]; [groupNameTextField autoPinTrailingToSuperviewMargin]; [groupNameTextField autoPinLeadingToTrailingEdgeOfView:avatarView offset:16.f]; - - [avatarView - addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarTouched:)]]; - avatarView.userInteractionEnabled = YES; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, groupNameTextField); return firstSectionHeader; } @@ -245,6 +249,11 @@ NS_ASSUME_NONNULL_BEGIN @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); } [cell configureWithRecipientId:recipientId]; + + NSString *cellName = [NSString stringWithFormat:@"non_signal_contact.%@", recipientId]; + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(NewGroupViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -333,6 +342,12 @@ NS_ASSUME_NONNULL_BEGIN } [cell configureWithRecipientId:signalAccount.recipientId]; + + NSString *cellName = + [NSString stringWithFormat:@"signal_contact.%@", signalAccount.recipientId]; + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(NewGroupViewController, cellName); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -392,15 +407,16 @@ NS_ASSUME_NONNULL_BEGIN { __weak NewGroupViewController *weakSelf = self; return [OWSTableItem - disclosureItemWithText:NSLocalizedString(@"NEW_GROUP_ADD_NON_CONTACT", - @"A label for the cell that lets you add a new non-contact member to a group.") - customRowHeight:UITableViewAutomaticDimension - actionBlock:^{ - AddToGroupViewController *viewController = [AddToGroupViewController new]; - viewController.addToGroupDelegate = weakSelf; - viewController.hideContacts = YES; - [weakSelf.navigationController pushViewController:viewController animated:YES]; - }]; + disclosureItemWithText:NSLocalizedString(@"NEW_GROUP_ADD_NON_CONTACT", + @"A label for the cell that lets you add a new non-contact member to a group.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(NewGroupViewController, @"add_non_contact") + customRowHeight:UITableViewAutomaticDimension + actionBlock:^{ + AddToGroupViewController *viewController = [AddToGroupViewController new]; + viewController.addToGroupDelegate = weakSelf; + viewController.hideContacts = YES; + [weakSelf.navigationController pushViewController:viewController animated:YES]; + }]; } - (void)removeRecipientId:(NSString *)recipientId @@ -570,6 +586,7 @@ NS_ASSUME_NONNULL_BEGIN [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON", @"The label for the 'discard' button in alerts and action sheets.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"discard") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { [self.navigationController popViewControllerAnimated:YES]; diff --git a/Signal/src/ViewControllers/OWS2FASettingsViewController.m b/Signal/src/ViewControllers/OWS2FASettingsViewController.m index 320e638c4..fae3c0e25 100644 --- a/Signal/src/ViewControllers/OWS2FASettingsViewController.m +++ b/Signal/src/ViewControllers/OWS2FASettingsViewController.m @@ -224,19 +224,19 @@ NS_ASSUME_NONNULL_BEGIN addItem:[OWSTableItem disclosureItemWithText: NSLocalizedString(@"ENABLE_2FA_VIEW_DISABLE_2FA", @"Label for the 'enable two-factor auth' item in the settings view") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"enable_2fa") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"enable_2fa") actionBlock:^{ [weakSelf tryToDisable2FA]; }]]; } else { - [section - addItem:[OWSTableItem disclosureItemWithText: - NSLocalizedString(@"ENABLE_2FA_VIEW_ENABLE_2FA", - @"Label for the 'enable two-factor auth' item in the settings view") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"disable_2fa") - actionBlock:^{ - [weakSelf showEnable2FAWorkUI]; - }]]; + [section addItem:[OWSTableItem + disclosureItemWithText: + NSLocalizedString(@"ENABLE_2FA_VIEW_ENABLE_2FA", + @"Label for the 'enable two-factor auth' item in the settings view") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"disable_2fa") + actionBlock:^{ + [weakSelf showEnable2FAWorkUI]; + }]]; } [contents addSection:section]; self.tableViewController.contents = contents; @@ -268,18 +268,18 @@ NS_ASSUME_NONNULL_BEGIN [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BACK_BUTTON", @"button text for back button") style:UIBarButtonItemStylePlain target:self - action:@selector(backButtonWasPressed)]; - backButton.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"back"); + action:@selector(backButtonWasPressed) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"back")]; self.navigationItem.backBarButtonItem = backButton; if (self.shouldHaveNextButton) { UIBarButtonItem *nextButton = [[UIBarButtonItem alloc] - initWithTitle:NSLocalizedString(@"ENABLE_2FA_VIEW_NEXT_BUTTON", - @"Label for the 'next' button in the 'enable two factor auth' views.") - style:UIBarButtonItemStylePlain - target:self - action:@selector(nextButtonWasPressed)]; - nextButton.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"next"); + initWithTitle:NSLocalizedString(@"ENABLE_2FA_VIEW_NEXT_BUTTON", + @"Label for the 'next' button in the 'enable two factor auth' views.") + style:UIBarButtonItemStylePlain + target:self + action:@selector(nextButtonWasPressed) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"next")]; self.navigationItem.rightBarButtonItem = nextButton; } else { self.navigationItem.rightBarButtonItem = nil; diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index f465ff6e9..a7599556a 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -112,7 +112,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat nameRow.userInteractionEnabled = YES; [nameRow addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(nameRowTapped:)]]; - nameRow.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"nameRow"); + nameRow.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"nameRow"); [rows addObject:nameRow]; UILabel *nameLabel = [UILabel new]; @@ -152,7 +152,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat avatarRow.userInteractionEnabled = YES; [avatarRow addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarRowTapped:)]]; - avatarRow.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"avatarRow"); + avatarRow.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"avatarRow"); [rows addObject:avatarRow]; UILabel *avatarLabel = [UILabel new]; @@ -165,7 +165,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat [avatarLabel autoVCenterInSuperview]; self.avatarView = [AvatarImageView new]; - self.avatarView.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"avatarView"); + self.avatarView.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"avatarView"); UIImage *cameraImage = [UIImage imageNamed:@"settings-avatar-camera"]; self.cameraImageView = [[UIImageView alloc] initWithImage:cameraImage]; @@ -189,7 +189,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat infoRow.userInteractionEnabled = YES; [infoRow addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(infoRowTapped:)]]; - infoRow.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"infoRow"); + infoRow.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"infoRow"); [rows addObject:infoRow]; UILabel *infoLabel = [UILabel new]; @@ -308,11 +308,11 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat UIAlertAction *discardAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON", @"The label for the 'discard' button in alerts and action sheets.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"discard") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) { [weakSelf profileCompletedOrSkipped]; }]; - discardAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"discard"); [alert addAction:discardAction]; [alert addAction:[OWSAlerts cancelAction]]; 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/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index aa3984d4c..1cc654e74 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -214,7 +214,8 @@ const CGFloat kIconViewLength = 24; [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"EDIT_TXT", nil) style:UIBarButtonItemStylePlain target:self - action:@selector(didTapEditButton)]; + action:@selector(didTapEditButton) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"edit")]; } } @@ -272,6 +273,7 @@ const CGFloat kIconViewLength = 24; self.tableView.rowHeight = UITableViewAutomaticDimension; _disappearingMessagesDurationLabel = [UILabel new]; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _disappearingMessagesDurationLabel); self.disappearingMessagesDurations = [OWSDisappearingMessagesConfiguration validDurationsSeconds]; @@ -323,21 +325,31 @@ const CGFloat kIconViewLength = 24; if ([self.thread isKindOfClass:[TSContactThread class]] && self.contactsManager.supportsContactEditing && !self.hasExistingContact) { - [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - return - [weakSelf disclosureCellWithName:NSLocalizedString(@"CONVERSATION_SETTINGS_NEW_CONTACT", - @"Label for 'new contact' button in conversation settings view.") - iconName:@"table_ic_new_contact"]; - } - actionBlock:^{ - [weakSelf presentContactViewController]; - }]]; - [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - return - [weakSelf disclosureCellWithName:NSLocalizedString(@"CONVERSATION_SETTINGS_ADD_TO_EXISTING_CONTACT", - @"Label for 'new contact' button in conversation settings view.") - iconName:@"table_ic_add_to_existing_contact"]; - } + [mainSection + addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + return [weakSelf + disclosureCellWithName: + NSLocalizedString(@"CONVERSATION_SETTINGS_NEW_CONTACT", + @"Label for 'new contact' button in conversation settings view.") + iconName:@"table_ic_new_contact" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"new_contact")]; + } + actionBlock:^{ + [weakSelf presentContactViewController]; + }]]; + [mainSection addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + return [weakSelf + disclosureCellWithName: + NSLocalizedString(@"CONVERSATION_SETTINGS_ADD_TO_EXISTING_CONTACT", + @"Label for 'new contact' button in conversation settings view.") + iconName:@"table_ic_add_to_existing_contact" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, + @"add_to_existing_contact")]; + } actionBlock:^{ OWSConversationSettingsViewController *strongSelf = weakSelf; OWSCAssertDebug(strongSelf); @@ -349,8 +361,11 @@ const CGFloat kIconViewLength = 24; [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - return [weakSelf disclosureCellWithName:MediaStrings.allMedia - iconName:@"actionsheet_camera_roll_black"]; + return [weakSelf + disclosureCellWithName:MediaStrings.allMedia + iconName:@"actionsheet_camera_roll_black" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"all_media")]; } actionBlock:^{ [weakSelf showMediaGallery]; @@ -362,24 +377,31 @@ const CGFloat kIconViewLength = 24; NSString *title = NSLocalizedString(@"CONVERSATION_SETTINGS_SEARCH", @"Table cell label in conversation settings which returns the user to the " @"conversation with 'search mode' activated"); - return - [weakSelf disclosureCellWithName:title iconName:@"conversation_settings_search"]; + return [weakSelf + disclosureCellWithName:title + iconName:@"conversation_settings_search" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"search")]; } actionBlock:^{ [weakSelf tappedConversationSearch]; }]]; if (!isNoteToSelf && !self.isGroupThread && self.thread.hasSafetyNumbers) { - [mainSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ - return [weakSelf - disclosureCellWithName: - NSLocalizedString(@"VERIFY_PRIVACY", - @"Label for button or row which allows users to verify the safety number of another user.") - iconName:@"table_ic_not_verified"]; - } - actionBlock:^{ - [weakSelf showVerificationView]; - }]]; + [mainSection + addItem:[OWSTableItem + itemWithCustomCellBlock:^{ + return [weakSelf + disclosureCellWithName:NSLocalizedString(@"VERIFY_PRIVACY", + @"Label for button or row which allows users to verify the " + @"safety number of another user.") + iconName:@"table_ic_not_verified" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"safety_numbers")]; + } + actionBlock:^{ + [weakSelf showVerificationView]; + }]]; } if (isNoteToSelf) { @@ -392,15 +414,18 @@ const CGFloat kIconViewLength = 24; OWSCAssertDebug(strongSelf); return [strongSelf - labelCellWithName: - (strongSelf.isGroupThread - ? NSLocalizedString( - @"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_GROUP", - @"Indicates that user's profile has been shared with a group.") - : NSLocalizedString( - @"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_USER", - @"Indicates that user's profile has been shared with a user.")) - iconName:@"table_ic_share_profile"]; + labelCellWithName: + (strongSelf.isGroupThread + ? NSLocalizedString( + @"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_GROUP", + @"Indicates that user's profile has been shared with a group.") + : NSLocalizedString( + @"CONVERSATION_SETTINGS_VIEW_PROFILE_IS_SHARED_WITH_USER", + @"Indicates that user's profile has been shared with a user.")) + iconName:@"table_ic_share_profile" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, + @"profile_is_shared")]; } actionBlock:nil]]; } else { @@ -411,13 +436,15 @@ const CGFloat kIconViewLength = 24; OWSCAssertDebug(strongSelf); UITableViewCell *cell = [strongSelf - disclosureCellWithName: - (strongSelf.isGroupThread - ? NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP", - @"Action that shares user profile with a group.") - : NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER", - @"Action that shares user profile with a user.")) - iconName:@"table_ic_share_profile"]; + disclosureCellWithName: + (strongSelf.isGroupThread + ? NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_GROUP", + @"Action that shares user profile with a group.") + : NSLocalizedString(@"CONVERSATION_SETTINGS_VIEW_SHARE_PROFILE_WITH_USER", + @"Action that shares user profile with a user.")) + iconName:@"table_ic_share_profile" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"share_profile")]; cell.userInteractionEnabled = !strongSelf.hasLeftGroup; return cell; @@ -476,6 +503,9 @@ const CGFloat kIconViewLength = 24; cell.userInteractionEnabled = !strongSelf.hasLeftGroup; + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"disappearing_messages"); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -524,6 +554,9 @@ const CGFloat kIconViewLength = 24; cell.userInteractionEnabled = !strongSelf.hasLeftGroup; + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"disappearing_messages_duration"); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -541,9 +574,12 @@ const CGFloat kIconViewLength = 24; [OWSConversationColor conversationColorOrDefaultForColorName:colorName].themeColor; NSString *title = NSLocalizedString(@"CONVERSATION_SETTINGS_CONVERSATION_COLOR", @"Label for table cell which leads to picking a new conversation color"); - return [strongSelf cellWithName:title - iconName:@"ic_color_palette" - disclosureIconColor:currentColor]; + return [strongSelf + cellWithName:title + iconName:@"ic_color_palette" + disclosureIconColor:currentColor + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"conversation_color")]; } actionBlock:^{ [weakSelf showColorPicker]; @@ -561,7 +597,9 @@ const CGFloat kIconViewLength = 24; UITableViewCell *cell = [weakSelf disclosureCellWithName:NSLocalizedString(@"EDIT_GROUP_ACTION", @"table cell label in conversation settings") - iconName:@"table_ic_group_edit"]; + iconName:@"table_ic_group_edit" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"edit_group")]; cell.userInteractionEnabled = !weakSelf.hasLeftGroup; return cell; } @@ -573,7 +611,9 @@ const CGFloat kIconViewLength = 24; UITableViewCell *cell = [weakSelf disclosureCellWithName:NSLocalizedString(@"LIST_GROUP_MEMBERS_ACTION", @"table cell label in conversation settings") - iconName:@"table_ic_group_members"]; + iconName:@"table_ic_group_members" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"group_members")]; cell.userInteractionEnabled = !weakSelf.hasLeftGroup; return cell; } @@ -585,7 +625,9 @@ const CGFloat kIconViewLength = 24; UITableViewCell *cell = [weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION", @"table cell label in conversation settings") - iconName:@"table_ic_group_leave"]; + iconName:@"table_ic_group_leave" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"leave_group")]; cell.userInteractionEnabled = !weakSelf.hasLeftGroup; return cell; @@ -638,6 +680,10 @@ const CGFloat kIconViewLength = 24; OWSSound sound = [OWSSounds notificationSoundForThread:strongSelf.thread]; cell.detailTextLabel.text = [OWSSounds displayNameForSound:sound]; + + cell.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"notifications"); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -706,6 +752,10 @@ const CGFloat kIconViewLength = 24; [contentRow autoPinEdgesToSuperviewMargins]; cell.detailTextLabel.text = muteStatus; + + cell.accessibilityIdentifier + = ACCESSIBILITY_IDENTIFIER_WITH_NAME(OWSConversationSettingsViewController, @"mute"); + return cell; } customRowHeight:UITableViewAutomaticDimension @@ -743,8 +793,11 @@ const CGFloat kIconViewLength = 24; cellTitle = NSLocalizedString(@"CONVERSATION_SETTINGS_BLOCK_THIS_USER", @"table cell label in conversation settings"); } - UITableViewCell *cell = - [strongSelf disclosureCellWithName:cellTitle iconName:@"table_ic_block"]; + UITableViewCell *cell = [strongSelf + disclosureCellWithName:cellTitle + iconName:@"table_ic_block" + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( + OWSConversationSettingsViewController, @"block")]; cell.selectionStyle = UITableViewCellSelectionStyleNone; @@ -755,6 +808,7 @@ const CGFloat kIconViewLength = 24; action:@selector(blockConversationSwitchDidChange:) forControlEvents:UIControlEventValueChanged]; cell.accessoryView = blockConversationSwitch; + return cell; } actionBlock:nil]]; @@ -812,17 +866,23 @@ const CGFloat kIconViewLength = 24; return cell; } -- (UITableViewCell *)disclosureCellWithName:(NSString *)name iconName:(NSString *)iconName +- (UITableViewCell *)disclosureCellWithName:(NSString *)name + iconName:(NSString *)iconName + accessibilityIdentifier:(NSString *)accessibilityIdentifier { UITableViewCell *cell = [self cellWithName:name iconName:iconName]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; + cell.accessibilityIdentifier = accessibilityIdentifier; return cell; } -- (UITableViewCell *)labelCellWithName:(NSString *)name iconName:(NSString *)iconName +- (UITableViewCell *)labelCellWithName:(NSString *)name + iconName:(NSString *)iconName + accessibilityIdentifier:(NSString *)accessibilityIdentifier { UITableViewCell *cell = [self cellWithName:name iconName:iconName]; cell.accessoryType = UITableViewCellAccessoryNone; + cell.accessibilityIdentifier = accessibilityIdentifier; return cell; } @@ -916,6 +976,8 @@ const CGFloat kIconViewLength = 24; action:@selector(conversationNameTouched:)]]; mainSectionHeader.userInteractionEnabled = YES; + SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, mainSectionHeader); + return mainSectionHeader; } @@ -1084,11 +1146,12 @@ const CGFloat kIconViewLength = 24; preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *leaveAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"LEAVE_BUTTON_TITLE", @"Confirmation button within contextual alert") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *_Nonnull action) { - [self leaveGroup]; - }]; + actionWithTitle:NSLocalizedString(@"LEAVE_BUTTON_TITLE", @"Confirmation button within contextual alert") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"leave_group_confirm") + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction *_Nonnull action) { + [self leaveGroup]; + }]; [alert addAction:leaveAction]; [alert addAction:[OWSAlerts cancelAction]]; @@ -1228,6 +1291,7 @@ const CGFloat kIconViewLength = 24; if (self.thread.isMuted) { UIAlertAction *action = [UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_UNMUTE_ACTION", @"Label for button to unmute a thread.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"unmute") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull ignore) { [weakSelf setThreadMutedUntilDate:nil]; @@ -1238,6 +1302,7 @@ const CGFloat kIconViewLength = 24; [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_MINUTE_ACTION", @"Label for button to mute a thread for a minute.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"mute_1_minute") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull ignore) { NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; @@ -1255,6 +1320,7 @@ const CGFloat kIconViewLength = 24; [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_HOUR_ACTION", @"Label for button to mute a thread for a hour.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"mute_1_hour") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull ignore) { NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; @@ -1271,6 +1337,7 @@ const CGFloat kIconViewLength = 24; [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_DAY_ACTION", @"Label for button to mute a thread for a day.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"mute_1_day") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull ignore) { NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; @@ -1287,6 +1354,7 @@ const CGFloat kIconViewLength = 24; [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_WEEK_ACTION", @"Label for button to mute a thread for a week.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"mute_1_week") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull ignore) { NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; @@ -1303,6 +1371,7 @@ const CGFloat kIconViewLength = 24; [actionSheet addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"CONVERSATION_SETTINGS_MUTE_ONE_YEAR_ACTION", @"Label for button to mute a thread for a year.") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"mute_1_year") style:UIAlertActionStyleDestructive handler:^(UIAlertAction *_Nonnull ignore) { NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; 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/Signal/src/util/Pastelog.m b/Signal/src/util/Pastelog.m index 00329126d..c2077534c 100644 --- a/Signal/src/util/Pastelog.m +++ b/Signal/src/util/Pastelog.m @@ -323,7 +323,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_EMAIL", @"Label for the 'email debug log' option of the debug log alert.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"send_email") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_email") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [Pastelog.sharedManager submitEmail:url]; @@ -332,7 +332,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error }]]; [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_COPY_LINK", @"Label for the 'copy link' option of the debug log alert.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"copy_link") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"copy_link") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { UIPasteboard *pb = [UIPasteboard generalPasteboard]; @@ -344,7 +344,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SEND_TO_SELF", @"Label for the 'send to self' option of the debug log alert.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"send_to_self") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_to_self") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [Pastelog.sharedManager sendToSelf:url]; @@ -352,7 +352,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error [alert addAction:[UIAlertAction actionWithTitle: NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SEND_TO_LAST_THREAD", @"Label for the 'send to last thread' option of the debug log alert.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"send_to_last_thread") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"send_to_last_thread") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [Pastelog.sharedManager sendToMostRecentThread:url]; @@ -362,14 +362,14 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error addAction: [UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_BUG_REPORT", @"Label for the 'Open a Bug Report' option of the debug log alert.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"submit_bug_report") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"submit_bug_report") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [Pastelog.sharedManager prepareRedirection:url completion:completion]; }]]; [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SHARE", @"Label for the 'Share' option of the debug log alert.") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"share") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"share") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [AttachmentSharing showShareUIForText:url.absoluteString @@ -515,7 +515,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error message:message preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"ok") style:UIAlertActionStyleDefault handler:nil]]; UIViewController *presentingViewController = UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts; @@ -573,7 +573,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error [alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"") - accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"ok") style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [UIApplication.sharedApplication diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.h b/SignalMessaging/ViewControllers/OWSTableViewController.h index 53942225c..0e22fd5bb 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.h +++ b/SignalMessaging/ViewControllers/OWSTableViewController.h @@ -89,6 +89,11 @@ typedef BOOL (^OWSTableSwitchBlock)(void); customRowHeight:(CGFloat)customRowHeight actionBlock:(nullable OWSTableActionBlock)actionBlock; ++ (OWSTableItem *)disclosureItemWithText:(NSString *)text + accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier + customRowHeight:(CGFloat)customRowHeight + actionBlock:(nullable OWSTableActionBlock)actionBlock; + + (OWSTableItem *)checkmarkItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)checkmarkItemWithText:(NSString *)text diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.m b/SignalMessaging/ViewControllers/OWSTableViewController.m index 921d7c563..5a4303c9a 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.m +++ b/SignalMessaging/ViewControllers/OWSTableViewController.m @@ -225,10 +225,22 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; + (OWSTableItem *)disclosureItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight actionBlock:(nullable OWSTableActionBlock)actionBlock +{ + return [self disclosureItemWithText:text + accessibilityIdentifier:nil + customRowHeight:customRowHeight + actionBlock:actionBlock]; +} + ++ (OWSTableItem *)disclosureItemWithText:(NSString *)text + accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier + customRowHeight:(CGFloat)customRowHeight + actionBlock:(nullable OWSTableActionBlock)actionBlock { OWSAssertDebug(customRowHeight > 0 || customRowHeight == UITableViewAutomaticDimension); - OWSTableItem *item = [self disclosureItemWithText:text actionBlock:actionBlock]; + OWSTableItem *item = + [self disclosureItemWithText:text accessibilityIdentifier:accessibilityIdentifier actionBlock:actionBlock]; item.customRowHeight = @(customRowHeight); return item; } 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/categories/UIView+OWS.swift b/SignalMessaging/categories/UIView+OWS.swift index 711cb4871..3b9656d0f 100644 --- a/SignalMessaging/categories/UIView+OWS.swift +++ b/SignalMessaging/categories/UIView+OWS.swift @@ -355,3 +355,42 @@ public extension UIBezierPath { addLine(to: first) } } + +// MARK: - + +public extension UIBarButtonItem { + @objc + public convenience init(image: UIImage?, style: UIBarButtonItem.Style, target: Any?, action: Selector?, accessibilityIdentifier: String) { + self.init(image: image, style: style, target: target, action: action) + + self.accessibilityIdentifier = accessibilityIdentifier + } + + @objc + public convenience init(image: UIImage?, landscapeImagePhone: UIImage?, style: UIBarButtonItem.Style, target: Any?, action: Selector?, accessibilityIdentifier: String) { + self.init(image: image, landscapeImagePhone: landscapeImagePhone, style: style, target: target, action: action) + + self.accessibilityIdentifier = accessibilityIdentifier + } + + @objc + public convenience init(title: String?, style: UIBarButtonItem.Style, target: Any?, action: Selector?, accessibilityIdentifier: String) { + self.init(title: title, style: style, target: target, action: action) + + self.accessibilityIdentifier = accessibilityIdentifier + } + + @objc + public convenience init(barButtonSystemItem systemItem: UIBarButtonItem.SystemItem, target: Any?, action: Selector?, accessibilityIdentifier: String) { + self.init(barButtonSystemItem: systemItem, target: target, action: action) + + self.accessibilityIdentifier = accessibilityIdentifier + } + + @objc + public convenience init(customView: UIView, accessibilityIdentifier: String) { + self.init(customView: customView) + + self.accessibilityIdentifier = accessibilityIdentifier + } +} diff --git a/SignalMessaging/categories/UIViewController+OWS.m b/SignalMessaging/categories/UIViewController+OWS.m index 04c1ba1d8..906d8f1c2 100644 --- a/SignalMessaging/categories/UIViewController+OWS.m +++ b/SignalMessaging/categories/UIViewController+OWS.m @@ -4,9 +4,11 @@ #import "Theme.h" #import "UIColor+OWS.h" +#import "UIUtil.h" #import "UIView+OWS.h" #import "UIViewController+OWS.h" #import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -120,7 +122,9 @@ NS_ASSUME_NONNULL_BEGIN action:selector]; } - UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; + UIBarButtonItem *backItem = + [[UIBarButtonItem alloc] initWithCustomView:backButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"back")]; backItem.width = buttonFrame.size.width; return backItem; 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]; diff --git a/SignalMessaging/utils/BlockListUIUtils.m b/SignalMessaging/utils/BlockListUIUtils.m index c5e7d7ea3..8541fac45 100644 --- a/SignalMessaging/utils/BlockListUIUtils.m +++ b/SignalMessaging/utils/BlockListUIUtils.m @@ -117,30 +117,30 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *blockAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *_Nonnull action) { - [self blockPhoneNumbers:phoneNumbers - displayName:displayName - fromViewController:fromViewController - blockingManager:blockingManager - completionBlock:^(UIAlertAction *ignore) { - if (completionBlock) { - completionBlock(YES); - } - }]; - }]; - blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block"); + 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) { + [self blockPhoneNumbers:phoneNumbers + displayName:displayName + fromViewController:fromViewController + blockingManager:blockingManager + completionBlock:^(UIAlertAction *ignore) { + if (completionBlock) { + completionBlock(YES); + } + }]; + }]; [actionSheet addAction:blockAction]; UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dismiss") style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) { if (completionBlock) { completionBlock(NO); } }]; - dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss"); [actionSheet addAction:dismissAction]; [fromViewController presentAlert:actionSheet]; } @@ -168,30 +168,30 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction *blockAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *_Nonnull action) { - [self blockGroup:groupThread - fromViewController:fromViewController - blockingManager:blockingManager - messageSender:messageSender - completionBlock:^(UIAlertAction *ignore) { - if (completionBlock) { - completionBlock(YES); - } - }]; - }]; - blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block"); + 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) { + [self blockGroup:groupThread + fromViewController:fromViewController + blockingManager:blockingManager + messageSender:messageSender + completionBlock:^(UIAlertAction *ignore) { + if (completionBlock) { + completionBlock(YES); + } + }]; + }]; [actionSheet addAction:blockAction]; UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dismiss") style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) { if (completionBlock) { completionBlock(NO); } }]; - dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss"); [actionSheet addAction:dismissAction]; [fromViewController presentAlert:actionSheet]; } @@ -333,31 +333,32 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet]; - UIAlertAction *unblockAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *_Nonnull action) { - [BlockListUIUtils unblockPhoneNumbers:phoneNumbers - displayName:displayName - fromViewController:fromViewController - blockingManager:blockingManager - completionBlock:^(UIAlertAction *ignore) { - if (completionBlock) { - completionBlock(NO); - } - }]; - }]; - unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock"); + UIAlertAction *unblockAction = + [UIAlertAction actionWithTitle:NSLocalizedString( + @"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"unblock") + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction *_Nonnull action) { + [BlockListUIUtils unblockPhoneNumbers:phoneNumbers + displayName:displayName + fromViewController:fromViewController + blockingManager:blockingManager + completionBlock:^(UIAlertAction *ignore) { + if (completionBlock) { + completionBlock(NO); + } + }]; + }]; [actionSheet addAction:unblockAction]; UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dismiss") style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) { if (completionBlock) { completionBlock(YES); } }]; - dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss"); [actionSheet addAction:dismissAction]; [fromViewController presentAlert:actionSheet]; } @@ -406,31 +407,31 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); message:message preferredStyle:UIAlertControllerStyleActionSheet]; - UIAlertAction *unblockAction = [UIAlertAction - actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *_Nonnull action) { - [BlockListUIUtils unblockGroup:groupModel - displayName:displayName - fromViewController:fromViewController - blockingManager:blockingManager - completionBlock:^(UIAlertAction *ignore) { - if (completionBlock) { - completionBlock(NO); - } - }]; - }]; - unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock"); + UIAlertAction *unblockAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", + @"Button label for the 'unblock' button") + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"unblock") + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction *_Nonnull action) { + [BlockListUIUtils unblockGroup:groupModel + displayName:displayName + fromViewController:fromViewController + blockingManager:blockingManager + completionBlock:^(UIAlertAction *ignore) { + if (completionBlock) { + completionBlock(NO); + } + }]; + }]; [actionSheet addAction:unblockAction]; UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"dismiss") style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) { if (completionBlock) { completionBlock(YES); } }]; - dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss"); [actionSheet addAction:dismissAction]; [fromViewController presentAlert:actionSheet]; } @@ -473,9 +474,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action); [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) + accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(self, @"ok") style:UIAlertActionStyleDefault handler:completionBlock]; - okAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok"); [alert addAction:okAction]; [fromViewController presentAlert:alert]; } diff --git a/SignalMessaging/utils/UIUtil.h b/SignalMessaging/utils/UIUtil.h index 715c4be62..f5f17972e 100644 --- a/SignalMessaging/utils/UIUtil.h +++ b/SignalMessaging/utils/UIUtil.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "UIColor+OWS.h" @@ -7,10 +7,10 @@ #import #import -#define SUBVIEW_ACCESSIBILITY_IDENTIFIER(_root_view, _variable_name) \ -([NSString stringWithFormat:@"%@.%@", _root_view.class, _variable_name]) +#define ACCESSIBILITY_IDENTIFIER_WITH_NAME(_root_view, _variable_name) \ + ([NSString stringWithFormat:@"%@.%@", _root_view.class, _variable_name]) #define SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(_root_view, _variable_name) \ -_variable_name.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(_root_view, (@ #_variable_name)) + _variable_name.accessibilityIdentifier = ACCESSIBILITY_IDENTIFIER_WITH_NAME(_root_view, (@ #_variable_name)) typedef void (^completionBlock)(void);