PrefsUtil.swift 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. //
  2. // PrefsUtil.swift
  3. // AppBuilder
  4. //
  5. // Created by Kevin Maulana on 23/03/22.
  6. //
  7. import Foundation
  8. import NexilisLite
  9. class PrefsUtil {
  10. static let CPAAS_MODE_FLOATING = 0
  11. static let CPAAS_MODE_DOCKED = 1
  12. static let CPAAS_MODE_BURGER = 2
  13. static let CPAAS_MODE_MIX = 4
  14. static let DEFAULT_CPAAS_MODE = CPAAS_MODE_DOCKED
  15. static func getCpaasMode() -> Int {
  16. let mode: Int! = SecureUserDefaults.shared.value(forKey: "cpaas_mode") ?? 0
  17. if(mode != 0) {
  18. return mode - 1
  19. }
  20. return PrefsUtil.DEFAULT_CPAAS_MODE
  21. }
  22. static func setCpaasMode(mode: Int){
  23. SecureUserDefaults.shared.set(mode+1, forKey: "cpaas_mode")
  24. }
  25. static var CUSTOM_TAB = "1,2,3,4"
  26. static func getCustomTab() -> String {
  27. if let cust: String = SecureUserDefaults.shared.value(forKey: "custom_tab") {
  28. if(!cust.isEmpty){
  29. return cust
  30. }
  31. }
  32. return PrefsUtil.CUSTOM_TAB
  33. }
  34. static func getURLFirstTab() -> String? {
  35. let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_url_first_tab")
  36. return value
  37. }
  38. static func getURLThirdTab() -> String? {
  39. let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_url_third_tab")
  40. return value
  41. }
  42. static func getURLBase() -> String {
  43. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_url_base") ?? "https://nexilis.io/"
  44. return value
  45. }
  46. static func getURLQMS() -> String? {
  47. let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_url_qms")
  48. return value
  49. }
  50. static func getIconDock() -> String {
  51. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_icon_dock") ?? ""
  52. return value
  53. }
  54. static func getIconSS() -> String? {
  55. let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_icon_ss")
  56. return value
  57. }
  58. static func getBackground() -> String {
  59. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_background") ?? ""
  60. return value
  61. }
  62. static func getBackgroundLight() -> String {
  63. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_background_light") ?? ""
  64. return value
  65. }
  66. static func getBackgroundDark() -> String {
  67. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_background_dark") ?? ""
  68. return value
  69. }
  70. static func getUrlSS() -> String? {
  71. return PrefsUtil.getURLBase() + "get_file_from_path?img=" + PrefsUtil.getIconSS()!
  72. }
  73. static func getUrlDock() -> String? {
  74. return PrefsUtil.getURLBase() + "get_file_from_path?img=" + PrefsUtil.getIconDock()
  75. }
  76. static func getURLPrivacyPolicy() -> String {
  77. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_url_privacy_policy") ?? "https://nexilis.io/privacypolicy"
  78. return value
  79. }
  80. static func getEnablePrivacyPolicy() -> Bool {
  81. let value: Bool = SecureUserDefaults.shared.value(forKey: "app_builder_enable_privacy_policy") ?? false
  82. return value
  83. }
  84. static func getAgreePrivacyPolicy() -> Bool {
  85. let value: Bool = SecureUserDefaults.shared.value(forKey: "agree_privacy_policy") ?? false
  86. return value
  87. }
  88. static func setAgreePrivacyPolicy(value: Bool){
  89. SecureUserDefaults.shared.set(value, forKey: "agree_privacy_policy")
  90. }
  91. static func getTerms() -> Bool {
  92. let value: Bool = SecureUserDefaults.shared.value(forKey: "terms_app") ?? false
  93. return value
  94. }
  95. static func setTerms(value: Bool){
  96. SecureUserDefaults.shared.set(value, forKey: "terms_app")
  97. }
  98. static func getCustomButtons() -> String {
  99. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_custom_buttons") ?? ""
  100. return value
  101. }
  102. static func getCustomFBIcon() -> String {
  103. let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_button_icon") ?? ""
  104. return value
  105. }
  106. static func getIconCenterAnim() -> String? {
  107. let value: String? = SecureUserDefaults.shared.value(forKey: "fb_icon_center_anim")
  108. return value
  109. }
  110. static let contentRulesAds = """
  111. [
  112. {
  113. "trigger": {
  114. "url-filter": ".*(ads|adserver|advert|doubleclick|popads|popcash|onclickads|adfly|shorte|media.net|buysellads|revcontent).*",
  115. "resource-type": ["script", "iframe", "xmlhttprequest", "media"],
  116. "unless-domain": ["nexilis.io"]
  117. },
  118. "action": { "type": "block" }
  119. },
  120. {
  121. "trigger": {
  122. "url-filter": ".*(taboola|outbrain|scorecardresearch|googlesyndication|tracking|track|pixel|cpxinteractive|zedo|rubiconproject).*",
  123. "resource-type": ["script", "iframe", "xmlhttprequest"],
  124. "unless-domain": ["nexilis.io"]
  125. },
  126. "action": { "type": "block" }
  127. },
  128. {
  129. "trigger": {
  130. "url-filter": ".*(google-analytics|facebook.com/tr|analytics|gtag|data-collect|collect|hotjar|mixpanel|segment|mouseflow).*",
  131. "resource-type": ["script", "xmlhttprequest"],
  132. "unless-domain": ["nexilis.io"]
  133. },
  134. "action": { "type": "block" }
  135. },
  136. {
  137. "trigger": {
  138. "url-filter": ".*(banner|sponsored|clicktrack|beacon|stats|metrics|impression|affiliate|clksite).*",
  139. "resource-type": ["script", "image", "iframe"],
  140. "unless-domain": ["nexilis.io"]
  141. },
  142. "action": { "type": "block" }
  143. },
  144. {
  145. "trigger": {
  146. "url-filter": ".*(interstitial|popunder|redirect|clickunder|popup|overlayad).*",
  147. "resource-type": ["script", "document", "subdocument"],
  148. "unless-domain": ["nexilis.io"]
  149. },
  150. "action": { "type": "block" }
  151. }
  152. ]
  153. """
  154. }