From 18aef75ca1c9890e699beb5297b89a937db73db7 Mon Sep 17 00:00:00 2001 From: REIS Benjamin Date: Fri, 7 Oct 2016 10:53:22 +0200 Subject: [PATCH] Fix phone number and country code control in Assistant --- Classes/AssistantLinkView.m | 6 ++++-- Classes/AssistantView.m | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Classes/AssistantLinkView.m b/Classes/AssistantLinkView.m index ba62ffca1..6218ab01d 100644 --- a/Classes/AssistantLinkView.m +++ b/Classes/AssistantLinkView.m @@ -235,8 +235,10 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph #pragma mark - UITextFieldDelegate Functions - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - LinphoneAccountCreatorStatus status = linphone_account_creator_set_phone_number(account_creator, [_phoneField.text UTF8String], [_countryCodeField.text UTF8String]); - if (status == LinphoneAccountCreatorPhoneNumberTooLong || self.phoneField.text.length < 8 || status == LinphoneAccountCreatorPhoneNumberInvalid) { + //remove the + from the country code to avoir error when checking its validity + NSString *newStr = [_countryCodeField.text substringWithRange:NSMakeRange(1, [_countryCodeField.text length]-1)]; + LinphoneAccountCreatorStatus status = linphone_account_creator_set_phone_number(account_creator, [_phoneField.text UTF8String], [newStr UTF8String]); + if (status == LinphoneAccountCreatorPhoneNumberTooLong || self.phoneField.text.length < 8) { self.phoneField.layer.borderWidth = .8; self.phoneField.layer.cornerRadius = 4.f; self.phoneField.layer.borderColor = [[UIColor redColor] CGColor]; diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index e299c25ef..102a747dd 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -930,6 +930,20 @@ void assistant_is_account_activated(LinphoneAccountCreator *creator, LinphoneAcc [self refreshYourUsername]; } [self shouldEnableNextButton]; + + //remove the + from the country code to avoir error when checking its validity + NSString *newStr = [[self findTextField:ViewElement_PhoneCC].text substringWithRange:NSMakeRange(1, [[self findTextField:ViewElement_PhoneCC].text length]-1)]; + LinphoneAccountCreatorStatus status = linphone_account_creator_set_phone_number(account_creator, [[self findTextField:ViewElement_Phone].text UTF8String], [newStr UTF8String]); + if (status == LinphoneAccountCreatorPhoneNumberTooLong || [self findTextField:ViewElement_Phone].text.length < 8) { + [self findTextField:ViewElement_Phone].layer.borderWidth = .8; + [self findTextField:ViewElement_Phone].layer.cornerRadius = 4.f; + [self findTextField:ViewElement_Phone].layer.borderColor = [[UIColor redColor] CGColor]; + [self findButton:ViewElement_NextButton].enabled = FALSE; + } else { + [self findTextField:ViewElement_Phone].layer.borderColor = [[UIColor clearColor] CGColor]; + [self findButton:ViewElement_NextButton].enabled = TRUE; + } + return replace; } }