Skip to content
Snippets Groups Projects
Commit 1dea47fc authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Kateryna Kostiuk
Browse files

account: add proxy server settings

Change-Id: I9fc231907bf651d8adef6649e2c03e46d5031502
parent 61691b49
No related branches found
No related tags found
No related merge requests found
...@@ -512,6 +512,45 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas ...@@ -512,6 +512,45 @@ class MeViewController: EditProfileViewController, StoryboardBased, ViewModelBas
}) })
.disposed(by: cell.disposeBag) .disposed(by: cell.disposeBag)
return cell return cell
case .proxy:
let cell = DisposableCell(style: .value1, reuseIdentifier: self.sipAccountCredentialsCell)
cell.backgroundColor = UIColor.jamiBackgroundColor
cell.selectionStyle = .none
let text = UITextField()
text.autocorrectionType = .no
text.font = UIFont.preferredFont(forTextStyle: .callout)
text.returnKeyType = .done
text.text = self.viewModel.proxyAddress.value
text.sizeToFit()
text.rx.controlEvent(.editingDidEndOnExit)
.observe(on: MainScheduler.instance)
.subscribe(onNext: { [weak self] _ in
guard let text = text.text else { return }
self?.viewModel.changeProxy(proxyServer: text)
})
.disposed(by: cell.disposeBag)
cell.textLabel?.text = "Proxy server"
cell.textLabel?.sizeToFit()
cell.sizeToFit()
cell.detailTextLabel?.font = UIFont.preferredFont(forTextStyle: .callout)
cell.detailTextLabel?.textColor = UIColor.clear
var frame = CGRect(x: self.sipCredentialsMargin, y: 0,
width: self.view.frame.width - self.sipCredentialsMargin,
height: cell.frame.height)
if self.view.frame.width - self.sipCredentialsMargin < text.frame.size.width {
let origin = CGPoint(x: 10, y: cell.textLabel!.frame.size.height + 25)
let size = text.frame.size
frame.origin = origin
frame.size = size
cell.detailTextLabel?.text = self.viewModel.proxyAddress.value
} else {
cell.detailTextLabel?.text = ""
}
cell.detailTextLabel?.sizeToFit()
text.frame = frame
cell.contentView.addSubview(text)
cell.sizeToFit()
return cell
case .sipUserName(let value): case .sipUserName(let value):
let cell = self let cell = self
.configureSipCredentialsCell(cellType: .sipUserName(value: value), .configureSipCredentialsCell(cellType: .sipUserName(value: value),
......
...@@ -51,6 +51,7 @@ enum SettingsSection: SectionModelType { ...@@ -51,6 +51,7 @@ enum SettingsSection: SectionModelType {
case jamiUserName(label: String) case jamiUserName(label: String)
case notifications case notifications
case sipUserName(value: String) case sipUserName(value: String)
case proxy
case sipPassword(value: String) case sipPassword(value: String)
case sipServer(value: String) case sipServer(value: String)
case port(value: String) case port(value: String)
...@@ -261,8 +262,16 @@ class MeViewModel: ViewModel, Stateable { ...@@ -261,8 +262,16 @@ class MeViewModel: ViewModel, Stateable {
}() }()
lazy var otherJamiSettings: Observable<SettingsSection> = { lazy var otherJamiSettings: Observable<SettingsSection> = {
var proxyServer = ""
if let account = self.accountService.currentAccount,
let details = account.details {
proxyServer = details.get(withConfigKeyModel: ConfigKeyModel.init(withKey: ConfigKey.proxyServer))
self.proxyAddress.accept(proxyServer)
}
let items: [SettingsSection.SectionRow] = [.peerDiscovery, let items: [SettingsSection.SectionRow] = [.peerDiscovery,
.blockedList, .blockedList,
.proxy,
SettingsSection.SectionRow
.accountState(state: self.accountStatus), .accountState(state: self.accountStatus),
.enableAccount, .enableAccount,
.changePassword, .changePassword,
...@@ -504,7 +513,6 @@ class MeViewModel: ViewModel, Stateable { ...@@ -504,7 +513,6 @@ class MeViewModel: ViewModel, Stateable {
self.showActionState.accept(.hideLoading) self.showActionState.accept(.hideLoading)
return return
} }
self.nameService self.nameService
.registerNameObservable(withAccount: accountId, .registerNameObservable(withAccount: accountId,
password: password, password: password,
...@@ -825,6 +833,15 @@ class MeViewModel: ViewModel, Stateable { ...@@ -825,6 +833,15 @@ class MeViewModel: ViewModel, Stateable {
self.accountService.enableTurn(enable: enable, accountId: account.id) self.accountService.enableTurn(enable: enable, accountId: account.id)
turnEnabled.accept(enable) turnEnabled.accept(enable)
} }
let proxyAddress = BehaviorRelay<String>(value: "")
func changeProxy(proxyServer: String) {
guard let accountId = self.accountService.currentAccount?.id else {
return
}
self.accountService.setProxyAddress(accountID: accountId, proxy: proxyServer)
self.proxyAddress.accept(proxyServer)
}
func enableUpnp(enable: Bool) { func enableUpnp(enable: Bool) {
guard self.upnpEnabled.value != enable, guard self.upnpEnabled.value != enable,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment