Add accessibility identifiers to privacy settings view.

pull/2/head
Matthew Chen 6 years ago
parent 99cd3f9b26
commit 79d6384bc9

@ -88,6 +88,7 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[blocklistSection [blocklistSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BLOCK_LIST_TITLE", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_BLOCK_LIST_TITLE",
@"Label for the block list section of the settings view") @"Label for the block list section of the settings view")
accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"blocklist"]
actionBlock:^{ actionBlock:^{
[weakSelf showBlocklist]; [weakSelf showBlocklist];
}]]; }]];
@ -101,11 +102,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[readReceiptsSection [readReceiptsSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_READ_RECEIPT", addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_READ_RECEIPT",
@"Label for the 'read receipts' setting.") @"Label for the 'read receipts' setting.")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"read_receipts"]
return [OWSReadReceiptManager.sharedManager areReadReceiptsEnabled]; isOnBlock:^{
} return [OWSReadReceiptManager.sharedManager areReadReceiptsEnabled];
target:weakSelf }
selector:@selector(didToggleReadReceiptsSwitch:)]]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleReadReceiptsSwitch:)]];
[contents addSection:readReceiptsSection]; [contents addSection:readReceiptsSection];
OWSTableSection *typingIndicatorsSection = [OWSTableSection new]; OWSTableSection *typingIndicatorsSection = [OWSTableSection new];
@ -116,11 +121,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[typingIndicatorsSection [typingIndicatorsSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_TYPING_INDICATORS", addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_TYPING_INDICATORS",
@"Label for the 'typing indicators' setting.") @"Label for the 'typing indicators' setting.")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"typing_indicators"]
return [SSKEnvironment.shared.typingIndicators areTypingIndicatorsEnabled]; isOnBlock:^{
} return [SSKEnvironment.shared.typingIndicators areTypingIndicatorsEnabled];
target:weakSelf }
selector:@selector(didToggleTypingIndicatorsSwitch:)]]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleTypingIndicatorsSwitch:)]];
[contents addSection:typingIndicatorsSection]; [contents addSection:typingIndicatorsSection];
OWSTableSection *screenLockSection = [OWSTableSection new]; OWSTableSection *screenLockSection = [OWSTableSection new];
@ -132,11 +141,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
addItem:[OWSTableItem addItem:[OWSTableItem
switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_LOCK_SWITCH_LABEL", switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_LOCK_SWITCH_LABEL",
@"Label for the 'enable screen lock' switch of the privacy settings.") @"Label for the 'enable screen lock' switch of the privacy settings.")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"screenlock"]
return [OWSScreenLock.sharedManager isScreenLockEnabled]; isOnBlock:^{
} return [OWSScreenLock.sharedManager isScreenLockEnabled];
target:self }
selector:@selector(isScreenLockEnabledDidChange:)]]; isEnabledBlock:^{
return YES;
}
target:self
selector:@selector(isScreenLockEnabledDidChange:)]];
[contents addSection:screenLockSection]; [contents addSection:screenLockSection];
if (OWSScreenLock.sharedManager.isScreenLockEnabled) { if (OWSScreenLock.sharedManager.isScreenLockEnabled) {
@ -145,13 +158,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
NSString *screenLockTimeoutString = [self formatScreenLockTimeout:screenLockTimeout useShortFormat:YES]; NSString *screenLockTimeoutString = [self formatScreenLockTimeout:screenLockTimeout useShortFormat:YES];
[screenLockTimeoutSection [screenLockTimeoutSection
addItem:[OWSTableItem addItem:[OWSTableItem
disclosureItemWithText: disclosureItemWithText:
NSLocalizedString(@"SETTINGS_SCREEN_LOCK_ACTIVITY_TIMEOUT", NSLocalizedString(@"SETTINGS_SCREEN_LOCK_ACTIVITY_TIMEOUT",
@"Label for the 'screen lock activity timeout' setting of the privacy settings.") @"Label for the 'screen lock activity timeout' setting of the privacy settings.")
detailText:screenLockTimeoutString detailText:screenLockTimeoutString
actionBlock:^{ accessibilityIdentifier:[NSString
[weakSelf showScreenLockTimeoutUI]; stringWithFormat:@"settings.privacy.%@", @"screen_lock_timeout"]
}]]; actionBlock:^{
[weakSelf showScreenLockTimeoutUI];
}]];
[contents addSection:screenLockTimeoutSection]; [contents addSection:screenLockTimeoutSection];
} }
@ -160,11 +175,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
screenSecuritySection.footerTitle = NSLocalizedString(@"SETTINGS_SCREEN_SECURITY_DETAIL", nil); screenSecuritySection.footerTitle = NSLocalizedString(@"SETTINGS_SCREEN_SECURITY_DETAIL", nil);
[screenSecuritySection [screenSecuritySection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_SECURITY", @"") addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_SCREEN_SECURITY", @"")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"screen_security"]
return [Environment.shared.preferences screenSecurityIsEnabled]; isOnBlock:^{
} return [Environment.shared.preferences screenSecurityIsEnabled];
target:weakSelf }
selector:@selector(didToggleScreenSecuritySwitch:)]]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleScreenSecuritySwitch:)]];
[contents addSection:screenSecuritySection]; [contents addSection:screenSecuritySection];
// Allow calls to connect directly vs. using TURN exclusively // Allow calls to connect directly vs. using TURN exclusively
@ -176,11 +195,16 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[callingSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString( [callingSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(
@"SETTINGS_CALLING_HIDES_IP_ADDRESS_PREFERENCE_TITLE", @"SETTINGS_CALLING_HIDES_IP_ADDRESS_PREFERENCE_TITLE",
@"Table cell label") @"Table cell label")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@",
return [Environment.shared.preferences doCallsHideIPAddress]; @"calling_hide_ip_address"]
} isOnBlock:^{
target:weakSelf return [Environment.shared.preferences doCallsHideIPAddress];
selector:@selector(didToggleCallsHideIPAddressSwitch:)]]; }
isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleCallsHideIPAddressSwitch:)]];
[contents addSection:callingSection]; [contents addSection:callingSection];
if (@available(iOS 11, *)) { if (@available(iOS 11, *)) {
@ -189,11 +213,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
addItem:[OWSTableItem switchItemWithText:NSLocalizedString( addItem:[OWSTableItem switchItemWithText:NSLocalizedString(
@"SETTINGS_PRIVACY_CALLKIT_SYSTEM_CALL_LOG_PREFERENCE_TITLE", @"SETTINGS_PRIVACY_CALLKIT_SYSTEM_CALL_LOG_PREFERENCE_TITLE",
@"Short table cell label") @"Short table cell label")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"callkit_history"]
return [Environment.shared.preferences isSystemCallLogEnabled]; isOnBlock:^{
} return [Environment.shared.preferences isSystemCallLogEnabled];
target:weakSelf }
selector:@selector(didToggleEnableSystemCallLogSwitch:)]]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleEnableSystemCallLogSwitch:)]];
callKitSection.footerTitle = NSLocalizedString( callKitSection.footerTitle = NSLocalizedString(
@"SETTINGS_PRIVACY_CALLKIT_SYSTEM_CALL_LOG_PREFERENCE_DESCRIPTION", @"Settings table section footer."); @"SETTINGS_PRIVACY_CALLKIT_SYSTEM_CALL_LOG_PREFERENCE_DESCRIPTION", @"Settings table section footer.");
[contents addSection:callKitSection]; [contents addSection:callKitSection];
@ -201,23 +229,32 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
OWSTableSection *callKitSection = [OWSTableSection new]; OWSTableSection *callKitSection = [OWSTableSection new];
callKitSection.footerTitle callKitSection.footerTitle
= NSLocalizedString(@"SETTINGS_SECTION_CALL_KIT_DESCRIPTION", @"Settings table section footer."); = NSLocalizedString(@"SETTINGS_SECTION_CALL_KIT_DESCRIPTION", @"Settings table section footer.");
[callKitSection addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_TITLE", [callKitSection
@"Short table cell label") addItem:[OWSTableItem switchItemWithText:NSLocalizedString(
isOnBlock:^{ @"SETTINGS_PRIVACY_CALLKIT_TITLE", @"Short table cell label")
return [Environment.shared.preferences isCallKitEnabled]; accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"callkit"]
} isOnBlock:^{
target:weakSelf return [Environment.shared.preferences isCallKitEnabled];
selector:@selector(didToggleEnableCallKitSwitch:)]]; }
isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleEnableCallKitSwitch:)]];
if (self.preferences.isCallKitEnabled) { if (self.preferences.isCallKitEnabled) {
[callKitSection [callKitSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_PRIVACY_TITLE", addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_PRIVACY_CALLKIT_PRIVACY_TITLE",
@"Label for 'CallKit privacy' preference") @"Label for 'CallKit privacy' preference")
isOnBlock:^{ accessibilityIdentifier:[NSString
return (BOOL) ! stringWithFormat:@"settings.privacy.%@", @"callkit_privacy"]
[Environment.shared.preferences isCallKitPrivacyEnabled]; isOnBlock:^{
} return (BOOL) ![Environment.shared.preferences isCallKitPrivacyEnabled];
target:weakSelf }
selector:@selector(didToggleEnableCallKitPrivacySwitch:)]]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleEnableCallKitPrivacySwitch:)]];
} }
[contents addSection:callKitSection]; [contents addSection:callKitSection];
} }
@ -236,17 +273,20 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
@"Indicates that 'two factor auth' is enabled in the privacy settings.") @"Indicates that 'two factor auth' is enabled in the privacy settings.")
: NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_DISABLED", : NSLocalizedString(@"SETTINGS_TWO_FACTOR_AUTH_DISABLED",
@"Indicates that 'two factor auth' is disabled in the privacy settings.")) @"Indicates that 'two factor auth' is disabled in the privacy settings."))
actionBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"2fa"]
[weakSelf show2FASettings]; actionBlock:^{
}]]; [weakSelf show2FASettings];
}]];
[contents addSection:twoFactorAuthSection]; [contents addSection:twoFactorAuthSection];
OWSTableSection *historyLogsSection = [OWSTableSection new]; OWSTableSection *historyLogsSection = [OWSTableSection new];
historyLogsSection.headerTitle = NSLocalizedString(@"SETTINGS_HISTORYLOG_TITLE", @"Section header"); historyLogsSection.headerTitle = NSLocalizedString(@"SETTINGS_HISTORYLOG_TITLE", @"Section header");
[historyLogsSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_CLEAR_HISTORY", @"") [historyLogsSection
actionBlock:^{ addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_CLEAR_HISTORY", @"")
[weakSelf clearHistoryLogs]; accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"clear_logs"]
}]]; actionBlock:^{
[weakSelf clearHistoryLogs];
}]];
[contents addSection:historyLogsSection]; [contents addSection:historyLogsSection];
OWSTableSection *unidentifiedDeliveryIndicatorsSection = [OWSTableSection new]; OWSTableSection *unidentifiedDeliveryIndicatorsSection = [OWSTableSection new];
@ -285,6 +325,8 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
action:@selector(didToggleUDShowIndicatorsSwitch:) action:@selector(didToggleUDShowIndicatorsSwitch:)
forControlEvents:UIControlEventValueChanged]; forControlEvents:UIControlEventValueChanged];
[cellSwitch setContentHuggingHorizontalHigh]; [cellSwitch setContentHuggingHorizontalHigh];
cellSwitch.accessibilityIdentifier =
[NSString stringWithFormat:@"settings.privacy.%@", @"sealed_sender"];
UIStackView *stackView = UIStackView *stackView =
[[UIStackView alloc] initWithArrangedSubviews:@[ label, iconView, spacer, cellSwitch ]]; [[UIStackView alloc] initWithArrangedSubviews:@[ label, iconView, spacer, cellSwitch ]];
@ -310,11 +352,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
OWSTableSection *unidentifiedDeliveryUnrestrictedSection = [OWSTableSection new]; OWSTableSection *unidentifiedDeliveryUnrestrictedSection = [OWSTableSection new];
OWSTableItem *unrestrictedAccessItem = [OWSTableItem OWSTableItem *unrestrictedAccessItem = [OWSTableItem
switchItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS", @"switch label") switchItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS", @"switch label")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"sealed_sender_unrestricted"]
return [SSKEnvironment.shared.udManager shouldAllowUnrestrictedAccessLocal]; isOnBlock:^{
} return [SSKEnvironment.shared.udManager shouldAllowUnrestrictedAccessLocal];
target:weakSelf }
selector:@selector(didToggleUDUnrestrictedAccessSwitch:)]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleUDUnrestrictedAccessSwitch:)];
[unidentifiedDeliveryUnrestrictedSection addItem:unrestrictedAccessItem]; [unidentifiedDeliveryUnrestrictedSection addItem:unrestrictedAccessItem];
unidentifiedDeliveryUnrestrictedSection.footerTitle unidentifiedDeliveryUnrestrictedSection.footerTitle
= NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", @"table section footer"); = NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", @"table section footer");
@ -324,6 +370,8 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[unidentifiedDeliveryLearnMoreSection [unidentifiedDeliveryLearnMoreSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_LEARN_MORE", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_LEARN_MORE",
@"Label for a link to more info about unidentified delivery.") @"Label for a link to more info about unidentified delivery.")
accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@",
@"sealed_sender_learn_more"]
actionBlock:^{ actionBlock:^{
NSURL *url = [NSURL URLWithString:kSealedSenderInfoURL]; NSURL *url = [NSURL URLWithString:kSealedSenderInfoURL];
OWSAssertDebug(url); OWSAssertDebug(url);
@ -335,11 +383,15 @@ static NSString *const kSealedSenderInfoURL = @"https://signal.org/blog/sealed-s
[linkPreviewsSection [linkPreviewsSection
addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_LINK_PREVIEWS", addItem:[OWSTableItem switchItemWithText:NSLocalizedString(@"SETTINGS_LINK_PREVIEWS",
@"Setting for enabling & disabling link previews.") @"Setting for enabling & disabling link previews.")
isOnBlock:^{ accessibilityIdentifier:[NSString stringWithFormat:@"settings.privacy.%@", @"link_previews"]
return [SSKPreferences areLinkPreviewsEnabled]; isOnBlock:^{
} return [SSKPreferences areLinkPreviewsEnabled];
target:weakSelf }
selector:@selector(didToggleLinkPreviewsEnabled:)]]; isEnabledBlock:^{
return YES;
}
target:weakSelf
selector:@selector(didToggleLinkPreviewsEnabled:)]];
linkPreviewsSection.headerTitle = NSLocalizedString( linkPreviewsSection.headerTitle = NSLocalizedString(
@"SETTINGS_LINK_PREVIEWS_HEADER", @"Header for setting for enabling & disabling link previews."); @"SETTINGS_LINK_PREVIEWS_HEADER", @"Header for setting for enabling & disabling link previews.");
linkPreviewsSection.footerTitle = NSLocalizedString( linkPreviewsSection.footerTitle = NSLocalizedString(

@ -72,8 +72,17 @@ typedef BOOL (^OWSTableSwitchBlock)(void);
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock; + (OWSTableItem *)disclosureItemWithText:(NSString *)text actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
detailText:(NSString *)detailText
actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text + (OWSTableItem *)disclosureItemWithText:(NSString *)text
detailText:(NSString *)detailText detailText:(NSString *)detailText
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
actionBlock:(nullable OWSTableActionBlock)actionBlock; actionBlock:(nullable OWSTableActionBlock)actionBlock;
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text + (OWSTableItem *)disclosureItemWithText:(NSString *)text
@ -115,6 +124,13 @@ typedef BOOL (^OWSTableSwitchBlock)(void);
target:(id)target target:(id)target
selector:(SEL)selector; selector:(SEL)selector;
+ (OWSTableItem *)switchItemWithText:(NSString *)text
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
isOnBlock:(OWSTableSwitchBlock)isOnBlock
isEnabledBlock:(OWSTableSwitchBlock)isEnabledBlock
target:(id)target
selector:(SEL)selector;
- (nullable UITableViewCell *)customCell; - (nullable UITableViewCell *)customCell;
- (NSNumber *)customRowHeight; - (NSNumber *)customRowHeight;

@ -170,6 +170,16 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
return [self itemWithText:text actionBlock:actionBlock accessoryType:UITableViewCellAccessoryDisclosureIndicator]; return [self itemWithText:text actionBlock:actionBlock accessoryType:UITableViewCellAccessoryDisclosureIndicator];
} }
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
actionBlock:(nullable OWSTableActionBlock)actionBlock
{
return [self itemWithText:text
accessibilityIdentifier:accessibilityIdentifier
actionBlock:actionBlock
accessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
+ (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 itemWithText:text actionBlock:actionBlock accessoryType:UITableViewCellAccessoryCheckmark];
@ -178,6 +188,14 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)itemWithText:(NSString *)text + (OWSTableItem *)itemWithText:(NSString *)text
actionBlock:(nullable OWSTableActionBlock)actionBlock actionBlock:(nullable OWSTableActionBlock)actionBlock
accessoryType:(UITableViewCellAccessoryType)accessoryType accessoryType:(UITableViewCellAccessoryType)accessoryType
{
return [self itemWithText:text accessibilityIdentifier:nil actionBlock:actionBlock accessoryType:accessoryType];
}
+ (OWSTableItem *)itemWithText:(NSString *)text
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
actionBlock:(nullable OWSTableActionBlock)actionBlock
accessoryType:(UITableViewCellAccessoryType)accessoryType
{ {
OWSAssertDebug(text.length > 0); OWSAssertDebug(text.length > 0);
OWSAssertDebug(actionBlock); OWSAssertDebug(actionBlock);
@ -188,6 +206,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
UITableViewCell *cell = [OWSTableItem newCell]; UITableViewCell *cell = [OWSTableItem newCell];
cell.textLabel.text = text; cell.textLabel.text = text;
cell.accessoryType = accessoryType; cell.accessoryType = accessoryType;
cell.accessibilityIdentifier = accessibilityIdentifier;
return cell; return cell;
}; };
return item; return item;
@ -207,6 +226,14 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text + (OWSTableItem *)disclosureItemWithText:(NSString *)text
detailText:(NSString *)detailText detailText:(NSString *)detailText
actionBlock:(nullable OWSTableActionBlock)actionBlock actionBlock:(nullable OWSTableActionBlock)actionBlock
{
return [self disclosureItemWithText:text detailText:detailText accessibilityIdentifier:nil actionBlock:actionBlock];
}
+ (OWSTableItem *)disclosureItemWithText:(NSString *)text
detailText:(NSString *)detailText
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
actionBlock:(nullable OWSTableActionBlock)actionBlock
{ {
OWSAssertDebug(text.length > 0); OWSAssertDebug(text.length > 0);
OWSAssertDebug(actionBlock); OWSAssertDebug(actionBlock);
@ -220,6 +247,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
cell.textLabel.text = text; cell.textLabel.text = text;
cell.detailTextLabel.text = detailText; cell.detailTextLabel.text = detailText;
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
cell.accessibilityIdentifier = accessibilityIdentifier;
return cell; return cell;
}; };
return item; return item;
@ -385,6 +413,21 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
isEnabledBlock:(OWSTableSwitchBlock)isEnabledBlock isEnabledBlock:(OWSTableSwitchBlock)isEnabledBlock
target:(id)target target:(id)target
selector:(SEL)selector selector:(SEL)selector
{
return [self switchItemWithText:text
accessibilityIdentifier:nil
isOnBlock:isOnBlock
isEnabledBlock:isEnabledBlock
target:target
selector:selector];
}
+ (OWSTableItem *)switchItemWithText:(NSString *)text
accessibilityIdentifier:(nullable NSString *)accessibilityIdentifier
isOnBlock:(OWSTableSwitchBlock)isOnBlock
isEnabledBlock:(OWSTableSwitchBlock)isEnabledBlock
target:(id)target
selector:(SEL)selector
{ {
OWSAssertDebug(text.length > 0); OWSAssertDebug(text.length > 0);
OWSAssertDebug(target); OWSAssertDebug(target);
@ -401,6 +444,7 @@ const CGFloat kOWSTable_DefaultCellHeight = 45.f;
[cellSwitch setOn:isOnBlock()]; [cellSwitch setOn:isOnBlock()];
[cellSwitch addTarget:weakTarget action:selector forControlEvents:UIControlEventValueChanged]; [cellSwitch addTarget:weakTarget action:selector forControlEvents:UIControlEventValueChanged];
cellSwitch.enabled = isEnabledBlock(); cellSwitch.enabled = isEnabledBlock();
cellSwitch.accessibilityIdentifier = accessibilityIdentifier;
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;

Loading…
Cancel
Save