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

Fix #6575: debug setting to toggle china edition of app #6576

Merged
merged 1 commit into from
May 8, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Client/Frontend/Settings/AppSettingsOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,20 @@ class ForceCrashSetting: HiddenSetting {
}
}

class ChangeToChinaSetting: HiddenSetting {
override var title: NSAttributedString? {
return NSAttributedString(string: "Debug: toggle China version (needs restart)", attributes: [NSAttributedString.Key.foregroundColor: UIColor.theme.tableView.rowText])
}

override func onClick(_ navigationController: UINavigationController?) {
if UserDefaults.standard.bool(forKey: debugPrefIsChinaEdition) {
UserDefaults.standard.removeObject(forKey: debugPrefIsChinaEdition)
} else {
UserDefaults.standard.set(true, forKey: debugPrefIsChinaEdition)
}
}
}

class SlowTheDatabase: HiddenSetting {
override var title: NSAttributedString? {
return NSAttributedString(string: "Debug: simulate slow database operations", attributes: [NSAttributedString.Key.foregroundColor: UIColor.theme.tableView.rowText])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class AppSettingsTableViewController: SettingsTableViewController {
SlowTheDatabase(settings: self),
ForgetSyncAuthStateDebugSetting(settings: self),
SentryIDSetting(settings: self),
ChangeToChinaSetting(settings: self)
])]

return settings
Expand Down
5 changes: 5 additions & 0 deletions Shared/AppInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import Foundation

public let debugPrefIsChinaEdition = "debugPrefIsChinaEdition"

open class AppInfo {
/// Return the main application bundle. If this is called from an extension, the containing app bundle is returned.
public static var applicationBundle: Bundle {
Expand Down Expand Up @@ -88,6 +90,9 @@ open class AppInfo {
public static var webserverPort = 6571

public static var isChinaEdition: Bool = {
if UserDefaults.standard.bool(forKey: debugPrefIsChinaEdition) {
return true
}
return Locale.current.identifier == "zh_CN"
}()
}