Add accessibility identifiers to settings popups.

pull/2/head
Matthew Chen 6 years ago
parent d7b1e65a71
commit 81508e9d02

@ -15,6 +15,7 @@
#import <SignalCoreKit/NSDate+OWS.h>
#import <SignalMessaging/OWSNavigationController.h>
#import <SignalMessaging/OWSProfileManager.h>
#import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalMessaging/UIUtil.h>
#import <SignalMessaging/UIViewController+OWS.h>
#import <SignalServiceKit/NSString+SSK.h>
@ -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

@ -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
}

Loading…
Cancel
Save