diff --git a/WireGuard/WireGuard/Base.lproj/Localizable.strings b/WireGuard/WireGuard/Base.lproj/Localizable.strings index 3cfe4ee..892e097 100644 --- a/WireGuard/WireGuard/Base.lproj/Localizable.strings +++ b/WireGuard/WireGuard/Base.lproj/Localizable.strings @@ -437,3 +437,7 @@ "macAppStoreUpdatingAlertMessage" = "App Store would like to update WireGuard"; "macAppStoreUpdatingAlertInfoWithOnDemand (%@)" = "Please disable on-demand for tunnel ‘%@’, deactivate it, and then continue updating in App Store."; "macAppStoreUpdatingAlertInfoWithoutOnDemand (%@)" = "Please deactivate tunnel ‘%@’ and then continue updating in App Store."; + +// Donation + +"donateLink" = "♥ Donate to the WireGuard Project"; diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift index 9956b7b..41e53b1 100644 --- a/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift +++ b/WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift @@ -11,6 +11,7 @@ class SettingsTableViewController: UITableViewController { case goBackendVersion case exportZipArchive case viewLog + case donateLink var localizedUIString: String { switch self { @@ -18,12 +19,13 @@ class SettingsTableViewController: UITableViewController { case .goBackendVersion: return tr("settingsVersionKeyWireGuardGoBackend") case .exportZipArchive: return tr("settingsExportZipButtonTitle") case .viewLog: return tr("settingsViewLogButtonTitle") + case .donateLink: return tr("donateLink") } } } let settingsFieldsBySection: [[SettingsFields]] = [ - [.iosAppVersion, .goBackendVersion], + [.iosAppVersion, .goBackendVersion, .donateLink], [.exportZipArchive], [.viewLog] ] @@ -160,14 +162,24 @@ extension SettingsTableViewController { self?.exportConfigurationsAsZipFile(sourceView: cell.button) } return cell - } else { - assert(field == .viewLog) + } else if field == .viewLog { let cell: ButtonCell = tableView.dequeueReusableCell(for: indexPath) cell.buttonText = field.localizedUIString cell.onTapped = { [weak self] in self?.presentLogView() } return cell + } else if field == .donateLink { + let cell: ButtonCell = tableView.dequeueReusableCell(for: indexPath) + cell.buttonText = field.localizedUIString + cell.onTapped = { + if let url = URL(string: "https://www.wireguard.com/donations/"), UIApplication.shared.canOpenURL(url) { + UIApplication.shared.open(url, options: [:]) + } + } + return cell + } else { + assert(false) } } } diff --git a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift index 5a4ff6e..cb24023 100644 --- a/WireGuard/WireGuard/UI/macOS/AppDelegate.swift +++ b/WireGuard/WireGuard/UI/macOS/AppDelegate.swift @@ -210,10 +210,13 @@ extension AppDelegate { tr(format: "macAppVersion (%@)", appVersion), tr(format: "macGoBackendVersion (%@)", WIREGUARD_GO_VERSION) ].joined(separator: "\n") + let donateString = NSMutableAttributedString(string: tr("donateLink")) + donateString.addAttribute(.link, value: "https://www.wireguard.com/donations/", range: NSRange(location: 0, length: donateString.length)) NSApp.activate(ignoringOtherApps: true) NSApp.orderFrontStandardAboutPanel(options: [ .applicationVersion: appVersionString, - .version: "" + .version: "", + .credits: donateString ]) } }