diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-11 21:31:20 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-10-11 21:44:12 +0200 |
commit | 84ca7fcf403da9bcdb2a33d5ac049749da02079e (patch) | |
tree | 37f6407cdba5f06fcd645f4e7b09d904af9ab5dd /WireGuard/WireGuard | |
parent | wireguard-go-bridge: reduce version checks and cleanup (diff) | |
download | wireguard-apple-84ca7fcf403da9bcdb2a33d5ac049749da02079e.tar.xz wireguard-apple-84ca7fcf403da9bcdb2a33d5ac049749da02079e.zip |
ui: add donation link
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
3 files changed, 23 insertions, 4 deletions
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 ]) } } |