diff --git a/Signal/src/ViewControllers/ProfileViewController.m b/Signal/src/ViewControllers/ProfileViewController.m index 06b0e94ef..f83cd04c1 100644 --- a/Signal/src/ViewControllers/ProfileViewController.m +++ b/Signal/src/ViewControllers/ProfileViewController.m @@ -15,6 +15,7 @@ #import #import #import +#import #import #import #import @@ -304,15 +305,22 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_MESSAGE", @"The alert message if user tries to exit the new group view without saving changes.") preferredStyle:UIAlertControllerStyleAlert]; - [controller - addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON", - @"The label for the 'discard' button in alerts and action sheets.") - style:UIAlertActionStyleDestructive - handler:^(UIAlertAction *action) { - [weakSelf profileCompletedOrSkipped]; - }]]; + UIAlertAction *discardAction = + [UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON", + @"The label for the 'discard' button in alerts and action sheets.") + style:UIAlertActionStyleDestructive + handler:^(UIAlertAction *action) { + [weakSelf profileCompletedOrSkipped]; + }]; + discardAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"discard"); + [controller addAction:discardAction]; + [controller addAction:[OWSAlerts cancelAction]]; - [self presentViewController:controller animated:YES completion:nil]; + [self presentViewController:controller + animated:YES + completion:^{ + [controller applyAccessibilityIdentifiers]; + }]; } - (void)avatarTapped diff --git a/SignalMessaging/Views/OWSAlerts.swift b/SignalMessaging/Views/OWSAlerts.swift index 64abd9526..7dd0e3d0f 100644 --- a/SignalMessaging/Views/OWSAlerts.swift +++ b/SignalMessaging/Views/OWSAlerts.swift @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // import Foundation @@ -12,10 +12,13 @@ import Foundation let alertTitle = NSLocalizedString("CALL_AUDIO_PERMISSION_TITLE", comment: "Alert title when calling and permissions for microphone are missing") let alertMessage = NSLocalizedString("CALL_AUDIO_PERMISSION_MESSAGE", comment: "Alert message when calling and permissions for microphone are missing") let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert) - let dismissAction = UIAlertAction(title: CommonStrings.dismissButton, style: .cancel) + let dismissAction = UIAlertAction(title: CommonStrings.dismissButton, style: .cancel) + dismissAction.accessibilityIdentifier = "OWSAlerts.\("dismiss")" alertController.addAction(dismissAction) + if let settingsAction = CurrentAppContext().openSystemSettingsAction { + settingsAction.accessibilityIdentifier = "OWSAlerts.\("settings")" alertController.addAction(settingsAction) } CurrentAppContext().frontmostViewController()?.present(alertController, animated: true, completion: nil) @@ -51,10 +54,13 @@ import Foundation @objc public class func showAlert(title: String?, message: String? = nil, buttonTitle: String? = nil, buttonAction: ((UIAlertAction) -> Void)? = nil, fromViewController: UIViewController?) { - let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "") let alert = UIAlertController(title: title, message: message, preferredStyle: .alert) - alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: buttonAction)) + + let actionTitle = buttonTitle ?? NSLocalizedString("OK", comment: "") + let okAction = UIAlertAction(title: actionTitle, style: .default, handler: buttonAction) + okAction.accessibilityIdentifier = "OWSAlerts.\("ok")" + alert.addAction(okAction) fromViewController?.present(alert, animated: true, completion: nil) } @@ -66,7 +72,9 @@ import Foundation alert.addAction(self.cancelAction) let actionTitle = proceedTitle ?? NSLocalizedString("OK", comment: "") - alert.addAction(UIAlertAction(title: actionTitle, style: .default, handler: proceedAction)) + let okAction = UIAlertAction(title: actionTitle, style: .default, handler: proceedAction) + okAction.accessibilityIdentifier = "OWSAlerts.\("ok")" + alert.addAction(okAction) CurrentAppContext().frontmostViewController()?.present(alert, animated: true, completion: nil) } @@ -82,6 +90,7 @@ import Foundation Logger.debug("Cancel item") // Do nothing. } + action.accessibilityIdentifier = "OWSAlerts.\("cancel")" return action }