Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

for chatmail accounts, hide some not useful settings #2166

Merged
merged 6 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 34 additions & 23 deletions deltachat-ios/Controller/Settings/AdvancedViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
}

private enum CellTags: Int {
case defaultTagValue = 0
case showEmails
case autocryptPreferences
case sendAutocryptMessage
case manageKeys
case videoChat
Expand Down Expand Up @@ -49,24 +49,23 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler

private lazy var autocryptPreferencesCell: UITableViewCell = {
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
cell.tag = CellTags.autocryptPreferences.rawValue
cell.textLabel?.text = String.localized("autocrypt_prefer_e2ee")
cell.accessoryView = autocryptSwitch
cell.selectionStyle = .none
return cell
}()

private lazy var sendAutocryptMessageCell: ActionCell = {
let cell = ActionCell()
private lazy var sendAutocryptMessageCell: UITableViewCell = {
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
cell.tag = CellTags.sendAutocryptMessage.rawValue
cell.actionTitle = String.localized("autocrypt_send_asm_title")
cell.textLabel?.text = String.localized("autocrypt_send_asm_title")
return cell
}()

private lazy var manageKeysCell: ActionCell = {
let cell = ActionCell()
private lazy var manageKeysCell: UITableViewCell = {
let cell = UITableViewCell(style: .default, reuseIdentifier: nil)
cell.tag = CellTags.manageKeys.rawValue
cell.actionTitle = String.localized("pref_manage_keys")
cell.textLabel?.text = String.localized("pref_manage_keys")
return cell
}()

Expand Down Expand Up @@ -219,20 +218,32 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler
headerTitle: String.localized("pref_experimental_features"),
footerTitle: nil,
cells: [videoChatInstanceCell, broadcastListsCell, locationStreamingCell])
let appAccessSection = SectionConfigs(
headerTitle: String.localized("pref_app_access"),
footerTitle: String.localized("pref_show_system_contacts_explain"),
cells: [showSystemContactsCell])
let autocryptSection = SectionConfigs(
headerTitle: String.localized("pref_encryption"),
footerTitle: nil,
cells: [autocryptPreferencesCell, manageKeysCell, sendAutocryptMessageCell]
)
let serverSection = SectionConfigs(
headerTitle: String.localized("pref_server"),
footerTitle: String.localized("pref_only_fetch_mvbox_explain"),
cells: [accountSettingsCell, sentboxWatchCell, sendCopyToSelfCell, mvboxMoveCell, onlyFetchMvboxCell])
return [viewLogSection, experimentalSection, appAccessSection, autocryptSection, serverSection]

if dcContext.isChatmail {
let encryptionSection = SectionConfigs(
headerTitle: String.localized("pref_encryption"),
footerTitle: nil,
zeitschlag marked this conversation as resolved.
Show resolved Hide resolved
cells: [manageKeysCell, sendAutocryptMessageCell])
let serverSection = SectionConfigs(
headerTitle: String.localized("pref_server"),
footerTitle: nil,
cells: [accountSettingsCell])
return [viewLogSection, experimentalSection, encryptionSection, serverSection]
} else {
let appAccessSection = SectionConfigs(
headerTitle: String.localized("pref_app_access"),
footerTitle: String.localized("pref_show_system_contacts_explain"),
cells: [showSystemContactsCell])
let encryptionSection = SectionConfigs(
headerTitle: String.localized("pref_encryption"),
footerTitle: nil,
cells: [autocryptPreferencesCell, manageKeysCell, sendAutocryptMessageCell])
let serverSection = SectionConfigs(
headerTitle: String.localized("pref_server"),
footerTitle: String.localized("pref_only_fetch_mvbox_explain"),
cells: [accountSettingsCell, sentboxWatchCell, sendCopyToSelfCell, mvboxMoveCell, onlyFetchMvboxCell])
return [viewLogSection, experimentalSection, appAccessSection, encryptionSection, serverSection]
}
}()

init(dcAccounts: DcAccounts) {
Expand Down Expand Up @@ -295,12 +306,12 @@ internal final class AdvancedViewController: UITableViewController, ProgressAler

switch cellTag {
case .showEmails: showClassicMailController()
case .autocryptPreferences: break
case .sendAutocryptMessage: sendAutocryptSetupMessage()
case .manageKeys: showManageKeysDialog()
case .videoChat: showVideoChatInstance()
case .viewLog: showLogViewController()
case .accountSettings: showAccountSettingsController()
case .defaultTagValue: break
}
}

Expand Down
4 changes: 4 additions & 0 deletions deltachat-ios/DC/DcContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,8 @@ public class DcContext {
get { return getConfigInt("show_emails") }
set { setConfigInt("show_emails", newValue) }
}

public var isChatmail: Bool {
return getConfigInt("is_chatmail") == 1
}
}
2 changes: 1 addition & 1 deletion deltachat-ios/Handler/DeviceContactsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DeviceContactsHandler {
}

public func importDeviceContacts() {
if dcContext.getConfigBool("ui.ios.show_system_contacts") && CNContactStore.authorizationStatus(for: .contacts) == .authorized {
if dcContext.getConfigBool("ui.ios.show_system_contacts") && !dcContext.isChatmail && CNContactStore.authorizationStatus(for: .contacts) == .authorized {
addContactsToCore()
}
}
Expand Down