diff --git a/Riot/Assets/fr.lproj/Vector.strings b/Riot/Assets/fr.lproj/Vector.strings index e17c741f5..d84d158a3 100644 --- a/Riot/Assets/fr.lproj/Vector.strings +++ b/Riot/Assets/fr.lproj/Vector.strings @@ -2796,5 +2796,5 @@ // Contacts "local_contacts_access_discovery_warning" = "Afin d’afficher qui parmi vos contacts utilise déjà Tchap, nous pouvons exploiter les adresses e-mails de votre carnet d'adresse. Ces données ne seront pas mémorisées. Pour plus d'informations, veuillez consulter les Termes et Conditions disponibles dans les paramètres de l'application."; // Events formatter -"notice_crypto_unable_to_decrypt" = "** Echec de déchiffrement : %@ **"; -"notice_crypto_error_unknown_inbound_session_id" = "Veuillez ouvrir Tchap sur vos autres appareils afin d'autoriser le partage de clés."; +"notice_crypto_unable_to_decrypt" = "Message verrouillé."; // Tchap +"notice_crypto_error_unknown_inbound_session_id" = "Ouvrez Tchap sur un autre appareil pour récupérer vos messages."; // Tchap diff --git a/Riot/Modules/Room/RoomViewController.m b/Riot/Modules/Room/RoomViewController.m index 8c59c88fd..cbaba7845 100644 --- a/Riot/Modules/Room/RoomViewController.m +++ b/Riot/Modules/Room/RoomViewController.m @@ -4714,6 +4714,17 @@ - (BOOL)dataSource:(MXKDataSource *)dataSource shouldDoAction:(NSString *)action } shouldDoAction = NO; } + else if ([absoluteURLString hasPrefix:EventFormatterFaqLinkAction]) // Tchap: custom Link to FAQ in case of crypto error on room's messages + { + NSArray *arguments = [absoluteURLString componentsSeparatedByString:EventFormatterLinkActionSeparator]; + if (arguments.count > 1) + { + NSString *faqUrl = [[arguments subarrayWithRange:NSMakeRange(1, arguments.count-1)] componentsJoinedByString:@"/"]; + WebSheetViewController *webCtrl = [[WebSheetViewController alloc] initWithTargetUrl:[NSURL URLWithString:faqUrl]]; + [self presentViewController:webCtrl animated:YES completion:nil]; + } + shouldDoAction = NO; + } else if (url && urlItemInteractionValue) { // Fallback case for external links diff --git a/Riot/Utils/EventFormatter.h b/Riot/Utils/EventFormatter.h index 3d7a39b1e..185ecc0f4 100644 --- a/Riot/Utils/EventFormatter.h +++ b/Riot/Utils/EventFormatter.h @@ -31,6 +31,11 @@ FOUNDATION_EXPORT NSString *const EventFormatterLinkActionSeparator; */ FOUNDATION_EXPORT NSString *const EventFormatterEditedEventLinkAction; +/** + Link string used in attributed strings to mark a Tchap FAQ article event action. + */ +FOUNDATION_EXPORT NSString *const EventFormatterFaqLinkAction; // Tchap + /** `EventFormatter` class inherits from `MXKEventFormatter` to define Vector formatting */ diff --git a/Riot/Utils/EventFormatter.m b/Riot/Utils/EventFormatter.m index 7d2af82d0..27b6a9906 100644 --- a/Riot/Utils/EventFormatter.m +++ b/Riot/Utils/EventFormatter.m @@ -32,6 +32,7 @@ NSString *const EventFormatterOnReRequestKeysLinkAction = @"EventFormatterOnReRequestKeysLinkAction"; NSString *const EventFormatterLinkActionSeparator = @"/"; NSString *const EventFormatterEditedEventLinkAction = @"EventFormatterEditedEventLinkAction"; +NSString *const EventFormatterFaqLinkAction = @"EventFormatterFaqLinkAction"; // Tchap NSString *const FunctionalMembersStateEventType = @"io.element.functional_members"; NSString *const FunctionalMembersServiceMembersKey = @"service_members"; @@ -340,31 +341,50 @@ - (NSAttributedString *)unsafeAttributedStringFromEvent:(MXEvent *)event if (event.decryptionError.code == MXDecryptingErrorUnknownInboundSessionIdCode) { + // Tchap: remove english message coming from server + // and add to custom message with a clickable part with a link to FAQ. + // Append to the displayed error an attibuted string with a tappable link // so that the user can try to fix the UTD - NSMutableAttributedString *attributedStringWithRerequestMessage = [attributedString mutableCopy]; - [attributedStringWithRerequestMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; +// NSMutableAttributedString *attributedStringWithRerequestMessage = [attributedString mutableCopy]; +// [attributedStringWithRerequestMessage appendAttributedString:[[NSAttributedString alloc] initWithString:@"\n"]]; +// +// NSString *linkActionString = [NSString stringWithFormat:@"%@%@%@", EventFormatterOnReRequestKeysLinkAction, +// EventFormatterLinkActionSeparator, +// event.eventId]; +// +// [attributedStringWithRerequestMessage appendAttributedString: +// [[NSAttributedString alloc] initWithString:[VectorL10n eventFormatterRerequestKeysPart1Link] +// attributes:@{ +// NSLinkAttributeName: linkActionString, +// NSForegroundColorAttributeName: self.sendingTextColor, +// NSFontAttributeName: self.encryptedMessagesTextFont, +// NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle] +// }]]; +// +// [attributedStringWithRerequestMessage appendAttributedString: +// [[NSAttributedString alloc] initWithString:[VectorL10n eventFormatterRerequestKeysPart2] +// attributes:@{ +// NSForegroundColorAttributeName: self.sendingTextColor, +// NSFontAttributeName: self.encryptedMessagesTextFont +// }]]; - NSString *linkActionString = [NSString stringWithFormat:@"%@%@%@", EventFormatterOnReRequestKeysLinkAction, + NSMutableAttributedString *attributedStringWithRerequestMessage = [attributedString mutableCopy]; + + [attributedStringWithRerequestMessage appendString:[NSString stringWithFormat:@" %@\n", VectorL10n.noticeCryptoErrorUnknownInboundSessionId]]; + NSString *linkActionString = [NSString stringWithFormat:@"%@%@%@", EventFormatterFaqLinkAction, EventFormatterLinkActionSeparator, - event.eventId]; - - [attributedStringWithRerequestMessage appendAttributedString: - [[NSAttributedString alloc] initWithString:[VectorL10n eventFormatterRerequestKeysPart1Link] - attributes:@{ - NSLinkAttributeName: linkActionString, - NSForegroundColorAttributeName: self.sendingTextColor, - NSFontAttributeName: self.encryptedMessagesTextFont, - NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle] - }]]; - + @"https://aide.tchap.beta.gouv.fr/fr/article/dechiffrement-impossible-de-mes-messages-comment-y-remedier-iphone-xotgv1"]; + [attributedStringWithRerequestMessage appendAttributedString: - [[NSAttributedString alloc] initWithString:[VectorL10n eventFormatterRerequestKeysPart2] + [[NSAttributedString alloc] initWithString: [TchapL10n roomDecryptionErrorFaqLinkMessage] attributes:@{ - NSForegroundColorAttributeName: self.sendingTextColor, - NSFontAttributeName: self.encryptedMessagesTextFont - }]]; - + NSLinkAttributeName: linkActionString, + NSForegroundColorAttributeName: self.sendingTextColor, + NSFontAttributeName: self.encryptedMessagesTextFont, + NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle] + }]]; + attributedString = attributedStringWithRerequestMessage; } } diff --git a/Tchap/Assets/Localizations/fr.lproj/Tchap.strings b/Tchap/Assets/Localizations/fr.lproj/Tchap.strings index 74e52114e..cf00b3668 100644 --- a/Tchap/Assets/Localizations/fr.lproj/Tchap.strings +++ b/Tchap/Assets/Localizations/fr.lproj/Tchap.strings @@ -302,6 +302,10 @@ "side_menu_action_invite_friends" = "Inviter à rejoindre Tchap"; //////////////////////////////////////////////////////////////////////////////// -// MARK: Device verification +// MARK: Secret Setup Recovery Key "secrets_setup_recovery_key_export_action_done" = "Clé copiée"; "secrets_setup_recovery_key_warning" = "Attention : c'est la seule fois que votre code est affiché !"; // Tchap + +//////////////////////////////////////////////////////////////////////////////// +// MARK: Room Decryption error +"room_decryption_error_faq_link_message" = "Sinon, consulter cet article de FAQ."; diff --git a/Tchap/Modules/WebSheet/WebSheetViewController.swift b/Tchap/Modules/WebSheet/WebSheetViewController.swift index c48d0ab44..347b522c1 100644 --- a/Tchap/Modules/WebSheet/WebSheetViewController.swift +++ b/Tchap/Modules/WebSheet/WebSheetViewController.swift @@ -16,7 +16,7 @@ import Foundation -class WebSheetViewController: UIViewController, WKUIDelegate { +@objc class WebSheetViewController: UIViewController, WKUIDelegate { private lazy var webview: WKWebView = { [unowned self] in let conf = WKWebViewConfiguration() @@ -69,7 +69,7 @@ class WebSheetViewController: UIViewController, WKUIDelegate { self.closeButtonIsHidden = false } - convenience init(targetUrl: URL) { + @objc convenience init(targetUrl: URL) { self.init() // set targetUrl before configuring else viewDidLoad will be called with an empty targetUrl. self.targetUrl = targetUrl @@ -141,13 +141,12 @@ extension WebSheetViewController: WKNavigationDelegate { func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { // Decides whether to allow or cancel a navigation. -// print("webView decidePolicyFor navigationAction: " + (webView.url?.absoluteString ?? "???")) // Test if target is _blank if navigationAction.targetFrame == nil { // If target is _blank, open page in external navigator if let targetUrl = navigationAction.request.url { - UIApplication.shared.openURL(targetUrl) + UIApplication.shared.open(targetUrl, options: [:], completionHandler: nil) } decisionHandler(.cancel) } else {