aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-03-09 15:35:49 +0530
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-18 06:46:55 +0100
commitb7f8f74b5698f120ce22c79c32ccfc6fdb37252f (patch)
tree2ae30e6aab44bf263b66293b03316b8ec61350d5
parenton-demand: iOS: Show list of SSIDs in a separate screen (diff)
downloadwireguard-apple-b7f8f74b5698f120ce22c79c32ccfc6fdb37252f.tar.xz
wireguard-apple-b7f8f74b5698f120ce22c79c32ccfc6fdb37252f.zip
on-demand: iOS: Only n SSIDs / Except m SSIDs
Signed-off-by: Roopesh Chander <roop@roopc.net>
-rw-r--r--WireGuard/WireGuard/Base.lproj/Localizable.strings4
-rw-r--r--WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift19
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift2
-rw-r--r--WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift2
4 files changed, 25 insertions, 2 deletions
diff --git a/WireGuard/WireGuard/Base.lproj/Localizable.strings b/WireGuard/WireGuard/Base.lproj/Localizable.strings
index de2a8c2f..32b792ff 100644
--- a/WireGuard/WireGuard/Base.lproj/Localizable.strings
+++ b/WireGuard/WireGuard/Base.lproj/Localizable.strings
@@ -89,6 +89,10 @@
"tunnelOnDemandAnySSID" = "Any SSID";
"tunnelOnDemandOnlySelectedSSIDs" = "Only selected SSIDs";
"tunnelOnDemandExceptSelectedSSIDs" = "Except selected SSIDs";
+"tunnelOnDemandOnlySSID (%d)" = "Only %d SSID";
+"tunnelOnDemandOnlySSIDs (%d)" = "Only %d SSIDs";
+"tunnelOnDemandExceptSSID (%d)" = "Except %d SSID";
+"tunnelOnDemandExceptSSIDs (%d)" = "Except %d SSIDs";
"tunnelOnDemandSSIDViewTitle" = "SSIDs";
"tunnelOnDemandSectionTitleSelectedSSIDs" = "SSIDs";
diff --git a/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift b/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift
index 2f13f074..c7d01739 100644
--- a/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift
+++ b/WireGuard/WireGuard/UI/ActivateOnDemandViewModel.swift
@@ -130,6 +130,25 @@ extension ActivateOnDemandViewModel {
}
}
+ var localizedSSIDDescription: String {
+ guard isWiFiInterfaceEnabled else { return "" }
+ switch ssidOption {
+ case .anySSID: return tr("tunnelOnDemandAnySSID")
+ case .onlySpecificSSIDs:
+ if selectedSSIDs.count == 1 {
+ return tr(format: "tunnelOnDemandOnlySSID (%d)", selectedSSIDs.count)
+ } else {
+ return tr(format: "tunnelOnDemandOnlySSIDs (%d)", selectedSSIDs.count)
+ }
+ case .exceptSpecificSSIDs:
+ if selectedSSIDs.count == 1 {
+ return tr(format: "tunnelOnDemandExceptSSID (%d)", selectedSSIDs.count)
+ } else {
+ return tr(format: "tunnelOnDemandExceptSSIDs (%d)", selectedSSIDs.count)
+ }
+ }
+ }
+
func fixSSIDOption() {
selectedSSIDs = uniquifiedNonEmptySelectedSSIDs()
if selectedSSIDs.isEmpty {
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
index abee8180..32393a9c 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelDetailTableViewController.swift
@@ -423,7 +423,7 @@ extension TunnelDetailTableViewController {
} else {
let cell: ChevronCell = tableView.dequeueReusableCell(for: indexPath)
cell.message = field.localizedUIString
- cell.detailMessage = onDemandViewModel.ssidOption.localizedUIString
+ cell.detailMessage = onDemandViewModel.localizedSSIDDescription
return cell
}
}
diff --git a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
index e5f322a3..943e7e5f 100644
--- a/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
+++ b/WireGuard/WireGuard/UI/iOS/ViewController/TunnelEditTableViewController.swift
@@ -442,7 +442,7 @@ extension TunnelEditTableViewController {
} else {
let cell: ChevronCell = tableView.dequeueReusableCell(for: indexPath)
cell.message = field.localizedUIString
- cell.detailMessage = onDemandViewModel.ssidOption.localizedUIString
+ cell.detailMessage = onDemandViewModel.localizedSSIDDescription
return cell
}
}