From faa4e15462cd51a268c62d5a0bbc781d802a85f0 Mon Sep 17 00:00:00 2001 From: Danmei Chen Date: Mon, 15 Feb 2021 11:24:53 +0100 Subject: [PATCH] add checkbox for accept terms of use and privacy policy --- Classes/AssistantView.h | 7 +- Classes/AssistantView.m | 35 ++++- Classes/Base.lproj/AssistantViewScreens.xib | 151 ++++++++++++++------ Resources/en.lproj/Localizable.strings | Bin 52084 -> 52510 bytes Resources/fr.lproj/Localizable.strings | Bin 55322 -> 55870 bytes 5 files changed, 149 insertions(+), 44 deletions(-) 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 13f93ebf210ce938c5c6eb030aef5978858edc7e..6b66641c8bcad2086dc1f5e9886d8a3c4624e8b5 100644 GIT binary patch delta 439 zcmew|jd|WI<_#sM>y;Qh859^28Ipl8m7##41jus&vT}ehl_7;8pCJzjQ-Pw+Kz1$= zmIC>iK-GyrwV7b~Vg^YC1t2e#p$I5n3{;!XkOm}6fozb@M4*loAYA~I&txbA+g1tY z=hp+R0U1`wpac}K1!DR-s2;;bNDi`Q-~u`am%k7W#;pQk0v3P6Y|%yXHy&j`RUo4P DYI9I{ delta 9 QcmbO?i}}km<_#sM0T%HDxBvhE diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings index 111352b45eb949f63b153cdbbb25cf35acae2609..b44a1e8489b205a0bc8e89cdb22e2eb751373daa 100644 GIT binary patch delta 468 zcmb7AI|{;35F8LhY^@Z;XYc}67Gj~P^cErS2>~_H7$H>-kl2~VoxGg1!0IP3UjxN38>Hoi?hcTK|_ifFW{!ou%$^SZ#Xi)tP!n#0t SH?8T1i+ni9@0Ggsr?dxbgj%5h delta 9 QcmdnDg?ZKn<_%Ie02ZJGWdHyG