From f765c6c1bb5ca4e142f15f3b3b354da18d0ebed5 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 22 Oct 2018 10:00:40 -0400 Subject: [PATCH 1/2] Update UD settings copy. --- .../PrivacySettingsTableViewController.m | 54 +++++++++++++++++-- .../translations/en.lproj/Localizable.strings | 9 ++-- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m index a71a71af7..d2afb7ea0 100644 --- a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m @@ -10,6 +10,7 @@ #import #import #import +#import #import #import #import @@ -218,6 +219,7 @@ NS_ASSUME_NONNULL_BEGIN target:weakSelf selector:@selector(didToggleUDShowIndicatorsSwitch:)]; [unidentifiedDeliveryIndicatorsSection addItem:showUDIndicatorsItem]; + [contents addSection:unidentifiedDeliveryIndicatorsSection]; OWSTableSection *unidentifiedDeliveryUnrestrictedSection = [OWSTableSection new]; OWSTableItem *unrestrictedAccessItem = [OWSTableItem @@ -226,13 +228,55 @@ NS_ASSUME_NONNULL_BEGIN target:weakSelf selector:@selector(didToggleUDUnrestrictedAccessSwitch:)]; [unidentifiedDeliveryUnrestrictedSection addItem:unrestrictedAccessItem]; - - unidentifiedDeliveryUnrestrictedSection.footerTitle - = NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", @"table section footer"); - - [contents addSection:unidentifiedDeliveryIndicatorsSection]; [contents addSection:unidentifiedDeliveryUnrestrictedSection]; + OWSTableSection *unidentifiedDeliveryLearnMoreSection = [OWSTableSection new]; + [unidentifiedDeliveryLearnMoreSection + addItem:[OWSTableItem + itemWithCustomCellBlock:^UITableViewCell * { + UITableViewCell *cell = [OWSTableItem newCell]; + cell.preservesSuperviewLayoutMargins = YES; + cell.contentView.preservesSuperviewLayoutMargins = YES; + + NSAttributedString *attributedText = [NSAttributedString new]; + attributedText = [attributedText + rtlSafeAppend:NSLocalizedString( + @"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", + @"table section footer") + attributes:@{ + NSFontAttributeName : [UIFont ows_dynamicTypeFootnoteFont], + NSForegroundColorAttributeName : [Theme secondaryColor], + }]; + attributedText = + [attributedText rtlSafeAppend:@" " + attributes:@{ + NSFontAttributeName : [UIFont ows_dynamicTypeFootnoteFont], + }]; + attributedText = [attributedText + rtlSafeAppend:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_LEARN_MORE", + @"Label for a link to more info about unidentified delivery.") + attributes:@{ + NSFontAttributeName : [UIFont ows_dynamicTypeFootnoteFont], + NSForegroundColorAttributeName : [UIColor ows_materialBlueColor], + }]; + + UILabel *label = [UILabel new]; + label.attributedText = attributedText; + label.numberOfLines = 0; + label.lineBreakMode = NSLineBreakByWordWrapping; + + [cell.contentView addSubview:label]; + [label ows_autoPinToSuperviewMargins]; + return cell; + } + customRowHeight:UITableViewAutomaticDimension + actionBlock:^{ + NSURL *url = [NSURL URLWithString:@"https://signal.org/blog/secret-sender/"]; + OWSAssertDebug(url); + [UIApplication.sharedApplication openURL:url]; + }]]; + [contents addSection:unidentifiedDeliveryLearnMoreSection]; + self.contents = contents; } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 9757f16ef..486a0b942 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -2090,20 +2090,23 @@ /* Title for the 'two factor auth' section of the privacy settings. */ "SETTINGS_TWO_FACTOR_AUTH_TITLE" = "Registration Lock"; +/* Label for a link to more info about unidentified delivery. */ +"SETTINGS_UNIDENTIFIED_DELIVERY_LEARN_MORE" = "Learn More"; + /* table section label */ -"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_TITLE" = "Unidentified Delivery"; +"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_TITLE" = "Secret Sender"; /* switch label */ "SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS" = "Display Indicators"; /* table section footer */ -"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS_FOOTER" = "Show a status icon when you select \"More Info\" on messages that were sent using unidentified delivery."; +"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS_FOOTER" = "Show a status icon when you select \"More Info\" on messages that were delivered using secret sender."; /* switch label */ "SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS" = "Allow from Anyone"; /* table section footer */ -"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER" = "Enable unidentified delivery for incoming messages from non-contacts and people with whom you have not shared your profile."; +"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER" = "Enable secret sender for incoming messages from non-contacts and people with whom you have not shared your profile."; /* No comment provided by engineer. */ "SETTINGS_VERSION" = "Version"; From 55ab6c39d462ca2cccd22bb75d06954de125249c Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 22 Oct 2018 14:28:46 -0400 Subject: [PATCH 2/2] Rework UD settings. --- .../PrivacySettingsTableViewController.m | 109 ++++++++++-------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m index d2afb7ea0..18abd1532 100644 --- a/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/PrivacySettingsTableViewController.m @@ -209,16 +209,58 @@ NS_ASSUME_NONNULL_BEGIN OWSTableSection *unidentifiedDeliveryIndicatorsSection = [OWSTableSection new]; unidentifiedDeliveryIndicatorsSection.headerTitle = NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SECTION_TITLE", @"table section label"); + [unidentifiedDeliveryIndicatorsSection + addItem:[OWSTableItem + itemWithCustomCellBlock:^UITableViewCell * { + UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 + reuseIdentifier:@"UITableViewCellStyleValue1"]; + [OWSTableItem configureCell:cell]; + cell.preservesSuperviewLayoutMargins = YES; + cell.contentView.preservesSuperviewLayoutMargins = YES; + cell.selectionStyle = UITableViewCellSelectionStyleNone; + + UILabel *label = [UILabel new]; + label.text + = NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS", @"switch label"); + label.font = [UIFont ows_regularFontWithSize:18.f]; + label.textColor = [Theme primaryColor]; + [label setContentHuggingHorizontalHigh]; + + UIImage *icon = [UIImage imageNamed:@"ic_secret_sender_indicator"]; + UIImageView *iconView = [[UIImageView alloc] + initWithImage:[icon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]]; + iconView.tintColor = Theme.secondaryColor; + [iconView setContentHuggingHorizontalHigh]; + + UIView *spacer = [UIView new]; + [spacer setContentHuggingHorizontalLow]; + + UISwitch *cellSwitch = [UISwitch new]; + cell.accessoryView = cellSwitch; + [cellSwitch setOn:weakSelf.preferences.shouldShowUnidentifiedDeliveryIndicators]; + [cellSwitch addTarget:weakSelf + action:@selector(didToggleUDShowIndicatorsSwitch:) + forControlEvents:UIControlEventValueChanged]; + [cellSwitch setContentHuggingHorizontalHigh]; + + UIStackView *stackView = + [[UIStackView alloc] initWithArrangedSubviews:@[ label, iconView, spacer, cellSwitch ]]; + stackView.axis = UILayoutConstraintAxisHorizontal; + stackView.spacing = 10; + + [cell.contentView addSubview:stackView]; + [stackView ows_autoPinToSuperviewMargins]; + return cell; + } + customRowHeight:UITableViewAutomaticDimension + actionBlock:^{ + NSURL *url = [NSURL URLWithString:@"https://signal.org/blog/secret-sender/"]; + OWSAssertDebug(url); + [UIApplication.sharedApplication openURL:url]; + }]]; unidentifiedDeliveryIndicatorsSection.footerTitle = NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS_FOOTER", @"table section footer"); - - OWSTableItem *showUDIndicatorsItem = [OWSTableItem - switchItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_SHOW_INDICATORS", @"switch label") - isOn:weakSelf.preferences.shouldShowUnidentifiedDeliveryIndicators - target:weakSelf - selector:@selector(didToggleUDShowIndicatorsSwitch:)]; - [unidentifiedDeliveryIndicatorsSection addItem:showUDIndicatorsItem]; [contents addSection:unidentifiedDeliveryIndicatorsSection]; OWSTableSection *unidentifiedDeliveryUnrestrictedSection = [OWSTableSection new]; @@ -228,53 +270,20 @@ NS_ASSUME_NONNULL_BEGIN target:weakSelf selector:@selector(didToggleUDUnrestrictedAccessSwitch:)]; [unidentifiedDeliveryUnrestrictedSection addItem:unrestrictedAccessItem]; + unidentifiedDeliveryUnrestrictedSection.footerTitle + = NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", @"table section footer"); [contents addSection:unidentifiedDeliveryUnrestrictedSection]; OWSTableSection *unidentifiedDeliveryLearnMoreSection = [OWSTableSection new]; [unidentifiedDeliveryLearnMoreSection - addItem:[OWSTableItem - itemWithCustomCellBlock:^UITableViewCell * { - UITableViewCell *cell = [OWSTableItem newCell]; - cell.preservesSuperviewLayoutMargins = YES; - cell.contentView.preservesSuperviewLayoutMargins = YES; - - NSAttributedString *attributedText = [NSAttributedString new]; - attributedText = [attributedText - rtlSafeAppend:NSLocalizedString( - @"SETTINGS_UNIDENTIFIED_DELIVERY_UNRESTRICTED_ACCESS_FOOTER", - @"table section footer") - attributes:@{ - NSFontAttributeName : [UIFont ows_dynamicTypeFootnoteFont], - NSForegroundColorAttributeName : [Theme secondaryColor], - }]; - attributedText = - [attributedText rtlSafeAppend:@" " - attributes:@{ - NSFontAttributeName : [UIFont ows_dynamicTypeFootnoteFont], - }]; - attributedText = [attributedText - rtlSafeAppend:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_LEARN_MORE", - @"Label for a link to more info about unidentified delivery.") - attributes:@{ - NSFontAttributeName : [UIFont ows_dynamicTypeFootnoteFont], - NSForegroundColorAttributeName : [UIColor ows_materialBlueColor], - }]; - - UILabel *label = [UILabel new]; - label.attributedText = attributedText; - label.numberOfLines = 0; - label.lineBreakMode = NSLineBreakByWordWrapping; - - [cell.contentView addSubview:label]; - [label ows_autoPinToSuperviewMargins]; - return cell; - } - customRowHeight:UITableViewAutomaticDimension - actionBlock:^{ - NSURL *url = [NSURL URLWithString:@"https://signal.org/blog/secret-sender/"]; - OWSAssertDebug(url); - [UIApplication.sharedApplication openURL:url]; - }]]; + addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_UNIDENTIFIED_DELIVERY_LEARN_MORE", + @"Label for a link to more info about unidentified delivery.") + actionBlock:^{ + NSURL *url = + [NSURL URLWithString:@"https://signal.org/blog/secret-sender/"]; + OWSAssertDebug(url); + [UIApplication.sharedApplication openURL:url]; + }]]; [contents addSection:unidentifiedDeliveryLearnMoreSection]; self.contents = contents;