PrefsUtil.swift 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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. }
  111. //public static String getHeaderColorSetting(Context pContext) {
  112. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  113. // String header_color = sharedPref.getString("header_color", "#00000000");
  114. // return header_color;
  115. // }
  116. //
  117. // public static String getHeaderTextColorSetting(Context pContext) {
  118. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  119. // String header_text_color = sharedPref.getString("header_text_color", "#FF000000");
  120. // return header_text_color;
  121. // }
  122. //
  123. // public static void setContentFilter(Context pContext, String new_value) {
  124. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  125. // SharedPreferences.Editor edit = sharedPref.edit();
  126. // edit.putString("content_filter",new_value);
  127. // edit.apply();
  128. // }
  129. //
  130. // public static String getContentFilter(Context pContext) {
  131. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  132. // String header_text_color = sharedPref.getString("content_filter", "1,2,3,4,5");
  133. // return header_text_color;
  134. // }
  135. //
  136. // public static void setContentSort(Context pContext, int new_value) {
  137. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  138. // SharedPreferences.Editor edit = sharedPref.edit();
  139. // edit.putInt("content_sort",new_value);
  140. // edit.apply();
  141. // }
  142. //
  143. // public static int getContentSort(Context pContext) {
  144. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  145. // int header_text_color = sharedPref.getInt("content_sort", 1);
  146. // return header_text_color;
  147. // }
  148. //
  149. // public static void setContentClassification(Context pContext, String new_value) {
  150. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  151. // SharedPreferences.Editor edit = sharedPref.edit();
  152. // edit.putString("content_class",new_value);
  153. // edit.apply();
  154. // }
  155. //
  156. // public static String getContentClassification(Context pContext) {
  157. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  158. // String header_text_color = sharedPref.getString("content_class", "1,2,3,4");
  159. // return header_text_color;
  160. // }
  161. //
  162. // public static final int CPAAS_MODE_FLOATING = 0;
  163. // public static final int CPAAS_MODE_DOCKED = 1;
  164. // public static final int CPAAS_MODE_BURGER = 2;
  165. // public static final int CPAAS_MODE_MIX = 4;
  166. // public static final int DEFAULT_CPAAS_MODE = CPAAS_MODE_DOCKED;
  167. // public static int getCpaasMode(Context pContext) {
  168. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  169. // int mode_index = sharedPref.getInt("cpaas_mode", DEFAULT_CPAAS_MODE);
  170. // return mode_index;
  171. // }
  172. //
  173. // public static void setCpaasMode(Context pContext, int new_value) {
  174. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  175. // SharedPreferences.Editor edit = sharedPref.edit();
  176. // edit.putInt("cpaas_mode",new_value);
  177. // edit.apply();
  178. // }
  179. //
  180. // public static final int CPAAS_FLOAT_MODE_IN_APP = 3;
  181. // public static final int CPAAS_FLOAT_MODE_OUT_APP = 4;
  182. // public static int getCpaasFloatMode(Context pContext) {
  183. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  184. // int mode_index = sharedPref.getInt("cpaas_float_mode", CPAAS_FLOAT_MODE_IN_APP);
  185. // return mode_index;
  186. // }
  187. // public static void setCpaasFloatMode(Context pContext, int new_value) {
  188. // final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);
  189. // SharedPreferences.Editor edit = sharedPref.edit();
  190. // edit.putInt("cpaas_float_mode",new_value);
  191. // edit.apply();
  192. // }
  193. //
  194. // public static String getURLFirstTab() {
  195. // return CoreDataSqlite_PrefsDB.get("app_builder_url_first_tab", "");
  196. // }
  197. //
  198. // public static String getURLThirdTab() {
  199. // return CoreDataSqlite_PrefsDB.get("app_builder_url_third_tab", "");
  200. // }
  201. //
  202. // public static String getURLBase() {
  203. // return CoreDataSqlite_PrefsDB.get("app_builder_url_base", Util_RandomCrypt.decrypt("3<rl;duhpt<<=vswwk"));
  204. // }
  205. //
  206. // public static void setURLFirstTab(String new_value) {
  207. // CoreDataSqlite_PrefsDB.put("app_builder_url_first_tab", new_value);
  208. // }
  209. //
  210. // public static void setURLThirdTab(String new_value) {
  211. // CoreDataSqlite_PrefsDB.put("app_builder_url_third_tab", new_value);
  212. // }
  213. //
  214. // public static void setURLBase(String new_value) {
  215. // CoreDataSqlite_PrefsDB.put("app_builder_url_base", new_value);
  216. // }
  217. //
  218. // public static String DEFAULT_TAB_AMOUNT = "4";
  219. //
  220. // public static String getTabAmount(){
  221. // return CoreDataSqlite_PrefsDB.get("app_builder_tab_amount", DEFAULT_TAB_AMOUNT);
  222. // }
  223. //
  224. // public static void setTabAmount(Context pContext, String new_value){
  225. // CoreDataSqlite_PrefsDB.put("app_builder_tab_amount", new_value);
  226. // }