Skip to content

Commit

Permalink
flatten experimental options, so that they become a real section
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed May 4, 2024
1 parent d6e2396 commit aa0006e
Showing 1 changed file with 38 additions and 55 deletions.
93 changes: 38 additions & 55 deletions deltachat-ios/Controller/Settings/AdvancedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
case autocryptPreferences
case sendAutocryptMessage
case manageKeys
case experimentalFeatures
case videoChat
case viewLog
}
Expand Down Expand Up @@ -140,13 +139,6 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
})
}()

private lazy var experimentalFeaturesCell: ActionCell = {
let cell = ActionCell()
cell.tag = CellTags.experimentalFeatures.rawValue
cell.actionTitle = String.localized("pref_experimental_features")
return cell
}()

private lazy var videoChatInstanceCell: UITableViewCell = {
let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
cell.tag = CellTags.videoChat.rawValue
Expand All @@ -155,6 +147,42 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
return cell
}()

lazy var broadcastListsCell: SwitchCell = {
return SwitchCell(
textLabel: String.localized("broadcast_lists"),
on: UserDefaults.standard.bool(forKey: "broadcast_lists"),
action: { cell in
UserDefaults.standard.set(cell.isOn, forKey: "broadcast_lists")
if cell.isOn {
let alert = UIAlertController(title: "Thanks for trying out the experimental feature 🧪 \"Broadcast Lists\"!",
message: "You can now create new \"Broadcast Lists\" from the \"New Chat\" dialog\n\n"
+ "In case you are using more than one device, broadcast lists are currently not synced between them\n\n"
+ "If you want to quit the experimental feature, you can disable it at \"Settings / Advanced\".",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
self.navigationController?.present(alert, animated: true, completion: nil)
}
})
}()

lazy var locationStreamingCell: SwitchCell = {
return SwitchCell(
textLabel: String.localized("pref_on_demand_location_streaming"),
on: UserDefaults.standard.bool(forKey: "location_streaming"),
action: { cell in
UserDefaults.standard.set(cell.isOn, forKey: "location_streaming")
if cell.isOn {
let alert = UIAlertController(title: "Thanks for trying out the experimental feature 🧪 \"Location streaming\"",
message: "You will find a corresponding option in the attach menu (the paper clip) of each chat now.\n\n"
+ "Moreover, \"Profiles\" and \"All Media\" will offer a map.\n\n"
+ "If you want to quit the experimental feature, you can disable it at \"Settings / Advanced\".",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
self.navigationController?.present(alert, animated: true, completion: nil)
}
})
}()

private lazy var viewLogCell: UITableViewCell = {
let cell = UITableViewCell(style: .value1, reuseIdentifier: nil)
cell.tag = CellTags.viewLog.rawValue
Expand All @@ -174,9 +202,9 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
footerTitle: String.localized("pref_only_fetch_mvbox_explain"),
cells: [sentboxWatchCell, sendCopyToSelfCell, mvboxMoveCell, onlyFetchMvboxCell])
let miscSection = SectionConfigs(
headerTitle: nil,
headerTitle: String.localized("pref_experimental_features"),
footerTitle: String.localized("pref_show_system_contacts_explain"),
cells: [experimentalFeaturesCell, videoChatInstanceCell, showSystemContactsCell])
cells: [videoChatInstanceCell, broadcastListsCell, locationStreamingCell, showSystemContactsCell])
let viewLogSection = SectionConfigs(
headerTitle: nil,
footerTitle: nil,
Expand Down Expand Up @@ -246,7 +274,6 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
case .autocryptPreferences: break
case .sendAutocryptMessage: sendAutocryptSetupMessage()
case .manageKeys: showManageKeysDialog()
case .experimentalFeatures: showExperimentalDialog()
case .videoChat: showVideoChatInstance()
case .viewLog: showLogViewController()
}
Expand Down Expand Up @@ -302,50 +329,6 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
navigationController?.pushViewController(controller, animated: true)
}

private func showExperimentalDialog() {
let alert = UIAlertController(title: String.localized("pref_experimental_features"), message: nil, preferredStyle: .safeActionSheet)

let broadcastLists = UserDefaults.standard.bool(forKey: "broadcast_lists")
alert.addAction(UIAlertAction(title: (broadcastLists ? "✔︎ " : "") + String.localized("broadcast_lists"),
style: .default, handler: { [weak self] _ in
guard let self else { return }
UserDefaults.standard.set(!broadcastLists, forKey: "broadcast_lists")
if !broadcastLists {
let alert = UIAlertController(title: "Thanks for trying out the experimental feature 🧪 \"Broadcast Lists\"!",
message: "You can now create new \"Broadcast Lists\" from the \"New Chat\" dialog\n\n"
+ "In case you are using more than one device, broadcast lists are currently not synced between them\n\n"
+ "If you want to quit the experimental feature, you can disable it at \"Settings / Advanced\".",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
self.navigationController?.present(alert, animated: true, completion: nil)
}
}))

let locationStreaming = UserDefaults.standard.bool(forKey: "location_streaming")
let title = (locationStreaming ? "✔︎ " : "") + String.localized("pref_on_demand_location_streaming")
alert.addAction(UIAlertAction(title: title, style: .default, handler: { [weak self] _ in
guard let self else { return }
UserDefaults.standard.set(!locationStreaming, forKey: "location_streaming")
if !locationStreaming {
let alert = UIAlertController(title: "Thanks for trying out the experimental feature 🧪 \"Location streaming\"",
message: "You will find a corresponding option in the attach menu (the paper clip) of each chat now.\n\n"
+ "Moreover, \"Profiles\" and \"All Media\" will offer a map.\n\n"
+ "If you want to quit the experimental feature, you can disable it at \"Settings / Advanced\".",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: String.localized("ok"), style: .default, handler: nil))
self.navigationController?.present(alert, animated: true, completion: nil)
} else if self.dcContext.isSendingLocationsToChat(chatId: 0) {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
appDelegate.locationManager.disableLocationStreamingInAllChats()
}
}))

alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
present(alert, animated: true, completion: nil)
}

private func showManageKeysDialog() {
let alert = UIAlertController(title: String.localized("pref_manage_keys"), message: nil, preferredStyle: .safeActionSheet)

Expand Down

0 comments on commit aa0006e

Please sign in to comment.