From 9a34c6804cd6a6c25ee0c2b03c9eeb7dc33e0fe2 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Wed, 23 May 2018 17:48:17 -0400 Subject: [PATCH] policy links // FREEBIE --- .../AppSettings/AboutTableViewController.m | 7 ++ .../Registration/RegistrationViewController.m | 92 +++++++++++++------ .../translations/en.lproj/Localizable.strings | 12 +++ SignalServiceKit/src/TSConstants.h | 3 + 4 files changed, 86 insertions(+), 28 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m b/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m index 65614f716..aeeb125b5 100644 --- a/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/AboutTableViewController.m @@ -48,6 +48,13 @@ [informationSection addItem:[OWSTableItem labelItemWithText:NSLocalizedString(@"SETTINGS_VERSION", @"") accessoryText:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]]]; + + [informationSection addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"SETTINGS_LEGAL_TERMS_CELL", + @"table cell label") + actionBlock:^{ + [[UIApplication sharedApplication] + openURL:[NSURL URLWithString:kLegalTermsUrlString]]; + }]]; [contents addSection:informationSection]; OWSTableSection *helpSection = [OWSTableSection new]; diff --git a/Signal/src/ViewControllers/Registration/RegistrationViewController.m b/Signal/src/ViewControllers/Registration/RegistrationViewController.m index 0aae5902d..0f6f9fa40 100644 --- a/Signal/src/ViewControllers/Registration/RegistrationViewController.m +++ b/Signal/src/ViewControllers/Registration/RegistrationViewController.m @@ -70,42 +70,54 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi UIView *headerWrapper = [UIView containerView]; [self.view addSubview:headerWrapper]; headerWrapper.backgroundColor = UIColor.ows_signalBrandBlueColor; - - UIView *headerContent = [UIView new]; - [headerWrapper addSubview:headerContent]; [headerWrapper autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsZero excludingEdge:ALEdgeBottom]; - [headerContent autoPinEdgeToSuperviewEdge:ALEdgeBottom]; - [headerContent autoPinToTopLayoutGuideOfViewController:self withInset:0]; - [headerContent autoPinWidthToSuperview]; UILabel *headerLabel = [UILabel new]; headerLabel.text = NSLocalizedString(@"REGISTRATION_TITLE_LABEL", @""); headerLabel.textColor = [UIColor whiteColor]; headerLabel.font = [UIFont ows_mediumFontWithSize:ScaleFromIPhone5To7Plus(20.f, 24.f)]; - [headerContent addSubview:headerLabel]; - [headerLabel autoHCenterInSuperview]; - [headerLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:14.f]; - - CGFloat screenHeight = MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height); - if (screenHeight < 568) { - // iPhone 4s or smaller. - [headerContent autoSetDimension:ALDimensionHeight toSize:20]; - headerLabel.hidden = YES; - } else if (screenHeight < 667) { - // iPhone 5 or smaller. - [headerContent autoSetDimension:ALDimensionHeight toSize:80]; - } else { - [headerContent autoSetDimension:ALDimensionHeight toSize:220]; - - UIImage *logo = [UIImage imageNamed:@"logoSignal"]; - OWSAssert(logo); - UIImageView *logoView = [UIImageView new]; - logoView.image = logo; - [headerContent addSubview:logoView]; - [logoView autoHCenterInSuperview]; - [logoView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:headerLabel withOffset:-14.f]; + + NSString *legalTopMatterFormat = NSLocalizedString(@"REGISTRATION_LEGAL_TOP_MATTER_FORMAT", + @"legal disclaimer, embeds a tappable {{link title}} which is styled as a hyperlink"); + NSString *legalTopMatterLinkWord = NSLocalizedString( + @"REGISTRATION_LEGAL_TOP_MATTER_LINK_TITLE", @"embedded in legal topmatter, styled as a link"); + NSString *legalTopMatter = [NSString stringWithFormat:legalTopMatterFormat, legalTopMatterLinkWord]; + NSMutableAttributedString *attributedLegalTopMatter = + [[NSMutableAttributedString alloc] initWithString:legalTopMatter]; + NSRange linkRange = [legalTopMatter rangeOfString:legalTopMatterLinkWord]; + NSDictionary *linkStyleAttributes = @{ + NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle | NSUnderlinePatternSolid), + }; + [attributedLegalTopMatter setAttributes:linkStyleAttributes range:linkRange]; + + UILabel *legalTopMatterLabel = [UILabel new]; + legalTopMatterLabel.textColor = UIColor.whiteColor; + legalTopMatterLabel.font = UIFont.ows_dynamicTypeFootnoteFont; + legalTopMatterLabel.numberOfLines = 0; + legalTopMatterLabel.textAlignment = NSTextAlignmentCenter; + legalTopMatterLabel.attributedText = attributedLegalTopMatter; + legalTopMatterLabel.userInteractionEnabled = YES; + + UITapGestureRecognizer *tapGesture = + [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapLegalTerms:)]; + [legalTopMatterLabel addGestureRecognizer:tapGesture]; + + UIStackView *headerContent = [[UIStackView alloc] initWithArrangedSubviews:@[ headerLabel, legalTopMatterLabel ]]; + headerContent.axis = UILayoutConstraintAxisVertical; + headerContent.alignment = UIStackViewAlignmentCenter; + headerContent.spacing = ScaleFromIPhone5To7Plus(8, 16); + headerContent.layoutMarginsRelativeArrangement = YES; + + { + CGFloat topMargin = ScaleFromIPhone5To7Plus(4, 16); + CGFloat bottomMargin = ScaleFromIPhone5To7Plus(8, 16); + headerContent.layoutMargins = UIEdgeInsetsMake(topMargin, 40, bottomMargin, 40); } + [headerWrapper addSubview:headerContent]; + [headerContent autoPinToTopLayoutGuideOfViewController:self withInset:0]; + [headerContent autoPinEdgesToSuperviewMarginsExcludingEdge:ALEdgeTop]; + const CGFloat kRowHeight = 60.f; const CGFloat kRowHMargin = 20.f; const CGFloat kSeparatorHeight = 1.f; @@ -229,6 +241,25 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi [spinnerView autoSetDimension:ALDimensionHeight toSize:20.f]; [spinnerView autoPinTrailingToSuperviewMarginWithInset:20.f]; [spinnerView stopAnimating]; + + NSString *bottomTermsLinkText = NSLocalizedString(@"REGISTRATION_LEGAL_TERMS_LINK", + @"one line label below submit button on registration screen, which links to an external webpage."); + UIButton *bottomLegalLinkButton = [UIButton new]; + bottomLegalLinkButton.titleLabel.font = UIFont.ows_dynamicTypeFootnoteFont; + [bottomLegalLinkButton setTitleColor:UIColor.ows_materialBlueColor forState:UIControlStateNormal]; + [bottomLegalLinkButton setTitle:bottomTermsLinkText forState:UIControlStateNormal]; + [contentView addSubview:bottomLegalLinkButton]; + [bottomLegalLinkButton addTarget:self + action:@selector(didTapLegalTerms:) + forControlEvents:UIControlEventTouchUpInside]; + + [bottomLegalLinkButton autoPinLeadingAndTrailingToSuperviewMargin]; + [bottomLegalLinkButton autoPinEdge:ALEdgeTop + toEdge:ALEdgeBottom + ofView:activateButton + withOffset:ScaleFromIPhone5To7Plus(8, 12)]; + [bottomLegalLinkButton setCompressionResistanceHigh]; + [bottomLegalLinkButton setContentHuggingHigh]; } - (void)viewDidAppear:(BOOL)animated @@ -350,6 +381,11 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi } } +- (void)didTapLegalTerms:(UIButton *)sender +{ + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:kLegalTermsUrlString]]; +} + - (void)changeCountryCodeTapped { CountryCodeViewController *countryCodeController = [CountryCodeViewController new]; diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index a240fbf3a..32f3b84e7 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1600,6 +1600,15 @@ /* alert body during registration */ "REGISTRATION_ERROR_BLANK_VERIFICATION_CODE" = "We can't activate your account until you verify the code we sent you."; +/* one line label below submit button on registration screen, which links to an external webpage. */ +"REGISTRATION_LEGAL_TERMS_LINK" = "Terms & Privacy Policy"; + +/* legal disclaimer, embeds a tappable {{link title}} which is styled as a hyperlink */ +"REGISTRATION_LEGAL_TOP_MATTER_FORMAT" = "By registering this device, you agree to Signal's %@"; + +/* embedded in legal topmatter, styled as a link */ +"REGISTRATION_LEGAL_TOP_MATTER_LINK_TITLE" = "terms"; + /* No comment provided by engineer. */ "REGISTRATION_NON_VALID_NUMBER" = "This phone number format is not supported, please contact support."; @@ -1888,6 +1897,9 @@ /* Label for settings view that allows user to change the notification sound. */ "SETTINGS_ITEM_NOTIFICATION_SOUND" = "Message Sound"; +/* table cell label */ +"SETTINGS_LEGAL_TERMS_CELL" = "Terms & Privacy Policy"; + /* Title for settings activity */ "SETTINGS_NAV_BAR_TITLE" = "Settings"; diff --git a/SignalServiceKit/src/TSConstants.h b/SignalServiceKit/src/TSConstants.h index 3ec11cbce..de19df9c4 100644 --- a/SignalServiceKit/src/TSConstants.h +++ b/SignalServiceKit/src/TSConstants.h @@ -17,6 +17,9 @@ typedef NS_ENUM(NSInteger, TSWhisperMessageType) { #define textSecureHTTPTimeOut 10 +// FIXME this is likely to change +#define kLegalTermsUrlString @"https://signal.org/signal/privacy/" + //#ifndef DEBUG // Production