Commit 3848eb43 authored by Jose Blaya's avatar Jose Blaya
Browse files

Trust cellular data networks

parent 034631f7
......@@ -39,7 +39,9 @@ enum Setting: Int {
case encryptionHandshake
case automaticReconnection
case trustCellularData
case trustedNetworks
case contentBlockerState
......@@ -92,6 +94,8 @@ class SettingsViewController: AutolayoutViewController {
case applicationSettings
case cellularData
case autoConnectSettings
case contentBlocker
......@@ -107,6 +111,7 @@ class SettingsViewController: AutolayoutViewController {
.connection,
.encryption,
.applicationSettings,
.cellularData,
.autoConnectSettings,
.applicationInformation,
.reset,
......@@ -128,6 +133,9 @@ class SettingsViewController: AutolayoutViewController {
.encryptionHandshake
],
.applicationSettings: [], // dynamic
.cellularData: [
.trustCellularData
],
.autoConnectSettings: [
.trustedNetworks
],
......@@ -165,7 +173,9 @@ class SettingsViewController: AutolayoutViewController {
private lazy var switchContentBlocker = FakeSwitch()
private lazy var switchDarkMode = UISwitch()
private lazy var switchCellularData = UISwitch()
private lazy var imvSelectedOption = UIImageView(image: Asset.accessorySelected.image)
private var isContentBlockerEnabled = false
......@@ -226,6 +236,7 @@ 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)
......@@ -273,6 +284,12 @@ class SettingsViewController: AutolayoutViewController {
redisplaySettings()
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) {
......@@ -629,7 +646,7 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
case .applicationSettings:
return L10n.Settings.ApplicationSettings.title
case .autoConnectSettings:
case .autoConnectSettings, .cellularData:
return nil
case .contentBlocker:
......@@ -656,7 +673,10 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
footer.append(L10n.Settings.ApplicationSettings.Mace.footer)
}
return footer.joined(separator: "\n\n")
case .cellularData:
return L10n.Settings.Hotspothelper.Cellular.description
case .autoConnectSettings:
return L10n.Settings.Hotspothelper.description
......@@ -813,6 +833,13 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
cell.textLabel?.text = "Resolve google-analytics.com"
cell.detailTextLabel?.text = nil
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 ?
......
......@@ -198,10 +198,10 @@ internal enum L10n {
internal enum Hotspothelper {
internal enum Display {
/// 🛡 Activate VPN WiFi Protection in PIA Settings to secure this connection.
/// 🔒 Activate VPN WiFi Protection in PIA Settings to secure this connection.
internal static let name = L10n.tr("Localizable", "hotspothelper.display.name")
internal enum Protected {
/// 🛡 PIA VPN WiFi Protection Enabled - We got your back.
/// 🔒 PIA VPN WiFi Protection Enabled - We got your back.
internal static let name = L10n.tr("Localizable", "hotspothelper.display.protected.name")
}
}
......@@ -468,6 +468,12 @@ internal enum L10n {
internal static let help = L10n.tr("Localizable", "settings.hotspothelper.available.add.help")
}
}
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")
/// 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.
internal static let description = L10n.tr("Localizable", "settings.hotspothelper.enable.description")
......
......@@ -215,3 +215,6 @@
"settings.trustedNetworks.message" = "PIA won't automatically connect on these networks.";
"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.cellular.description" = "PIA automatically enables the VPN when connecting to cellular networks if this option is disabled.";
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