diff --git a/Classes/AssistantLinkView.m b/Classes/AssistantLinkView.m index 555b1c4ac..aad8083b9 100644 --- a/Classes/AssistantLinkView.m +++ b/Classes/AssistantLinkView.m @@ -119,16 +119,38 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - popup - (void)showErrorPopup:(const char *)err { - UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Account configuration issue", nil) - message:[AssistantView StringForXMLRPCError:err] - preferredStyle:UIAlertControllerStyleAlert]; - - UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; - - [errView addAction:defaultAction]; - [self presentViewController:errView animated:YES completion:nil]; + if (strcmp(err, "ERROR_KEY_DOESNT_MATCH") == 0) { + UIAlertController *errView = + [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Account configuration issue", nil) + message:[AssistantView StringForXMLRPCError:err] + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + self.linkAccountView.hidden = NO; + self.linkAccountView.userInteractionEnabled = YES; + self.activateSMSView.userInteractionEnabled = NO; + self.activateSMSView.hidden = YES; + self.activationCodeField.text = @""; + }]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; + } else { + UIAlertController *errView = + [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Account configuration issue", nil) + message:[AssistantView StringForXMLRPCError:err] + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action){ + }]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; + } } #pragma mark - cbs diff --git a/Classes/AssistantView.h b/Classes/AssistantView.h index 305b26df4..1c3b6a042 100644 --- a/Classes/AssistantView.h +++ b/Classes/AssistantView.h @@ -65,6 +65,7 @@ @property (weak, nonatomic) IBOutlet UILabel *accountLabel; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *createAccountNextButtonPositionConstraint; +@property(weak, nonatomic) IBOutlet UITextField *loginPhoneField; + (NSString *)errorForStatus:(LinphoneAccountCreatorStatus)status; + (NSString *)StringForXMLRPCError:(const char *)err; diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index ac0db68fe..693f85a6a 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -840,6 +840,24 @@ static UICompositeViewDescription *compositeDescription = nil; [errView addAction:defaultAction]; [errView addAction:continueAction]; [self presentViewController:errView animated:YES completion:nil]; + } else if (strcmp(err, "ERROR_KEY_DOESNT_MATCH") == 0) { + UIAlertController *errView = + [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Account configuration issue", nil) + message:[AssistantView StringForXMLRPCError:err] + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction *defaultAction = [UIAlertAction + actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *action) { + NSString *tmp_phone = + [NSString stringWithUTF8String:linphone_account_creator_get_phone_number(account_creator)]; + [self changeView:_linphoneLoginView back:TRUE animation:TRUE]; + self.loginPhoneField.text = tmp_phone; + }]; + + [errView addAction:defaultAction]; + [self presentViewController:errView animated:YES completion:nil]; } else { UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Account configuration issue", nil) message:[AssistantView StringForXMLRPCError:err] @@ -1111,7 +1129,11 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun - (IBAction)onCreateAccountActivationClick:(id)sender { ONCLICKBUTTON(sender, 100, { _waitView.hidden = NO; - linphone_account_creator_set_activation_code(account_creator, ((UITextField*)[self findView:ViewElement_SMSCode inView:_contentView ofType:UITextField.class]).text.UTF8String); + ((UITextField *)[self findView:ViewElement_SMSCode inView:_contentView ofType:UITextField.class]).text = @""; + linphone_account_creator_set_activation_code( + account_creator, + ((UITextField *)[self findView:ViewElement_SMSCode inView:_contentView ofType:UITextField.class]) + .text.UTF8String); if (linphone_account_creator_get_password(account_creator) == NULL && linphone_account_creator_get_ha1(account_creator) == NULL) { linphone_account_creator_activate_account(account_creator); @@ -1143,6 +1165,7 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun - (IBAction)onLinphoneLoginClick:(id)sender { ONCLICKBUTTON(sender, 100, { _waitView.hidden = NO; + ((UITextField *)[self findView:ViewElement_SMSCode inView:_contentView ofType:UITextField.class]).text = @""; _activationTitle.text = @"USE LINPHONE ACCOUNT"; if ((linphone_account_creator_get_phone_number(account_creator) != NULL) && linphone_account_creator_get_password(account_creator) == NULL && @@ -1293,9 +1316,13 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun - (IBAction)onBackClick:(id)sender { if ([historyViews count] > 0) { - UIView *view = [historyViews lastObject]; - [historyViews removeLastObject]; - [self changeView:view back:TRUE animation:TRUE]; + if (currentView == _createAccountActivateSMSView || currentView == _createAccountActivateEmailView) { + UIView *view = [historyViews lastObject]; + [historyViews removeLastObject]; + [self changeView:view back:TRUE animation:TRUE]; + } else { + [self changeView:_welcomeView back:TRUE animation:TRUE]; + } } } diff --git a/Classes/Base.lproj/AssistantViewScreens.xib b/Classes/Base.lproj/AssistantViewScreens.xib index d520b07cc..41d8b1f81 100644 --- a/Classes/Base.lproj/AssistantViewScreens.xib +++ b/Classes/Base.lproj/AssistantViewScreens.xib @@ -1,8 +1,11 @@ - + + + + - + @@ -19,12 +22,14 @@ + + @@ -40,6 +45,7 @@ - + @@ -211,7 +224,7 @@ - + @@ -224,7 +237,7 @@ - + - +