]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
ui: add donation link
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 11 Oct 2019 19:31:20 +0000 (21:31 +0200)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 11 Oct 2019 19:44:12 +0000 (21:44 +0200)
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
WireGuard/WireGuard/Base.lproj/Localizable.strings
WireGuard/WireGuard/UI/iOS/ViewController/SettingsTableViewController.swift
WireGuard/WireGuard/UI/macOS/AppDelegate.swift

index 3cfe4eea8a270c6e1aab6570cb8dcaffa8c09245..892e097a640836d1b62a0cfc8a7b711dfff73542 100644 (file)
 "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";
index 9956b7b890ba426de88e3cc8deb7d865517981c1..41e53b174eaf31c8cd1123d7c60b06359c5366f4 100644 (file)
@@ -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)
         }
     }
 }
index 5a4ff6e349b6818f7f496a3d3925b3724e66537e..cb240230b78dc298335ddb2db0f7e47340c10e88 100644 (file)
@@ -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
         ])
     }
 }