From b658866319be70f876de2d5cc0d4463c683e23dd Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Wed, 13 Feb 2019 16:21:07 -0500 Subject: [PATCH] Sketch out the 'onboarding phone number' view. --- .../OnboardingPhoneNumberViewController.swift | 31 ++----------------- .../OnboardingSplashViewController.swift | 6 +++- .../ViewControllers/ViewControllerUtils.h | 7 ----- .../ViewControllers/ViewControllerUtils.m | 21 ------------- 4 files changed, 7 insertions(+), 58 deletions(-) diff --git a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift index e12e1c8ec..cddbc39b5 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingPhoneNumberViewController.swift @@ -21,25 +21,6 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController { private let phoneNumberTextField = UITextField() private var nextButton: OWSFlatButton? - // - (void)didTapLegalTerms:(UIButton *)sender -//{ -// [[UIApplication sharedApplication] openURL:[NSURL URLWithString:kLegalTermsUrlString]]; -// } -//#pragma mark - Keyboard notifications -// -//- (void)initializeKeyboardHandlers -//{ -// UITapGestureRecognizer *outsideTabRecognizer = -// [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboardFromAppropriateSubView)]; -// [self.view addGestureRecognizer:outsideTabRecognizer]; -// } -// -// - (void)dismissKeyboardFromAppropriateSubView -// { -// [self.view endEditing:NO]; -//} -// - override public func loadView() { super.loadView() @@ -62,8 +43,6 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController { // Country - // TODO: dynamic - let fontSizePoints: CGFloat = ScaleFromIPhone5To7Plus(16, 20) let rowHeight: CGFloat = 40 countryNameLabel.textColor = Theme.primaryColor @@ -74,9 +53,6 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController { let countryIcon = UIImage(named: (CurrentAppContext().isRTL ? "small_chevron_left" : "small_chevron_right")) -// NavBarBackRTL -// small_chevron_right -// system_disclosure_indicator_rtl let countryImageView = UIImageView(image: countryIcon?.withRenderingMode(.alwaysTemplate)) countryImageView.tintColor = Theme.placeholderColor countryImageView.setContentHuggingHigh() @@ -472,11 +448,8 @@ public class OnboardingPhoneNumberViewController: OnboardingBaseViewController { extension OnboardingPhoneNumberViewController: UITextFieldDelegate { public func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool { - var prefix = self.callingCode - if prefix.hasPrefix(COUNTRY_CODE_PREFIX) { - prefix = prefix.substring(from: COUNTRY_CODE_PREFIX.count) - } - ViewControllerUtils.phoneNumber(textField, shouldChangeCharactersIn: range, replacementString: string, countryCode: countryCode, prefix: prefix) + // TODO: Fix auto-format of phone numbers. + ViewControllerUtils.phoneNumber(textField, shouldChangeCharactersIn: range, replacementString: string, countryCode: countryCode) // Inform our caller that we took care of performing the change. return false diff --git a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift index aa4b0ce71..6d474ddbf 100644 --- a/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift +++ b/Signal/src/ViewControllers/Registration/OnboardingSplashViewController.swift @@ -80,7 +80,11 @@ public class OnboardingSplashViewController: OnboardingBaseViewController { guard sender.state == .recognized else { return } - // TODO: + guard let url = URL(string: kLegalTermsUrlString) else { + owsFailDebug("Invalid URL.") + return + } + UIApplication.shared.openURL(url) } @objc func continuePressed() { diff --git a/SignalMessaging/ViewControllers/ViewControllerUtils.h b/SignalMessaging/ViewControllers/ViewControllerUtils.h index c115c3769..38b26561d 100644 --- a/SignalMessaging/ViewControllers/ViewControllerUtils.h +++ b/SignalMessaging/ViewControllers/ViewControllerUtils.h @@ -22,13 +22,6 @@ extern NSString *const TappedStatusBarNotification; replacementString:(NSString *)insertionText countryCode:(NSString *)countryCode; -// The same method, but it temporarily adds a prefix during the formatting process. -+ (void)phoneNumberTextField:(UITextField *)textField - shouldChangeCharactersInRange:(NSRange)range - replacementString:(NSString *)insertionText - countryCode:(NSString *)countryCode - prefix:(nullable NSString *)prefix; - + (void)ows2FAPINTextField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)insertionText; diff --git a/SignalMessaging/ViewControllers/ViewControllerUtils.m b/SignalMessaging/ViewControllers/ViewControllerUtils.m index 68ad7fc19..441e3e797 100644 --- a/SignalMessaging/ViewControllers/ViewControllerUtils.m +++ b/SignalMessaging/ViewControllers/ViewControllerUtils.m @@ -90,11 +90,6 @@ const NSUInteger kMax2FAPinLength = 16; // reformat the phone number, trying to keep the cursor beside the inserted or deleted digit NSUInteger cursorPositionAfterChange = MIN(left.length + center.length, textAfterChange.length); - // if (prefix.length > 0) { - // textAfterChange = [prefix stringByAppendingString:textAfterChange]; - // cursorPositionAfterChange += prefix.length; - // } - NSString *textAfterReformat = [PhoneNumber bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:textAfterChange withSpecifiedCountryCodeString:countryCode]; @@ -103,22 +98,6 @@ const NSUInteger kMax2FAPinLength = 16; to:textAfterReformat stickingRightward:isJustDeletion]; - // if (prefix.length > 0) { - // OWSAssertDebug([textAfterReformat hasPrefix:prefix]); - // if ([textAfterReformat hasPrefix:prefix]) { - // textAfterReformat = [textAfterReformat substringFromIndex:prefix.length]; - // cursorPositionAfterReformat -= prefix.length; - // - // NSRange trimRange = [textAfterReformat - // rangeOfCharacterFromSet:NSCharacterSet.whitespaceCharacterSet.invertedSet]; if (trimRange.location > - // 0) { - // textAfterReformat = [textAfterReformat - // stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet]; - // cursorPositionAfterReformat -= trimRange.location; - // } - // } - // } - textField.text = textAfterReformat; UITextPosition *pos = [textField positionFromPosition:textField.beginningOfDocument offset:(NSInteger)cursorPositionAfterReformat];