From 0ed0b8f2580afc30ad70da9dba70eee800150aae Mon Sep 17 00:00:00 2001 From: REIS Benjamin Date: Wed, 12 Oct 2016 11:33:09 +0200 Subject: [PATCH] Set language in assistant for validation sms + update submodule linphone --- Classes/AssistantLinkView.m | 20 ++++++++++++++++++-- Classes/AssistantView.m | 15 +++++++++++++-- submodules/linphone | 2 +- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Classes/AssistantLinkView.m b/Classes/AssistantLinkView.m index 2c666adaa..f1e402a19 100644 --- a/Classes/AssistantLinkView.m +++ b/Classes/AssistantLinkView.m @@ -138,7 +138,7 @@ void assistant_link_phone_number_with_account(LinphoneAccountCreator *creator, L thiz.linkAccountView.hidden = thiz.activateSMSView.userInteractionEnabled = YES; thiz.activateSMSView.hidden = thiz.linkAccountView.userInteractionEnabled = NO; } else { - if (strcmp(resp, "Missing required parameters") ==0) { + if (strcmp(resp, "Missing required parameters") == 0) { [thiz showErrorPopup:"ERROR_NO_PHONE_NUMBER"]; } else { [thiz showErrorPopup:resp]; @@ -173,6 +173,17 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph [_countryButton setTitle:c ? [c objectForKey:@"name"] : NSLocalizedString(@"Unknown country code", nil) forState:UIControlStateNormal]; } + if ([[_countryButton currentTitle] isEqualToString:@"Unknown country code"]) { + _countryCodeField.layer.borderWidth = .8; + _countryCodeField.layer.cornerRadius = 4.f; + _countryCodeField.layer.borderColor = [[UIColor redColor] CGColor]; + self.linkAccountButton.enabled = FALSE; + } else { + _countryCodeField.layer.borderColor = [[UIColor clearColor] CGColor]; + if (_phoneField.layer.borderColor != [[UIColor redColor] CGColor]) { + self.linkAccountButton.enabled = TRUE; + } + } } - (IBAction)onCountryCodeFieldChange:(id)sender { @@ -194,6 +205,9 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph NSString *newStr = [_countryCodeField.text substringWithRange:NSMakeRange(1, [_countryCodeField.text length]-1)]; linphone_account_creator_set_phone_number(account_creator, _phoneField.text.UTF8String, newStr.UTF8String); + + NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; + linphone_account_creator_set_language(account_creator, [[language substringToIndex:2] UTF8String]); linphone_account_creator_link_phone_number_with_account(account_creator); } @@ -246,7 +260,9 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph self.linkAccountButton.enabled = FALSE; } else { self.phoneField.layer.borderColor = [[UIColor clearColor] CGColor]; - self.linkAccountButton.enabled = TRUE; + if (_countryCodeField.layer.borderColor != [[UIColor redColor] CGColor]){ + self.linkAccountButton.enabled = TRUE; + } } return YES; } diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 355500fac..5e80a8693 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -117,6 +117,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [NSNotificationCenter.defaultCenter removeObserver:self]; + } - (void)fitContent { @@ -797,6 +798,8 @@ static UICompositeViewDescription *compositeDescription = nil; if (status == LinphoneAccountCreatorAccountExist || status == LinphoneAccountCreatorAccountExistWithAlias) { linphone_account_creator_is_account_activated(account_creator); } else if (status == LinphoneAccountCreatorAccountNotExist) { + NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; + linphone_account_creator_set_language(account_creator, [[language substringToIndex:2] UTF8String]); linphone_account_creator_create_account(account_creator); } else { [self showErrorPopup:resp]; @@ -866,6 +869,8 @@ void assistant_is_account_activated(LinphoneAccountCreator *creator, LinphoneAcc [thiz showErrorPopup:"ERROR_ACCOUNT_ALREADY_IN_USE"]; [thiz findButton:ViewElement_NextButton].enabled = NO; } else { + NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; + linphone_account_creator_set_language(creator, [[language substringToIndex:2] UTF8String]); linphone_account_creator_recover_phone_account(creator); } } else { @@ -1001,8 +1006,10 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun linphone_account_creator_get_ha1(account_creator) == NULL) { linphone_account_creator_activate_account(account_creator); } else { + NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; + linphone_account_creator_set_language(account_creator, [[language substringToIndex:2] UTF8String]); linphone_account_creator_link_phone_number_with_account(account_creator); - linphone_account_creator_link_phone_number_with_account(account_creator); + linphone_account_creator_activate_phone_number_link(account_creator); } }); } @@ -1010,13 +1017,15 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun - (IBAction)onCreateAccountCheckActivatedClick:(id)sender { ONCLICKBUTTON(sender, 100, { _waitView.hidden = NO; - linphone_account_creator_is_account_linked(account_creator); + linphone_account_creator_is_account_activated(account_creator); }); } - (IBAction)onLinkAccountClick:(id)sender { ONCLICKBUTTON(sender, 100, { _waitView.hidden = NO; + NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; + linphone_account_creator_set_language(account_creator, [[language substringToIndex:2] UTF8String]); linphone_account_creator_link_phone_number_with_account(account_creator); }); } @@ -1028,6 +1037,8 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun if ((linphone_account_creator_get_phone_number(account_creator) != NULL) && linphone_account_creator_get_password(account_creator) == NULL && linphone_account_creator_get_ha1(account_creator) == NULL) { + NSString * language = [[NSLocale preferredLanguages] objectAtIndex:0]; + linphone_account_creator_set_language(account_creator, [[language substringToIndex:2] UTF8String]); linphone_account_creator_recover_phone_account(account_creator); } else { // check if account is already linked with a phone number. diff --git a/submodules/linphone b/submodules/linphone index 0a9176ebb..8958eaa2b 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 0a9176ebbacdf22aeb4ee5d73b50ced25d186d9b +Subproject commit 8958eaa2b51b1203d406009495774b56d20d5f83