diff --git a/Classes/AssistantView.h b/Classes/AssistantView.h index 15372850a..bcca483ea 100644 --- a/Classes/AssistantView.h +++ b/Classes/AssistantView.h @@ -43,7 +43,6 @@ @property(nonatomic, strong) IBOutlet UIView *createAccountView; @property(nonatomic, strong) IBOutlet UIView *createAccountActivateEmailView; @property(nonatomic, strong) IBOutlet UIView *linphoneLoginView; -@property(strong, nonatomic) IBOutlet UIView *linkAccountView; @property(nonatomic, strong) IBOutlet UIView *loginView; @property(nonatomic, strong) IBOutlet UIView *remoteProvisioningLoginView; @property(strong, nonatomic) IBOutlet UIView *remoteProvisioningView; @@ -56,6 +55,7 @@ @property(nonatomic, strong) IBOutlet UIButton *gotoRemoteProvisioningButton; @property (weak, nonatomic) IBOutlet UILabel *accountLabel; +@property (weak, nonatomic) IBOutlet UIButton *countryButton; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *createAccountNextButtonPositionConstraint; + (NSString *)errorForStatus:(LinphoneAccountCreatorStatus)status; @@ -78,7 +78,6 @@ - (IBAction)onRemoteProvisioningLoginClick:(id)sender; - (IBAction)onRemoteProvisioningDownloadClick:(id)sender; - (IBAction)onCreateAccountCheckActivatedClick:(id)sender; -- (IBAction)onLinkAccountClick:(id)sender; - (IBAction)onFormSwitchToggle:(id)sender; - (IBAction)onCountryCodeClick:(id)sender; diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 3b3ae56f9..8f4da2359 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -50,8 +50,6 @@ typedef enum _ViewElement { ViewElement_Username_Label = 120, ViewElement_NextButton = 130, - ViewElement_PhoneButton = 150, - ViewElement_UsernameFormView = 181, ViewElement_EmailFormView = 182, } ViewElement; @@ -96,6 +94,14 @@ static UICompositeViewDescription *compositeDescription = nil; #pragma mark - ViewController Functions +- (void)viewDidLoad { + [super viewDidLoad]; + _countryButton.layer.borderWidth = .8; + _countryButton.layer.borderColor = _countryButton.backgroundColor.CGColor; + _countryButton.layer.cornerRadius = 4.f; + _countryButton.layer.masksToBounds = YES; +} + - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; @@ -361,7 +367,7 @@ static UICompositeViewDescription *compositeDescription = nil; [self fitContent]; // also force next button alignement on create account page - if ([self findView:ViewElement_PhoneButton inView:currentView ofType:UIButton.class]) { + if (currentView == _createAccountView) { CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new]; CTCarrier *carrier = networkInfo.subscriberCellularProvider; NSDictionary *country = [CountryListViewController countryWithIso:carrier.isoCountryCode]; @@ -388,12 +394,6 @@ static UICompositeViewDescription *compositeDescription = nil; [self onFormSwitchToggle:nil]; } - UIButton *countryButton = [self findButton:ViewElement_PhoneButton]; - countryButton.layer.borderWidth = .8; - countryButton.layer.borderColor = countryButton.backgroundColor.CGColor; - countryButton.layer.cornerRadius = 4.f; - countryButton.layer.masksToBounds = YES; - [self prepareErrorLabels]; } @@ -446,8 +446,6 @@ static UICompositeViewDescription *compositeDescription = nil; if ([view isKindOfClass:UIAssistantTextField.class]) { [(UIAssistantTextField *)view setText:@""]; ((UIAssistantTextField *)view).canShowError = NO; - } else if (view.tag == ViewElement_PhoneButton) { - [(UIButton *)view setTitle:NSLocalizedString(@"Select your country", nil) forState:UIControlStateNormal]; } else { for (UIView *subview in view.subviews) { [AssistantView cleanTextField:subview]; @@ -494,21 +492,19 @@ static UICompositeViewDescription *compositeDescription = nil; [createPhone showError:[AssistantView errorForStatus:LinphoneAccountCreatorPhoneNumberInvalid] when:^BOOL(NSString *inputEntry) { UIAssistantTextField* countryCodeField = [self findTextField:ViewElement_PhoneCC]; - NSString *prefix = (inputEntry.length > 0 && countryCodeField.text.length > 0) - ? [countryCodeField.text substringFromIndex:1] - : nil; + NSString* prefix = countryCodeField.text.length > 0 ? [countryCodeField.text substringFromIndex:1] : nil; LinphoneAccountCreatorStatus s = linphone_account_creator_set_phone_number(account_creator, inputEntry.length > 0 ? inputEntry.UTF8String : NULL, prefix.UTF8String); - if (s != LinphoneAccountCreatorOK) { - linphone_account_creator_set_phone_number(account_creator, NULL, NULL); - // if phone is empty and username is empty, this is wrong - if (linphone_account_creator_get_username(account_creator) == NULL) { - s = LinphoneAccountCreatorPhoneNumberTooShort; - } + if (s != LinphoneAccountCreatorOK) linphone_account_creator_set_phone_number(account_creator, NULL, NULL); + + // if phone is empty and username is empty, this is wrong + if (linphone_account_creator_get_username(account_creator) == NULL) { + s = LinphoneAccountCreatorPhoneNumberTooShort; } createPhone.errorLabel.text = [AssistantView errorForStatus:s]; + return s != LinphoneAccountCreatorOK; }]; @@ -678,69 +674,18 @@ static UICompositeViewDescription *compositeDescription = nil; } } -- (NSString *)stringForError:(const char *)err { -#define IS(x) (strcmp(err, #x) == 0) - if - IS(ERROR_ACCOUNT_ALREADY_ACTIVATED) - return NSLocalizedString(@"This account is already activated.", nil); - if - IS(ERROR_ACCOUNT_ALREADY_IN_USE) - return NSLocalizedString(@"This account is already in use.", nil); - if - IS(ERROR_ACCOUNT_DOESNT_EXIST) - return NSLocalizedString(@"This account does not exist.", nil); - if - IS(ERROR_ACCOUNT_NOT_ACTIVATED) - return NSLocalizedString(@"This account is not activated yet.", nil); - if - IS(ERROR_ALIAS_ALREADY_IN_USE) - return NSLocalizedString(@"This alias is already used.", nil); - if - IS(ERROR_ALIAS_DOESNT_EXIST) - return NSLocalizedString(@"This alias does not exist.", nil); - if - IS(ERROR_EMAIL_ALREADY_IN_USE) - return NSLocalizedString(@"This email address is already used.", nil); - if - IS(ERROR_EMAIL_DOESNT_EXIST) - return NSLocalizedString(@"This email does not exist.", nil); - if - IS(ERROR_KEY_DOESNT_MATCH) - return NSLocalizedString(@"The confirmation code is invalid.", nil); - if - IS(ERROR_PASSWORD_DOESNT_MATCH) - return NSLocalizedString(@"Passwords do not match.", nil); - if - IS(ERROR_PHONE_ISNT_E164) - return NSLocalizedString(@"Your phone number is invalid.", nil); - - if (!linphone_core_is_network_reachable(LC)) - return NSLocalizedString(@"There is no network connection available, enable " - @"WIFI or WWAN prior to configure an account", - nil); - - return NSLocalizedString(@"Unknown error, please try again later", nil); -} - -- (void)showErrorPopup:(const char *)err { - UIAlertView *errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Account configuration issue", nil) - message:[self stringForError:err] - delegate:nil - cancelButtonTitle:NSLocalizedString(@"Cancel", nil) - otherButtonTitles:nil, nil]; +- (void)genericError { + UIAlertView *errorView = [[UIAlertView alloc] + initWithTitle:NSLocalizedString(@"Account creation issue", nil) + message:NSLocalizedString(@"Your account could not be created, please try again later.", nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil, nil]; [errorView show]; } -- (void)isAccountUsed:(LinphoneAccountCreatorStatus)status withResp:(const char *)resp { - if (currentView == _linphoneLoginView) { - if (status == LinphoneAccountCreatorAccountExistWithAlias) { - [self configureProxyConfig]; - } else if (status == LinphoneAccountCreatorAccountExist) { - [self changeView:_linkAccountView back:NO animation:YES]; - } else { - [self showErrorPopup:resp]; - } - } else { +- (void)isAccountUsed:(LinphoneAccountCreatorStatus)status { + if (currentView == _createAccountView) { if (status == LinphoneAccountCreatorAccountExist || status == LinphoneAccountCreatorAccountExistWithAlias) { ViewElement ve = ([self findTextField:ViewElement_Username].isVisible) ? ViewElement_Username : ViewElement_Phone; [[self findTextField:ve] showError:NSLocalizedString(@"This account already exists.", nil)]; @@ -748,20 +693,30 @@ static UICompositeViewDescription *compositeDescription = nil; } else if (status == LinphoneAccountCreatorAccountNotExist) { linphone_account_creator_create_account(account_creator); } else { - [self showErrorPopup:resp]; + [self genericError]; + } + } else if (currentView == _linphoneLoginView) { + [self findTextField:ViewElement_PhoneCC].enabled = + [self findTextField:ViewElement_Phone].enabled = + [self findTextField:ViewElement_DisplayName].enabled = + [self findTextField:ViewElement_Password].enabled = (status == LinphoneAccountCreatorAccountExist); + if (status == LinphoneAccountCreatorAccountExistWithAlias) { + [self findButton:ViewElement_NextButton].enabled = YES; + } else { + [self shouldEnableNextButton]; } } } #pragma mark - Account creator callbacks -void assistant_is_account_used(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +void assistant_is_account_used(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; - [thiz isAccountUsed:status withResp:resp]; + [thiz isAccountUsed:status]; } -void assistant_create_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, const char *resp) { +void assistant_create_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; if (status == LinphoneAccountCreatorAccountCreated) { @@ -771,37 +726,42 @@ void assistant_create_account(LinphoneAccountCreator *creator, LinphoneAccountCr [thiz changeView:thiz.createAccountActivateEmailView back:FALSE animation:TRUE]; } } else { - [thiz showErrorPopup:resp]; + [thiz genericError]; } } -void assistant_recover_phone_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, - const char *resp) { +void assistant_recover_phone_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; if (status == LinphoneAccountCreatorOK) { [thiz changeView:thiz.createAccountActivateSMSView back:FALSE animation:TRUE]; } else { - [thiz showErrorPopup:resp]; + [thiz genericError]; } } -void assistant_activate_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, - const char *resp) { +void assistant_activate_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; if (status == LinphoneAccountCreatorAccountActivated) { [thiz configureProxyConfig]; + } else if (status == LinphoneAccountCreatorAccountNotActivated) { + UIAlertView *errorView = [[UIAlertView alloc] + initWithTitle:NSLocalizedString(@"Account activation issue", nil) + message:NSLocalizedString(@"Your account could not be activated, please check SMS code.", nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil, nil]; + [errorView show]; } else if (status == LinphoneAccountCreatorAccountAlreadyActivated) { // in case we are actually trying to link account, let's try it now linphone_account_creator_activate_phone_number_link(creator); } else { - [thiz showErrorPopup:resp]; + [thiz genericError]; } } -void assistant_is_account_activated(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, - const char *resp) { +void assistant_is_account_activated(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; if (status == LinphoneAccountCreatorAccountActivated) { @@ -821,29 +781,39 @@ void assistant_is_account_activated(LinphoneAccountCreator *creator, LinphoneAcc }]; [alert show]; } else { - [thiz showErrorPopup:resp]; + [thiz genericError]; } } -void assistant_link_phone_number_with_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, - const char *resp) { +void assistant_link_phone_number_with_account(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; if (status == LinphoneAccountCreatorOK) { [thiz changeView:thiz.createAccountActivateSMSView back:FALSE animation:TRUE]; } else { - [thiz showErrorPopup:resp]; + UIAlertView *errorView = [[UIAlertView alloc] + initWithTitle:NSLocalizedString(@"Account link issue", nil) + message:NSLocalizedString(@"Could not link your phone number with your account, please try again later.", nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil, nil]; + [errorView show]; } } -void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status, - const char *resp) { +void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, LinphoneAccountCreatorStatus status) { AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; if (status == LinphoneAccountCreatorOK) { [thiz configureProxyConfig]; } else { - [thiz showErrorPopup:resp]; + UIAlertView *errorView = [[UIAlertView alloc] + initWithTitle:NSLocalizedString(@"Account link issue", nil) + message:NSLocalizedString(@"Could not link your phone number with your account, please try again later.", nil) + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil, nil]; + [errorView show]; } } @@ -857,6 +827,11 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph - (void)textFieldDidEndEditing:(UITextField *)textField { UIAssistantTextField *atf = (UIAssistantTextField *)textField; [atf textFieldDidEndEditing:atf]; + + if (textField.tag == ViewElement_Username && currentView == _linphoneLoginView) { + linphone_account_creator_is_account_used(account_creator); + } + [self shouldEnableNextButton]; } @@ -967,25 +942,21 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph }); } -- (IBAction)onLinkAccountClick:(id)sender { - ONCLICKBUTTON(sender, 100, { - _waitView.hidden = NO; - linphone_account_creator_link_phone_number_with_account(account_creator); - }); -} - - (IBAction)onLinphoneLoginClick:(id)sender { ONCLICKBUTTON(sender, 100, { _waitView.hidden = NO; - if ((linphone_account_creator_get_phone_number(account_creator) != NULL) && - linphone_account_creator_get_password(account_creator) == NULL) { - linphone_account_creator_recover_phone_account(account_creator); - } else { - // check if account is already linked with a phone number. - // if not, propose it to the user - linphone_account_creator_is_account_used(account_creator); - } + NSString *phone = [self findTextField:ViewElement_Phone].text; + if (phone.length > 0) { + linphone_account_creator_link_phone_number_with_account(account_creator); + } else { + if ((linphone_account_creator_get_phone_number(account_creator) != NULL) + && [self findTextField:ViewElement_Password].text.length == 0) { + linphone_account_creator_recover_phone_account(account_creator); + } else { + [self configureProxyConfig]; + } + } }); } @@ -1040,11 +1011,7 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph emailView.hidden = !emailSwitch.isOn; UIAssistantTextField* countryCodeField = [self findTextField:ViewElement_PhoneCC]; - UIButton *phoneButton = - (UIButton *)[self findView:ViewElement_PhoneButton inView:currentView ofType:UIButton.class]; - usernameSwitch.enabled = phoneButton.enabled = countryCodeField.enabled = countryCodeField.userInteractionEnabled = - [self findTextField:ViewElement_Phone].userInteractionEnabled = [self findTextField:ViewElement_Phone].enabled = - !emailSwitch.isOn; + usernameSwitch.enabled = _countryButton.enabled = countryCodeField.enabled = countryCodeField.userInteractionEnabled = [self findTextField:ViewElement_Phone].userInteractionEnabled = [self findTextField:ViewElement_Phone].enabled = !emailSwitch.isOn; [self refreshYourUsername]; @@ -1076,10 +1043,7 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph UIAssistantTextField* countryCodeField = [self findTextField:ViewElement_PhoneCC]; NSDictionary *c = [CountryListViewController countryWithCountryCode:countryCodeField.text]; if (c || force) { - UIButton *phoneButton = - (UIButton *)[self findView:ViewElement_PhoneButton inView:currentView ofType:UIButton.class]; - [phoneButton setTitle:c ? [c objectForKey:@"name"] : NSLocalizedString(@"Unknown country code", nil) - forState:UIControlStateNormal]; + [_countryButton setTitle:c ? [c objectForKey:@"name"] : NSLocalizedString(@"Unknown country code", nil) forState:UIControlStateNormal]; } } @@ -1123,9 +1087,7 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph #pragma mark - select country delegate - (void)didSelectCountry:(NSDictionary *)country{ - UIButton *phoneButton = - (UIButton *)[self findView:ViewElement_PhoneButton inView:currentView ofType:UIButton.class]; - [phoneButton setTitle:[country objectForKey:@"name"] forState:UIControlStateNormal]; + [_countryButton setTitle:[country objectForKey:@"name"] forState:UIControlStateNormal]; UIAssistantTextField* countryCodeField = [self findTextField:ViewElement_PhoneCC]; countryCodeField.text = countryCodeField.lastText = [country objectForKey:@"code"]; phone_number_length = [[country objectForKey:@"phone_length"] integerValue]; diff --git a/Classes/Base.lproj/AssistantViewScreens.xib b/Classes/Base.lproj/AssistantViewScreens.xib index 54b37365e..8bea0f8db 100644 --- a/Classes/Base.lproj/AssistantViewScreens.xib +++ b/Classes/Base.lproj/AssistantViewScreens.xib @@ -1,25 +1,23 @@ - + - - - + - + + - @@ -33,23 +31,26 @@ - + @@ -151,40 +155,44 @@ - - + + @@ -202,9 +211,10 @@ - + + - + @@ -214,14 +224,16 @@ + + - + - + + + @@ -448,6 +485,7 @@ + @@ -470,13 +508,10 @@ - - - @@ -484,9 +519,16 @@ + + + + + + + @@ -494,47 +536,53 @@ + - + @@ -586,45 +634,50 @@ - + @@ -668,243 +721,188 @@ Once it is done, come back here and click on the button. - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - + @@ -1150,28 +1042,31 @@ Once it is done, come back here and click on the button. - + + - + @@ -1181,28 +1076,31 @@ Once it is done, come back here and click on the button. - + + - + @@ -1212,22 +1110,25 @@ Once it is done, come back here and click on the button. + @@ -1236,23 +1137,25 @@ Once it is done, come back here and click on the button. - + - + + - + @@ -1261,14 +1164,16 @@ Once it is done, come back here and click on the button. - + @@ -1352,37 +1257,41 @@ Once it is done, come back here and click on the button. - + + - + @@ -1391,14 +1300,16 @@ Once it is done, come back here and click on the button. - + @@ -1449,37 +1360,41 @@ Once it is done, come back here and click on the button. - + + - + @@ -1488,20 +1403,22 @@ Once it is done, come back here and click on the button. - + + - + @@ -1510,20 +1427,22 @@ Once it is done, come back here and click on the button. - + + - + @@ -1532,6 +1451,7 @@ Once it is done, come back here and click on the button. - + diff --git a/Classes/Base.lproj/ShopView.xib b/Classes/Base.lproj/ShopView.xib index 30244a970..0edad4a8d 100644 --- a/Classes/Base.lproj/ShopView.xib +++ b/Classes/Base.lproj/ShopView.xib @@ -1,9 +1,8 @@ - + - - + @@ -12,6 +11,7 @@ + @@ -22,24 +22,24 @@ - + - + - + - + - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -105,14 +233,11 @@ + + - - - - - diff --git a/Classes/Utils/XMLRPC/XMLRPC.xcodeproj/project.pbxproj b/Classes/Utils/XMLRPC/XMLRPC.xcodeproj/project.pbxproj index c168ec50a..56618966f 100755 --- a/Classes/Utils/XMLRPC/XMLRPC.xcodeproj/project.pbxproj +++ b/Classes/Utils/XMLRPC/XMLRPC.xcodeproj/project.pbxproj @@ -315,7 +315,7 @@ 0867D690FE84028FC02AAC07 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0700; }; buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "XMLRPC" */; compatibilityVersion = "Xcode 3.2"; diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 14a759bfd..6367cc89f 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -3114,7 +3114,7 @@ 29B97313FDCFA39411CA2CEA /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0730; TargetAttributes = { 1D6058900D05DD3D006BFB54 = { DevelopmentTeam = Z2V957B3D6; diff --git a/linphone.xcodeproj/xcshareddata/xcschemes/LinphoneTester.xcscheme b/linphone.xcodeproj/xcshareddata/xcschemes/LinphoneTester.xcscheme index bdb2c169f..dac8a6c4d 100644 --- a/linphone.xcodeproj/xcshareddata/xcschemes/LinphoneTester.xcscheme +++ b/linphone.xcodeproj/xcshareddata/xcschemes/LinphoneTester.xcscheme @@ -1,6 +1,6 @@