Respond to CR.

This commit is contained in:
Matthew Chen 2019-03-21 10:26:38 -04:00
parent 1a80f0c293
commit c9d62f47cc
10 changed files with 67 additions and 95 deletions

View File

@ -165,7 +165,7 @@
[accessoryLabel sizeToFit];
cell.accessoryView = accessoryLabel;
cell.accessibilityIdentifier
= SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"network_status");
= SUBVIEW_ACCESSIBILITY_IDENTIFIER(AppSettingsViewController, @"network_status");
return cell;
}
actionBlock:nil]];

View File

@ -96,8 +96,8 @@ NS_ASSUME_NONNULL_BEGIN
itemWithCustomCellBlock:^{
ContactTableViewCell *cell = [ContactTableViewCell new];
[cell configureWithRecipientId:phoneNumber];
cell.accessibilityIdentifier
= SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"user");
cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(
BlockListViewController, @"user");
return cell;
}
customRowHeight:UITableViewAutomaticDimension

View File

@ -40,8 +40,9 @@
if (selectedNotifType == notificationType) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(
self, NSStringForNotificationType(notificationType));
cell.accessibilityIdentifier
= SUBVIEW_ACCESSIBILITY_IDENTIFIER(NotificationSettingsOptionsViewController,
NSStringForNotificationType(notificationType));
return cell;
}
actionBlock:^{

View File

@ -327,7 +327,7 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1;
cell.detailTextLabel.text
= NSLocalizedString(@"LINK_NEW_DEVICE_SUBTITLE", @"Subheading for 'Link New Device' navigation");
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"add");
cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(OWSLinkedDevicesTableViewController, @"add");
return cell;
} else if (indexPath.section == OWSLinkedDevicesTableViewControllerSectionExistingDevices) {
OWSDeviceTableViewCell *cell =

View File

@ -411,13 +411,13 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
- (void)clearHistoryLogs
{
UIAlertController *alertController =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:nil
message:NSLocalizedString(@"SETTINGS_DELETE_HISTORYLOG_CONFIRMATION",
@"Alert message before user confirms clearing history")
preferredStyle:UIAlertControllerStyleAlert];
[alertController addAction:[OWSAlerts cancelAction]];
[alert addAction:[OWSAlerts cancelAction]];
UIAlertAction *deleteAction =
[UIAlertAction actionWithTitle:
@ -428,13 +428,9 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
handler:^(UIAlertAction *_Nonnull action) {
[self deleteThreadsAndMessages];
}];
[alertController addAction:deleteAction];
[alert addAction:deleteAction];
[self presentViewController:alertController
animated:true
completion:^{
[alertController applyAccessibilityIdentifiers];
}];
[self presentAlert:alert animated:YES];
}
- (void)deleteThreadsAndMessages
@ -552,7 +548,7 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
{
OWSLogInfo(@"");
UIAlertController *controller = [UIAlertController
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:NSLocalizedString(@"SETTINGS_SCREEN_LOCK_ACTIVITY_TIMEOUT",
@"Label for the 'screen lock activity timeout' setting of the privacy settings.")
message:nil
@ -568,15 +564,11 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[OWSScreenLock.sharedManager setScreenLockTimeout:screenLockTimeout];
}];
action.accessibilityIdentifier = [NSString stringWithFormat:@"settings.privacy.timeout.%@", timeoutValue];
[controller addAction:action];
[alert addAction:action];
}
[controller addAction:[OWSAlerts cancelAction]];
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *fromViewController = [[UIApplication sharedApplication] frontmostViewController];
[fromViewController presentViewController:controller
animated:YES
completion:^{
[controller applyAccessibilityIdentifiers];
}];
[fromViewController presentAlert:alert animated:YES];
}
- (NSString *)formatScreenLockTimeout:(NSInteger)value useShortFormat:(BOOL)useShortFormat

View File

