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