Simplify usage of accessibilityIdentifiers.

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

@ -6,6 +6,7 @@
#import <AVFoundation/AVFoundation.h> #import <AVFoundation/AVFoundation.h>
#import <SignalMessaging/OWSAudioPlayer.h> #import <SignalMessaging/OWSAudioPlayer.h>
#import <SignalMessaging/OWSSounds.h> #import <SignalMessaging/OWSSounds.h>
#import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalMessaging/UIUtil.h> #import <SignalMessaging/UIUtil.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -46,17 +47,19 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateNavigationItems - (void)updateNavigationItems
{ {
UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel UIBarButtonItem *cancelItem =
target:self [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
action:@selector(cancelWasPressed:)]; target:self
cancelItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"cancel"); action:@selector(cancelWasPressed:)
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"cancel")];
self.navigationItem.leftBarButtonItem = cancelItem; self.navigationItem.leftBarButtonItem = cancelItem;
if (self.isDirty) { if (self.isDirty) {
UIBarButtonItem *saveItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave UIBarButtonItem *saveItem =
target:self [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
action:@selector(saveWasPressed:)]; target:self
saveItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"save"); action:@selector(saveWasPressed:)
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"save")];
self.navigationItem.rightBarButtonItem = saveItem; self.navigationItem.rightBarButtonItem = saveItem;
} else { } else {
self.navigationItem.rightBarButtonItem = nil; self.navigationItem.rightBarButtonItem = nil;

@ -561,11 +561,11 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
UIAlertAction *action = UIAlertAction *action =
[UIAlertAction actionWithTitle:screenLockTimeoutString [UIAlertAction actionWithTitle:screenLockTimeoutString
accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.timeout.%@", timeoutValue]
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:^(UIAlertAction *ignore) { handler:^(UIAlertAction *ignore) {
[OWSScreenLock.sharedManager setScreenLockTimeout:screenLockTimeout]; [OWSScreenLock.sharedManager setScreenLockTimeout:screenLockTimeout];
}]; }];
action.accessibilityIdentifier = [NSString stringWithFormat:@"settings.privacy.timeout.%@", timeoutValue];
[alert addAction:action]; [alert addAction:action];
} }
[alert addAction:[OWSAlerts cancelAction]]; [alert addAction:[OWSAlerts cancelAction]];

