diff --git a/Classes/AssistantView.h b/Classes/AssistantView.h index 80423e53c..975103249 100644 --- a/Classes/AssistantView.h +++ b/Classes/AssistantView.h @@ -22,7 +22,7 @@ #import "TPKeyboardAvoidingScrollView.h" #import "PhoneMainView.h" -@interface AssistantView : UIViewController { +@interface AssistantView : UIViewController { @private LinphoneAccountCreator *account_creator; @@ -33,6 +33,7 @@ size_t number_of_configs_before; BOOL mustRestoreView; long phone_number_length; + BOOL acceptTerms; } @property(nonatomic) UICompositeViewDescription *outgoingView; @@ -70,6 +71,10 @@ @property (weak, nonatomic) IBOutlet UIButton *downloadButton; @property (weak, nonatomic) IBOutlet UITextField *urlLabel; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *createAccountNextButtonPositionConstraint; +@property (weak, nonatomic) IBOutlet UIButton *acceptButton; +- (IBAction)onAcceptTermsClick:(id)sender; +@property (weak, nonatomic) IBOutlet UITextView *acceptText; + + (NSString *)StringForXMLRPCError:(const char *)err; + (NSString *)errorForLinphoneAccountCreatorPhoneNumberStatus:(LinphoneAccountCreatorPhoneNumberStatus)status; diff --git a/Classes/AssistantView.m b/Classes/AssistantView.m index f00e7be8f..30bde7f05 100644 --- a/Classes/AssistantView.m +++ b/Classes/AssistantView.m @@ -62,6 +62,7 @@ typedef enum _ViewElement { historyViews = [[NSMutableArray alloc] init]; currentView = nil; mustRestoreView = NO; + acceptTerms = NO; } return self; } @@ -119,12 +120,28 @@ static UICompositeViewDescription *compositeDescription = nil; _outgoingView = DialerView.compositeViewDescription; _qrCodeButton.hidden = !ENABLE_QRCODE; [self resetLiblinphone:FALSE]; + [self enableWelcomeViewButtons]; + NSString *message = NSLocalizedString(@"I accept Belledonne Communications’ terms of use and privacy policy", nil); + NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:message]; + [attributedString addAttribute:NSLinkAttributeName + value:@"https://www.linphone.org/general-terms" + range:[[attributedString string] rangeOfString:NSLocalizedString(@"terms of use", nil)]]; + [attributedString addAttribute:NSLinkAttributeName + value:@"https://www.linphone.org/privacy-policy" + range:[[attributedString string] rangeOfString:NSLocalizedString(@"privacy policy", nil)]]; + + NSDictionary *linkAttributes = @{NSForegroundColorAttributeName : [UIColor redColor], + NSUnderlineStyleAttributeName : @(NSUnderlineStyleSingle)}; + + _acceptText.linkTextAttributes = linkAttributes; + _acceptText.attributedText = attributedString; + _acceptText.editable = NO; + _acceptText.delegate = self; } - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [NSNotificationCenter.defaultCenter removeObserver:self]; - } - (void)fitContent { @@ -143,6 +160,11 @@ static UICompositeViewDescription *compositeDescription = nil; [self fitContent]; } +#pragma mark - UITextViewDelegate +- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction { + return [[UIApplication sharedApplication] openURL:URL]; +} + #pragma mark - Utils - (void)resetLiblinphone:(BOOL)core { @@ -269,6 +291,12 @@ static UICompositeViewDescription *compositeDescription = nil; return NSLocalizedString(@"Unknown error, please try again later.", nil); } +- (void)enableWelcomeViewButtons { + UIImage *image = acceptTerms ? [UIImage imageNamed:@"checkbox_checked.png"] : [UIImage imageNamed:@"checkbox_unchecked.png"]; + [_acceptButton setImage:image forState:UIControlStateNormal]; + _gotoRemoteProvisioningButton.enabled = _gotoLinphoneLoginButton.enabled = _gotoCreateAccountButton.enabled = _gotoLoginButton.enabled = acceptTerms; +} + + (NSString *)errorForLinphoneAccountCreatorPhoneNumberStatus:(LinphoneAccountCreatorPhoneNumberStatus)status { switch (status) { case LinphoneAccountCreatorPhoneNumberStatusTooShort: /**< Phone number too short */ @@ -1654,6 +1682,11 @@ void assistant_is_account_linked(LinphoneAccountCreator *creator, LinphoneAccoun } } +- (IBAction)onAcceptTermsClick:(id)sender { + acceptTerms = !acceptTerms; + [self enableWelcomeViewButtons]; +} + #pragma mark - select country delegate - (void)didSelectCountry:(NSDictionary *)country { diff --git a/Classes/Base.lproj/AssistantViewScreens.xib b/Classes/Base.lproj/AssistantViewScreens.xib index 6dd202962..abf045536 100644 --- a/Classes/Base.lproj/AssistantViewScreens.xib +++ b/Classes/Base.lproj/AssistantViewScreens.xib @@ -1,14 +1,17 @@ - + - + + + + @@ -42,7 +45,7 @@ + + + + + + + + + + + + + + + + + + + + + + - + @@ -221,7 +272,7 @@ - + @@ -293,7 +344,7 @@ - + @@ -344,7 +395,7 @@ - + @@ -373,7 +424,7 @@ - + @@ -402,7 +453,7 @@ - + @@ -458,7 +509,7 @@ - + @@ -586,7 +637,7 @@ - + @@ -600,7 +651,7 @@ - + @@ -692,7 +743,7 @@ Once it is done, come back here and click on the button. - + @@ -756,7 +807,7 @@ Once it is done, come back here and click on the button. - + @@ -765,7 +816,7 @@ Once it is done, come back here and click on the button. - + @@ -776,7 +827,7 @@ Once it is done, come back here and click on the button. - + @@ -824,7 +875,7 @@ Once it is done, come back here and click on the button. - + @@ -857,7 +908,7 @@ Once it is done, come back here and click on the button. - + @@ -882,7 +933,7 @@ Once it is done, come back here and click on the button. - + @@ -928,7 +979,7 @@ Once it is done, come back here and click on the button. - + @@ -1033,7 +1084,7 @@ Once it is done, come back here and click on the button. - + @@ -1066,7 +1117,7 @@ Once it is done, come back here and click on the button. - + @@ -1099,7 +1150,7 @@ Once it is done, come back here and click on the button. - + @@ -1153,7 +1204,7 @@ Once it is done, come back here and click on the button. - + @@ -1184,7 +1235,7 @@ Once it is done, come back here and click on the button. - + @@ -1288,7 +1339,7 @@ Once it is done, come back here and click on the button. - + @@ -1319,7 +1370,7 @@ Once it is done, come back here and click on the button. - + @@ -1339,7 +1390,7 @@ Once it is done, come back here and click on the button. - + @@ -1412,7 +1463,7 @@ Once it is done, come back here and click on the button. - + @@ -1435,7 +1486,7 @@ Once it is done, come back here and click on the button. - + @@ -1458,7 +1509,7 @@ Once it is done, come back here and click on the button. - + @@ -1480,7 +1531,7 @@ Once it is done, come back here and click on the button. - + @@ -1539,6 +1590,22 @@ Once it is done, come back here and click on the button. + + + + + + + + + + + + + + + + diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 13f93ebf2..6b66641c8 100644 Binary files a/Resources/en.lproj/Localizable.strings and b/Resources/en.lproj/Localizable.strings differ diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings index 111352b45..b44a1e848 100644 Binary files a/Resources/fr.lproj/Localizable.strings and b/Resources/fr.lproj/Localizable.strings differ