From ba3b82ed513c853cf13bde4e9c691d6236ebb6f6 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 29 Jul 2016 16:48:03 +0200 Subject: [PATCH] finishing assistant --- Classes/AssistantView.h | 1 + Classes/AssistantView.m | 48 +- Classes/Base.lproj/AssistantViewScreens.xib | 879 +++++++++++++++----- Classes/LinphoneManager.h | 1 + Classes/LinphoneUI/UIAssistantTextField.h | 1 + Resources/assistant_linphone_create.rc | 2 +- Resources/assistant_linphone_existing.rc | 2 +- TestsUI/ChatTester.m | 2 +- 8 files changed, 698 insertions(+), 238 deletions(-) diff --git a/Classes/AssistantView.h b/Classes/AssistantView.h index bea9d732a..930e73f01 100644 --- a/Classes/AssistantView.h +++ b/Classes/AssistantView.h @@ -56,6 +56,7 @@ @property (weak, nonatomic) IBOutlet UILabel *accountLabel; @property (weak, nonatomic) IBOutlet UIButton *countryButton; +@property (weak, nonatomic) IBOutlet NSLayoutConstraint *createAccountNextButtonPositionConstraint; + (NSString *)errorForStatus:(LinphoneAccountCreatorStatus)status; diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index 189e57b7b..72f0466c6 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -384,11 +384,20 @@ static UICompositeViewDescription *compositeDescription = nil; frame.size.width = size.width; [button setFrame:frame]; + [self fitContent]; + // also force next button alignement on create account page if (currentView == _createAccountView) { CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new]; CTCarrier *carrier = networkInfo.subscriberCellularProvider; NSDictionary *country = [CountryListViewController countryWithIso:carrier.isoCountryCode]; + + if (!IPAD) { + UISwitch *emailSwitch = (UISwitch *)[self findView:ViewElement_EmailFormView inView:self.contentView ofType:UISwitch.class]; + UILabel *emailLabel = (UILabel *)[self findView:ViewElement_EmailFormView inView:self.contentView ofType:UILabel.class]; + emailSwitch.hidden = emailLabel.hidden = YES; + } + if (!country) { //fetch phone locale for (NSString* lang in [NSLocale preferredLanguages]) { @@ -401,13 +410,12 @@ static UICompositeViewDescription *compositeDescription = nil; if (country) { [self didSelectCountry:country]; - [self onFormSwitchToggle:nil]; } + [self onFormSwitchToggle:nil]; } [self prepareErrorLabels]; - [self fitContent]; } - (void)fillDefaultValues { @@ -524,6 +532,14 @@ static UICompositeViewDescription *compositeDescription = nil; 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); createPhone.errorLabel.text = [AssistantView errorForStatus:s]; + + // if phone is empty and username is empty, this is wrong + if (s == LinphoneAccountCreatorOK) { + if (linphone_account_creator_get_phone_number(account_creator) == NULL + && linphone_account_creator_get_username(account_creator) == NULL) { + return LinphoneAccountCreatorPhoneNumberInvalid; + } + } return s != LinphoneAccountCreatorOK; }]; @@ -709,7 +725,8 @@ void assistant_is_account_used(LinphoneAccountCreator *creator, LinphoneAccountC AssistantView *thiz = (__bridge AssistantView *)(linphone_account_creator_get_user_data(creator)); thiz.waitView.hidden = YES; if (status == LinphoneAccountCreatorAccountExist) { - [[thiz findTextField:ViewElement_Username] showError:NSLocalizedString(@"This account already exists.", nil)]; + ViewElement ve = ([thiz findTextField:ViewElement_Username].isVisible) ? ViewElement_Username : ViewElement_Phone; + [[thiz findTextField:ve] showError:NSLocalizedString(@"This account already exists.", nil)]; [thiz findButton:ViewElement_NextButton].enabled = NO; } else if (status == LinphoneAccountCreatorAccountNotExist) { linphone_account_creator_create_account(thiz->account_creator); @@ -994,25 +1011,18 @@ void assistant_activate_phone_number_link(LinphoneAccountCreator *creator, Linph [self refreshYourUsername]; // put next button right after latest field (avoid blanks) - UIRoundBorderedButton* nextButton = [self findButton:ViewElement_NextButton]; - CGRect pos = nextButton.frame; - if (usernameView.hidden) { - pos.origin.y = usernameView.frame.origin.y; - } else if (emailView.hidden) { - pos.origin.y = emailView.frame.origin.y; - } else { - pos.origin.y = emailView.frame.origin.y + emailView.frame.size.height; + int old = _createAccountNextButtonPositionConstraint.constant; + _createAccountNextButtonPositionConstraint.constant = IPAD || !usernameView.hidden ? 21 : -10; + if (!usernameView.hidden) { + _createAccountNextButtonPositionConstraint.constant += usernameView.frame.size.height; + } + if (!emailView.hidden) { + _createAccountNextButtonPositionConstraint.constant += emailView.frame.size.height; } - nextButton.frame = pos; - // make view scrollable only if next button is too away CGRect viewframe = currentView.frame; - viewframe.size.height = pos.origin.y + pos.size.height; - currentView.autoresizesSubviews = NO; - currentView.frame = viewframe; - currentView.autoresizesSubviews = YES; - [self fitContent]; - + viewframe.size.height = 30 + _createAccountNextButtonPositionConstraint.constant - old + [self findButton:ViewElement_NextButton].frame.origin.y + [self findButton:ViewElement_NextButton].frame.size.height; + [_contentView setContentSize:viewframe.size]; [self shouldEnableNextButton]; } diff --git a/Classes/Base.lproj/AssistantViewScreens.xib b/Classes/Base.lproj/AssistantViewScreens.xib index 4444096e6..fbe8e52c3 100644 --- a/Classes/Base.lproj/AssistantViewScreens.xib +++ b/Classes/Base.lproj/AssistantViewScreens.xib @@ -1,8 +1,9 @@ - + + @@ -11,6 +12,7 @@ + @@ -28,30 +30,33 @@ - + + + + + + + + + + + + + + + + + + + + + @@ -122,35 +154,43 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + @@ -457,36 +633,41 @@ - + + + + + + + + + + + + + + + + + + @@ -523,36 +724,41 @@ Once it is done, come back here and click on the button. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -884,36 +1256,41 @@ Once it is done, come back here and click on the button. - + + + + + + + + + + + + + + + + + + + + + @@ -957,36 +1359,41 @@ Once it is done, come back here and click on the button. - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 97835c707..bc49613bf 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -33,6 +33,7 @@ #import "InAppProductsManager.h" #include "linphone/linphonecore.h" +#include "bctoolbox/list.h" extern NSString *const LINPHONERC_APPLICATION_KEY; diff --git a/Classes/LinphoneUI/UIAssistantTextField.h b/Classes/LinphoneUI/UIAssistantTextField.h index 4bab5652e..ed834c0e8 100644 --- a/Classes/LinphoneUI/UIAssistantTextField.h +++ b/Classes/LinphoneUI/UIAssistantTextField.h @@ -23,5 +23,6 @@ typedef BOOL (^DisplayErrorPred)(NSString *inputEntry); - (void)showError:(NSString *)msg when:(DisplayErrorPred)pred; - (void)showError:(NSString *)msg; - (BOOL)isInvalid; +- (BOOL)isVisible; @end diff --git a/Resources/assistant_linphone_create.rc b/Resources/assistant_linphone_create.rc index 8427fd932..130a83dbf 100644 --- a/Resources/assistant_linphone_create.rc +++ b/Resources/assistant_linphone_create.rc @@ -28,6 +28,6 @@ 64 1 ^[a-z0-9_.\-]*$ - http://sip3.linphone.org/xmlrpc.php + https://sip3.linphone.org:444/xmlrpc.php diff --git a/Resources/assistant_linphone_existing.rc b/Resources/assistant_linphone_existing.rc index da64ddffb..e16a435df 100644 --- a/Resources/assistant_linphone_existing.rc +++ b/Resources/assistant_linphone_existing.rc @@ -28,6 +28,6 @@ 64 1 ^[a-z0-9_.\-]*$ - http://sip3.linphone.org/xmlrpc.php + https://sip3.linphone.org:444/xmlrpc.php diff --git a/TestsUI/ChatTester.m b/TestsUI/ChatTester.m index 861d0b716..7f2511d0f 100644 --- a/TestsUI/ChatTester.m +++ b/TestsUI/ChatTester.m @@ -194,7 +194,7 @@ for (int i = 0; i < 50; i++) { [tester waitForTimeInterval:.5f]; - if (ms_list_size(linphone_chat_room_get_history(room, 0)) == count) { + if (bctbx_list_size(linphone_chat_room_get_history(room, 0)) == count) { break; } }