123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- //
- // PrefsUtil.swift
- // AppBuilder
- //
- // Created by Kevin Maulana on 23/03/22.
- //
- import Foundation
- import NexilisLite
- class PrefsUtil {
- static let CPAAS_MODE_FLOATING = 0
- static let CPAAS_MODE_DOCKED = 1
- static let CPAAS_MODE_BURGER = 2
- static let CPAAS_MODE_MIX = 4
- static let DEFAULT_CPAAS_MODE = CPAAS_MODE_DOCKED
-
- static func getCpaasMode() -> Int {
- let mode: Int! = SecureUserDefaults.shared.value(forKey: "cpaas_mode") ?? 0
- if(mode != 0) {
- return mode - 1
- }
- return PrefsUtil.DEFAULT_CPAAS_MODE
- }
-
- static func setCpaasMode(mode: Int){
- SecureUserDefaults.shared.set(mode+1, forKey: "cpaas_mode")
- }
-
- static var CUSTOM_TAB = "1,2,3,4"
-
- static func getCustomTab() -> String {
- if let cust: String = SecureUserDefaults.shared.value(forKey: "custom_tab") {
- if(!cust.isEmpty){
- return cust
- }
- }
- return PrefsUtil.CUSTOM_TAB
- }
-
- static func getURLFirstTab() -> String? {
- let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_url_first_tab")
- return value
- }
-
- static func getURLThirdTab() -> String? {
- let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_url_third_tab")
- return value
- }
- static func getURLBase() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_url_base") ?? "https://nexilis.io/"
- return value
- }
- static func getURLQMS() -> String? {
- let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_url_qms")
- return value
- }
- static func getIconDock() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_icon_dock") ?? ""
- return value
- }
- static func getIconSS() -> String? {
- let value: String? = SecureUserDefaults.shared.value(forKey: "app_builder_icon_ss")
- return value
- }
- static func getBackground() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_background") ?? ""
- return value
- }
-
- static func getBackgroundLight() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_background_light") ?? ""
- return value
- }
- static func getBackgroundDark() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_background_dark") ?? ""
- return value
- }
-
- static func getUrlSS() -> String? {
- return PrefsUtil.getURLBase() + "get_file_from_path?img=" + PrefsUtil.getIconSS()!
- }
- static func getUrlDock() -> String? {
- return PrefsUtil.getURLBase() + "get_file_from_path?img=" + PrefsUtil.getIconDock()
- }
-
- static func getURLPrivacyPolicy() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_url_privacy_policy") ?? "https://nexilis.io/privacypolicy"
- return value
- }
-
- static func getEnablePrivacyPolicy() -> Bool {
- let value: Bool = SecureUserDefaults.shared.value(forKey: "app_builder_enable_privacy_policy") ?? false
- return value
- }
-
- static func getAgreePrivacyPolicy() -> Bool {
- let value: Bool = SecureUserDefaults.shared.value(forKey: "agree_privacy_policy") ?? false
- return value
- }
-
- static func setAgreePrivacyPolicy(value: Bool){
- SecureUserDefaults.shared.set(value, forKey: "agree_privacy_policy")
- }
- static func getTerms() -> Bool {
- let value: Bool = SecureUserDefaults.shared.value(forKey: "terms_app") ?? false
- return value
- }
-
- static func setTerms(value: Bool){
- SecureUserDefaults.shared.set(value, forKey: "terms_app")
- }
-
- static func getCustomButtons() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_custom_buttons") ?? ""
- return value
- }
-
- static func getCustomFBIcon() -> String {
- let value: String = SecureUserDefaults.shared.value(forKey: "app_builder_button_icon") ?? ""
- return value
- }
-
- static func getIconCenterAnim() -> String? {
- let value: String? = SecureUserDefaults.shared.value(forKey: "fb_icon_center_anim")
- return value
- }
-
- static let contentRulesAds = """
- [
- {
- "trigger": {
- "url-filter": ".*(ads|adserver|advert|doubleclick|popads|popcash|onclickads|adfly|shorte|media.net|buysellads|revcontent).*",
- "resource-type": ["script", "iframe", "xmlhttprequest", "media"],
- "unless-domain": ["nexilis.io"]
- },
- "action": { "type": "block" }
- },
- {
- "trigger": {
- "url-filter": ".*(taboola|outbrain|scorecardresearch|googlesyndication|tracking|track|pixel|cpxinteractive|zedo|rubiconproject).*",
- "resource-type": ["script", "iframe", "xmlhttprequest"],
- "unless-domain": ["nexilis.io"]
- },
- "action": { "type": "block" }
- },
- {
- "trigger": {
- "url-filter": ".*(google-analytics|facebook.com/tr|analytics|gtag|data-collect|collect|hotjar|mixpanel|segment|mouseflow).*",
- "resource-type": ["script", "xmlhttprequest"],
- "unless-domain": ["nexilis.io"]
- },
- "action": { "type": "block" }
- },
- {
- "trigger": {
- "url-filter": ".*(banner|sponsored|clicktrack|beacon|stats|metrics|impression|affiliate|clksite).*",
- "resource-type": ["script", "image", "iframe"],
- "unless-domain": ["nexilis.io"]
- },
- "action": { "type": "block" }
- },
- {
- "trigger": {
- "url-filter": ".*(interstitial|popunder|redirect|clickunder|popup|overlayad).*",
- "resource-type": ["script", "document", "subdocument"],
- "unless-domain": ["nexilis.io"]
- },
- "action": { "type": "block" }
- }
- ]
- """
-
- }
|