Commit 52803e24 authored by Jose Blaya's avatar Jose Blaya
Browse files

Refactor NMT tile

parent 1d35a73f
......@@ -77,7 +77,8 @@ class NetworkManagementToolTile: UIView, Tileable {
if let ssid = hotspotHelper.currentWiFiNetwork() {
networkLabel.text = ssid.uppercased()
if Client.preferences.useWiFiProtection {
if Client.preferences.trustedNetworks.contains(ssid) {
if Client.preferences.trustedNetworks.contains(ssid) ||
Client.preferences.shouldConnectForAllNetworks {
statusButton.setImage(Theme.current.palette.appearance == .light ? Asset.Piax.Global.trustedLightIcon.image :
Asset.Piax.Global.trustedDarkIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.trusted
......@@ -94,13 +95,13 @@ class NetworkManagementToolTile: UIView, Tileable {
} else {
networkLabel.text = L10n.Tiles.Nmt.cellular
if Client.preferences.trustCellularData {
statusButton.setImage(Theme.current.palette.appearance == .light ? Asset.Piax.Global.trustedLightIcon.image :
Asset.Piax.Global.trustedDarkIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.trusted
} else {
statusButton.setImage(Theme.current.palette.appearance == .light ? Asset.Piax.Global.untrustedLightIcon.image :
Asset.Piax.Global.untrustedDarkIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.untrusted
} else {
statusButton.setImage(Theme.current.palette.appearance == .light ? Asset.Piax.Global.trustedLightIcon.image :
Asset.Piax.Global.trustedDarkIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.trusted
}
}
} else { // if NMT disabled
......
......@@ -89,6 +89,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
let preferences = Client.preferences.editable()
preferences.shouldConnectForAllNetworks = sender.isOn
preferences.commit()
hasUpdatedPreferences = true
}
@objc private func toggleUseWiFiProtection(_ sender: UISwitch) {
......@@ -289,6 +290,7 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
case .current:
if let ssid = hotspotHelper.currentWiFiNetwork() {
hotspotHelper.saveTrustedNetwork(ssid)
hasUpdatedPreferences = true
}
case .available:
let ssid = availableNetworks[indexPath.row]
......@@ -317,6 +319,7 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
if editingStyle == .delete {
let ssid = trustedNetworks[indexPath.row]
hotspotHelper.removeTrustedNetwork(ssid)
hasUpdatedPreferences = true
filterAvailableNetworks()
}
}
......
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