Add accessibility identifiers to notification settings views.

pull/2/head
Matthew Chen 6 years ago
parent 02340864f8
commit b48e204b90

@ -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" #import "NotificationSettingsOptionsViewController.h"
@ -40,6 +40,8 @@
if (selectedNotifType == notificationType) { if (selectedNotifType == notificationType) {
cell.accessoryType = UITableViewCellAccessoryCheckmark; cell.accessoryType = UITableViewCellAccessoryCheckmark;
} }
cell.accessibilityIdentifier = SUBVIEW_ACCESSIBILITY_IDENTIFIER(
self, NSStringForNotificationType(notificationType));
return cell; return cell;
} }
actionBlock:^{ actionBlock:^{

@ -8,6 +8,7 @@
#import <SignalMessaging/Environment.h> #import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSPreferences.h> #import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/OWSSounds.h> #import <SignalMessaging/OWSSounds.h>
#import <SignalMessaging/UIUtil.h>
@implementation NotificationSettingsViewController @implementation NotificationSettingsViewController
@ -47,6 +48,7 @@
NSLocalizedString(@"SETTINGS_ITEM_NOTIFICATION_SOUND", NSLocalizedString(@"SETTINGS_ITEM_NOTIFICATION_SOUND",
@"Label for settings view that allows user to change the notification sound.") @"Label for settings view that allows user to change the notification sound.")
detailText:[OWSSounds displayNameForSound:[OWSSounds globalNotificationSound]] detailText:[OWSSounds displayNameForSound:[OWSSounds globalNotificationSound]]
accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"message_sound")
actionBlock:^{ actionBlock:^{
OWSSoundSettingsViewController *vc = [OWSSoundSettingsViewController new]; OWSSoundSettingsViewController *vc = [OWSSoundSettingsViewController new];
[weakSelf.navigationController pushViewController:vc animated:YES]; [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 " @"Table cell switch label. When disabled, Signal will not play notification sounds while the app is in the "
@"foreground."); @"foreground.");
[soundsSection addItem:[OWSTableItem switchItemWithText:inAppSoundsLabelText [soundsSection addItem:[OWSTableItem switchItemWithText:inAppSoundsLabelText
isOnBlock:^{ accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"in_app_sounds")
return [prefs soundInForeground]; isOnBlock:^{
} return [prefs soundInForeground];
target:weakSelf }
selector:@selector(didToggleSoundNotificationsSwitch:)]]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleSoundNotificationsSwitch:)]];
[contents addSection:soundsSection]; [contents addSection:soundsSection];
OWSTableSection *backgroundSection = [OWSTableSection new]; OWSTableSection *backgroundSection = [OWSTableSection new];
backgroundSection.headerTitle = NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_TITLE", @"table section header"); backgroundSection.headerTitle = NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_TITLE", @"table section header");
[backgroundSection [backgroundSection
addItem:[OWSTableItem addItem:[OWSTableItem
disclosureItemWithText:NSLocalizedString(@"NOTIFICATIONS_SHOW", nil) disclosureItemWithText:NSLocalizedString(@"NOTIFICATIONS_SHOW", nil)
detailText:[prefs nameForNotificationPreviewType:[prefs notificationPreviewType]] detailText:[prefs nameForNotificationPreviewType:[prefs notificationPreviewType]]
actionBlock:^{ accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, @"options")
NotificationSettingsOptionsViewController *vc = actionBlock:^{
[NotificationSettingsOptionsViewController new]; NotificationSettingsOptionsViewController *vc =
[weakSelf.navigationController pushViewController:vc animated:YES]; [NotificationSettingsOptionsViewController new];
}]]; [weakSelf.navigationController pushViewController:vc animated:YES];
}]];
backgroundSection.footerTitle backgroundSection.footerTitle
= NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_DESCRIPTION", @"table section footer"); = NSLocalizedString(@"SETTINGS_NOTIFICATION_CONTENT_DESCRIPTION", @"table section footer");
[contents addSection:backgroundSection]; [contents addSection:backgroundSection];

