diff --git a/Passepartout-iOS/Base.lproj/About.storyboard b/Passepartout-iOS/Base.lproj/About.storyboard index 6e04d622..1296b7b4 100644 --- a/Passepartout-iOS/Base.lproj/About.storyboard +++ b/Passepartout-iOS/Base.lproj/About.storyboard @@ -1,108 +1,13 @@ - - - - + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -113,10 +18,10 @@ - + - + - - - diff --git a/Passepartout-iOS/Global/Macros.swift b/Passepartout-iOS/Global/Macros.swift index d3d7837a..a984e45d 100644 --- a/Passepartout-iOS/Global/Macros.swift +++ b/Passepartout-iOS/Global/Macros.swift @@ -61,3 +61,9 @@ extension UIColor { self.init(red: r, green: g, blue: b, alpha: alpha) } } + +func delay(_ block: @escaping () -> Void) { + DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) { + block() + } +} diff --git a/Passepartout-iOS/Global/SwiftGen+Segues.swift b/Passepartout-iOS/Global/SwiftGen+Segues.swift index 05c138ee..f1353ad1 100644 --- a/Passepartout-iOS/Global/SwiftGen+Segues.swift +++ b/Passepartout-iOS/Global/SwiftGen+Segues.swift @@ -14,7 +14,6 @@ import UIKit internal enum StoryboardSegue { internal enum About: String, SegueType { case creditsSegueIdentifier = "CreditsSegueIdentifier" - case versionSegueIdentifier = "VersionSegueIdentifier" } internal enum Main: String, SegueType { case accountSegueIdentifier = "AccountSegueIdentifier" diff --git a/Passepartout-iOS/Scenes/About/AboutViewController.swift b/Passepartout-iOS/Scenes/About/AboutViewController.swift index 4f0828c7..1dcfefe1 100644 --- a/Passepartout-iOS/Scenes/About/AboutViewController.swift +++ b/Passepartout-iOS/Scenes/About/AboutViewController.swift @@ -68,7 +68,12 @@ class AboutViewController: UITableViewController, StrongTableHost { // MARK: Actions private func showVersion() { - perform(segue: StoryboardSegue.About.versionSegueIdentifier) + let vc = VersionViewController() + vc.appIcon = Asset.Assets.logo.image + vc.extraText = L10n.Core.Version.Labels.intro + vc.backgroundColor = Theme.current.palette.primaryBackground + vc.textColor = Theme.current.palette.primaryLightText + navigationController?.pushViewController(vc, animated: true) } private func openCredits() { @@ -86,7 +91,7 @@ class AboutViewController: UITableViewController, StrongTableHost { present(vc, animated: true, completion: nil) } - @IBAction private func dismiss() { + @IBAction private func close() { dismiss(animated: true, completion: nil) } } diff --git a/Passepartout-iOS/Scenes/About/VersionViewController.swift b/Passepartout-iOS/Scenes/About/VersionViewController.swift deleted file mode 100644 index 96ac81ca..00000000 --- a/Passepartout-iOS/Scenes/About/VersionViewController.swift +++ /dev/null @@ -1,58 +0,0 @@ -// -// VersionViewController.swift -// Passepartout-iOS -// -// Created by Davide De Rosa on 9/27/18. -// Copyright (c) 2019 Davide De Rosa. All rights reserved. -// -// https://github.com/passepartoutvpn -// -// This file is part of Passepartout. -// -// Passepartout is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Passepartout is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Passepartout. If not, see . -// - -import UIKit -import PassepartoutCore -import Convenience - -class VersionViewController: UIViewController { - @IBOutlet private weak var scrollView: UIScrollView? - - @IBOutlet private weak var labelTitle: UILabel? - - @IBOutlet private weak var labelVersion: UILabel? - - @IBOutlet private weak var labelIntro: UILabel? - - override func awakeFromNib() { - super.awakeFromNib() - - applyDetailTitle(.current) - } - - override func viewDidLoad() { - super.viewDidLoad() - - title = L10n.Core.Version.title - labelTitle?.text = GroupConstants.App.name - labelVersion?.text = ApplicationInfo.appVersion - labelIntro?.text = L10n.Core.Version.Labels.intro - - scrollView?.applyPrimaryBackground(.current) - for label in [labelTitle, labelVersion, labelIntro] { - label?.applyLight(.current) - } - } -} diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index d9deada6..2f1d95e5 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -273,7 +273,7 @@ class ServiceViewController: UIViewController, StrongTableHost { guard error == nil else { // XXX: delay to avoid weird toggle state - DispatchQueue.main.asyncAfter(deadline: .now() + .milliseconds(500)) { + delay { cell.setOn(false, animated: true) if error as? ApplicationError == .externalResources { self.requireDownload() @@ -346,6 +346,15 @@ class ServiceViewController: UIViewController, StrongTableHost { } } + private func trustMobileNetwork(cell: ToggleTableViewCell) { + if #available(iOS 12, *) { + IntentDispatcher.donateTrustCellularNetwork() + IntentDispatcher.donateUntrustCellularNetwork() + } + + trustedNetworks.setMobile(cell.isOn) + } + private func trustCurrentWiFi() { if #available(iOS 13, *) { let auth = CLLocationManager.authorizationStatus() @@ -390,6 +399,14 @@ class ServiceViewController: UIViewController, StrongTableHost { } } + private func toggleTrustWiFi(cell: ToggleTableViewCell, at row: Int) { + if cell.isOn { + trustedNetworks.enableWifi(at: row) + } else { + trustedNetworks.disableWifi(at: row) + } + } + private func toggleTrustedConnectionPolicy(_ isOn: Bool, sender: ToggleTableViewCell) { let completionHandler: () -> Void = { self.service.preferences.trustPolicy = isOn ? .disconnect : .ignore @@ -1071,22 +1088,13 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog toggleDisconnectsOnSleep(cell.isOn) case .trustedMobile: - if #available(iOS 12, *) { - IntentDispatcher.donateTrustCellularNetwork() - IntentDispatcher.donateUntrustCellularNetwork() - } - - trustedNetworks.setMobile(cell.isOn) + trustMobileNetwork(cell: cell) case .trustedWiFi: guard let indexPath = tableView.indexPath(for: cell) else { return } - if cell.isOn { - trustedNetworks.enableWifi(at: indexPath.row) - } else { - trustedNetworks.disableWifi(at: indexPath.row) - } + toggleTrustWiFi(cell: cell, at: indexPath.row) case .trustedPolicy: toggleTrustedConnectionPolicy(cell.isOn, sender: cell) diff --git a/Passepartout.xcodeproj/project.pbxproj b/Passepartout.xcodeproj/project.pbxproj index d7454f2a..39d6ab50 100644 --- a/Passepartout.xcodeproj/project.pbxproj +++ b/Passepartout.xcodeproj/project.pbxproj @@ -64,7 +64,6 @@ 0E36D25C224034AD006AF062 /* ShortcutsConnectToViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E36D25B224034AD006AF062 /* ShortcutsConnectToViewController.swift */; }; 0E3CAFC0229AAE770008E5C8 /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = 0E3CAFAD229AAE760008E5C8 /* Intents.intentdefinition */; }; 0E3CAFC4229AAF8E0008E5C8 /* API in Resources */ = {isa = PBXBuildFile; fileRef = 0E3CAFC3229AAF8E0008E5C8 /* API */; }; - 0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */; }; 0E45E6E022BD793800F19312 /* App.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0E45E6E222BD793800F19312 /* App.strings */; }; 0E45E6E422BD799700F19312 /* SwiftGen+Strings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E45E6E322BD799700F19312 /* SwiftGen+Strings.swift */; }; 0E45E6FA22BD8FC500F19312 /* Core.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0E3CAF98229AAE760008E5C8 /* Core.strings */; }; @@ -197,7 +196,6 @@ 0E3CAFB3229AAE760008E5C8 /* fr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = fr; path = fr.lproj/Core.strings; sourceTree = ""; }; 0E3CAFB5229AAE760008E5C8 /* nl */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Core.strings; sourceTree = ""; }; 0E3CAFC3229AAF8E0008E5C8 /* API */ = {isa = PBXFileReference; lastKnownFileType = folder; path = API; sourceTree = ""; }; - 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionViewController.swift; sourceTree = ""; }; 0E45E6E122BD793800F19312 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/App.strings; sourceTree = ""; }; 0E45E6E322BD799700F19312 /* SwiftGen+Strings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SwiftGen+Strings.swift"; sourceTree = ""; }; 0E45E6F122BD897E00F19312 /* it */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = it; path = it.lproj/App.strings; sourceTree = ""; }; @@ -361,7 +359,6 @@ 0EE3BBB1215ED3A900F30952 /* AboutViewController.swift */, 0EFBFAC021AC464800887A8C /* CreditsViewController.swift */, 0EFD943F215BED8E00529B64 /* LabelViewController.swift */, - 0E3DA370215CB5BF00B40FC9 /* VersionViewController.swift */, ); path = About; sourceTree = ""; @@ -985,7 +982,6 @@ 0E242740225951B00064A1A3 /* ProductManager.swift in Sources */, 0E1066C920E0F84A004F98B7 /* Cells.swift in Sources */, 0EF56BBB2185AC8500B0C8AB /* SwiftGen+Segues.swift in Sources */, - 0E3DA371215CB5BF00B40FC9 /* VersionViewController.swift in Sources */, 0E05C5D620D1645F006EE732 /* SwiftGen+Scenes.swift in Sources */, 0E773BF8224BF37600CDDC8E /* ShortcutsViewController.swift in Sources */, 0E3419AD2350815E00419E18 /* Donation.swift in Sources */,