Commit 29c7a6f2 authored by Jose Blaya's avatar Jose Blaya
Browse files

Update NMT

parent 33595375
This diff is collapsed.
......@@ -322,6 +322,10 @@ class DashboardViewController: AutolayoutViewController {
}
}
if !Client.preferences.nmtRulesEnabled { //if NMT disabled...
showAlert = false
}
if showAlert {
let alert = Macros.alert(
nil,
......
......@@ -48,7 +48,7 @@ class PIAHotspotHelper {
*/
public func configureHotspotHelper() -> Bool {
let hotspotDisplayName = Client.preferences.useWiFiProtection ?
let hotspotDisplayName = (Client.preferences.nmtRulesEnabled && Client.preferences.useWiFiProtection) ?
L10n.Hotspothelper.Display.Protected.name :
L10n.Hotspothelper.Display.name
......
......@@ -563,12 +563,11 @@ class SettingsViewController: AutolayoutViewController {
AppPreferences.shared.piaSocketType = pendingOpenVPNSocketType
//Update with values from Trusted Network Settings
pendingPreferences.trustedNetworks = Client.preferences.trustedNetworks
pendingPreferences.disconnectOnTrusted = Client.preferences.disconnectOnTrusted
pendingPreferences.nmtRulesEnabled = Client.preferences.nmtRulesEnabled
pendingPreferences.availableNetworks = Client.preferences.availableNetworks
pendingPreferences.shouldConnectForAllNetworks = Client.preferences.shouldConnectForAllNetworks
pendingPreferences.useWiFiProtection = Client.preferences.useWiFiProtection
pendingPreferences.trustCellularData = Client.preferences.trustCellularData
pendingPreferences.disconnectOnTrusted = Client.preferences.disconnectOnTrusted
pendingPreferences.commit()
}
......
......@@ -23,7 +23,6 @@ internal enum StoryboardSegue {
case selectRegionAnimatedSegueIdentifier = "SelectRegionAnimatedSegueIdentifier"
case selectRegionSegueIdentifier = "SelectRegionSegueIdentifier"
case settingsSegueIdentifier = "SettingsSegueIdentifier"
case trustedNetworkRulesSegueIdentifier = "TrustedNetworkRulesSegueIdentifier"
case trustedNetworksSegueIdentifier = "TrustedNetworksSegueIdentifier"
case unwindContentBlockerSegueIdentifier = "UnwindContentBlockerSegueIdentifier"
case unwindRegionsSegueIdentifier = "UnwindRegionsSegueIdentifier"
......
......@@ -71,32 +71,41 @@ class NetworkManagementToolTile: UIView, Tileable {
}
@objc private func updateNetwork() {
statusButton.isUserInteractionEnabled = true
if let ssid = hotspotHelper.currentWiFiNetwork() {
networkLabel.text = ssid.uppercased()
if Client.preferences.useWiFiProtection {
if Client.preferences.trustedNetworks.contains(ssid) {
if Client.preferences.nmtRulesEnabled {
statusButton.isUserInteractionEnabled = true
if let ssid = hotspotHelper.currentWiFiNetwork() {
networkLabel.text = ssid.uppercased()
if Client.preferences.useWiFiProtection {
if Client.preferences.trustedNetworks.contains(ssid) {
statusButton.setImage(Asset.Piax.Global.trustedIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.trusted
} else {
statusButton.setImage(Asset.Piax.Global.untrustedIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.untrusted
}
} else {
statusButton.isUserInteractionEnabled = false
statusButton.setImage(nil, for: [])
statusButton.accessibilityLabel = nil
}
} else {
networkLabel.text = L10n.Tiles.Nmt.cellular
if Client.preferences.trustCellularData {
statusButton.setImage(Asset.Piax.Global.trustedIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.trusted
} else {
statusButton.setImage(Asset.Piax.Global.untrustedIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.untrusted
}
} else {
statusButton.isUserInteractionEnabled = false
statusButton.setImage(nil, for: [])
statusButton.accessibilityLabel = nil
}
} else {
networkLabel.text = L10n.Tiles.Nmt.cellular
if Client.preferences.trustCellularData {
statusButton.setImage(Asset.Piax.Global.trustedIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.trusted
} else {
statusButton.setImage(Asset.Piax.Global.untrustedIcon.image, for: [])
statusButton.accessibilityLabel = L10n.Tiles.Nmt.Accessibility.untrusted
}
} else { // if NMT disabled
statusButton.isUserInteractionEnabled = false
networkLabel.text = L10n.Global.disabled
statusButton.setImage(nil, for: [])
statusButton.accessibilityLabel = L10n.Global.disabled
}
}
@IBAction func changeNetworkTrustMode(_ sender: Any) {
......
//
// TrustedNetworkRulesViewController.swift
// PIA VPN
//
// Created by Jose Antonio Blaya Garcia on 18/02/2019.
// Copyright © 2019 London Trust Media. All rights reserved.
//
import UIKit
import PIALibrary
class TrustedNetworkRulesViewController: AutolayoutViewController {
@IBOutlet private weak var tableView: UITableView!
private lazy var switchTrusted = UISwitch()
private enum Sections: Int, EnumsBuilder {
case trusted = 0
}
private struct Cells {
static let rules = "RulesCell"
}
override func viewDidLoad() {
super.viewDidLoad()
self.title = L10n.Settings.Hotspothelper.Rules.title
self.switchTrusted.addTarget(self, action: #selector(toggleTrusted(_:)), for: .valueChanged)
configureTableView()
}
// MARK: Private Methods
private func configureTableView() {
if #available(iOS 11, *) {
tableView.sectionFooterHeight = UITableViewAutomaticDimension
tableView.estimatedSectionFooterHeight = 1.0
}
}
// MARK: Restylable
override func viewShouldRestyle() {
super.viewShouldRestyle()
styleNavigationBarWithTitle(L10n.Settings.Hotspothelper.Rules.title)
if let viewContainer = viewContainer {
Theme.current.applyPrincipalBackground(viewContainer)
}
Theme.current.applyPrincipalBackground(tableView)
Theme.current.applyDividerToSeparator(tableView)
}
@objc private func toggleTrusted(_ sender: UISwitch) {
let preferences = Client.preferences.editable()
preferences.disconnectOnTrusted = sender.isOn
preferences.commit()
}
}
extension TrustedNetworkRulesViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return Sections.countCases()
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
switch Sections.objectIdentifyBy(index: section) {
case .trusted:
return L10n.Settings.Trusted.Networks.Sections.trusted.uppercased()
}
}
func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
switch Sections.objectIdentifyBy(index: section) {
case .trusted:
return L10n.Settings.Trusted.Networks.Sections.Trusted.Rule.description
}
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 1
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: Cells.rules, for: indexPath)
cell.selectionStyle = .default
cell.accessoryType = .none
cell.accessoryView = nil
cell.isUserInteractionEnabled = true
cell.imageView?.image = Asset.iconWifi.image.withRenderingMode(.alwaysTemplate)
cell.imageView?.tintColor = Theme.current.palette.textColor(forRelevance: 3, appearance: .dark)
switch Sections.objectIdentifyBy(index: indexPath.section) {
case .trusted:
cell.imageView?.image = nil
cell.textLabel?.text = L10n.Settings.Trusted.Networks.Sections.Trusted.Rule.action
cell.accessoryView = switchTrusted
cell.selectionStyle = .none
switchTrusted.isOn = Client.preferences.disconnectOnTrusted
}
cell.textLabel?.backgroundColor = .clear
Theme.current.applySecondaryBackground(cell)
Theme.current.applyDetailTableCell(cell)
if let textLabel = cell.textLabel {
Theme.current.applySettingsCellTitle(textLabel,
appearance: .dark)
textLabel.backgroundColor = .clear
}
let backgroundView = UIView()
Theme.current.applyPrincipalBackground(backgroundView)
cell.selectedBackgroundView = backgroundView
return cell
}
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
Theme.current.applyTableSectionHeader(view)
}
func tableView(_ tableView: UITableView, willDisplayFooterView view: UIView, forSection section: Int) {
Theme.current.applyTableSectionFooter(view)
}
}
......@@ -19,6 +19,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
private lazy var switchWiFiProtection = UISwitch()
private lazy var switchAutoJoinAllNetworks = UISwitch()
private lazy var switchCellularData = UISwitch()
private lazy var switchRules = UISwitch()
var shouldReconnectAutomatically = false
var hasUpdatedPreferences = false
......@@ -44,6 +45,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
self.switchAutoJoinAllNetworks.addTarget(self, action: #selector(toggleAutoconnectWithAllNetworks(_:)), for: .valueChanged)
self.switchWiFiProtection.addTarget(self, action: #selector(toggleUseWiFiProtection(_:)), for: .valueChanged)
self.switchCellularData.addTarget(self, action: #selector(toggleCellularData(_:)), for: .valueChanged)
self.switchRules.addTarget(self, action: #selector(toggleRules(_:)), for: .valueChanged)
NotificationCenter.default.addObserver(self, selector: #selector(filterAvailableNetworks), name: .UIApplicationDidBecomeActive, object: nil)
......@@ -109,6 +111,15 @@ class TrustedNetworksViewController: AutolayoutViewController {
preferences.commit()
hasUpdatedPreferences = true
}
@objc private func toggleRules(_ sender: UISwitch) {
let preferences = Client.preferences.editable()
preferences.nmtRulesEnabled = sender.isOn
preferences.commit()
hasUpdatedPreferences = true
tableView.reloadData()
}
// MARK: Private Methods
private func configureTableView() {
......@@ -143,7 +154,11 @@ class TrustedNetworksViewController: AutolayoutViewController {
extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return Client.preferences.useWiFiProtection ? Sections.countCases() : 3
if Client.preferences.nmtRulesEnabled {
return Client.preferences.useWiFiProtection ? Sections.countCases() : 3
} else {
return 1
}
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
......@@ -158,6 +173,8 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
return L10n.Settings.Trusted.Networks.Sections.trusted.uppercased()
case .cellularData:
return L10n.Settings.Hotspothelper.Cellular.networks.uppercased()
case .rules:
return L10n.Settings.Hotspothelper.title.uppercased()
default:
return nil
}
......@@ -177,6 +194,8 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
return availableNetworks.isEmpty ?
L10n.Settings.Hotspothelper.Available.help :
L10n.Settings.Hotspothelper.Available.Add.help
case .rules:
return L10n.Settings.Trusted.Networks.Sections.Trusted.Rule.description
default:
return nil
}
......@@ -207,9 +226,10 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
switch Sections.objectIdentifyBy(index: indexPath.section) {
case .rules:
cell.imageView?.image = nil
cell.textLabel?.text = L10n.Settings.Hotspothelper.Rules.title
cell.accessoryType = .disclosureIndicator
cell.accessoryView = nil
cell.textLabel?.text = L10n.Global.enabled
cell.accessoryView = switchRules
cell.selectionStyle = .none
switchRules.isOn = Client.preferences.nmtRulesEnabled
case .current:
if let ssid = hotspotHelper.currentWiFiNetwork() {
if trustedNetworks.contains(ssid) {
......@@ -278,8 +298,6 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
let ssid = trustedNetworks[indexPath.row]
hotspotHelper.removeTrustedNetwork(ssid)
hasUpdatedPreferences = true
case .rules:
self.perform(segue: StoryboardSegue.Main.trustedNetworkRulesSegueIdentifier)
default:
break
}
......
......@@ -64,7 +64,7 @@
<nil key="highlightedColor"/>
</label>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="favorite-selected" translatesAutoresizingMaskIntoConstraints="NO" id="Tt7-8W-weg">
<rect key="frame" x="286.66666666666663" y="17.333333333333332" width="17" height="14.999999999999996"/>
<rect key="frame" x="286.66666666666669" y="17.333333333333332" width="17" height="14.999999999999996"/>
<constraints>
<constraint firstAttribute="width" constant="17" id="40a-ne-jOu"/>
<constraint firstAttribute="height" constant="15" id="C6M-is-D59"/>
......@@ -1294,79 +1294,12 @@
<connections>
<outlet property="tableView" destination="Si7-46-a7E" id="xk9-1a-OcZ"/>
<outlet property="viewContainer" destination="p4O-Dy-PbF" id="Aw9-9G-NGH"/>
<segue destination="X1D-87-Kfq" kind="show" identifier="TrustedNetworkRulesSegueIdentifier" id="iVj-sa-AkP"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="QBf-Kp-bhx" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="2697" y="-1767"/>
</scene>
<!--Trusted Network Rules View Controller-->
<scene sceneID="ZcL-4t-DjL">
<objects>
<viewController id="X1D-87-Kfq" customClass="TrustedNetworkRulesViewController" customModule="PIA_VPN" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="y8k-Fi-i7P">
<rect key="frame" x="0.0" y="0.0" width="375" height="724"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Vzv-qD-0Zg">
<rect key="frame" x="0.0" y="0.0" width="375" height="724"/>
<subviews>
<tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" translatesAutoresizingMaskIntoConstraints="NO" id="OQK-UT-QqU">
<rect key="frame" x="0.0" y="0.0" width="375" height="724"/>
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="RulesCell" textLabel="IBn-4E-8vj" style="IBUITableViewCellStyleDefault" id="muw-wh-O9e">
<rect key="frame" x="0.0" y="55.333333333333343" width="375" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="muw-wh-O9e" id="qfS-EF-1Ka">
<rect key="frame" x="0.0" y="0.0" width="375" height="43.666666666666664"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" insetsLayoutMarginsFromSafeArea="NO" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="IBn-4E-8vj">
<rect key="frame" x="15" y="0.0" width="345" height="43.666666666666664"/>
<autoresizingMask key="autoresizingMask"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
</tableViewCellContentView>
</tableViewCell>
</prototypes>
<connections>
<outlet property="dataSource" destination="X1D-87-Kfq" id="Z5O-M8-t0o"/>
<outlet property="delegate" destination="X1D-87-Kfq" id="1ia-2f-iZg"/>
</connections>
</tableView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="OQK-UT-QqU" secondAttribute="trailing" id="4g6-bw-6kf"/>
<constraint firstAttribute="bottom" secondItem="OQK-UT-QqU" secondAttribute="bottom" id="ZIq-Ay-Ye0"/>
<constraint firstItem="OQK-UT-QqU" firstAttribute="top" secondItem="Vzv-qD-0Zg" secondAttribute="top" id="oGB-md-10q"/>
<constraint firstItem="OQK-UT-QqU" firstAttribute="leading" secondItem="Vzv-qD-0Zg" secondAttribute="leading" id="waY-e8-8q1"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="Vzv-qD-0Zg" firstAttribute="top" secondItem="y8k-Fi-i7P" secondAttribute="top" id="7AF-EQ-Got"/>
<constraint firstItem="Vzv-qD-0Zg" firstAttribute="trailing" secondItem="PQe-2d-DU0" secondAttribute="trailing" id="ZBq-3v-Nc0"/>
<constraint firstAttribute="bottom" secondItem="Vzv-qD-0Zg" secondAttribute="bottom" id="oxA-nh-x0I"/>
<constraint firstItem="Vzv-qD-0Zg" firstAttribute="leading" secondItem="PQe-2d-DU0" secondAttribute="leading" id="ySY-bs-2Xk"/>
</constraints>
<viewLayoutGuide key="safeArea" id="PQe-2d-DU0"/>
</view>
<connections>
<outlet property="tableView" destination="OQK-UT-QqU" id="FKf-eL-peI"/>
<outlet property="viewContainer" destination="Vzv-qD-0Zg" id="s2g-cy-7vB"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Npk-IL-6xz" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="3703" y="-1769"/>
</scene>
<!--CustomDNS Settings View Controller-->
<scene sceneID="TrO-qA-66V">
<objects>
......
......@@ -53,7 +53,7 @@ end
def shared_main_pods
pod 'AlamofireImage'
#library_by_path('')
library_by_git('168186c')
library_by_git('1af7fe7')
#library_by_version('~> 1.1.3')
end
......
......@@ -114,10 +114,10 @@ DEPENDENCIES:
- FXPageControl
- HockeySDK
- iRate
- PIALibrary/Library (from `https://github.com/pia-foss/client-library-apple`, commit `168186c`)
- PIALibrary/Mock (from `https://github.com/pia-foss/client-library-apple`, commit `168186c`)
- PIALibrary/UI (from `https://github.com/pia-foss/client-library-apple`, commit `168186c`)
- PIALibrary/VPN (from `https://github.com/pia-foss/client-library-apple`, commit `168186c`)
- PIALibrary/Library (from `https://github.com/pia-foss/client-library-apple`, commit `1af7fe7`)
- PIALibrary/Mock (from `https://github.com/pia-foss/client-library-apple`, commit `1af7fe7`)
- PIALibrary/UI (from `https://github.com/pia-foss/client-library-apple`, commit `1af7fe7`)
- PIALibrary/VPN (from `https://github.com/pia-foss/client-library-apple`, commit `1af7fe7`)
- PIATunnel (from `https://github.com/pia-foss/tunnel-apple`, commit `bd53e0a`)
- PopupDialog
- SideMenu (= 3.1.5)
......@@ -154,7 +154,7 @@ SPEC REPOS:
EXTERNAL SOURCES:
PIALibrary:
:commit: 168186c
:commit: 1af7fe7
:git: https://github.com/pia-foss/client-library-apple
PIATunnel:
:commit: bd53e0a
......@@ -162,7 +162,7 @@ EXTERNAL SOURCES:
CHECKOUT OPTIONS:
PIALibrary:
:commit: 168186c
:commit: 1af7fe7
:git: https://github.com/pia-foss/client-library-apple
PIATunnel:
:commit: bd53e0a
......@@ -198,6 +198,6 @@ SPEC CHECKSUMS:
SwiftyBeaver: ccfcdf85a04d429f1633f668650b0ce8020bda3a
TPKeyboardAvoiding: cb69d5ddbe90ce0170e4bc2db1e5e41d4a3ad9a4
PODFILE CHECKSUM: 0275905eaa8f2e3656b3fd9a50b24fa58c303e0b
PODFILE CHECKSUM: 1bf5195cb13c6f7f53836ce692f5a95530f1f833
COCOAPODS: 1.5.3
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