diff --git a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m index 05eca55a7..2e7da11a3 100644 --- a/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/NotificationSettingsOptionsViewController.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "NotificationSettingsOptionsViewController.h" @@ -40,6 +40,8 @@ if (selectedNotifType == notificationType) { cell.accessoryType = UITableViewCellAccessoryCheckmark; } + cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER( + self, NSStringForNotificationType(notificationType)); return cell; } actionBlock:^{ diff --git a/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m index 7b9f0cfa2..5ac5722c7 100644 --- a/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/NotificationSettingsViewController.m @@ -8,6 +8,7 @@ #import #import #import +#import @implementation NotificationSettingsViewController @@ -47,6 +48,7 @@ NSLocalizedString(@"SETTINGS_ITEM_NOTIFICATION_SOUND", @"Label for settings view that allows user to change the notification sound.") detailText:[OWSSounds displayNameForSound:[OWSSounds globalNotificationSound]] + accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"message_sound") actionBlock:^{ OWSSoundSettingsViewController *vc = [OWSSoundSettingsViewController new]; [weakSelf.navigationController pushViewController:vc animated:YES]; @@ -56,24 +58,29 @@ @"Table cell switch label. When disabled, Signal will not play notification sounds while the app is in the " @"foreground."); [soundsSection addItem:[OWSTableItem switchItemWithText:inAppSoundsLabelText - isOnBlock:^{ - return [prefs soundInForeground]; - } - target:weakSelf - selector:@selector(didToggleSoundNotificationsSwitch:)]]; + accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"in_app_sounds") + isOnBlock:^{ + return [prefs soundInForeground]; + } + isEnabledBlock:^{ + return YES; + } + target:weakSelf + selector:@selector(didToggleSoundNotificationsSwitch:)]]; [contents addSection:soundsSection]; OWSTableSection *backgroundSection = [OWSTableSection new]; backgroundSection.headerTitle = NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_TITLE", @"table section header"); [backgroundSection addItem:[OWSTableItem - disclosureItemWithText:NSLocalizedString(@"NOTIFICATIONS_SHOW", nil) - detailText:[prefs nameForNotificationPreviewType:[prefs notificationPreviewType]] - actionBlock:^{ - NotificationSettingsOptionsViewController *vc = - [NotificationSettingsOptionsViewController new]; - [weakSelf.navigationController pushViewController:vc animated:YES]; - }]]; + disclosureItemWithText:NSLocalizedString(@"NOTIFICATIONS_SHOW", nil) + detailText:[prefs nameForNotificationPreviewType:[prefs notificationPreviewType]] + accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"options") + actionBlock:^{ + NotificationSettingsOptionsViewController *vc = + [NotificationSettingsOptionsViewController new]; + [weakSelf.navigationController pushViewController:vc animated:YES]; + }]]; backgroundSection.footerTitle = NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_DESCRIPTION", @"table section footer"); [contents addSection:backgroundSection]; diff --git a/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m b/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m index c218cd34d..659a30514 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSSoundSettingsViewController.m @@ -1,11 +1,12 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSSoundSettingsViewController.h" #import #import #import +#import NS_ASSUME_NONNULL_BEGIN @@ -89,15 +90,19 @@ NS_ASSUME_NONNULL_BEGIN }(); if (sound == self.currentSound) { - item = [OWSTableItem checkmarkItemWithText:soundLabelText - actionBlock:^{ - [weakSelf soundWasSelected:sound]; - }]; + item = [OWSTableItem + checkmarkItemWithText:soundLabelText + accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, [OWSSounds displayNameForSound:sound]) + actionBlock:^{ + [weakSelf soundWasSelected:sound]; + }]; } else { - item = [OWSTableItem actionItemWithText:soundLabelText - actionBlock:^{ - [weakSelf soundWasSelected:sound]; - }]; + item = [OWSTableItem + actionItemWithText:soundLabelText + accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, [OWSSounds displayNameForSound:sound]) + actionBlock:^{ + [weakSelf soundWasSelected:sound]; + }]; } [soundsSection addItem:item]; } diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.h b/SignalMessaging/ViewControllers/OWSTableViewController.h index c525a2684..53942225c 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.h +++ b/SignalMessaging/ViewControllers/OWSTableViewController.h @@ -91,6 +91,10 @@ typedef BOOL (^OWSTableSwitchBlock)(void); + (OWSTableItem *)checkmarkItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; ++ (OWSTableItem *)checkmarkItemWithText:(NSString *)text + accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier + actionBlock:(nullable OWSTableActionBlock)actionBlock; + + (OWSTableItem *)itemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock accessoryType:(UITableViewCellAccessoryType)accessoryType; @@ -103,6 +107,10 @@ typedef BOOL (^OWSTableSwitchBlock)(void); + (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; ++ (OWSTableItem *)actionItemWithText:(NSString *)text + accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier + actionBlock:(nullable OWSTableActionBlock)actionBlock; + + (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text; + (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight; diff --git a/SignalMessaging/ViewControllers/OWSTableViewController.m b/SignalMessaging/ViewControllers/OWSTableViewController.m index f0625f368..921d7c563 100644 --- a/SignalMessaging/ViewControllers/OWSTableViewController.m +++ b/SignalMessaging/ViewControllers/OWSTableViewController.m @@ -182,7 +182,17 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; + (OWSTableItem *)checkmarkItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock { - return [self itemWithText:text actionBlock:actionBlock accessoryType:UITableViewCellAccessoryCheckmark]; + return [self checkmarkItemWithText:text accessibilityIdentifier:nil actionBlock:actionBlock]; +} + ++ (OWSTableItem *)checkmarkItemWithText:(NSString *)text + accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier + actionBlock:(nullable OWSTableActionBlock)actionBlock; +{ + return [self itemWithText:text + accessibilityIdentifier:accessibilityIdentifier + actionBlock:actionBlock + accessoryType:UITableViewCellAccessoryCheckmark]; } + (OWSTableItem *)itemWithText:(NSString *)text @@ -290,6 +300,13 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; } + (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock +{ + return [self actionItemWithText:text accessibilityIdentifier:nil actionBlock:actionBlock]; +} + ++ (OWSTableItem *)actionItemWithText:(NSString *)text + accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier + actionBlock:(nullable OWSTableActionBlock)actionBlock; { OWSAssertDebug(text.length > 0); OWSAssertDebug(actionBlock); @@ -299,6 +316,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f; item.customCellBlock = ^{ UITableViewCell *cell = [OWSTableItem newCell]; cell.textLabel.text = text; + cell.accessibilityIdentifier = accessibilityIdentifier; return cell; }; return item; diff --git a/SignalMessaging/utils/OWSPreferences.h b/SignalMessaging/utils/OWSPreferences.h index 5bb5c7b3d..a13ae4d1d 100644 --- a/SignalMessaging/utils/OWSPreferences.h +++ b/SignalMessaging/utils/OWSPreferences.h @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // NS_ASSUME_NONNULL_BEGIN @@ -13,6 +13,8 @@ typedef NS_ENUM(NSUInteger, NotificationType) { NotificationNamePreview, }; +NSString *NSStringForNotificationType(NotificationType value); + // Used when migrating logging to NSUserDefaults. extern NSString *const OWSPreferencesSignalDatabaseCollection; extern NSString *const OWSPreferencesKeyEnableDebugLog; diff --git a/SignalMessaging/utils/OWSPreferences.m b/SignalMessaging/utils/OWSPreferences.m index 56d736f28..287dada8f 100644 --- a/SignalMessaging/utils/OWSPreferences.m +++ b/SignalMessaging/utils/OWSPreferences.m @@ -1,5 +1,5 @@ // -// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// Copyright (c) 2019 Open Whisper Systems. All rights reserved. // #import "OWSPreferences.h" @@ -14,6 +14,18 @@ NS_ASSUME_NONNULL_BEGIN +NSString *NSStringForNotificationType(NotificationType value) +{ + switch (notificationType) { + case NotificationNamePreview: + return @"NotificationNamePreview"; + case NotificationNameNoPreview: + return @"NotificationNameNoPreview"; + case NotificationNoNameNoPreview: + return @"NotificationNoNameNoPreview"; + } +} + NSString *const OWSPreferencesSignalDatabaseCollection = @"SignalPreferences"; NSString *const OWSPreferencesCallLoggingDidChangeNotification = @"OWSPreferencesCallLoggingDidChangeNotification";