From 25671e7442fb1147913bcdc6fbfaf4c802e05ad1 Mon Sep 17 00:00:00 2001 From: Davide De Rosa Date: Tue, 30 Apr 2019 13:43:47 +0200 Subject: [PATCH] Make compression framing/algorithm editable --- CHANGELOG.md | 4 + .../Scenes/ConfigurationViewController.swift | 77 ++++++++++++------- 2 files changed, 53 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bff53cc0..87c1dbd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Override network settings. [#77](https://github.com/passepartoutvpn/passepartout-ios/pull/77) +### Changed + +- Host compression framing and algorithm are now editable. + ## 1.6.0 (2019-05-01) ### Added diff --git a/Passepartout-iOS/Scenes/ConfigurationViewController.swift b/Passepartout-iOS/Scenes/ConfigurationViewController.swift index 2eb8460a..f0bf1620 100644 --- a/Passepartout-iOS/Scenes/ConfigurationViewController.swift +++ b/Passepartout-iOS/Scenes/ConfigurationViewController.swift @@ -54,11 +54,11 @@ class ConfigurationViewController: UIViewController, TableModelHost { // sections model.add(.communication) + model.add(.compression) if isEditable { model.add(.reset) } model.add(.tls) - model.add(.compression) // model.add(.network) model.add(.other) @@ -253,6 +253,24 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat cell.leftText = L10n.Configuration.Cells.Digest.caption cell.rightText = configuration.fallbackDigest.description + case .compressionFraming: + cell.leftText = L10n.Configuration.Cells.CompressionFraming.caption + cell.rightText = configuration.fallbackCompressionFraming.cellDescription + + case .compressionAlgorithm: + cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption + if let compressionAlgorithm = configuration.compressionAlgorithm { + cell.rightText = compressionAlgorithm.cellDescription + } else { + cell.rightText = L10n.Global.Cells.disabled + } + if configuration.compressionFraming != .disabled { + cell.isTappable = true + } else { + cell.accessoryType = .none + cell.isTappable = false + } + case .resetOriginal: cell.leftText = L10n.Configuration.Cells.ResetOriginal.caption cell.applyAction(Theme.current) @@ -285,22 +303,6 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat cell.accessoryType = .none cell.isTappable = false - case .compressionFraming: - cell.leftText = L10n.Configuration.Cells.CompressionFraming.caption - cell.rightText = configuration.fallbackCompressionFraming.cellDescription - cell.accessoryType = .none - cell.isTappable = false - - case .compressionAlgorithm: - cell.leftText = L10n.Configuration.Cells.CompressionAlgorithm.caption - if let compressionAlgorithm = configuration.compressionAlgorithm { - cell.rightText = compressionAlgorithm.cellDescription - } else { - cell.rightText = L10n.Global.Cells.disabled - } - cell.accessoryType = .none - cell.isTappable = false - case .defaultGateway: cell.leftText = L10n.Configuration.Cells.DefaultGateway.caption if let policies = configuration.routingPolicies { @@ -399,18 +401,37 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat } navigationController?.pushViewController(vc, animated: true) -// case .compressionFraming: -// let vc = OptionViewController() -// vc.title = settingCell?.leftText -// vc.options = [.disabled, .compLZO, .compress] -// vc.selectedOption = configuration.compressionFraming -// vc.descriptionBlock = { $0.cellDescription } -// vc.selectionBlock = { [weak self] in -// self?.configuration.compressionFraming = $0 -// self?.popAndCheckRefresh() -// } -// navigationController?.pushViewController(vc, animated: true) + case .compressionFraming: + let vc = OptionViewController() + vc.title = settingCell?.leftText + vc.options = [.disabled, .compLZO, .compress] + vc.selectedOption = configuration.compressionFraming + vc.descriptionBlock = { $0.cellDescription } + vc.selectionBlock = { [weak self] in + self?.configuration.compressionFraming = $0 + if $0 == .disabled { + self?.configuration.compressionAlgorithm = .disabled + } + self?.popAndCheckRefresh() + } + navigationController?.pushViewController(vc, animated: true) + case .compressionAlgorithm: + guard configuration.compressionFraming != .disabled else { + return + } + + let vc = OptionViewController() + vc.title = settingCell?.leftText + vc.options = [.disabled, .LZO] + vc.selectedOption = configuration.compressionAlgorithm + vc.descriptionBlock = { $0.cellDescription } + vc.selectionBlock = { [weak self] in + self?.configuration.compressionAlgorithm = $0 + self?.popAndCheckRefresh() + } + navigationController?.pushViewController(vc, animated: true) + case .resetOriginal: tableView.deselectRow(at: indexPath, animated: true) resetOriginalConfiguration()