Commit a52c8a9c authored by Jose Blaya's avatar Jose Blaya
Browse files

Added option that disables the warning alert when disconnecting from the VPN...

Added option that disables the warning alert when disconnecting from the VPN when the NMT option is enabled.
parent a0d5f2ea
...@@ -17,6 +17,7 @@ private let log = SwiftyBeaver.self ...@@ -17,6 +17,7 @@ private let log = SwiftyBeaver.self
class AppPreferences { class AppPreferences {
private struct Entries { private struct Entries {
static let version = "Version" static let version = "Version"
static let launched = "Launched" // discard 2.2 key and invert logic static let launched = "Launched" // discard 2.2 key and invert logic
...@@ -44,6 +45,8 @@ class AppPreferences { ...@@ -44,6 +45,8 @@ class AppPreferences {
static let todayWidgetVpnStatus = "vpn.status" static let todayWidgetVpnStatus = "vpn.status"
static let todayWidgetButtonTitle = "vpn.button.description" static let todayWidgetButtonTitle = "vpn.button.description"
static let optOutAskDisconnectVPNUsingNMT = "OptOutAskDisconnectVPNUsingNMT"
} }
static let shared = AppPreferences() static let shared = AppPreferences()
...@@ -180,6 +183,15 @@ class AppPreferences { ...@@ -180,6 +183,15 @@ class AppPreferences {
} }
} }
var optOutAskDisconnectVPNUsingNMT: Bool{
get {
return defaults.bool(forKey: Entries.optOutAskDisconnectVPNUsingNMT)
}
set {
defaults.set(newValue, forKey: Entries.optOutAskDisconnectVPNUsingNMT)
}
}
@available(iOS 12.0, *) @available(iOS 12.0, *)
var connectShortcut: INVoiceShortcut? { var connectShortcut: INVoiceShortcut? {
get { get {
...@@ -229,6 +241,7 @@ class AppPreferences { ...@@ -229,6 +241,7 @@ class AppPreferences {
Entries.themeCode: ThemeCode.light.rawValue, Entries.themeCode: ThemeCode.light.rawValue,
Entries.useConnectSiriShortcuts: false, Entries.useConnectSiriShortcuts: false,
Entries.useDisconnectSiriShortcuts: false, Entries.useDisconnectSiriShortcuts: false,
Entries.optOutAskDisconnectVPNUsingNMT: false,
Entries.todayWidgetButtonTitle: L10n.Today.Widget.login Entries.todayWidgetButtonTitle: L10n.Today.Widget.login
]) ])
} }
...@@ -318,6 +331,7 @@ class AppPreferences { ...@@ -318,6 +331,7 @@ class AppPreferences {
func reset() { func reset() {
piaSocketType = nil piaSocketType = nil
favoriteServerIdentifiers = [] favoriteServerIdentifiers = []
optOutAskDisconnectVPNUsingNMT = false
useConnectSiriShortcuts = false useConnectSiriShortcuts = false
useDisconnectSiriShortcuts = false useDisconnectSiriShortcuts = false
if #available(iOS 12.0, *) { if #available(iOS 12.0, *) {
...@@ -329,6 +343,7 @@ class AppPreferences { ...@@ -329,6 +343,7 @@ class AppPreferences {
func clean() { func clean() {
favoriteServerIdentifiers = [] favoriteServerIdentifiers = []
optOutAskDisconnectVPNUsingNMT = false
useConnectSiriShortcuts = false useConnectSiriShortcuts = false
useDisconnectSiriShortcuts = false useDisconnectSiriShortcuts = false
if #available(iOS 12.0, *) { if #available(iOS 12.0, *) {
......
...@@ -284,7 +284,7 @@ class DashboardViewController: AutolayoutViewController { ...@@ -284,7 +284,7 @@ class DashboardViewController: AutolayoutViewController {
} }
} }
if !Client.preferences.nmtRulesEnabled { //if NMT disabled... if !Client.preferences.nmtRulesEnabled || AppPreferences.shared.optOutAskDisconnectVPNUsingNMT { //if NMT disabled...
showAlert = false showAlert = false
} }
......
...@@ -505,6 +505,16 @@ internal enum L10n { ...@@ -505,6 +505,16 @@ internal enum L10n {
/// The VPN kill switch is currently disabled. In order to ensure that the Network Management Tool is functioning, and that you are able to reconnect when switching networks, please enable the VPN kill switch in your settings. /// The VPN kill switch is currently disabled. In order to ensure that the Network Management Tool is functioning, and that you are able to reconnect when switching networks, please enable the VPN kill switch in your settings.
internal static let disabled = L10n.tr("Localizable", "settings.nmt.killswitch.disabled") internal static let disabled = L10n.tr("Localizable", "settings.nmt.killswitch.disabled")
} }
internal enum Optout {
internal enum Disconnect {
/// Opt-out disconnect confirmation alert
internal static let alerts = L10n.tr("Localizable", "settings.nmt.optout.disconnect.alerts")
internal enum Alerts {
/// Disables the warning alert when disconnecting from the VPN.
internal static let description = L10n.tr("Localizable", "settings.nmt.optout.disconnect.alerts.description")
}
}
}
} }
internal enum Reset { internal enum Reset {
/// This will reset all of the above settings to default. /// This will reset all of the above settings to default.
......
...@@ -20,6 +20,7 @@ class TrustedNetworksViewController: AutolayoutViewController { ...@@ -20,6 +20,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
private lazy var switchAutoJoinAllNetworks = UISwitch() private lazy var switchAutoJoinAllNetworks = UISwitch()
private lazy var switchCellularData = UISwitch() private lazy var switchCellularData = UISwitch()
private lazy var switchRules = UISwitch() private lazy var switchRules = UISwitch()
private lazy var switchAskForDisconnect = UISwitch()
var shouldReconnectAutomatically = false var shouldReconnectAutomatically = false
var hasUpdatedPreferences = false var hasUpdatedPreferences = false
var persistentConnectionValue = false var persistentConnectionValue = false
...@@ -27,6 +28,7 @@ class TrustedNetworksViewController: AutolayoutViewController { ...@@ -27,6 +28,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
private enum Sections: Int, EnumsBuilder { private enum Sections: Int, EnumsBuilder {
case rules = 0 case rules = 0
case optOutAlerts
case cellularData case cellularData
case useVpnWifiProtection case useVpnWifiProtection
case autoConnectAllNetworksSettings case autoConnectAllNetworksSettings
...@@ -47,6 +49,7 @@ class TrustedNetworksViewController: AutolayoutViewController { ...@@ -47,6 +49,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
self.switchWiFiProtection.addTarget(self, action: #selector(toggleUseWiFiProtection(_:)), for: .valueChanged) self.switchWiFiProtection.addTarget(self, action: #selector(toggleUseWiFiProtection(_:)), for: .valueChanged)
self.switchCellularData.addTarget(self, action: #selector(toggleCellularData(_:)), for: .valueChanged) self.switchCellularData.addTarget(self, action: #selector(toggleCellularData(_:)), for: .valueChanged)
self.switchRules.addTarget(self, action: #selector(toggleRules(_:)), for: .valueChanged) self.switchRules.addTarget(self, action: #selector(toggleRules(_:)), for: .valueChanged)
self.switchAskForDisconnect.addTarget(self, action: #selector(toggleAskForDisconnect(_:)), for: .valueChanged)
NotificationCenter.default.addObserver(self, selector: #selector(filterAvailableNetworks), name: UIApplication.didBecomeActiveNotification, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(filterAvailableNetworks), name: UIApplication.didBecomeActiveNotification, object: nil)
...@@ -131,7 +134,11 @@ class TrustedNetworksViewController: AutolayoutViewController { ...@@ -131,7 +134,11 @@ class TrustedNetworksViewController: AutolayoutViewController {
tableView.reloadData() tableView.reloadData()
} }
@objc private func toggleAskForDisconnect(_ sender: UISwitch) {
AppPreferences.shared.optOutAskDisconnectVPNUsingNMT = sender.isOn
tableView.reloadData()
}
// MARK: Private Methods // MARK: Private Methods
private func presentKillSwitchAlert() { private func presentKillSwitchAlert() {
let alert = Macros.alert(nil, L10n.Settings.Nmt.Killswitch.disabled) let alert = Macros.alert(nil, L10n.Settings.Nmt.Killswitch.disabled)
...@@ -221,6 +228,8 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou ...@@ -221,6 +228,8 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
L10n.Settings.Hotspothelper.Available.Add.help L10n.Settings.Hotspothelper.Available.Add.help
case .rules: case .rules:
return L10n.Settings.Trusted.Networks.Sections.Trusted.Rule.description return L10n.Settings.Trusted.Networks.Sections.Trusted.Rule.description
case .optOutAlerts:
return L10n.Settings.Nmt.Optout.Disconnect.Alerts.description
default: default:
return nil return nil
} }
...@@ -255,6 +264,12 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou ...@@ -255,6 +264,12 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
cell.accessoryView = switchRules cell.accessoryView = switchRules
cell.selectionStyle = .none cell.selectionStyle = .none
switchRules.isOn = Client.preferences.nmtRulesEnabled switchRules.isOn = Client.preferences.nmtRulesEnabled
case .optOutAlerts:
cell.imageView?.image = nil
cell.textLabel?.text = L10n.Settings.Nmt.Optout.Disconnect.alerts
cell.accessoryView = switchAskForDisconnect
cell.selectionStyle = .none
switchAskForDisconnect.isOn = AppPreferences.shared.optOutAskDisconnectVPNUsingNMT
case .current: case .current:
if let ssid = hotspotHelper.currentWiFiNetwork() { if let ssid = hotspotHelper.currentWiFiNetwork() {
if trustedNetworks.contains(ssid) { if trustedNetworks.contains(ssid) {
......
...@@ -222,6 +222,8 @@ ...@@ -222,6 +222,8 @@
"settings.trusted.networks.sections.trusted.rule.action"= "Disconnect from PIA VPN"; "settings.trusted.networks.sections.trusted.rule.action"= "Disconnect from PIA VPN";
"tiles.quicksetting.nmt.title" = "Network Management"; "tiles.quicksetting.nmt.title" = "Network Management";
"settings.nmt.killswitch.disabled" = "The VPN kill switch is currently disabled. In order to ensure that the Network Management Tool is functioning, and that you are able to reconnect when switching networks, please enable the VPN kill switch in your settings."; "settings.nmt.killswitch.disabled" = "The VPN kill switch is currently disabled. In order to ensure that the Network Management Tool is functioning, and that you are able to reconnect when switching networks, please enable the VPN kill switch in your settings.";
"settings.nmt.optout.disconnect.alerts" = "Opt-out disconnect confirmation alert";
"settings.nmt.optout.disconnect.alerts.description" = "Disables the warning alert when disconnecting from the VPN.";
// REGION // REGION
......
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