Make compression framing/algorithm editable

This commit is contained in:
Davide De Rosa 2019-04-30 13:43:47 +02:00
parent 98756438b1
commit 25671e7442
2 changed files with 53 additions and 28 deletions

View File

@ -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) - 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) ## 1.6.0 (2019-05-01)
### Added ### Added

View File

@ -54,11 +54,11 @@ class ConfigurationViewController: UIViewController, TableModelHost {
// sections // sections
model.add(.communication) model.add(.communication)
model.add(.compression)
if isEditable { if isEditable {
model.add(.reset) model.add(.reset)
} }
model.add(.tls) model.add(.tls)
model.add(.compression)
// model.add(.network) // model.add(.network)
model.add(.other) model.add(.other)
@ -253,6 +253,24 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
cell.leftText = L10n.Configuration.Cells.Digest.caption cell.leftText = L10n.Configuration.Cells.Digest.caption
cell.rightText = configuration.fallbackDigest.description 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: case .resetOriginal:
cell.leftText = L10n.Configuration.Cells.ResetOriginal.caption cell.leftText = L10n.Configuration.Cells.ResetOriginal.caption
cell.applyAction(Theme.current) cell.applyAction(Theme.current)
@ -285,22 +303,6 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
cell.accessoryType = .none cell.accessoryType = .none
cell.isTappable = false 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: case .defaultGateway:
cell.leftText = L10n.Configuration.Cells.DefaultGateway.caption cell.leftText = L10n.Configuration.Cells.DefaultGateway.caption
if let policies = configuration.routingPolicies { if let policies = configuration.routingPolicies {
@ -399,17 +401,36 @@ extension ConfigurationViewController: UITableViewDataSource, UITableViewDelegat
} }
navigationController?.pushViewController(vc, animated: true) navigationController?.pushViewController(vc, animated: true)
// case .compressionFraming: case .compressionFraming:
// let vc = OptionViewController<SessionProxy.CompressionFraming>() let vc = OptionViewController<SessionProxy.CompressionFraming>()
// vc.title = settingCell?.leftText vc.title = settingCell?.leftText
// vc.options = [.disabled, .compLZO, .compress] vc.options = [.disabled, .compLZO, .compress]
// vc.selectedOption = configuration.compressionFraming vc.selectedOption = configuration.compressionFraming
// vc.descriptionBlock = { $0.cellDescription } vc.descriptionBlock = { $0.cellDescription }
// vc.selectionBlock = { [weak self] in vc.selectionBlock = { [weak self] in
// self?.configuration.compressionFraming = $0 self?.configuration.compressionFraming = $0
// self?.popAndCheckRefresh() if $0 == .disabled {
// } self?.configuration.compressionAlgorithm = .disabled
// navigationController?.pushViewController(vc, animated: true) }
self?.popAndCheckRefresh()
}
navigationController?.pushViewController(vc, animated: true)
case .compressionAlgorithm:
guard configuration.compressionFraming != .disabled else {
return
}
let vc = OptionViewController<SessionProxy.CompressionAlgorithm>()
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: case .resetOriginal:
tableView.deselectRow(at: indexPath, animated: true) tableView.deselectRow(at: indexPath, animated: true)