@ -297,7 +297,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
}
__weak ProfileViewController *weakSelf = self;
UIAlertController *controller = [UIAlertController
UIAlertController *alert = [UIAlertController
alertControllerWithTitle:
NSLocalizedString(@"NEW_GROUP_VIEW_UNSAVED_CHANGES_TITLE",
@"The alert title if user tries to exit the new group view without saving changes.")
@ -313,14 +313,10 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
[weakSelf profileCompletedOrSkipped];
}];
discardAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"discard");
[controller addAction:discardAction];
[alert addAction:discardAction];
[controller addAction:[OWSAlerts cancelAction]];
[self presentViewController:controller
animated:YES
completion:^{
[controller applyAccessibilityIdentifiers];
}];
[alert addAction:[OWSAlerts cancelAction]];
[self presentAlert:alert animated:YES];
}
- (void)avatarTapped

View File

@ -378,11 +378,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
[alert addAction:[OWSAlerts cancelAction]];
UIViewController *presentingViewController
= UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
[presentingViewController presentViewController:alert
animated:NO
completion:^{
[alert applyAccessibilityIdentifiers];
}];
[presentingViewController presentAlert:alert animated:NO];
}];
}
@ -523,11 +519,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
style:UIAlertActionStyleDefault
handler:nil]];
UIViewController *presentingViewController = UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
[presentingViewController presentViewController:alert
animated:NO
completion:^{
[alert applyAccessibilityIdentifiers];
}];
[presentingViewController presentAlert:alert animated:NO];
}
#pragma mark Logs submission
@ -592,11 +584,7 @@ typedef void (^DebugLogUploadFailure)(DebugLogUploader *uploader, NSError *error
completion();
}]];
UIViewController *presentingViewController = UIApplication.sharedApplication.frontmostViewControllerIgnoringAlerts;
[presentingViewController presentViewController:alert
animated:NO
completion:^{
[alert applyAccessibilityIdentifiers];
}];
[presentingViewController presentAlert:alert animated:NO];
}
- (void)sendToSelf:(NSURL *)url

View File

@ -11,20 +11,17 @@ import Foundation
public class func showNoMicrophonePermissionAlert() {
let alertTitle = NSLocalizedString("CALL_AUDIO_PERMISSION_TITLE", comment: "Alert title when calling and permissions for microphone are missing")
let alertMessage = NSLocalizedString("CALL_AUDIO_PERMISSION_MESSAGE", comment: "Alert message when calling and permissions for microphone are missing")
let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert)
let alert = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: .alert)
let dismissAction = UIAlertAction(title: CommonStrings.dismissButton, style: .cancel)
dismissAction.accessibilityIdentifier = "OWSAlerts.\("dismiss")"
alertController.addAction(dismissAction)
alert.addAction(dismissAction)
if let settingsAction = CurrentAppContext().openSystemSettingsAction {
settingsAction.accessibilityIdentifier = "OWSAlerts.\("settings")"
alertController.addAction(settingsAction)
alert.addAction(settingsAction)
}
CurrentAppContext().frontmostViewController()?.present(alertController, animated: true,
completion: {
alertController.applyAccessibilityIdentifiers()
})
CurrentAppContext().frontmostViewController()?.presentAlert(alert)
}
@objc
@ -33,10 +30,7 @@ import Foundation
owsFailDebug("frontmostViewController was unexpectedly nil")
return
}
frontmostViewController.present(alert, animated: true,
completion: {
alert.applyAccessibilityIdentifiers()
})
frontmostViewController.presentAlert(alert)
}
@objc
@ -67,10 +61,7 @@ import Foundation
let okAction = UIAlertAction(title: actionTitle, style: .default, handler: buttonAction)
okAction.accessibilityIdentifier = "OWSAlerts.\("ok")"
alert.addAction(okAction)
fromViewController?.present(alert, animated: true,
completion: {
alert.applyAccessibilityIdentifiers()
})
fromViewController?.presentAlert(alert)
}
@objc
@ -85,10 +76,7 @@ import Foundation
okAction.accessibilityIdentifier = "OWSAlerts.\("ok")"
alert.addAction(okAction)
CurrentAppContext().frontmostViewController()?.present(alert, animated: true,
completion: {
alert.applyAccessibilityIdentifiers()
})
CurrentAppContext().frontmostViewController()?.presentAlert(alert)
}
@objc

