Add accessibility identifiers to privacy popups and subviews.

pull/2/head
Matthew Chen 6 years ago
parent f37a3059fa
commit cb5ce42e76

@ -46,16 +46,18 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateNavigationItems - (void)updateNavigationItems
{ {
self.navigationItem.leftBarButtonItem = UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self target:self
action:@selector(cancelWasPressed:)]; action:@selector(cancelWasPressed:)];
cancelItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"cancel");
self.navigationItem.leftBarButtonItem = cancelItem;
if (self.isDirty) { if (self.isDirty) {
self.navigationItem.rightBarButtonItem = UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self target:self
action:@selector(saveWasPressed:)]; action:@selector(saveWasPressed:)];
saveItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"save");
self.navigationItem.rightBarButtonItem = saveItem;
} else { } else {
self.navigationItem.rightBarButtonItem = nil; self.navigationItem.rightBarButtonItem = nil;
} }

@ -419,16 +419,22 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[alertController addAction:[OWSAlerts cancelAction]]; [alertController addAction:[OWSAlerts cancelAction]];
UIAlertAction *deleteAction = [UIAlertAction UIAlertAction *deleteAction =
actionWithTitle:NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION_BUTTON", [UIAlertAction actionWithTitle:
NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION_BUTTON",
@"Confirmation text for button which deletes all message, calling, attachments, etc.") @"Confirmation text for button which deletes all message, calling, attachments, etc.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"delete")
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[self deleteThreadsAndMessages]; [self deleteThreadsAndMessages];
}]; }];
[alertController addAction:deleteAction]; [alertController addAction:deleteAction];
[self presentViewController:alertController animated:true completion:nil]; [self presentViewController:alertController
animated:true
completion:^{
[alertController applyAccessibilityIdentifiers];
}];
} }
- (void)deleteThreadsAndMessages - (void)deleteThreadsAndMessages

@ -122,6 +122,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.pinTextfield addTarget:self [self.pinTextfield addTarget:self
action:@selector(textFieldDidChange:) action:@selector(textFieldDidChange:)
forControlEvents:UIControlEventEditingChanged]; forControlEvents:UIControlEventEditingChanged];
SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, _pinTextfield);
[self.view addSubview:self.pinTextfield]; [self.view addSubview:self.pinTextfield];
} }
@ -144,6 +145,7 @@ NS_ASSUME_NONNULL_BEGIN
: NSLocalizedString(@"ENABLE_2FA_VIEW_STATUS_DISABLED_INSTRUCTIONS", : NSLocalizedString(@"ENABLE_2FA_VIEW_STATUS_DISABLED_INSTRUCTIONS",
@"Indicates that user has 'two factor auth pin' disabled.")); @"Indicates that user has 'two factor auth pin' disabled."));
UILabel *instructionsLabel = [self createLabelWithText:instructions]; UILabel *instructionsLabel = [self createLabelWithText:instructions];
SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, instructionsLabel);
[self createTableView]; [self createTableView];
@ -191,6 +193,7 @@ NS_ASSUME_NONNULL_BEGIN
[instructionsLabel autoPinTopToSuperviewMarginWithInset:kVSpacing]; [instructionsLabel autoPinTopToSuperviewMarginWithInset:kVSpacing];
[instructionsLabel autoPinEdgeToSuperviewSafeArea:ALEdgeLeading withInset:self.hMargin]; [instructionsLabel autoPinEdgeToSuperviewSafeArea:ALEdgeLeading withInset:self.hMargin];
[instructionsLabel autoPinEdgeToSuperviewSafeArea:ALEdgeTrailing withInset:self.hMargin]; [instructionsLabel autoPinEdgeToSuperviewSafeArea:ALEdgeTrailing withInset:self.hMargin];
SET_SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, instructionsLabel);
[self.pinTextfield autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:instructionsLabel withOffset:kVSpacing]; [self.pinTextfield autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:instructionsLabel withOffset:kVSpacing];
[self.pinTextfield autoPinEdgeToSuperviewSafeArea:ALEdgeLeading withInset:self.hMargin]; [self.pinTextfield autoPinEdgeToSuperviewSafeArea:ALEdgeLeading withInset:self.hMargin];
@ -221,6 +224,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem disclosureItemWithText: addItem:[OWSTableItem disclosureItemWithText:
NSLocalizedString(@"ENABLE_2FA_VIEW_DISABLE_2FA", NSLocalizedString(@"ENABLE_2FA_VIEW_DISABLE_2FA",
@"Label for the 'enable two-factor auth' item in the settings view") @"Label for the 'enable two-factor auth' item in the settings view")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"enable_2fa")
actionBlock:^{ actionBlock:^{
[weakSelf tryToDisable2FA]; [weakSelf tryToDisable2FA];
}]]; }]];
@ -229,6 +233,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem disclosureItemWithText: addItem:[OWSTableItem disclosureItemWithText:
NSLocalizedString(@"ENABLE_2FA_VIEW_ENABLE_2FA", NSLocalizedString(@"ENABLE_2FA_VIEW_ENABLE_2FA",
@"Label for the 'enable two-factor auth' item in the settings view") @"Label for the 'enable two-factor auth' item in the settings view")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"disable_2fa")
actionBlock:^{ actionBlock:^{
[weakSelf showEnable2FAWorkUI]; [weakSelf showEnable2FAWorkUI];
}]]; }]];
@ -259,19 +264,23 @@ NS_ASSUME_NONNULL_BEGIN
// Note: This affects how the "back" button will look if another // Note: This affects how the "back" button will look if another
// view is pushed on top of this one, not how the "back" // view is pushed on top of this one, not how the "back"
// button looks when this view is visible. // button looks when this view is visible.
self.navigationItem.backBarButtonItem = UIBarButtonItem *backButton =
[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BACK_BUTTON", @"button text for back button") [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"BACK_BUTTON", @"button text for back button")
style:UIBarButtonItemStylePlain style:UIBarButtonItemStylePlain
target:self target:self
action:@selector(backButtonWasPressed)]; action:@selector(backButtonWasPressed)];
backButton.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"back");
self.navigationItem.backBarButtonItem = backButton;
if (self.shouldHaveNextButton) { if (self.shouldHaveNextButton) {
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] UIBarButtonItem *nextButton = [[UIBarButtonItem alloc]
initWithTitle:NSLocalizedString(@"ENABLE_2FA_VIEW_NEXT_BUTTON", initWithTitle:NSLocalizedString(@"ENABLE_2FA_VIEW_NEXT_BUTTON",
@"Label for the 'next' button in the 'enable two factor auth' views.") @"Label for the 'next' button in the 'enable two factor auth' views.")
style:UIBarButtonItemStylePlain style:UIBarButtonItemStylePlain
target:self target:self
action:@selector(nextButtonWasPressed)]; action:@selector(nextButtonWasPressed)];
nextButton.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"next");
self.navigationItem.rightBarButtonItem = nextButton;
} else { } else {
self.navigationItem.rightBarButtonItem = nil; self.navigationItem.rightBarButtonItem = nil;
} }

@ -10,7 +10,7 @@ extension UIAlertController {
for action in actions { for action in actions {
guard let view = action.value(forKey: "__representer") as? UIView else { guard let view = action.value(forKey: "__representer") as? UIView else {
owsFailDebug("Missing representer.") owsFailDebug("Missing representer.")
return continue
} }
view.accessibilityIdentifier = action.accessibilityIdentifier view.accessibilityIdentifier = action.accessibilityIdentifier
} }

Loading…
Cancel
Save