Add accessibility identifiers to notification settings views.

This commit is contained in:
Matthew Chen 2019-03-19 16:17:10 -04:00
parent 02340864f8
commit b48e204b90
7 changed files with 79 additions and 25 deletions

View File

@ -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:^{

View File

@ -8,6 +8,7 @@
#import <SignalMessaging/Environment.h>
#import <SignalMessaging/OWSPreferences.h>
#import <SignalMessaging/OWSSounds.h>
#import <SignalMessaging/UIUtil.h>
@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];

View File

@ -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 <AVFoundation/AVFoundation.h>
#import <SignalMessaging/OWSAudioPlayer.h>
#import <SignalMessaging/OWSSounds.h>
#import <SignalMessaging/UIUtil.h>
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];
}

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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";