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 =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self target:self
action:@selector(cancelWasPressed:)]; action:@selector(cancelWasPressed:)
cancelItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"cancel"); 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 =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave
target:self target:self
action:@selector(saveWasPressed:)]; action:@selector(saveWasPressed:)
saveItem.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"save"); 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,8 +268,8 @@ 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) {
@ -278,8 +278,8 @@ NS_ASSUME_NONNULL_BEGIN
@"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]];

@ -118,6 +118,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
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")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block")
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[self blockPhoneNumbers:phoneNumbers [self blockPhoneNumbers:phoneNumbers
@ -130,17 +131,16 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
} }
}]; }];
}]; }];
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];
} }
@ -169,6 +169,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
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")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block")
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[self blockGroup:groupThread [self blockGroup:groupThread
@ -181,17 +182,16 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
} }
}]; }];
}]; }];
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,8 +333,10 @@ 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(
@"BLOCK_LIST_UNBLOCK_BUTTON", @"Button label for the 'unblock' button")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock")
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[BlockListUIUtils unblockPhoneNumbers:phoneNumbers [BlockListUIUtils unblockPhoneNumbers:phoneNumbers
@ -347,17 +349,16 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
} }
}]; }];
}]; }];
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,8 +407,9 @@ 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")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock")
style:UIAlertActionStyleDestructive style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *_Nonnull action) { handler:^(UIAlertAction *_Nonnull action) {
[BlockListUIUtils unblockGroup:groupModel [BlockListUIUtils unblockGroup:groupModel
@ -420,17 +422,16 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
} }
}]; }];
}]; }];
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