Commit 7ecc3fd8 authored by Jose Blaya's avatar Jose Blaya
Browse files

Network management tool reskinning

parent 3c5cc95b
......@@ -40,8 +40,6 @@ enum Setting: Int {
case automaticReconnection
case trustCellularData
case trustedNetworks
case contentBlockerState
......@@ -99,8 +97,6 @@ class SettingsViewController: AutolayoutViewController {
case encryption
case applicationSettings
case cellularData
case autoConnectSettings
......@@ -117,7 +113,6 @@ class SettingsViewController: AutolayoutViewController {
.connection,
.encryption,
.applicationSettings,
.cellularData,
.autoConnectSettings,
.applicationInformation,
.reset,
......@@ -139,9 +134,6 @@ class SettingsViewController: AutolayoutViewController {
.encryptionHandshake
],
.applicationSettings: [], // dynamic
.cellularData: [
.trustCellularData
],
.autoConnectSettings: [
.trustedNetworks
],
......@@ -183,8 +175,6 @@ class SettingsViewController: AutolayoutViewController {
private lazy var switchDarkMode = UISwitch()
private lazy var switchCellularData = UISwitch()
private lazy var imvSelectedOption = UIImageView(image: Asset.accessorySelected.image)
private var isContentBlockerEnabled = false
......@@ -245,7 +235,6 @@ class SettingsViewController: AutolayoutViewController {
// switchContentBlocker.isGrayed = true
switchContentBlocker.addTarget(self, action: #selector(showContentBlockerTutorial), for: .touchUpInside)
switchDarkMode.addTarget(self, action: #selector(toggleDarkMode(_:)), for: .valueChanged)
switchCellularData.addTarget(self, action: #selector(toggleCellularData(_:)), for: .valueChanged)
redisplaySettings()
NotificationCenter.default.addObserver(self, selector: #selector(refreshContentBlockerState), name: .UIApplicationDidBecomeActive, object: nil)
......@@ -294,12 +283,6 @@ class SettingsViewController: AutolayoutViewController {
reportUpdatedPreferences()
}
@objc private func toggleCellularData(_ sender: UISwitch) {
pendingPreferences.trustCellularData = sender.isOn
redisplaySettings()
reportUpdatedPreferences()
}
// XXX: no need to bufferize app preferences
@objc private func toggleDarkMode(_ sender: UISwitch) {
AppPreferences.shared.transitionTheme(to: sender.isOn ? .dark : .light)
......@@ -658,7 +641,7 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
case .applicationSettings:
return L10n.Settings.ApplicationSettings.title
case .autoConnectSettings, .cellularData:
case .autoConnectSettings:
return nil
case .contentBlocker:
......@@ -686,9 +669,6 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
}
return footer.joined(separator: "\n\n")
case .cellularData:
return L10n.Settings.Hotspothelper.Cellular.description
case .autoConnectSettings:
return L10n.Settings.Hotspothelper.description
......@@ -882,19 +862,8 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
cell.textLabel?.text = "Password"
cell.detailTextLabel?.text = Client.providers.accountProvider.currentUser?.credentials.password ?? ""
cell.accessoryType = .none
case .trustCellularData:
cell.textLabel?.text = L10n.Settings.Hotspothelper.Cellular.title
cell.detailTextLabel?.text = nil
cell.accessoryView = switchCellularData
cell.selectionStyle = .none
switchCellularData.isOn = pendingPreferences.trustCellularData
case .trustedNetworks:
cell.textLabel?.text = L10n.Settings.Hotspothelper.title
cell.detailTextLabel?.text = Client.preferences.useWiFiProtection ?
L10n.Global.enabled :
L10n.Global.disabled
}
Theme.current.applySolidLightBackground(cell)
......
......@@ -448,9 +448,9 @@ internal enum L10n {
}
}
internal enum Hotspothelper {
/// VPN WiFi Protection automatically engages the VPN when connecting to untrusted networks.
/// Configure how PIA will behave on connection to WiFi or cellular networks.
internal static let description = L10n.tr("Localizable", "settings.hotspothelper.description")
/// VPN WiFi Protection
/// Network management tool
internal static let title = L10n.tr("Localizable", "settings.hotspothelper.title")
internal enum All {
/// VPN WiFi Protection will activate on all networks, including trusted networks.
......@@ -469,13 +469,23 @@ internal enum L10n {
internal enum Cellular {
/// PIA automatically enables the VPN when connecting to cellular networks if this option is disabled.
internal static let description = L10n.tr("Localizable", "settings.hotspothelper.cellular.description")
/// Cellular networks
internal static let networks = L10n.tr("Localizable", "settings.hotspothelper.cellular.networks")
/// Trust cellular networks
internal static let title = L10n.tr("Localizable", "settings.hotspothelper.cellular.title")
}
internal enum Enable {
/// VPN WiFi Protection automatically enables the VPN when connecting to untrusted networks.
/// VPN WiFi Protection automatically enables the VPN when connecting to untrusted networks if this option is enabled.
internal static let description = L10n.tr("Localizable", "settings.hotspothelper.enable.description")
}
internal enum Wifi {
/// WiFi networks
internal static let networks = L10n.tr("Localizable", "settings.hotspothelper.wifi.networks")
internal enum Trust {
/// VPN WiFi Protection
internal static let title = L10n.tr("Localizable", "settings.hotspothelper.wifi.trust.title")
}
}
}
internal enum Reset {
/// This will reset all of the above settings to default.
......
......@@ -18,9 +18,12 @@ class TrustedNetworksViewController: AutolayoutViewController {
private var hotspotHelper: PIAHotspotHelper!
private lazy var switchWiFiProtection = UISwitch()
private lazy var switchAutoJoinAllNetworks = UISwitch()
private lazy var switchCellularData = UISwitch()
private enum Sections: Int, EnumsBuilder {
case useVpnWifiProtection = 0
case cellularData = 0
case useVpnWifiProtection
case autoConnectAllNetworksSettings
case current
case available
......@@ -37,6 +40,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
self.hotspotHelper = PIAHotspotHelper(withDelegate: self)
self.switchAutoJoinAllNetworks.addTarget(self, action: #selector(toggleAutoconnectWithAllNetworks(_:)), for: .valueChanged)
self.switchWiFiProtection.addTarget(self, action: #selector(toggleUseWiFiProtection(_:)), for: .valueChanged)
self.switchCellularData.addTarget(self, action: #selector(toggleCellularData(_:)), for: .valueChanged)
configureTableView()
}
......@@ -82,6 +86,12 @@ class TrustedNetworksViewController: AutolayoutViewController {
}
}
@objc private func toggleCellularData(_ sender: UISwitch) {
let preferences = Client.preferences.editable()
preferences.trustCellularData = sender.isOn
preferences.commit()
}
// MARK: Private Methods
private func configureTableView() {
if #available(iOS 11, *) {
......@@ -115,19 +125,21 @@ class TrustedNetworksViewController: AutolayoutViewController {
extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return Client.preferences.useWiFiProtection ? Sections.countCases() : 1
return Client.preferences.useWiFiProtection ? Sections.countCases() : 2
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch Sections.objectIdentifyBy(index: section) {
case .useVpnWifiProtection:
return L10n.Settings.Hotspothelper.title.uppercased()
return L10n.Settings.Hotspothelper.Wifi.networks.uppercased()
case .current:
return L10n.Settings.Trusted.Networks.Sections.current.uppercased()
case .available:
return L10n.Settings.Trusted.Networks.Sections.available.uppercased()
case .trusted:
return L10n.Settings.Trusted.Networks.Sections.trusted.uppercased()
case .cellularData:
return L10n.Settings.Hotspothelper.Cellular.networks.uppercased()
default:
return nil
}
......@@ -141,6 +153,8 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
return L10n.Settings.Trusted.Networks.message
case .autoConnectAllNetworksSettings:
return L10n.Settings.Hotspothelper.All.description
case .cellularData:
return L10n.Settings.Hotspothelper.Cellular.description
case .available:
return availableNetworks.isEmpty ?
L10n.Settings.Hotspothelper.Available.help :
......@@ -195,10 +209,17 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
switchAutoJoinAllNetworks.isOn = Client.preferences.shouldConnectForAllNetworks
case .useVpnWifiProtection:
cell.imageView?.image = nil
cell.textLabel?.text = L10n.Global.enabled
cell.textLabel?.text = L10n.Settings.Hotspothelper.Wifi.Trust.title
cell.accessoryView = switchWiFiProtection
cell.selectionStyle = .none
switchWiFiProtection.isOn = Client.preferences.useWiFiProtection
case .cellularData:
cell.imageView?.image = nil
cell.textLabel?.text = L10n.Settings.Hotspothelper.Cellular.title
cell.detailTextLabel?.text = nil
cell.accessoryView = switchCellularData
cell.selectionStyle = .none
switchCellularData.isOn = Client.preferences.trustCellularData
}
......
......@@ -201,9 +201,9 @@
// HOTSPOT HELPER
"settings.hotspothelper.title" = "VPN WiFi Protection";
"settings.hotspothelper.description" = "VPN WiFi Protection automatically engages the VPN when connecting to untrusted networks.";
"settings.hotspothelper.enable.description" = "VPN WiFi Protection automatically enables the VPN when connecting to untrusted networks.";
"settings.hotspothelper.title" = "Network management tool";
"settings.hotspothelper.description" = "Configure how PIA will behave on connection to WiFi or cellular networks.";
"settings.hotspothelper.enable.description" = "VPN WiFi Protection automatically enables the VPN when connecting to untrusted networks if this option is enabled.";
"settings.hotspothelper.all.title" = "Protect all networks";
"settings.hotspothelper.all.description" = "VPN WiFi Protection will activate on all networks, including trusted networks.";
"settings.hotspothelper.available.help" = "To populate this list go to iOS Settings > WiFi.";
......@@ -216,5 +216,8 @@
"hotspothelper.display.name" = "🔒 Activate VPN WiFi Protection in PIA Settings to secure this connection.";
"hotspothelper.display.protected.name" = "🔒 PIA VPN WiFi Protection Enabled - We got your back.";
"settings.hotspothelper.cellular.title" = "Trust cellular networks";
"settings.hotspothelper.wifi.trust.title" = "VPN WiFi Protection";
"settings.hotspothelper.cellular.description" = "PIA automatically enables the VPN when connecting to cellular networks if this option is disabled.";
"settings.hotspothelper.cellular.networks" = "Cellular networks";
"settings.hotspothelper.wifi.networks" = "WiFi networks";
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment