From 6ed70feb775b986c5e83c4c4439eca7f9317c6aa Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 21 Oct 2018 09:45:59 +0200 Subject: [PATCH 1/4] Reconnect with a specific action cell --- .../Scenes/ServiceViewController.swift | 27 ++++++++++++------- .../Resources/en.lproj/Localizable.strings | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 274ef0e5..779cb126 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -397,12 +397,14 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog } enum RowType: Int { + case useProfile + case vpnService case connectionStatus - case useProfile - + case reconnect + case account case endpoint @@ -503,6 +505,12 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let row = model.row(at: indexPath) switch row { + case .useProfile: + let cell = Cells.setting.dequeue(from: tableView, for: indexPath) + cell.applyAction(Theme.current) + cell.leftText = L10n.Service.Cells.UseProfile.caption + return cell + case .vpnService: guard service.isActiveProfile(uncheckedProfile) else { fatalError("Do not show vpnService in non-active profile") @@ -522,13 +530,14 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog cell.applyVPN(Theme.current, with: vpn.isEnabled ? vpn.status : nil) cell.leftText = L10n.Service.Cells.ConnectionStatus.caption cell.accessoryType = .none - cell.isTappable = !service.needsCredentials(for: uncheckedProfile) && vpn.isEnabled return cell - case .useProfile: + case .reconnect: let cell = Cells.setting.dequeue(from: tableView, for: indexPath) cell.applyAction(Theme.current) - cell.leftText = L10n.Service.Cells.UseProfile.caption + cell.leftText = L10n.Service.Cells.Reconnect.caption + cell.accessoryType = .none + cell.isTappable = !service.needsCredentials(for: uncheckedProfile) && vpn.isEnabled return cell // shared cells @@ -695,12 +704,12 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog // true if enters subscreen private func handle(row: RowType, cell: UITableViewCell) -> Bool { switch row { - case .connectionStatus: - confirmVpnReconnection() - case .useProfile: activate() + case .reconnect: + confirmVpnReconnection() + case .account: perform(segue: StoryboardSegue.Main.accountSegueIdentifier, sender: cell) return true @@ -852,7 +861,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog // rows if isActiveProfile { - model.set([.vpnService, .connectionStatus], in: .vpn) + model.set([.vpnService, .connectionStatus, .reconnect], in: .vpn) } else { model.set([.useProfile], in: .vpn) } diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index d40146be..c936d3ec 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -72,9 +72,9 @@ "service.sections.diagnostics.header" = "Diagnostics"; //"service.sections.destruction.footer" = "Delete configuration from device settings."; +"service.cells.use_profile.caption" = "Use this profile"; "service.cells.vpn_service.caption" = "Enabled"; "service.cells.connection_status.caption" = "Status"; -"service.cells.use_profile.caption" = "Use this profile"; "service.cells.reconnect.caption" = "Reconnect"; "service.cells.account.caption" = "Account"; "service.cells.account.none" = "None configured"; From 2e764ec14d21f2517b60ef753ff86dba3945bdf0 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 21 Oct 2018 10:05:39 +0200 Subject: [PATCH 2/4] Only show Reconnect if VPN is enabled --- .../Scenes/ServiceViewController.swift | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Passepartout-iOS/Scenes/ServiceViewController.swift b/Passepartout-iOS/Scenes/ServiceViewController.swift index 779cb126..bfac173e 100644 --- a/Passepartout-iOS/Scenes/ServiceViewController.swift +++ b/Passepartout-iOS/Scenes/ServiceViewController.swift @@ -92,7 +92,7 @@ class ServiceViewController: UIViewController, TableModelHost { // run this no matter what // XXX: convenient here vs AppDelegate for updating table vpn.prepare(withProfile: profile) { -// self.reloadVpnStatus() + self.reloadModel() self.tableView.reloadData() } @@ -206,11 +206,13 @@ class ServiceViewController: UIViewController, TableModelHost { cell.setOn(false, animated: true) return } - self.reloadVpnStatus() + self.reloadModel() + self.tableView.reloadData() } } else { vpn.disconnect { (error) in - self.reloadVpnStatus() + self.reloadModel() + self.tableView.reloadData() } } } @@ -530,6 +532,7 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog cell.applyVPN(Theme.current, with: vpn.isEnabled ? vpn.status : nil) cell.leftText = L10n.Service.Cells.ConnectionStatus.caption cell.accessoryType = .none + cell.isTappable = false return cell case .reconnect: @@ -861,7 +864,11 @@ extension ServiceViewController: UITableViewDataSource, UITableViewDelegate, Tog // rows if isActiveProfile { - model.set([.vpnService, .connectionStatus, .reconnect], in: .vpn) + var rows: [RowType] = [.vpnService, .connectionStatus] + if vpn.isEnabled { + rows.append(.reconnect) + } + model.set(rows, in: .vpn) } else { model.set([.useProfile], in: .vpn) } From 3dd7f9e77928e29d499740d861299737fdc0afec Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Sun, 21 Oct 2018 10:08:56 +0200 Subject: [PATCH 3/4] Update VPN section footer accordingly --- Passepartout/Resources/en.lproj/Localizable.strings | 2 +- Passepartout/Sources/SwiftGen+Strings.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Passepartout/Resources/en.lproj/Localizable.strings b/Passepartout/Resources/en.lproj/Localizable.strings index c936d3ec..362c2ec6 100644 --- a/Passepartout/Resources/en.lproj/Localizable.strings +++ b/Passepartout/Resources/en.lproj/Localizable.strings @@ -61,7 +61,7 @@ "service.sections.status.header" = "Connection"; "service.sections.diagnostics.header" = "Diagnostics"; -"service.sections.vpn.footer" = "The connection will be established whenever necessary. Tap \"Status\" to enforce a reconnection."; +"service.sections.vpn.footer" = "The connection will be established whenever necessary."; "service.sections.configuration.header" = "Configuration"; "service.sections.provider_infrastructure.footer" = "Last updated on %@."; "service.sections.vpn_survives_sleep.footer" = "Disable to improve battery usage, at the expense of occasional slowdowns due to wake-up reconnections."; diff --git a/Passepartout/Sources/SwiftGen+Strings.swift b/Passepartout/Sources/SwiftGen+Strings.swift index 1042013a..e3bbf1a1 100644 --- a/Passepartout/Sources/SwiftGen+Strings.swift +++ b/Passepartout/Sources/SwiftGen+Strings.swift @@ -639,7 +639,7 @@ internal enum L10n { } internal enum Vpn { - /// The connection will be established whenever necessary. Tap "Status" to enforce a reconnection. + /// The connection will be established whenever necessary. internal static let footer = L10n.tr("Localizable", "service.sections.vpn.footer") /// VPN internal static let header = L10n.tr("Localizable", "service.sections.vpn.header") From 34455410ae9a6b3fc71926cc27598dc65baebe94 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Mon, 22 Oct 2018 01:44:24 +0200 Subject: [PATCH 4/4] Update CHANGELOG --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a4db6ec2..a80855c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## Unreleased + +### Added + +- Explicit "Reconnect" button. [#9](https://github.com/keeshux/passepartout-ios/pull/9) ### Fixed