Simplify usage of accessibilityIdentifiers.

pull/2/head
Matthew Chen 6 years ago
parent 2d854406a1
commit 95e125d55e

@ -6,6 +6,7 @@
#import <AVFoundation/AVFoundation.h>
#import <SignalMessaging/OWSAudioPlayer.h>
#import <SignalMessaging/OWSSounds.h>
#import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalMessaging/UIUtil.h>
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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"save")];
self.navigationItem.rightBarButtonItem = saveItem;
} else {
self.navigationItem.rightBarButtonItem = nil;

@ -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]];

@ -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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"next")];
self.navigationItem.rightBarButtonItem = nextButton;
} else {
self.navigationItem.rightBarButtonItem = nil;

@ -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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"discard")
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
[weakSelf profileCompletedOrSkipped];
}];
discardAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"discard");
[alert addAction:discardAction];
[alert addAction:[OWSAlerts cancelAction]];

@ -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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(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:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok")
style:UIAlertActionStyleDefault
handler:completionBlock];
okAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok");
[alert addAction:okAction];
[fromViewController presentAlert:alert];
}

Loading…
Cancel
Save