Browse Source

add video chat instance settings

cyberta 4 years ago
parent
commit
608527ebfa

+ 4 - 0
deltachat-ios.xcodeproj/project.pbxproj

@@ -26,6 +26,7 @@
 		302B84C72396770B001C261F /* RelayHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302B84C42396627F001C261F /* RelayHelper.swift */; };
 		302B84CE2397F6CD001C261F /* URL+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302B84CD2397F6CD001C261F /* URL+Extension.swift */; };
 		302D5450268B6B2300A8B271 /* MessageUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302D544F268B6B2300A8B271 /* MessageUtils.swift */; };
+		302D5454268B84CB00A8B271 /* SettingsVideoChatInstanceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302D5453268B84CB00A8B271 /* SettingsVideoChatInstanceController.swift */; };
 		302E1BB4252B5AB4008F4264 /* PlayButtonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 302E1BB3252B5AB4008F4264 /* PlayButtonView.swift */; };
 		30349291256441E200A523D0 /* QuotePreview.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30349290256441E200A523D0 /* QuotePreview.swift */; };
 		303492952565AABC00A523D0 /* DraftModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 303492942565AABC00A523D0 /* DraftModel.swift */; };
@@ -240,6 +241,7 @@
 		302B84C42396627F001C261F /* RelayHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RelayHelper.swift; sourceTree = "<group>"; };
 		302B84CD2397F6CD001C261F /* URL+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URL+Extension.swift"; sourceTree = "<group>"; };
 		302D544F268B6B2300A8B271 /* MessageUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MessageUtils.swift; sourceTree = "<group>"; };
+		302D5453268B84CB00A8B271 /* SettingsVideoChatInstanceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsVideoChatInstanceController.swift; sourceTree = "<group>"; };
 		302E1BB3252B5AB4008F4264 /* PlayButtonView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PlayButtonView.swift; path = "deltachat-ios/Chat/Views/PlayButtonView.swift"; sourceTree = SOURCE_ROOT; };
 		30349290256441E200A523D0 /* QuotePreview.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuotePreview.swift; sourceTree = "<group>"; };
 		303492942565AABC00A523D0 /* DraftModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DraftModel.swift; sourceTree = "<group>"; };
@@ -800,6 +802,7 @@
 				78E45E3921D3CFBC00D4B15E /* SettingsController.swift */,
 				B20462E32440A4A600367A57 /* SettingsAutodelOverviewController.swift */,
 				B20462E52440C99600367A57 /* SettingsAutodelSetController.swift */,
+				302D5453268B84CB00A8B271 /* SettingsVideoChatInstanceController.swift */,
 				AE76E5ED242BF2EA003CF461 /* WelcomeViewController.swift */,
 				AE8F503424753DFE007FEE0B /* GalleryViewController.swift */,
 				30734325249A280B00BF9AD1 /* MediaQualityController.swift */,
@@ -1337,6 +1340,7 @@
 				AEC67A1E241FCFE0007DDBE1 /* ChatListViewModel.swift in Sources */,
 				30FDB71F24D8170E0066C48D /* TextMessageCell.swift in Sources */,
 				AE1988A523EB2FBA00B4CD5F /* Errors.swift in Sources */,
+				302D5454268B84CB00A8B271 /* SettingsVideoChatInstanceController.swift in Sources */,
 				AEFBE22F23FEF23D0045327A /* ProviderInfoCell.swift in Sources */,
 				AE6EC5242497663200A400E4 /* UIImageView+Extensions.swift in Sources */,
 				30F8817624DA97DA0023780E /* BackgroundContainer.swift in Sources */,

+ 18 - 1
deltachat-ios/Controller/SettingsController.swift

@@ -25,6 +25,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         case autodel = 11
         case mediaQuality = 12
         case switchAccount = 13
+        case videoChat = 14
     }
 
     private var dcContext: DcContext
@@ -100,6 +101,15 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         return cell
     }()
 
