Merge branch 'charlesmchen/emptyRegistrationView'

pull/1/head
Matthew Chen 8 years ago
commit 7655226a44

@ -119,44 +119,58 @@ static NSString *const kCodeSentSegue = @"codeSent";
{ {
DDLogInfo(@"called %s", __PRETTY_FUNCTION__); DDLogInfo(@"called %s", __PRETTY_FUNCTION__);
NSString *alertTitleFormat = NSLocalizedString(@"EXISTING_USER_REGISTRATION_ALERT_TITLE", [OWSAlerts
@"during registration, embeds {{device type}}, e.g. \"iPhone\" or \"iPad\""); showAlertWithTitle:
NSString *alertTitle = [NSString stringWithFormat:alertTitleFormat, [UIDevice currentDevice].localizedModel]; [NSString stringWithFormat:NSLocalizedString(@"EXISTING_USER_REGISTRATION_ALERT_TITLE",
NSString *alertBody = NSLocalizedString(@"EXISTING_USER_REGISTRATION_ALERT_BODY", @"during registration"); @"during registration, embeds {{device type}}, e.g. \"iPhone\" or \"iPad\""),
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:alertTitle [UIDevice currentDevice].localizedModel]
message:alertBody message:NSLocalizedString(@"EXISTING_USER_REGISTRATION_ALERT_BODY", @"during registration")];
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction =
[UIAlertAction actionWithTitle:NSLocalizedString(@"OK", nil) style:UIAlertActionStyleCancel handler:nil];
[alertController addAction:cancelAction];
[self presentViewController:alertController animated:YES completion:nil];
} }
- (IBAction)sendCodeAction:(id)sender { - (IBAction)sendCodeAction:(id)sender {
NSString *phoneNumber = [NSString stringWithFormat:@"%@%@", _callingCode, _phoneNumberTextField.text]; NSString *phoneNumberText =
[_phoneNumberTextField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
if (phoneNumberText.length < 1) {
[OWSAlerts
showAlertWithTitle:NSLocalizedString(@"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_TITLE",
@"Title of alert indicating that users needs to enter a phone number to register.")
message:
NSLocalizedString(@"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_MESSAGE",
@"Message of alert indicating that users needs to enter a phone number to register.")];
return;
}
NSString *phoneNumber = [NSString stringWithFormat:@"%@%@", _callingCode, phoneNumberText];
PhoneNumber *localNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:phoneNumber]; PhoneNumber *localNumber = [PhoneNumber tryParsePhoneNumberFromUserSpecifiedText:phoneNumber];
NSString *parsedPhoneNumber = localNumber.toE164;
if (parsedPhoneNumber.length < 1) {
[OWSAlerts showAlertWithTitle:
NSLocalizedString(@"REGISTRATION_VIEW_INVALID_PHONE_NUMBER_ALERT_TITLE",
@"Title of alert indicating that users needs to enter a valid phone number to register.")
message:NSLocalizedString(@"REGISTRATION_VIEW_INVALID_PHONE_NUMBER_ALERT_MESSAGE",
@"Message of alert indicating that users needs to enter a valid phone number "
@"to register.")];
return;
}
[_sendCodeButton setEnabled:NO]; [_sendCodeButton setEnabled:NO];
[_spinnerView startAnimating]; [_spinnerView startAnimating];
[_phoneNumberTextField resignFirstResponder]; [_phoneNumberTextField resignFirstResponder];
[TSAccountManager registerWithPhoneNumber:localNumber.toE164 [TSAccountManager registerWithPhoneNumber:parsedPhoneNumber
success:^{ success:^{
[self performSegueWithIdentifier:@"codeSent" sender:self]; [self performSegueWithIdentifier:@"codeSent" sender:self];
[_spinnerView stopAnimating]; [_spinnerView stopAnimating];
} }
failure:^(NSError *error) { failure:^(NSError *error) {
if (error.code == 400) { if (error.code == 400) {
[OWSAlerts showAlertWithTitle:NSLocalizedString(@"REGISTRATION_ERROR", nil) [OWSAlerts showAlertWithTitle:NSLocalizedString(@"REGISTRATION_ERROR", nil)
message:NSLocalizedString(@"REGISTRATION_NON_VALID_NUMBER", nil)]; message:NSLocalizedString(@"REGISTRATION_NON_VALID_NUMBER", nil)];
} else { } else {
[OWSAlerts showAlertWithTitle:error.localizedDescription message:error.localizedRecoverySuggestion]; [OWSAlerts showAlertWithTitle:error.localizedDescription message:error.localizedRecoverySuggestion];
} }
[_sendCodeButton setEnabled:YES]; [_sendCodeButton setEnabled:YES];
[_spinnerView stopAnimating]; [_spinnerView stopAnimating];
} }
smsVerification:YES]; smsVerification:YES];
} }

@ -997,6 +997,18 @@
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"REGISTRATION_VERIFY_DEVICE" = "Activate This Device"; "REGISTRATION_VERIFY_DEVICE" = "Activate This Device";
/* Message of alert indicating that users needs to enter a valid phone number to register. */
"REGISTRATION_VIEW_INVALID_PHONE_NUMBER_ALERT_MESSAGE" = "Please enter a valid phone number to register.";
/* Title of alert indicating that users needs to enter a valid phone number to register. */
"REGISTRATION_VIEW_INVALID_PHONE_NUMBER_ALERT_TITLE" = "Invalid Phone Number";
/* Message of alert indicating that users needs to enter a phone number to register. */
"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_MESSAGE" = "Please enter a phone number to register.";
/* Title of alert indicating that users needs to enter a phone number to register. */
"REGISTRATION_VIEW_NO_PHONE_NUMBER_ALERT_TITLE" = "No Phone Number";
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"REJECT_CALL_BUTTON_TITLE" = "Reject"; "REJECT_CALL_BUTTON_TITLE" = "Reject";

Loading…
Cancel
Save