@ -268,18 +268,18 @@ NS_ASSUME_NONNULL_BEGIN
[[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"); accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"back")];
self.navigationItem.backBarButtonItem = backButton; self.navigationItem.backBarButtonItem = backButton;
if (self.shouldHaveNextButton) { if (self.shouldHaveNextButton) {
UIBarButtonItem *nextButton = [[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"); accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"next")];
self.navigationItem.rightBarButtonItem = nextButton; self.navigationItem.rightBarButtonItem = nextButton;
} else { } else {
self.navigationItem.rightBarButtonItem = nil; self.navigationItem.rightBarButtonItem = nil;

@ -308,11 +308,11 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
UIAlertAction *discardAction = UIAlertAction *discardAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON", [UIAlertAction actionWithTitle:NSLocalizedString(@"ALERT_DISCARD_BUTTON",
@"The label for the 'discard' button in alerts and action sheets.") @"The label for the 'discard' button in alerts and action sheets.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"discard")
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) { handler:^(UIAlertAction *action) {
[weakSelf profileCompletedOrSkipped]; [weakSelf profileCompletedOrSkipped];
}]; }];
discardAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"discard");
[alert addAction:discardAction]; [alert addAction:discardAction];
[alert addAction:[OWSAlerts cancelAction]]; [alert addAction:[OWSAlerts cancelAction]];

@ -117,30 +117,30 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
preferredStyle:UIAlertControllerStyleActionSheet]; preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *blockAction = [UIAlertAction UIAlertAction *blockAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button") actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button")
style:UIAlertActionStyleDestructive accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block")
handler:^(UIAlertAction *_Nonnull action) { style:UIAlertActionStyleDestructive
[self blockPhoneNumbers:phoneNumbers handler:^(UIAlertAction *_Nonnull action) {
displayName:displayName [self blockPhoneNumbers:phoneNumbers
fromViewController:fromViewController displayName:displayName
blockingManager:blockingManager fromViewController:fromViewController
completionBlock:^(UIAlertAction *ignore) { blockingManager:blockingManager
if (completionBlock) { completionBlock:^(UIAlertAction *ignore) {
completionBlock(YES); if (completionBlock) {
} completionBlock(YES);
}]; }
}]; }];
blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block"); }];
[actionSheet addAction:blockAction]; [actionSheet addAction:blockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss")
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
if (completionBlock) { if (completionBlock) {
completionBlock(NO); completionBlock(NO);
} }
}]; }];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheet addAction:dismissAction]; [actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet]; [fromViewController presentAlert:actionSheet];
} }
@ -168,30 +168,30 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
preferredStyle:UIAlertControllerStyleActionSheet]; preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *blockAction = [UIAlertAction UIAlertAction *blockAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button") actionWithTitle:NSLocalizedString(@"BLOCK_LIST_BLOCK_BUTTON", @"Button label for the 'block' button")
style:UIAlertActionStyleDestructive accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block")
handler:^(UIAlertAction *_Nonnull action) { style:UIAlertActionStyleDestructive
[self blockGroup:groupThread handler:^(UIAlertAction *_Nonnull action) {
fromViewController:fromViewController [self blockGroup:groupThread
blockingManager:blockingManager fromViewController:fromViewController
messageSender:messageSender blockingManager:blockingManager
completionBlock:^(UIAlertAction *ignore) { messageSender:messageSender
if (completionBlock) { completionBlock:^(UIAlertAction *ignore) {
completionBlock(YES); if (completionBlock) {
} completionBlock(YES);
}]; }
}]; }];
blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block"); }];
[actionSheet addAction:blockAction]; [actionSheet addAction:blockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss")
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
if (completionBlock) { if (completionBlock) {
completionBlock(NO); completionBlock(NO);
} }
}]; }];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheet addAction:dismissAction]; [actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet]; [fromViewController presentAlert:actionSheet];
} }
@ -333,31 +333,32 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
UIAlertController *actionSheet = UIAlertController *actionSheet =
[UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet]; [UIAlertController alertControllerWithTitle:title message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *unblockAction = [UIAlertAction UIAlertAction *unblockAction =
actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button") [UIAlertAction actionWithTitle:NSLocalizedString(
style:UIAlertActionStyleDestructive @"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button")
handler:^(UIAlertAction *_Nonnull action) { accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock")
[BlockListUIUtils unblockPhoneNumbers:phoneNumbers style:UIAlertActionStyleDestructive
displayName:displayName handler:^(UIAlertAction *_Nonnull action) {
fromViewController:fromViewController [BlockListUIUtils unblockPhoneNumbers:phoneNumbers
blockingManager:blockingManager displayName:displayName
completionBlock:^(UIAlertAction *ignore) { fromViewController:fromViewController
if (completionBlock) { blockingManager:blockingManager
completionBlock(NO); completionBlock:^(UIAlertAction *ignore) {
} if (completionBlock) {
}]; completionBlock(NO);
}]; }
unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock"); }];
}];
[actionSheet addAction:unblockAction]; [actionSheet addAction:unblockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss")
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
if (completionBlock) { if (completionBlock) {
completionBlock(YES); completionBlock(YES);
} }
}]; }];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheet addAction:dismissAction]; [actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet]; [fromViewController presentAlert:actionSheet];
} }
@ -406,31 +407,31 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
message:message message:message
preferredStyle:UIAlertControllerStyleActionSheet]; preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *unblockAction = [UIAlertAction UIAlertAction *unblockAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON",
actionWithTitle:NSLocalizedString(@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button") @"Button label for the 'unblock' button")
style:UIAlertActionStyleDestructive accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock")
handler:^(UIAlertAction *_Nonnull action) { style:UIAlertActionStyleDestructive
[BlockListUIUtils unblockGroup:groupModel handler:^(UIAlertAction *_Nonnull action) {
displayName:displayName [BlockListUIUtils unblockGroup:groupModel
fromViewController:fromViewController displayName:displayName
blockingManager:blockingManager fromViewController:fromViewController
completionBlock:^(UIAlertAction *ignore) { blockingManager:blockingManager
if (completionBlock) { completionBlock:^(UIAlertAction *ignore) {
completionBlock(NO); if (completionBlock) {
} completionBlock(NO);
}]; }
}]; }];
unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock"); }];
[actionSheet addAction:unblockAction]; [actionSheet addAction:unblockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss")
style:UIAlertActionStyleCancel style:UIAlertActionStyleCancel
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
if (completionBlock) { if (completionBlock) {
completionBlock(YES); completionBlock(YES);
} }
}]; }];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheet addAction:dismissAction]; [actionSheet addAction:dismissAction];
[fromViewController presentAlert:actionSheet]; [fromViewController presentAlert:actionSheet];
} }
@ -473,9 +474,9 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
[UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok")
style:UIAlertActionStyleDefault style:UIAlertActionStyleDefault
handler:completionBlock]; handler:completionBlock];
okAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok");
[alert addAction:okAction]; [alert addAction:okAction];
[fromViewController presentAlert:alert]; [fromViewController presentAlert:alert];
} }

Loading…
Cancel
Save