Skip to content

Commit

Permalink
Fix mozilla-mobile#6575: debug setting to toggle china edition of app
Browse files Browse the repository at this point in the history
  • Loading branch information
garvankeeley committed May 8, 2020
1 parent 567ecab commit d3cafd6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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"
}()
}

0 comments on commit d3cafd6

Please sign in to comment.