From 470ec60d994264f81f89052069bb2535b7a6fae8 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Mon, 13 Mar 2023 17:15:12 +0100 Subject: [PATCH] When deleting account, replace previous system alert pop up with a custom confirmation dialog that includes (if the account was a linphone account) a link to susbscribe.linphone.org for permanent deletion --- .../Base.lproj/UIConfirmationDialog.xib | 18 +++++++- Classes/LinphoneUI/UIConfirmationDialog.h | 3 ++ Classes/LinphoneUI/UIConfirmationDialog.m | 8 ++++ Classes/SettingsView.m | 41 +++++++++++------- Resources/en.lproj/Localizable.strings | Bin 53308 -> 54184 bytes Resources/fr.lproj/Localizable.strings | Bin 74688 -> 75698 bytes 6 files changed, 53 insertions(+), 17 deletions(-) diff --git a/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib b/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib index e6a555139..19b1b5271 100644 --- a/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib +++ b/Classes/LinphoneUI/Base.lproj/UIConfirmationDialog.xib @@ -18,6 +18,7 @@ + @@ -105,12 +106,27 @@ + - + + + + + + diff --git a/Classes/LinphoneUI/UIConfirmationDialog.h b/Classes/LinphoneUI/UIConfirmationDialog.h index d026bdfe5..08dadf985 100644 --- a/Classes/LinphoneUI/UIConfirmationDialog.h +++ b/Classes/LinphoneUI/UIConfirmationDialog.h @@ -56,11 +56,14 @@ typedef void (^UIConfirmationBlock)(void); @property(weak, nonatomic) IBOutlet UILabel *titleLabel; @property(weak, nonatomic) IBOutlet UIView *firstView; @property (weak, nonatomic) IBOutlet UIButton *authButton; +@property(weak, nonatomic) IBOutlet UILabel *subscribeLabel; + - (void)setSpecialColor; -(void) setWhiteCancel; - (IBAction)onCancelClick:(id)sender; - (IBAction)onConfirmationClick:(id)sender; - (IBAction)onAuthClick:(id)sender; +- (IBAction)onSubscribeTap:(id)sender; - (void)dismiss; @end diff --git a/Classes/LinphoneUI/UIConfirmationDialog.m b/Classes/LinphoneUI/UIConfirmationDialog.m index 327bb3f04..0abd0ecc4 100644 --- a/Classes/LinphoneUI/UIConfirmationDialog.m +++ b/Classes/LinphoneUI/UIConfirmationDialog.m @@ -145,4 +145,12 @@ - (void)dismiss { [self onCancelClick:nil]; } + +- (IBAction)onSubscribeTap:(id)sender { + UIGestureRecognizer *gest = sender; + NSString *url = ((UILabel *)gest.view).text; + if (![UIApplication.sharedApplication openURL:[NSURL URLWithString:url]]) { + LOGE(@"Failed to open %@, invalid URL", url); + } +} @end diff --git a/Classes/SettingsView.m b/Classes/SettingsView.m index dccfa4b6c..f92f93988 100644 --- a/Classes/SettingsView.m +++ b/Classes/SettingsView.m @@ -885,25 +885,34 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat [PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription]; return; } else if ([key isEqual:@"account_mandatory_remove_button"]) { - UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) - message:NSLocalizedString(@"Are you sure to want to remove your proxy setup?", nil) - preferredStyle:UIAlertControllerStyleAlert]; + NSString *popUpText; + NSString *appDomain = [LinphoneManager.instance lpConfigStringForKey:@"domain_name" + inSection:@"app" + withDefault:@"sip.linphone.org"]; - UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) {}]; + MSList *accountList = [LinphoneManager.instance createAccountsNotHiddenList]; + LinphoneAccount *account = bctbx_list_nth_data(accountList, + [settingsStore integerForKey:@"current_proxy_config_preference"]); - UIAlertAction* continueAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Yes", nil) - style:UIAlertActionStyleDefault - handler:^(UIAlertAction * action) { - [settingsStore removeAccount]; - [self recomputeAccountLabelsAndSync]; - [_settingsController.navigationController popViewControllerAnimated:NO]; - }]; + bool isLinphoneAccount = strcmp(appDomain.UTF8String, linphone_account_params_get_domain(linphone_account_get_params(account))) == 0; + if (isLinphoneAccount) { + popUpText = NSLocalizedString(@"Your account will only be deleted locally.\nTo delete it permanently, go to our account management platform:", nil); + } else { + popUpText = NSLocalizedString(@"Your account will only be deleted locally.\nTo delete it permanently, go on your SIP provider website.", nil); + } + bctbx_free(accountList); - [errView addAction:defaultAction]; - [errView addAction:continueAction]; - [self presentViewController:errView animated:YES completion:nil]; + UIConfirmationDialog *dialog = [UIConfirmationDialog ShowWithMessage:popUpText + cancelMessage:nil + confirmMessage:nil + onCancelClick:nil + onConfirmationClick:^() { + [settingsStore removeAccount]; + [self recomputeAccountLabelsAndSync]; + [_settingsController.navigationController popViewControllerAnimated:NO]; + }]; + dialog.subscribeLabel.hidden = !isLinphoneAccount; // Only display link to https://subscribe.linphone.org for linphone accounts + } else if ([key isEqual:@"account_mandatory_change_password"]) { UIAlertController *alertView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Change your password", nil) message:NSLocalizedString(@"Please enter and confirm your new password", nil) diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index bd19a5cae76d062a4475c915e18a76ae91050bad..488bda1dd96a963b702136655f81d036338626f7 100644 GIT binary patch delta 510 zcmdn9fO*Ao<_%}IPM)xZN3fhBlOYEP6&Ugv@_=;ZPqCNJEqN^W>lX75hn$sabeY(BHKKneh`lX_18 delta 14 WcmZ3noO#az<_%}IZnoH2AO!$7A_oxw diff --git a/Resources/fr.lproj/Localizable.strings b/Resources/fr.lproj/Localizable.strings index da2f63ca4bd92f76208b11c0a2a6c1da9daf6c7a..791066e50394471eb16c6b98244b69df6dcf86a3 100644 GIT binary patch delta 710 zcmd5)yH3MU3^h_E7!Xycs=$D_Dnfleu?hKo<8`r)WtIZD(c0n$>XurZi;TO;BC}33!A-kbEjX|klYN%|Jx(G?}w{PO>%#^ zN#>}gc=yTPn|0x0#*4mX7a{hLqn{Z1BkJ(m)czkcyp$Pg=*sK4&$Rk;wPqXgmaejD Y8!|uHk=P3VVT`U4c#Pe7Tq$3Azj!sC&;S4c delta 14 WcmdmVp5?%CmJJfeH*=j{5d#1>Ee9+B