Commit 20e7cb08 authored by Jose Blaya's avatar Jose Blaya
Browse files

- Confirm to disconnect the vpn in untrusted networks

- Fix issue in NMT tile
parent 456be3f0
This diff is collapsed.
......@@ -300,13 +300,45 @@ class DashboardViewController: AutolayoutViewController {
object: self,
userInfo: nil)
} else {
Client.providers.vpnProvider.disconnect({ [weak self] _ in
self?.reloadUsageTileAfter(seconds: 1) //Reset the usage statistics after stop the VPN
})
var showAlert = false
if let ssid = UIDevice.current.WiFiSSID {
if (Client.preferences.useWiFiProtection && (!Client.preferences.trustedNetworks.contains(ssid) || Client.preferences.shouldConnectForAllNetworks)) {
showAlert = true
}
} else {
if !Client.preferences.trustCellularData {
showAlert = true
}
}
if showAlert {
let alert = Macros.alert(
nil,
L10n.Dashboard.Vpn.Disconnect.untrusted
)
alert.addCancelActionWithTitle(L10n.Global.cancel) {
}
alert.addActionWithTitle(L10n.Shortcuts.disconnect) {
self.disconnectWithOneSecondDelay()
}
present(alert, animated: true, completion: nil)
} else {
disconnectWithOneSecondDelay()
}
}
Macros.postNotification(.PIAVPNUsageUpdate)
}
private func disconnectWithOneSecondDelay() {
Client.providers.vpnProvider.disconnect({ [weak self] _ in
self?.reloadUsageTileAfter(seconds: 1) //Reset the usage statistics after stop the VPN
})
}
private func reloadUsageTileAfter(seconds: TimeInterval) {
DispatchQueue.main.asyncAfter(deadline: .now() + seconds) {
Macros.postNotification(.PIAVPNUsageUpdate)
......
......@@ -131,6 +131,10 @@ internal enum L10n {
internal static let disconnecting = L10n.tr("Localizable", "dashboard.vpn.disconnecting")
/// VPN: ON
internal static let on = L10n.tr("Localizable", "dashboard.vpn.on")
internal enum Disconnect {
/// This network is untrusted. Do you really want to disconnect the VPN?
internal static let untrusted = L10n.tr("Localizable", "dashboard.vpn.disconnect.untrusted")
}
}
}
......
......@@ -71,6 +71,7 @@ class NetworkManagementToolTile: UIView, Tileable {
}
@objc private func updateNetwork() {
statusButton.isUserInteractionEnabled = true
if let ssid = hotspotHelper.currentWiFiNetwork() {
networkLabel.text = ssid.uppercased()
if Client.preferences.useWiFiProtection {
......@@ -82,6 +83,7 @@ class NetworkManagementToolTile: UIView, Tileable {
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.untrusted
}
} else {
statusButton.isUserInteractionEnabled = false
statusButton.setImage(nil, for: [])
statusButton.accessibilityLabel = nil
}
......
......@@ -168,6 +168,7 @@
"dashboard.vpn.on" = "VPN: ON";
"dashboard.vpn.disconnecting" = "Disconnecting...";
"dashboard.vpn.changing_region" = "Changing region...";
"dashboard.vpn.disconnect.untrusted" = "This network is untrusted. Do you really want to disconnect the VPN?";
// VPN PERMISSION
......
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