View File

@ -13,6 +13,8 @@ public extension UIEdgeInsets {
}
}
// MARK: -
@objc
public extension UINavigationController {
@objc
@ -45,6 +47,8 @@ public extension UINavigationController {
}
}
// MARK: -
extension UIView {
public func renderAsImage() -> UIImage? {
return renderAsImage(opaque: false, scale: UIScreen.main.scale)
@ -124,6 +128,21 @@ extension UIView {
}
}
// MARK: -
extension UIViewController {
@objc
public func presentAlert(_ alert: UIAlertController, animated: Bool = true) {
self.present(alert,
animated: animated,
completion: {
alert.applyAccessibilityIdentifiers()
})
}
}
// MARK: -
public extension CGFloat {
public func clamp(_ minValue: CGFloat, _ maxValue: CGFloat) -> CGFloat {
return CGFloatClamp(self, minValue, maxValue)
@ -155,6 +174,8 @@ public extension CGFloat {
}
}
// MARK: -
public extension Int {
public func clamp(_ minValue: Int, _ maxValue: Int) -> Int {
assert(minValue <= maxValue)
@ -163,6 +184,8 @@ public extension Int {
}
}
// MARK: -
public extension CGPoint {
public func toUnitCoordinates(viewBounds: CGRect, shouldClamp: Bool) -> CGPoint {
return CGPoint(x: (x - viewBounds.origin.x).inverseLerp(0, viewBounds.width, shouldClamp: shouldClamp),
@ -233,6 +256,8 @@ public extension CGPoint {
}
}
// MARK: -
public extension CGSize {
var aspectRatio: CGFloat {
guard self.height > 0 else {
@ -251,6 +276,8 @@ public extension CGSize {
}
}
// MARK: -
public extension CGRect {
public var center: CGPoint {
return CGPoint(x: midX, y: midY)
@ -273,6 +300,8 @@ public extension CGRect {
}
}
// MARK: -
public extension CGAffineTransform {
public static func translate(_ point: CGPoint) -> CGAffineTransform {
return CGAffineTransform(translationX: point.x, y: point.y)
@ -295,6 +324,8 @@ public extension CGAffineTransform {
}
}
// MARK: -
public extension UIBezierPath {
public func addRegion(withPoints points: [CGPoint]) {
guard let first = points.first else {

View File

@ -142,12 +142,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
[fromViewController presentAlert:actionSheetController animated:YES];
}
+ (void)showBlockGroupActionSheet:(TSGroupThread *)groupThread
@ -198,12 +193,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
[fromViewController presentAlert:actionSheetController animated:YES];
}
+ (void)blockPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
@ -369,12 +359,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
[fromViewController presentAlert:actionSheetController animated:YES];
}
+ (void)unblockPhoneNumbers:(NSArray<NSString *> *)phoneNumbers
@ -448,12 +433,7 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
}];
dismissAction.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"dismiss");
[actionSheetController addAction:dismissAction];
[fromViewController presentViewController:actionSheetController
animated:YES
completion:^{
[actionSheetController applyAccessibilityIdentifiers];
}];
[fromViewController presentAlert:actionSheetController animated:YES];
}
+ (void)unblockGroup:(TSGroupModel *)groupModel
@ -490,19 +470,15 @@ typedef void (^BlockAlertCompletionBlock)(UIAlertAction *action);
OWSAssertDebug(title.length > 0);
OWSAssertDebug(fromViewController);
UIAlertController *controller =
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
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];
}];
[alert addAction:okAction];
[fromViewController presentAlert:alert animated:YES];
}
+ (NSString *)formatDisplayNameForAlertTitle:(NSString *)displayName