@ -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 "OWSSoundSettingsViewController.h"
#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/UIUtil.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@ -89,15 +90,19 @@ NS_ASSUME_NONNULL_BEGIN
}(); }();
if (sound == self.currentSound) { if (sound == self.currentSound) {
item = [OWSTableItem checkmarkItemWithText:soundLabelText item = [OWSTableItem
actionBlock:^{ checkmarkItemWithText:soundLabelText
[weakSelf soundWasSelected:sound]; accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, [OWSSounds displayNameForSound:sound])
}]; actionBlock:^{
[weakSelf soundWasSelected:sound];
}];
} else { } else {
item = [OWSTableItem actionItemWithText:soundLabelText item = [OWSTableItem
actionBlock:^{ actionItemWithText:soundLabelText
[weakSelf soundWasSelected:sound]; accessibilityIdentifier:SUBVIEW_ACCESSIBILITY_IDENTIFIER(self, [OWSSounds displayNameForSound:sound])
}]; actionBlock:^{
[weakSelf soundWasSelected:sound];
}];
} }
[soundsSection addItem:item]; [soundsSection addItem:item];
} }

@ -91,6 +91,10 @@ typedef BOOL (^OWSTableSwitchBlock)(void);
+ (OWSTableItem *)checkmarkItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)checkmarkItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)checkmarkItemWithText:(NSString *)text
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)itemWithText:(NSString *)text + (OWSTableItem *)itemWithText:(NSString *)text
actionBlock:(nullable OWSTableActionBlock)actionBlock actionBlock:(nullable OWSTableActionBlock)actionBlock
accessoryType:(UITableViewCellAccessoryType)accessoryType; accessoryType:(UITableViewCellAccessoryType)accessoryType;
@ -103,6 +107,10 @@ typedef BOOL (^OWSTableSwitchBlock)(void);
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; + (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;
+ (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight; + (OWSTableItem *)softCenterLabelItemWithText:(NSString *)text customRowHeight:(CGFloat)customRowHeight;

@ -182,7 +182,17 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)checkmarkItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock + (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 + (OWSTableItem *)itemWithText:(NSString *)text
@ -290,6 +300,13 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
} }
+ (OWSTableItem *)actionItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock + (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(text.length > 0);
OWSAssertDebug(actionBlock); OWSAssertDebug(actionBlock);
@ -299,6 +316,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
item.customCellBlock = ^{ item.customCellBlock = ^{
UITableViewCell *cell = [OWSTableItem newCell]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.accessibilityIdentifier = accessibilityIdentifier;
return cell; return cell;
}; };
return item; return item;

@ -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 NS_ASSUME_NONNULL_BEGIN
@ -13,6 +13,8 @@ typedef NS_ENUM(NSUInteger, NotificationType) {
NotificationNamePreview, NotificationNamePreview,
}; };
NSString *NSStringForNotificationType(NotificationType value);
// Used when migrating logging to NSUserDefaults. // Used when migrating logging to NSUserDefaults.
extern NSString *const OWSPreferencesSignalDatabaseCollection; extern NSString *const OWSPreferencesSignalDatabaseCollection;
extern NSString *const OWSPreferencesKeyEnableDebugLog; extern NSString *const OWSPreferencesKeyEnableDebugLog;

@ -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" #import "OWSPreferences.h"
@ -14,6 +14,18 @@
NS_ASSUME_NONNULL_BEGIN 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 OWSPreferencesSignalDatabaseCollection = @"SignalPreferences";
NSString *const OWSPreferencesCallLoggingDidChangeNotification = @"OWSPreferencesCallLoggingDidChangeNotification"; NSString *const OWSPreferencesCallLoggingDidChangeNotification = @"OWSPreferencesCallLoggingDidChangeNotification";

Loading…
Cancel
Save