Add accessibility identifiers to blocklist popups.

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

@ -144,6 +144,7 @@
346941A3215D2EE400B5BFAD /* Theme.m in Sources */ = {isa = PBXBuildFile; fileRef = 3469419F215D2EE400B5BFAD /* Theme.m */; };
346941A4215D2EE400B5BFAD /* OWSConversationColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 346941A0215D2EE400B5BFAD /* OWSConversationColor.h */; settings = {ATTRIBUTES = (Public, ); }; };
346B66311F4E29B200E5122F /* CropScaleImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */; };
346E35BE224283B100E55D5F /* UIAlertController+OWS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346E35BD224283B000E55D5F /* UIAlertController+OWS.swift */; };
346E9D5421B040B700562252 /* RegistrationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 346E9D5321B040B600562252 /* RegistrationController.swift */; };
347850311FD7494A007B8332 /* dripicons-v2.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5B1E787A9800DF2FB9 /* dripicons-v2.ttf */; };
347850321FD7494A007B8332 /* ElegantIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 34330A5D1E787BD800DF2FB9 /* ElegantIcons.ttf */; };
@ -833,6 +834,7 @@
3469419F215D2EE400B5BFAD /* Theme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Theme.m; sourceTree = "<group>"; };
346941A0215D2EE400B5BFAD /* OWSConversationColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OWSConversationColor.h; sourceTree = "<group>"; };
346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CropScaleImageViewController.swift; sourceTree = "<group>"; };
346E35BD224283B000E55D5F /* UIAlertController+OWS.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIAlertController+OWS.swift"; sourceTree = "<group>"; };
346E9D5321B040B600562252 /* RegistrationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RegistrationController.swift; sourceTree = "<group>"; };
347850561FD86544007B8332 /* SAEFailedViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SAEFailedViewController.swift; sourceTree = "<group>"; };
3478505A1FD999D5007B8332 /* et */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = et; path = translations/et.lproj/Localizable.strings; sourceTree = "<group>"; };
@ -1797,7 +1799,6 @@
346129CE1FD207F200532771 /* Views */ = {
isa = PBXGroup;
children = (
4523149F1F7E9E18003A428C /* DirectionalPanGestureRecognizer.swift */,
34AC0A0C211B39EA00997B47 /* AvatarImageView.swift */,
34AC0A07211B39E900997B47 /* CommonStrings.swift */,
34AC0A0A211B39EA00997B47 /* ContactCellView.h */,
@ -1806,6 +1807,7 @@
34AC0A02211B39E700997B47 /* ContactsViewHelper.m */,
34AC09FC211B39E700997B47 /* ContactTableViewCell.h */,
34AC09FF211B39E700997B47 /* ContactTableViewCell.m */,
4523149F1F7E9E18003A428C /* DirectionalPanGestureRecognizer.swift */,
34AC0A00211B39E700997B47 /* DisappearingTimerConfigurationView.swift */,
4CA46F49219C78050038ABDE /* GalleryRailView.swift */,
34AC0A08211B39E900997B47 /* GradientView.swift */,
@ -1826,6 +1828,7 @@
34AC0A0D211B39EA00997B47 /* ThreadViewHelper.h */,
34AC0A0B211B39EA00997B47 /* ThreadViewHelper.m */,
4CA5F792211E1F06008C2708 /* Toast.swift */,
346E35BD224283B000E55D5F /* UIAlertController+OWS.swift */,
34AC0A04211B39E800997B47 /* VideoPlayerView.swift */,
);
path = Views;
@ -3417,6 +3420,7 @@
34480B621FD0A98800BC14EF /* UIColor+OWS.m in Sources */,
4C20B2B720CA0034001BAC90 /* ThreadViewModel.swift in Sources */,
34BBC857220C7ADA00857249 /* ImageEditorItem.swift in Sources */,
346E35BE224283B100E55D5F /* UIAlertController+OWS.swift in Sources */,
34480B641FD0A98800BC14EF /* UIView+OWS.m in Sources */,
34AC0A1C211B39EA00997B47 /* OWSFlatButton.swift in Sources */,
340872D822397F4600CB25B0 /* AttachmentCaptionViewController.swift in Sources */,

@ -0,0 +1,36 @@
//
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
import Foundation
extension UIAlertController {
@objc
public func applyAccessibilityIdentifiers() {
for action in actions {
guard let view = action.value(forKey: "__representer") as? UIView else {
owsFailDebug("Missing representer.")
return
}
view.accessibilityIdentifier = action.accessibilityIdentifier
}
}
}
// MARK: -
extension UIAlertAction {
private struct AssociatedKeys {
static var AccessibilityIdentifier = "ows_accessibilityIdentifier"
}
@objc
public var accessibilityIdentifier: String? {
get {
return objc_getAssociatedObject(self, &AssociatedKeys.AccessibilityIdentifier) as? String
}
set {
objc_setAssociatedObject(self, &AssociatedKeys.AccessibilityIdentifier, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
}
}
}

@ -1,5 +1,5 @@
//
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
// Copyright (c) 2019 Open Whisper Systems. All rights reserved.
//
#import "BlockListUIUtils.h"
@ -130,6 +130,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
}];
blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block");
[actionSheetController addAction:blockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
@ -139,9 +140,14 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
completionBlock(NO);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController animated:YES completion:nil];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
}
+ (void)showBlockGroupActionSheet:(TSGroupThread *)groupThread
@ -180,6 +186,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
}];
blockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"block");
[actionSheetController addAction:blockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
@ -189,9 +196,14 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
completionBlock(NO);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController animated:YES completion:nil];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
}
+ (void)blockPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
@ -345,6 +357,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
}];
unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock");
[actionSheetController addAction:unblockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
@ -354,9 +367,14 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
completionBlock(YES);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController animated:YES completion:nil];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
}
+ (void)unblockPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
@ -418,6 +436,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}
}];
}];
unblockAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"unblock");
[actionSheetController addAction:unblockAction];
UIAlertAction *dismissAction = [UIAlertAction actionWithTitle:CommonStrings.cancelButton
@ -427,9 +446,14 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
completionBlock(YES);
}
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController animated:YES completion:nil];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
}
+ (void)unblockGroup:(TSGroupModel *)groupModel
@ -469,10 +493,16 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
UIAlertController *controller =
[UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
[controller addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDefault
handler:completionBlock]];
[fromViewController presentViewController:controller animated:YES completion:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil)
style:UIAlertActionStyleDefault
handler:completionBlock];
okAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"ok");
[controller addAction:okAction];
[fromViewController presentViewController:controller
animated:YES
completion:^{
[controller applyAccessibilityIdentifiers];
}];
}
+ (NSString *)formatDisplayNameForAlertTitle:(NSString *)displayName

Loading…
Cancel
Save