+    private lazy var videoChatInstanceCell: UITableViewCell = {
+        let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
+        cell.tag = CellTags.videoChat.rawValue
+        cell.textLabel?.text = String.localized("videochat_instance")
+        cell.accessoryType = .disclosureIndicator
+        cell.detailTextLabel?.text = dcContext.getConfig("webrtc_instance")
+        return cell
+    }()
+
     private lazy var notificationSwitch: UISwitch = {
         let switchControl = UISwitch()
         switchControl.isOn = !UserDefaults.standard.bool(forKey: "notifications_disabled")
@@ -197,7 +207,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         let preferencesSection = SectionConfigs(
             headerTitle: String.localized("pref_chats_and_media"),
             footerTitle: String.localized("pref_read_receipts_explain"),
-            cells: [contactRequestCell, showEmailsCell, blockedContactsCell, autodelCell, mediaQualityCell, notificationCell, receiptConfirmationCell]
+            cells: [contactRequestCell, showEmailsCell, blockedContactsCell, autodelCell, mediaQualityCell, videoChatInstanceCell, notificationCell, receiptConfirmationCell]
         )
         let autocryptSection = SectionConfigs(
             headerTitle: String.localized("autocrypt"),
@@ -294,6 +304,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         case .blockedContacts: showBlockedContacts()
         case .autodel: showAutodelOptions()
         case .mediaQuality: showMediaQuality()
+        case .videoChat: showVideoChatInstance()
         case .notifications: break
         case .receiptConfirmation: break
         case .autocryptPreferences: break
@@ -507,6 +518,7 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         profileCell.updateCell(cellViewModel: ProfileViewModel(context: dcContext))
         showEmailsCell.detailTextLabel?.text = SettingsClassicViewController.getValString(val: dcContext.showEmails)
         mediaQualityCell.detailTextLabel?.text = MediaQualityController.getValString(val: dcContext.getConfigInt("media_quality"))
+        videoChatInstanceCell.detailTextLabel?.text = dcContext.getConfig("webrtc_instance")
         autodelCell.detailTextLabel?.text = autodelSummary()
     }
 
@@ -526,6 +538,11 @@ internal final class SettingsViewController: UITableViewController, ProgressAler
         navigationController?.pushViewController(mediaQualityController, animated: true)
     }
 
+    private func showVideoChatInstance() {
+        let videoInstanceController = SettingsVideoChatInstanceController(dcContext: dcContext)
+        navigationController?.pushViewController(videoInstanceController, animated: true)
+    }
+
     private func showBlockedContacts() {
         let blockedContactsController = BlockedContactsViewController(dcContext: dcContext)
         navigationController?.pushViewController(blockedContactsController, animated: true)

+ 53 - 0
deltachat-ios/Controller/SettingsVideoChatInstanceController.swift

@@ -0,0 +1,53 @@
+import UIKit
+import DcCore
+class SettingsVideoChatInstanceController: UITableViewController {
+
+    private var dcContext: DcContext
+
+    private lazy var videoInstanceCell: TextFieldCell = {
+        let cell = TextFieldCell.makeConfigCell(labelID: String.localized("videochat_instance"),
+                                                placeholderID: String.localized("videochat_instance_placeholder"))
+        cell.textField.autocapitalizationType = .none
+        cell.textField.autocorrectionType = .no
+        cell.textField.textContentType = .URL
+        return cell
+    }()
+
+    init(dcContext: DcContext) {
+        self.dcContext = dcContext
+        super.init(style: .grouped)
+        self.title = String.localized("videochat_instance")
+        hidesBottomBarWhenPushed = true
+    }
+
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    // MARK: - Table view data source
+
+    override func numberOfSections(in tableView: UITableView) -> Int {
+        return 1
+    }
+
+    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
+        return 1
+    }
+
+    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
+        tableView.deselectRow(at: indexPath, animated: true)
+    }
+
+    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
+        videoInstanceCell.textField.text = dcContext.getConfig("webrtc_instance")
+        return videoInstanceCell
+    }
+
+    override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
+        return String.localized("videochat_instance_explain")
+    }
+
+    override func viewWillDisappear(_ animated: Bool) {
+        dcContext.setConfig("webrtc_instance", videoInstanceCell.getText())
+    }
+}