diff --git a/Podfile.lock b/Podfile.lock index d49098516..93280668d 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -136,7 +136,7 @@ CHECKOUT OPTIONS: :commit: 7054e4b13ee5bcd6d524adb6dc9a726e8c466308 :git: https://github.com/WhisperSystems/JSQMessagesViewController.git SignalServiceKit: - :commit: 2bb745930313156f3cd5e526e107ed7ef97d9078 + :commit: 2dc7c7cf292a3b97b356a67149c9d17684968f22 :git: https://github.com/WhisperSystems/SignalServiceKit.git SocketRocket: :commit: 877ac7438be3ad0b45ef5ca3969574e4b97112bf diff --git a/Signal/src/ViewControllers/SelectRecipientViewController.m b/Signal/src/ViewControllers/SelectRecipientViewController.m index 62a104da9..e0ac6992a 100644 --- a/Signal/src/ViewControllers/SelectRecipientViewController.m +++ b/Signal/src/ViewControllers/SelectRecipientViewController.m @@ -39,6 +39,8 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien @property (nonatomic) UIButton *phoneNumberButton; +@property (nonatomic) UILabel *examplePhoneNumberLabel; + @property (nonatomic, readonly) OWSTableViewController *tableViewController; @property (nonatomic) NSString *callingCode; @@ -132,6 +134,22 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien return phoneNumberLabel; } +- (UIFont *)examplePhoneNumberFont +{ + return [UIFont ows_regularFontWithSize:16.f]; +} + +- (UILabel *)examplePhoneNumberLabel +{ + if (!_examplePhoneNumberLabel) { + _examplePhoneNumberLabel = [UILabel new]; + _examplePhoneNumberLabel.font = [self examplePhoneNumberFont]; + _examplePhoneNumberLabel.textColor = [UIColor colorWithWhite:0.5f alpha:1.f]; + } + + return _examplePhoneNumberLabel; +} + - (UITextField *)phoneNumberTextField { if (!_phoneNumberTextField) { @@ -212,6 +230,26 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien NSString *title = [NSString stringWithFormat:@"%@ (%@)", callingCode, countryCode.uppercaseString]; [self.countryCodeButton setTitle:title forState:UIControlStateNormal]; [self.countryCodeButton layoutSubviews]; + + NSString *examplePhoneNumber = [PhoneNumberUtil examplePhoneNumberForCountryCode:countryCode]; + OWSAssert(!examplePhoneNumber || [examplePhoneNumber hasPrefix:callingCode]); + if (examplePhoneNumber && [examplePhoneNumber hasPrefix:callingCode]) { + NSString *formattedPhoneNumber = + [PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:examplePhoneNumber + withSpecifiedCountryCodeString:countryCode]; + if (formattedPhoneNumber.length > 0) { + examplePhoneNumber = formattedPhoneNumber; + } + + self.examplePhoneNumberLabel.text = [NSString + stringWithFormat: + NSLocalizedString(@"PHONE_NUMBER_EXAMPLE_FORMAT", + @"A format for a label showing an example phone number. Embeds {{the example phone number}}."), + [examplePhoneNumber substringFromIndex:callingCode.length]]; + } else { + self.examplePhoneNumberLabel.text = @""; + } + [self.examplePhoneNumberLabel.superview layoutSubviews]; } - (void)setCallingCode:(NSString *)callingCode @@ -404,6 +442,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien phoneNumberSection.headerTitle = [self.delegate phoneNumberSectionTitle]; const CGFloat kCountryRowHeight = 50; const CGFloat kPhoneNumberRowHeight = 50; + const CGFloat examplePhoneNumberRowHeight = self.examplePhoneNumberFont.lineHeight + 3.f; const CGFloat kButtonRowHeight = 60; [phoneNumberSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ SelectRecipientViewController *strongSelf = weakSelf; @@ -442,9 +481,17 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien [self.phoneNumberTextField autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:phoneNumberLabel withOffset:0]; [self.phoneNumberTextField autoVCenterInSuperview]; + // Example row. + UIView *examplePhoneNumberRow = [self createRowWithHeight:examplePhoneNumberRowHeight + previousRow:phoneNumberRow + superview:cell.contentView]; + [examplePhoneNumberRow addSubview:self.examplePhoneNumberLabel]; + [self.examplePhoneNumberLabel autoVCenterInSuperview]; + [self.examplePhoneNumberLabel autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:20.f]; + // Phone Number Button Row UIView *buttonRow = - [self createRowWithHeight:kButtonRowHeight previousRow:phoneNumberRow superview:cell.contentView]; + [self createRowWithHeight:kButtonRowHeight previousRow:examplePhoneNumberRow superview:cell.contentView]; [buttonRow addSubview:self.phoneNumberButton]; [self.phoneNumberButton autoVCenterInSuperview]; [self.phoneNumberButton autoPinEdgeToSuperviewEdge:ALEdgeRight withInset:20.f]; @@ -455,6 +502,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien return cell; } customRowHeight:kCountryRowHeight + kPhoneNumberRowHeight + + examplePhoneNumberRowHeight + kButtonRowHeight actionBlock:nil]]; [contents addSection:phoneNumberSection]; diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index f7342b6cb..5d67b003c 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -4,9 +4,6 @@ /* Action sheet item */ "ACCEPT_NEW_IDENTITY_ACTION" = "Accept new safety number"; -/* No comment provided by engineer. */ -"ACTION_REQUIRED_TITLE" = "Action Required"; - /* A label for the 'add by phone number' button in the 'add group member' view */ "ADD_GROUP_MEMBER_VIEW_BUTTON" = "Add"; @@ -511,7 +508,7 @@ /* No comment provided by engineer. */ "GROUP_CREATING" = "Creating new group"; -/* No comment provided by engineer. */ +/* Title of alert indicating that new group could not be created. */ "GROUP_CREATING_FAILED" = "Group creation failed"; /* Conversation settings table section title */ @@ -538,7 +535,7 @@ /* No comment provided by engineer. */ "GROUP_REMOVING" = "Leaving group %@"; -/* No comment provided by engineer. */ +/* Title of alert indicating that group deletion failed. */ "GROUP_REMOVING_FAILED" = "Failed to leave group"; /* No comment provided by engineer. */ @@ -841,6 +838,9 @@ /* The title of the 'oversize text message' view. */ "OVERSIZE_TEXT_MESSAGE_VIEW_TITLE" = "Message"; +/* A format for a label showing an example phone number. Embeds {{the example phone number}}. */ +"PHONE_NUMBER_EXAMPLE_FORMAT" = "Example: %@"; + /* Format for phone number label with an index. Embeds {{Phone number label (e.g. 'home')}} and {{index, e.g. 2}}. */ "PHONE_NUMBER_TYPE_AND_INDEX_FORMAT" = "%@ %d"; @@ -913,15 +913,12 @@ /* No comment provided by engineer. */ "PUSH_MANAGER_REPLY" = "Reply"; -/* Alert title */ +/* Title of alert shown when push tokens sync job succeeds. */ "PUSH_REGISTER_SUCCESS" = "Successfully re-registered for push notifications."; /* Used in table section header and alert view title contexts */ "PUSH_REGISTER_TITLE" = "Push Notifications"; -/* No comment provided by engineer. */ -"PUSH_SETTINGS_MESSAGE" = "Signal requires push notification alerts and sounds to be enabled to work properly. Please change it in the Settings app >> Notification Center >> Signal."; - /* No comment provided by engineer. */ "QUESTIONMARK_PUNCTUATION" = "?"; @@ -952,7 +949,7 @@ /* No comment provided by engineer. */ "REGISTERED_NUMBER_TEXT" = "Registered Number"; -/* Alert title */ +/* Title of alert shown when push tokens sync job fails. */ "REGISTRATION_BODY" = "Failed to re-register for push notifications."; /* Label for the country code field */