Commit 33893c84 authored by Jose Blaya's avatar Jose Blaya
Browse files

- New Rules view controller to decide actions when joining a trusted or untrusted network.

- Fix xib issues with old images
- Bump version
parent 3b7cc244
......@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
......
......@@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSExtension</key>
......
This diff is collapsed.
......@@ -29,8 +29,8 @@ struct AppConstants {
}
struct InApp {
static let yearlyProductIdentifier = "com.privateinternetaccess.ios.iap.1year"
static let monthlyProductIdentifier = "com.privateinternetaccess.ios.iap.1month"
static let yearlyProductIdentifier = "com.privateinternetaccess.ios.iap.2019.1year"
static let monthlyProductIdentifier = "com.privateinternetaccess.ios.iap.2019.1month"
}
struct LegacyInApp {
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSpokenName</key>
......
......@@ -487,6 +487,8 @@ class SettingsViewController: AutolayoutViewController {
AppPreferences.shared.piaSocketType = pendingOpenVPNSocketType
//Update with values from Trusted Network Settings
pendingPreferences.trustedNetworks = Client.preferences.trustedNetworks
pendingPreferences.connectOnUntrusted = Client.preferences.connectOnUntrusted
pendingPreferences.disconnectOnTrusted = Client.preferences.disconnectOnTrusted
pendingPreferences.availableNetworks = Client.preferences.availableNetworks
pendingPreferences.shouldConnectForAllNetworks = Client.preferences.shouldConnectForAllNetworks
pendingPreferences.useWiFiProtection = Client.preferences.useWiFiProtection
......@@ -874,7 +876,8 @@ extension SettingsViewController: UITableViewDataSource, UITableViewDelegate {
case .trustedNetworks:
cell.textLabel?.text = L10n.Settings.Hotspothelper.title
cell.detailTextLabel?.text = nil
case .publicUsername:
cell.textLabel?.text = "Public username"
cell.detailTextLabel?.text = Client.providers.accountProvider.publicUsername ?? ""
......
......@@ -22,6 +22,7 @@ internal enum StoryboardSegue {
case selectRegionAnimatedSegueIdentifier = "SelectRegionAnimatedSegueIdentifier"
case selectRegionSegueIdentifier = "SelectRegionSegueIdentifier"
case settingsSegueIdentifier = "SettingsSegueIdentifier"
case trustedNetworkRulesSegueIdentifier = "TrustedNetworkRulesSegueIdentifier"
case trustedNetworksSegueIdentifier = "TrustedNetworksSegueIdentifier"
case unwindContentBlockerSegueIdentifier = "UnwindContentBlockerSegueIdentifier"
case unwindRegionsSegueIdentifier = "UnwindRegionsSegueIdentifier"
......
......@@ -477,6 +477,10 @@ internal enum L10n {
/// VPN WiFi Protection automatically enables the VPN when connecting to untrusted networks if this option is enabled.
internal static let description = L10n.tr("Localizable", "settings.hotspothelper.enable.description")
}
internal enum Rules {
/// Rules
internal static let title = L10n.tr("Localizable", "settings.hotspothelper.rules.title")
}
internal enum Wifi {
/// WiFi networks
internal static let networks = L10n.tr("Localizable", "settings.hotspothelper.wifi.networks")
......@@ -519,6 +523,24 @@ internal enum L10n {
internal static let current = L10n.tr("Localizable", "settings.trusted.networks.sections.current")
/// Trusted networks
internal static let trusted = L10n.tr("Localizable", "settings.trusted.networks.sections.trusted")
/// Untrusted networks
internal static let untrusted = L10n.tr("Localizable", "settings.trusted.networks.sections.untrusted")
internal enum Trusted {
internal enum Rule {
/// Disconnect from PIA VPN
internal static let action = L10n.tr("Localizable", "settings.trusted.networks.sections.trusted.rule.action")
/// Perform actions when joining trusted networks.
internal static let description = L10n.tr("Localizable", "settings.trusted.networks.sections.trusted.rule.description")
}
}
internal enum Untrusted {
internal enum Rule {
/// Connect to PIA VPN
internal static let action = L10n.tr("Localizable", "settings.trusted.networks.sections.untrusted.rule.action")
/// Perform actions when joining untrusted networks.
internal static let description = L10n.tr("Localizable", "settings.trusted.networks.sections.untrusted.rule.description")
}
}
}
}
}
......
......@@ -25,7 +25,7 @@
<constraint firstAttribute="width" constant="34" id="ikS-W5-PPW"/>
<constraint firstAttribute="height" constant="34" id="n0k-fl-4f4"/>
</constraints>
<state key="normal" image="eye-active"/>
<state key="normal" image="eye-active-dark"/>
<connections>
<action selector="changeTileVisibility" destination="gTV-IL-0wX" eventType="touchUpInside" id="URh-aw-dI1"/>
</connections>
......@@ -63,7 +63,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="eye-active" width="19" height="10"/>
<image name="eye-active-dark" width="17" height="11"/>
<image name="open-tile-details" width="12" height="12"/>
</resources>
</document>
......@@ -25,7 +25,7 @@
<constraint firstAttribute="height" constant="34" id="Hd2-do-D1T"/>
<constraint firstAttribute="width" constant="34" id="kff-Q9-RvK"/>
</constraints>
<state key="normal" image="eye-active"/>
<state key="normal" image="eye-active-dark"/>
<connections>
<action selector="changeTileVisibility" destination="gTV-IL-0wX" eventType="touchUpInside" id="msP-nd-W8g"/>
</connections>
......@@ -63,7 +63,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="eye-active" width="19" height="10"/>
<image name="eye-active-dark" width="17" height="11"/>
<image name="open-tile-details" width="12" height="12"/>
</resources>
</document>
......@@ -25,7 +25,7 @@
<constraint firstAttribute="height" constant="34" id="jHP-Dd-1IU"/>
<constraint firstAttribute="width" constant="34" id="wOe-Lk-jKc"/>
</constraints>
<state key="normal" image="eye-active"/>
<state key="normal" image="eye-active-dark"/>
<connections>
<action selector="changeTileVisibility" destination="gTV-IL-0wX" eventType="touchUpInside" id="VQ4-bh-35U"/>
</connections>
......@@ -65,7 +65,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="eye-active" width="19" height="10"/>
<image name="eye-active-dark" width="17" height="11"/>
<image name="open-tile-details" width="12" height="12"/>
</resources>
</document>
......@@ -25,7 +25,7 @@
<constraint firstAttribute="height" constant="34" id="3kv-h3-PHR"/>
<constraint firstAttribute="width" constant="34" id="j1R-gh-Ars"/>
</constraints>
<state key="normal" image="eye-active"/>
<state key="normal" image="eye-active-dark"/>
<connections>
<action selector="changeTileVisibility" destination="gTV-IL-0wX" eventType="touchUpInside" id="iTO-De-9xK"/>
</connections>
......@@ -63,7 +63,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="eye-active" width="19" height="10"/>
<image name="eye-active-dark" width="17" height="11"/>
<image name="open-tile-details" width="12" height="12"/>
</resources>
</document>
......@@ -25,7 +25,7 @@
<constraint firstAttribute="height" constant="34" id="6GE-p9-jbu"/>
<constraint firstAttribute="width" constant="34" id="BJI-EI-k0I"/>
</constraints>
<state key="normal" image="eye-active"/>
<state key="normal" image="eye-active-dark"/>
<connections>
<action selector="changeTileVisibility" destination="gTV-IL-0wX" eventType="touchUpInside" id="bFk-gl-t55"/>
</connections>
......@@ -63,7 +63,7 @@
</collectionViewCell>
</objects>
<resources>
<image name="eye-active" width="16" height="16"/>
<image name="eye-active-dark" width="17" height="11"/>
<image name="open-tile-details" width="12" height="12"/>
</resources>
</document>
//
// 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 lazy var switchUntrusted = UISwitch()
private enum Sections: Int, EnumsBuilder {
case trusted = 0
case untrusted
}
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)
self.switchUntrusted.addTarget(self, action: #selector(toggleUntrusted(_:)), 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()
}
@objc private func toggleUntrusted(_ sender: UISwitch) {
let preferences = Client.preferences.editable()
preferences.connectOnUntrusted = 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()
case .untrusted:
return L10n.Settings.Trusted.Networks.Sections.untrusted.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
case .untrusted:
return L10n.Settings.Trusted.Networks.Sections.Untrusted.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
case .untrusted:
cell.imageView?.image = nil
cell.textLabel?.text = L10n.Settings.Trusted.Networks.Sections.Untrusted.Rule.action
cell.detailTextLabel?.text = nil
cell.accessoryView = switchUntrusted
cell.selectionStyle = .none
switchUntrusted.isOn = Client.preferences.connectOnUntrusted
}
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)
}
}
......@@ -22,7 +22,8 @@ class TrustedNetworksViewController: AutolayoutViewController {
private enum Sections: Int, EnumsBuilder {
case cellularData = 0
case rules = 0
case cellularData
case useVpnWifiProtection
case autoConnectAllNetworksSettings
case current
......@@ -125,7 +126,7 @@ class TrustedNetworksViewController: AutolayoutViewController {
extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return Client.preferences.useWiFiProtection ? Sections.countCases() : 2
return Client.preferences.useWiFiProtection ? Sections.countCases() : 3
}
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
......@@ -180,12 +181,18 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: Cells.network, 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 .rules:
cell.imageView?.image = nil
cell.textLabel?.text = L10n.Settings.Hotspothelper.Rules.title
cell.accessoryType = .disclosureIndicator
cell.accessoryView = nil
case .current:
if let ssid = hotspotHelper.currentWiFiNetwork() {
if trustedNetworks.contains(ssid) {
......@@ -252,6 +259,8 @@ extension TrustedNetworksViewController: UITableViewDelegate, UITableViewDataSou
case .trusted:
let ssid = trustedNetworks[indexPath.row]
hotspotHelper.removeTrustedNetwork(ssid)
case .rules:
self.perform(segue: StoryboardSegue.Main.trustedNetworkRulesSegueIdentifier)
default:
break
}
......
......@@ -213,7 +213,12 @@
"settings.hotspothelper.cellular.description" = "PIA automatically enables the VPN when connecting to cellular networks if this option is disabled.";
"settings.hotspothelper.cellular.networks" = "Cellular networks";
"settings.hotspothelper.wifi.networks" = "WiFi networks";
"settings.trusted.networks.sections.untrusted" = "Untrusted networks";
"settings.hotspothelper.rules.title" = "Rules";
"settings.trusted.networks.sections.trusted.rule.description"= "Perform actions when joining trusted networks.";
"settings.trusted.networks.sections.untrusted.rule.description"= "Perform actions when joining untrusted networks.";
"settings.trusted.networks.sections.trusted.rule.action"= "Disconnect from PIA VPN";
"settings.trusted.networks.sections.untrusted.rule.action"= "Connect to PIA VPN";
// REGION
......@@ -235,4 +240,4 @@
"tiles.usage.title" = "Usage";
"tiles.usage.ipsec.title" = "USAGE (Disabled unless using OpenVPN)";
"tiles.usage.upload" = "Upload";
"tiles.usage.download" = "Download";
\ No newline at end of file
"tiles.usage.download" = "Download";
This diff is collapsed.
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>3.0.0</string>
<string>3.0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
......
......@@ -64,8 +64,8 @@ PODS:
- nanopb/decode (0.3.901)
- nanopb/encode (0.3.901)
- OpenSSL-Apple (1.1.0h)
- PIALibrary/Core (2.0.0)
- PIALibrary/Library (2.0.0):
- PIALibrary/Core (2.0.1)
- PIALibrary/Library (2.0.1):
- Alamofire (~> 4)
- Gloss (~> 2)
- PIALibrary/Core
......@@ -73,17 +73,17 @@ PODS:
- PopupDialog
- ReachabilitySwift
- SwiftyBeaver
- PIALibrary/Mock (2.0.0):
- PIALibrary/Mock (2.0.1):
- PIALibrary/Library
- PIALibrary/UI (2.0.0):
- PIALibrary/UI (2.0.1):
- lottie-ios
- PIALibrary/Library
- SwiftEntryKit (= 0.7.2)
- SwiftyBeaver
- TPKeyboardAvoiding
- PIALibrary/Util (2.0.0):
- PIALibrary/Util (2.0.1):
- PIALibrary/Core
- PIALibrary/VPN (2.0.0):
- PIALibrary/VPN (2.0.1):
- PIALibrary/Library
- PIATunnel (~> 1.1.8)
- PIATunnel (1.1.8):
......@@ -178,7 +178,7 @@ SPEC CHECKSUMS:
lottie-ios: 3fef45d3fabe63e3c7c2eb603dd64ddfffc73062
nanopb: 2901f78ea1b7b4015c860c2fdd1ea2fee1a18d48
OpenSSL-Apple: cd153d705ef350eb834ae7ff5f21f792b51ed208
PIALibrary: 7ddf4142286031c89313a3cf7dcd6580a14f1db5
PIALibrary: 55ba3de7c08812ce17af699690cb5778c7e86d8b
PIATunnel: fc7e7d0a812c6c98138ac315e7a43008aadd15b2
PopupDialog: 03985b669c29802661c187513bf827340db1ae4d
QuickLayout: a730730b646b231fd4ef7cffaeb1e81fe0e1ca92
......
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