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

This commit is contained in:
QuentinArguillere 2023-03-13 17:15:12 +01:00
parent 211714167a
commit 470ec60d99
6 changed files with 53 additions and 17 deletions

View file

@ -18,6 +18,7 @@
<outlet property="forwardImage" destination="1Wh-Yi-cUe" id="YQq-bt-pk1"/> <outlet property="forwardImage" destination="1Wh-Yi-cUe" id="YQq-bt-pk1"/>
<outlet property="groupCallImage" destination="SVn-4k-9yc" id="sAP-8V-ttn"/> <outlet property="groupCallImage" destination="SVn-4k-9yc" id="sAP-8V-ttn"/>
<outlet property="securityImage" destination="bbo-g3-bGy" id="qZa-li-yrl"/> <outlet property="securityImage" destination="bbo-g3-bGy" id="qZa-li-yrl"/>
<outlet property="subscribeLabel" destination="Xbl-Qs-GaE" id="Qnf-pA-nL0"/>
<outlet property="titleLabel" destination="jLz-g1-cTe" id="qaj-OB-2r1"/> <outlet property="titleLabel" destination="jLz-g1-cTe" id="qaj-OB-2r1"/>
<outlet property="view" destination="2Vb-Xy-rci" id="nNw-EJ-AY3"/> <outlet property="view" destination="2Vb-Xy-rci" id="nNw-EJ-AY3"/>
</connections> </connections>
@ -105,12 +106,27 @@
<rect key="frame" x="100" y="50" width="136" height="54"/> <rect key="frame" x="100" y="50" width="136" height="54"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/> <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView> </imageView>
<label hidden="YES" opaque="NO" tag="13" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="https://subscribe.linphone.org" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Xbl-Qs-GaE" userLabel="subscribeLabel">
<rect key="frame" x="-42" y="291" width="414" height="29"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.98766469960000003" green="0.27512490750000002" blue="0.029739789660000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<connections>
<outletCollection property="gestureRecognizers" destination="tfG-O1-yfD" appends="YES" id="Jcg-KH-U5B"/>
</connections>
</label>
</subviews> </subviews>
</view> </view>
</subviews> </subviews>
<nil key="simulatedStatusBarMetrics"/> <nil key="simulatedStatusBarMetrics"/>
<point key="canvasLocation" x="871.20000000000005" y="261.31934032983509"/> <point key="canvasLocation" x="548" y="34"/>
</view> </view>
<tapGestureRecognizer id="tfG-O1-yfD" userLabel="onSubscribeTap">
<connections>
<action selector="onSubscribeTap:" destination="-1" id="Zq2-mP-ccM"/>
</connections>
</tapGestureRecognizer>
</objects> </objects>
<resources> <resources>
<image name="checkbox_checked.png" width="27.200000762939453" height="27.200000762939453"/> <image name="checkbox_checked.png" width="27.200000762939453" height="27.200000762939453"/>

View file

@ -56,11 +56,14 @@ typedef void (^UIConfirmationBlock)(void);
@property(weak, nonatomic) IBOutlet UILabel *titleLabel; @property(weak, nonatomic) IBOutlet UILabel *titleLabel;
@property(weak, nonatomic) IBOutlet UIView *firstView; @property(weak, nonatomic) IBOutlet UIView *firstView;
@property (weak, nonatomic) IBOutlet UIButton *authButton; @property (weak, nonatomic) IBOutlet UIButton *authButton;
@property(weak, nonatomic) IBOutlet UILabel *subscribeLabel;
- (void)setSpecialColor; - (void)setSpecialColor;
-(void) setWhiteCancel; -(void) setWhiteCancel;
- (IBAction)onCancelClick:(id)sender; - (IBAction)onCancelClick:(id)sender;
- (IBAction)onConfirmationClick:(id)sender; - (IBAction)onConfirmationClick:(id)sender;
- (IBAction)onAuthClick:(id)sender; - (IBAction)onAuthClick:(id)sender;
- (IBAction)onSubscribeTap:(id)sender;
- (void)dismiss; - (void)dismiss;
@end @end

View file

@ -145,4 +145,12 @@
- (void)dismiss { - (void)dismiss {
[self onCancelClick:nil]; [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 @end

View file

@ -885,25 +885,34 @@ void update_hash_cbs(LinphoneAccountCreator *creator, LinphoneAccountCreatorStat
[PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription]; [PhoneMainView.instance changeCurrentView:AssistantView.compositeViewDescription];
return; return;
} else if ([key isEqual:@"account_mandatory_remove_button"]) { } else if ([key isEqual:@"account_mandatory_remove_button"]) {
UIAlertController *errView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Warning", nil) NSString *popUpText;
message:NSLocalizedString(@"Are you sure to want to remove your proxy setup?", nil) NSString *appDomain = [LinphoneManager.instance lpConfigStringForKey:@"domain_name"
preferredStyle:UIAlertControllerStyleAlert]; inSection:@"app"
withDefault:@"sip.linphone.org"];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", nil) MSList *accountList = [LinphoneManager.instance createAccountsNotHiddenList];
style:UIAlertActionStyleDefault LinphoneAccount *account = bctbx_list_nth_data(accountList,
handler:^(UIAlertAction * action) {}]; [settingsStore integerForKey:@"current_proxy_config_preference"]);
UIAlertAction* continueAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"Yes", nil) bool isLinphoneAccount = strcmp(appDomain.UTF8String, linphone_account_params_get_domain(linphone_account_get_params(account))) == 0;
style:UIAlertActionStyleDefault if (isLinphoneAccount) {
handler:^(UIAlertAction * action) { popUpText = NSLocalizedString(@"Your account will only be deleted locally.\nTo delete it permanently, go to our account management platform:", nil);
[settingsStore removeAccount]; } else {
[self recomputeAccountLabelsAndSync]; popUpText = NSLocalizedString(@"Your account will only be deleted locally.\nTo delete it permanently, go on your SIP provider website.", nil);
[_settingsController.navigationController popViewControllerAnimated:NO]; }
}]; bctbx_free(accountList);
[errView addAction:defaultAction]; UIConfirmationDialog *dialog = [UIConfirmationDialog ShowWithMessage:popUpText
[errView addAction:continueAction]; cancelMessage:nil
[self presentViewController:errView animated:YES completion: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"]) { } else if ([key isEqual:@"account_mandatory_change_password"]) {
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Change your password", nil) UIAlertController *alertView = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Change your password", nil)
message:NSLocalizedString(@"Please enter and confirm your new password", nil) message:NSLocalizedString(@"Please enter and confirm your new password", nil)