Merge branch 'email-templates'

This commit is contained in:
Davide De Rosa 2019-04-07 16:32:17 +02:00
commit 651e3857e1
6 changed files with 88 additions and 33 deletions

View File

@ -57,7 +57,7 @@ class IssueReporter: NSObject {
func present(in viewController: UIViewController, withAttachments attachments: Attachments) {
guard MFMailComposeViewController.canSendMail() else {
let alert = Macros.alert(L10n.IssueReporter.title, L10n.IssueReporter.Alerts.EmailNotConfigured.message)
let alert = Macros.alert(L10n.IssueReporter.title, L10n.Global.emailNotConfigured)
alert.addCancelAction(L10n.Global.ok)
viewController.present(alert, animated: true, completion: nil)
return
@ -83,9 +83,9 @@ class IssueReporter: NSObject {
let metadata = DebugLog(raw: "--").decoratedString()
let vc = MFMailComposeViewController()
vc.setToRecipients([AppConstants.IssueReporter.recipient])
vc.setSubject(L10n.IssueReporter.Email.subject(GroupConstants.App.name))
vc.setMessageBody(L10n.IssueReporter.Email.body(description ?? L10n.IssueReporter.Email.description, metadata), isHTML: false)
vc.setToRecipients([AppConstants.IssueReporter.Email.recipient])
vc.setSubject(AppConstants.IssueReporter.Email.subject(GroupConstants.App.name))
vc.setMessageBody(AppConstants.IssueReporter.Email.body(description ?? AppConstants.IssueReporter.Email.template, metadata), isHTML: false)
if let raw = debugLog {
let attachment = DebugLog(raw: raw).decoratedData()
vc.addAttachmentData(attachment, mimeType: AppConstants.IssueReporter.MIME.debugLog, fileName: AppConstants.IssueReporter.Filenames.debugLog)

View File

@ -24,6 +24,7 @@
//
import UIKit
import MessageUI
import Passepartout_Core
// XXX: convoluted due to the separation of provider/host profiles
@ -61,7 +62,7 @@ class OrganizerViewController: UITableViewController, TableModelHost {
model.set([.siriShortcuts], in: .siri)
}
model.setHeader(L10n.Organizer.Sections.Support.header, for: .support)
model.set([.donate, .patreon], in: .support)
model.set([.donate, .patreon, .translate], in: .support)
model.set([.openAbout], in: .about)
model.set([.uninstall], in: .destruction)
if AppConstants.Flags.isBeta {
@ -199,6 +200,23 @@ class OrganizerViewController: UITableViewController, TableModelHost {
UIApplication.shared.open(AppConstants.URLs.patreon, options: [:], completionHandler: nil)
}
private func offerTranslation() {
guard MFMailComposeViewController.canSendMail() else {
let alert = Macros.alert(L10n.IssueReporter.title, L10n.Global.emailNotConfigured)
alert.addCancelAction(L10n.Global.ok)
present(alert, animated: true, completion: nil)
return
}
let vc = MFMailComposeViewController()
vc.setToRecipients([AppConstants.Translations.Email.recipient])
vc.setSubject(AppConstants.Translations.Email.subject(GroupConstants.App.name))
vc.setMessageBody(AppConstants.Translations.Email.body(AppConstants.Translations.Email.template), isHTML: false)
vc.mailComposeDelegate = self
vc.apply(Theme.current)
present(vc, animated: true, completion: nil)
}
private func about() {
perform(segue: StoryboardSegue.Organizer.aboutSegueIdentifier, sender: nil)
}
@ -315,6 +333,8 @@ extension OrganizerViewController {
case donate
case patreon
case translate
case openAbout
@ -401,6 +421,11 @@ extension OrganizerViewController {
cell.leftText = L10n.Organizer.Cells.Patreon.caption
return cell
case .translate:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Organizer.Cells.Translate.caption
return cell
case .openAbout:
let cell = Cells.setting.dequeue(from: tableView, for: indexPath)
cell.leftText = L10n.Organizer.Cells.About.caption(GroupConstants.App.name)
@ -445,6 +470,9 @@ extension OrganizerViewController {
case .patreon:
visitPatreon()
case .translate:
offerTranslation()
case .openAbout:
about()
@ -588,3 +616,9 @@ extension OrganizerViewController: ConnectionServiceDelegate {
}
}
}
extension OrganizerViewController: MFMailComposeViewControllerDelegate {
func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
dismiss(animated: true, completion: nil)
}
}

View File

@ -29,6 +29,7 @@
"global.close" = "Close";
"global.host.title_input.message" = "Acceptable characters are alphanumerics plus dash \"-\", underscore \"_\" and dot \".\".";
"global.host.title_input.placeholder" = "My profile";
"global.email_not_configured" = "No e-mail account is configured.";
"reddit.title" = "Reddit";
"reddit.message" = "Did you know that Passepartout has a subreddit? Subscribe for updates or to discuss issues, features, new platforms or whatever you like.\n\nIt's also a great way to show you care about this project.";
@ -49,6 +50,7 @@
"organizer.cells.siri_shortcuts.caption" = "Manage shortcuts";
"organizer.cells.donate.caption" = "Make a donation";
"organizer.cells.patreon.caption" = "Support me on Patreon";
"organizer.cells.translate.caption" = "Offer to translate";
"organizer.cells.about.caption" = "About %@";
"organizer.cells.uninstall.caption" = "Remove VPN configuration";
"organizer.alerts.exhausted_providers.message" = "You have created profiles for any available provider.";
@ -212,10 +214,8 @@
"issue_reporter.title" = "Report issue";
"issue_reporter.message" = "The debug log of your latest connections is crucial to resolve your connectivity issues and is completely anonymous.\n\nThe .ovpn configuration file, if any, is attached stripped of any sensitive data.\n\nPlease double check the e-mail attachments if unsure.";
"issue_reporter.buttons.accept" = "I understand";
"issue_reporter.alerts.email_not_configured.message" = "No e-mail account is configured.";
"issue_reporter.email.subject" = "%@ - Report issue";
"issue_reporter.email.body" = "Hi,\n\n%@\n\n%@\n\nRegards";
"issue_reporter.email.description" = "description of the issue:";
"translations.title" = "Translations";
"shortcuts.add.title" = "Add shortcut";
"shortcuts.add.sections.vpn.header" = "VPN";

View File

@ -29,6 +29,7 @@
"global.close" = "Chiudi";
"global.host.title_input.message" = "I caratteri ammessi sono gli alfanumerici e il trattino breve \"-\", il trattino basso \"_\" ed il punto \".\".";
"global.host.title_input.placeholder" = "Il mio profilo";
"global.email_not_configured" = "Nessun account e-mail configurato.";
"reddit.title" = "Reddit";
"reddit.message" = "Sapevi che Passepartout ha un subreddit? Iscriviti per aggiornamenti o per discutere problemi, aggiunte, nuove piattaforme o qualunque cosa tu voglia.\n\nÈ anche un ottimo modo per dimostrare che hai a cuore questo progetto.";
@ -49,6 +50,7 @@
"organizer.cells.siri_shortcuts.caption" = "Gestisci comandi rapidi";
"organizer.cells.donate.caption" = "Fai una donazione";
"organizer.cells.patreon.caption" = "Supportami su Patreon";
"organizer.cells.translate.caption" = "Proponi una traduzione";
"organizer.cells.about.caption" = "Informazioni su %@";
"organizer.cells.uninstall.caption" = "Rimuovi configurazione VPN";
"organizer.alerts.exhausted_providers.message" = "Hai creato profili per tutti i provider disponibili.";
@ -212,10 +214,8 @@
"issue_reporter.title" = "Segnala problema";
"issue_reporter.message" = "Il debug log delle tue ultime connessioni è cruciale per risolvere i tuoi problemi di connettività ed è completamente anonimo.\n\nIl file di configurazione .ovpn, se presente, è allegato privato di ogni dato sensibile.\n\nPer favore controlla gli allegati dell'e-mail se non sei sicuro/a.";
"issue_reporter.buttons.accept" = "Ho capito";
"issue_reporter.alerts.email_not_configured.message" = "Nessun account e-mail configurato.";
"issue_reporter.email.subject" = "%@ - Segnala problema";
"issue_reporter.email.body" = "Ciao,\n\n%@\n\n%@\n\nGrazie";
"issue_reporter.email.description" = "descrizione del problema:";
"translations.title" = "Traduzioni";
"shortcuts.add.title" = "Aggiungi comando rapido";
"shortcuts.add.sections.vpn.header" = "VPN";

View File

@ -109,7 +109,19 @@ public class AppConstants {
}
public class IssueReporter {
public static let recipient = "issues@\(Domain.name)"
public class Email {
public static let recipient = "issues@\(Domain.name)"
public static func subject(_ appName: String) -> String {
return "\(appName) - Report issue";
}
public static func body(_ description: String, _ metadata: String) -> String {
return "Hi,\n\n\(description)\n\n\(metadata)\n\nRegards";
}
public static let template = "description of the issue: ";
}
public class Filenames {
public static var debugLog: String {
@ -130,7 +142,23 @@ public class AppConstants {
public static let configuration = "text/plain"
}
}
public class Translations {
public class Email {
public static let recipient = "translate@\(Domain.name)"
public static func subject(_ appName: String) -> String {
return "\(appName) - Translations";
}
public static func body(_ description: String) -> String {
return "Hi,\n\n\(description)\n\nRegards";
}
public static let template = "I offer to translate to: ";
}
}
public class URLs {
public static let website = URL(string: "https://\(Domain.name)")!

View File

@ -346,6 +346,8 @@ public enum L10n {
public static let cancel = L10n.tr("Localizable", "global.cancel")
/// Close
public static let close = L10n.tr("Localizable", "global.close")
/// No e-mail account is configured.
public static let emailNotConfigured = L10n.tr("Localizable", "global.email_not_configured")
/// Next
public static let next = L10n.tr("Localizable", "global.next")
/// OK
@ -370,28 +372,10 @@ public enum L10n {
public static let message = L10n.tr("Localizable", "issue_reporter.message")
/// Report issue
public static let title = L10n.tr("Localizable", "issue_reporter.title")
public enum Alerts {
public enum EmailNotConfigured {
/// No e-mail account is configured.
public static let message = L10n.tr("Localizable", "issue_reporter.alerts.email_not_configured.message")
}
}
public enum Buttons {
/// I understand
public static let accept = L10n.tr("Localizable", "issue_reporter.buttons.accept")
}
public enum Email {
/// Hi,\n\n%@\n\n%@\n\nRegards
public static func body(_ p1: String, _ p2: String) -> String {
return L10n.tr("Localizable", "issue_reporter.email.body", p1, p2)
}
/// description of the issue:
public static let description = L10n.tr("Localizable", "issue_reporter.email.description")
/// %@ - Report issue
public static func subject(_ p1: String) -> String {
return L10n.tr("Localizable", "issue_reporter.email.subject", p1)
}
}
}
public enum Label {
@ -449,6 +433,10 @@ public enum L10n {
/// Manage shortcuts
public static let caption = L10n.tr("Localizable", "organizer.cells.siri_shortcuts.caption")
}
public enum Translate {
/// Offer to translate
public static let caption = L10n.tr("Localizable", "organizer.cells.translate.caption")
}
public enum Uninstall {
/// Remove VPN configuration
public static let caption = L10n.tr("Localizable", "organizer.cells.uninstall.caption")
@ -870,6 +858,11 @@ public enum L10n {
}
}
public enum Translations {
/// Translations
public static let title = L10n.tr("Localizable", "translations.title")
}
public enum Version {
/// Version
public static let title = L10n.tr("Localizable", "version.title")