Add accessibility identifiers to debug log popups.

This commit is contained in:
Matthew Chen 2019-03-20 10:56:45 -04:00
parent 81508e9d02
commit f37a3059fa
4 changed files with 102 additions and 42 deletions

View File

@ -555,16 +555,22 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
uint32_t screenLockTimeout = (uint32_t)round(timeoutValue.doubleValue);
NSString *screenLockTimeoutString = [self formatScreenLockTimeout:screenLockTimeout useShortFormat:NO];
[controller addAction:[UIAlertAction actionWithTitle:screenLockTimeoutString
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[OWSScreenLock.sharedManager
setScreenLockTimeout:screenLockTimeout];
}]];
UIAlertAction *action =
[UIAlertAction actionWithTitle:screenLockTimeoutString
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *ignore) {
[OWSScreenLock.sharedManager setScreenLockTimeout:screenLockTimeout];
}];
action.accessibilityIdentifier = [NSString stringWithFormat:@"settings.privacy.timeout.%@", timeoutValue];
[controller addAction:action];
}
[controller addAction:[OWSAlerts cancelAction]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentViewController:controller animated:YES completion:nil];
[fromViewController presentViewController:controller
animated:YES
completion:^{
[controller applyAccessibilityIdentifiers];
}];
}
- (NSString *)formatScreenLockTimeout:(NSInteger)value useShortFormat:(BOOL)useShortFormat

View File

@ -319,17 +319,20 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
alertControllerWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_TITLE", @"Title of the debug log alert.")
message:NSLocalizedString(@"DEBUG_LOG_ALERT_MESSAGE", @"Message of the debug log alert.")
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_EMAIL",
@"Label for the 'email debug log' option of the debug log alert.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager submitEmail:url];
[alert
addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_EMAIL",
@"Label for the 'email debug log' option of the debug log alert.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"send_email")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager submitEmail:url];
completion();
}]];
completion();
}]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_COPY_LINK",
@"Label for the 'copy link' option of the debug log alert.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"copy_link")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
UIPasteboard *pb = [UIPasteboard generalPasteboard];
@ -341,27 +344,32 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
[alert
addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SEND_TO_SELF",
@"Label for the 'send to self' option of the debug log alert.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"send_to_self")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager sendToSelf:url];
}]];
[alert addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SEND_TO_LAST_THREAD",
@"Label for the 'send to last thread' option of the debug log alert.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager sendToMostRecentThread:url];
}]];
[alert addAction:[UIAlertAction actionWithTitle:
NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SEND_TO_LAST_THREAD",
@"Label for the 'send to last thread' option of the debug log alert.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"send_to_last_thread")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager sendToMostRecentThread:url];
}]];
#endif
[alert addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_BUG_REPORT",
@"Label for the 'Open a Bug Report' option of the debug log alert.")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager prepareRedirection:url completion:completion];
}]];
[alert
addAction:
[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_BUG_REPORT",
@"Label for the 'Open a Bug Report' option of the debug log alert.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"submit_bug_report")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[Pastelog.sharedManager prepareRedirection:url completion:completion];
}]];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"DEBUG_LOG_ALERT_OPTION_SHARE",
@"Label for the 'Share' option of the debug log alert.")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"share")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[AttachmentSharing showShareUIForText:url.absoluteString
@ -370,7 +378,11 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *presentingViewController
= UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
[presentingViewController presentViewController:alert animated:NO completion:nil];
[presentingViewController presentViewController:alert
animated:NO
completion:^{
[alert applyAccessibilityIdentifiers];
}];
}];
}
@ -507,10 +519,15 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
message:message
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok")
style:UIAlertActionStyleDefault
handler:nil]];
UIViewController *presentingViewController = UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
[presentingViewController presentViewController:alert animated:NO completion:nil];
[presentingViewController presentViewController:alert
animated:NO
completion:^{
[alert applyAccessibilityIdentifiers];
}];
}
#pragma mark Logs submission
@ -561,18 +578,25 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
message:NSLocalizedString(@"DEBUG_LOG_GITHUB_ISSUE_ALERT_MESSAGE",
@"Message of the alert before redirecting to GitHub Issues.")
preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[UIApplication.sharedApplication
openURL:[NSURL URLWithString:[[NSBundle mainBundle]
objectForInfoDictionaryKey:@"LOGS_URL"]]];
[alert
addAction:[UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"")
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action) {
[UIApplication.sharedApplication
openURL:[NSURL
URLWithString:[[NSBundle mainBundle]
objectForInfoDictionaryKey:@"LOGS_URL"]]];
completion();
}]];
completion();
}]];
UIViewController *presentingViewController = UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
[presentingViewController presentViewController:alert animated:NO completion:nil];
[presentingViewController presentViewController:alert
animated:NO
completion:^{
[alert applyAccessibilityIdentifiers];
}];
}
- (void)sendToSelf:(NSURL *)url

View File

@ -156,6 +156,17 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value);
@end
#pragma mark -
@interface UIAlertAction (OWS)
+ (instancetype)actionWithTitle:(nullable NSString *)title
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
style:(UIAlertActionStyle)style
handler:(void (^__nullable)(UIAlertAction *action))handler;
@end
#pragma mark - Macros
CGFloat CGHairlineWidth(void);

View File

@ -2,9 +2,10 @@
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "UIView+OWS.h"
#import "OWSMath.h"
#import "UIView+OWS.h"
#import <SignalCoreKit/iOSVersions.h>
#import <SignalMessaging/SignalMessaging-Swift.h>
#import <SignalServiceKit/AppContext.h>
NS_ASSUME_NONNULL_BEGIN
@ -594,6 +595,24 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
@end
#pragma mark -
@implementation UIAlertAction (OWS)
+ (instancetype)actionWithTitle:(nullable NSString *)title
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
style:(UIAlertActionStyle)style
handler:(void (^__nullable)(UIAlertAction *action))handler
{
UIAlertAction *action = [UIAlertAction actionWithTitle:title style:style handler:handler];
action.accessibilityIdentifier = accessibilityIdentifier;
return action;
}
@end
#pragma mark -
CGFloat CGHairlineWidth()
{
return 1.f / UIScreen.mainScreen.scale;