alqindiirsyam 2 jaren geleden
bovenliggende
commit
6b7c94876b

+ 5 - 5
appbuilder-ios/AppBuilder/AppBuilder/AppDelegate.swift

@@ -104,9 +104,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
     }
 
     func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
-        // Override point for customization after application launch.
-        // Nexilis.connect(apiKey: "09ED34439CFE435E5D528E73F2D3DC1B23307B56EAB28A4883700D47BB5ADE07", delegate: self, showButton: false)
-//        Nexilis.connect(apiKey: "E6FF534BDA45A78619488E44AC90592327DDF33ACF6213A58DB55B78300BA8EE", delegate: self, showButton: false)
         if !CheckConnection.isConnectedToNetwork() {
             let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
             imageView.tintColor = .white
@@ -158,8 +155,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
                             if let background = j["app_builder_background"] as? String {
                                 PrefsUtil.setBackground(value: background)
                             }
-                            if let background = j["app_builder_compressor"] as? String {
-                                PrefsUtil.setCompressor(value: background)
+                            if let url_privacy_policy = j["app_builder_url_privacy_policy"] as? String {
+                                PrefsUtil.setURLPrivacyPolicy(value: url_privacy_policy)
+                            }
+                            if let enable_privacy_policy = j["app_builder_enable_privacy_policy"] as? String {
+                                PrefsUtil.setEnablePrivacyPolicy(value: enable_privacy_policy == "1" ? true : false)
                             }
                         }
                     }

+ 24 - 6
appbuilder-ios/AppBuilder/AppBuilder/PrefsUtil.swift

@@ -64,9 +64,6 @@ class PrefsUtil {
     static func getBackground() -> String? {
         return UserDefaults.standard.string(forKey: "app_builder_background")
     }
-    static func getCompressor() -> String? {
-        return UserDefaults.standard.string(forKey: "app_builder_compressor")
-    }
     static func getUrlSS() -> String? {
         return PrefsUtil.getURLBase() + "dashboardv2/uploads/splashscreen/" + PrefsUtil.getIconSS()!
     }
@@ -96,9 +93,6 @@ class PrefsUtil {
     static func setBackground(value: String) {
         UserDefaults.standard.set(value, forKey: "app_builder_background")
     }
-    static func setCompressor(value: String) {
-        UserDefaults.standard.set(value, forKey: "app_builder_compressor")
-    }
     static func getTerms() -> Bool {
         return UserDefaults.standard.bool(forKey: "terms_app")
     }
@@ -107,6 +101,30 @@ class PrefsUtil {
         UserDefaults.standard.set(value, forKey: "terms_app")
     }
     
+    static func getURLPrivacyPolicy() -> String {
+        return UserDefaults.standard.string(forKey: "app_builder_url_privacy_policy") ?? "https://newuniverse.io/privacypolicy-nu"
+    }
+    
+    static func setURLPrivacyPolicy(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_url_privacy_policy")
+    }
+    
+    static func getEnablePrivacyPolicy() -> Bool {
+        return UserDefaults.standard.bool(forKey: "app_builder_enable_privacy_policy")
+    }
+    
+    static func setEnablePrivacyPolicy(value: Bool){
+        UserDefaults.standard.set(value, forKey: "app_builder_enable_privacy_policy")
+    }
+    
+    static func getAgreePrivacyPolicy() -> Bool {
+        return UserDefaults.standard.bool(forKey: "agree_privacy_policy")
+    }
+    
+    static func setAgreePrivacyPolicy(value: Bool){
+        UserDefaults.standard.set(value, forKey: "agree_privacy_policy")
+    }
+    
 }
 //public static String getHeaderColorSetting(Context pContext) {
 //        final SharedPreferences sharedPref = pContext.getSharedPreferences("PREF_SYS", Context.MODE_PRIVATE);

+ 69 - 0
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -44,6 +44,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
     static var listPullFB: [String] = []
     static var datePullFB: Date?
     let welcomeVC = UIViewController()
+    let privacyPolicyVC = UIViewController()
     var termVC: UIViewController?
     let welcomeDesc = UILabel()
     let termText = "Read our Terms of Service. Tap \"Agree and Continue\" to accept Terms of Service.".localized()
@@ -441,9 +442,13 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
     
     override func viewWillAppear(_ animated: Bool) {
         let acceptTerm = PrefsUtil.getTerms()
+        let enable_privacy_policy = PrefsUtil.getEnablePrivacyPolicy()
         if !acceptTerm {
             showWelocomeView()
             return
+        } else if enable_privacy_policy && !PrefsUtil.getAgreePrivacyPolicy() {
+            showPrivacyPolicyView()
+            return
         } else {
             if !Utils.getForceAnonymous() && !Utils.getSetProfile() {
                 let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "changeDevice") as! ChangeDeviceViewController
@@ -474,6 +479,65 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         }
     }
     
+    func showPrivacyPolicyView() {
+        if let privacyView = privacyPolicyVC.view {
+            let bgImage = UIImageView()
+            privacyView.addSubview(bgImage)
+            bgImage.anchor(top: privacyView.topAnchor, left: privacyView.leftAnchor, bottom: privacyView.bottomAnchor, right: privacyView.rightAnchor)
+            bgImage.backgroundColor = .white
+            DispatchQueue.global().async {
+                if let listBg = PrefsUtil.getBackground() {
+                    if listBg.isEmpty {
+                       return
+                    }
+                    var bgChoosen = ""
+                    let arrayBg = listBg.split(separator: ",")
+                    bgChoosen = String(arrayBg[Int.random(in: 0..<arrayBg.count)])
+                    ViewController.getDataImageFromUrl(from: URL(string: PrefsUtil.getURLBase() + "/dashboardv2/uploads/background/" + bgChoosen)!) { data, response, error in
+                        guard let data = data, error == nil else { return }
+                        // always update the UI from the main thread
+                        DispatchQueue.main.async() {
+                            bgImage.image = UIImage(data: data)!
+                        }
+                    }
+                }
+            }
+            
+            let containerButton = UIView()
+            privacyView.addSubview(containerButton)
+            containerButton.anchor(left: privacyView.safeAreaLayoutGuide.leftAnchor, bottom: privacyView.safeAreaLayoutGuide.bottomAnchor, paddingLeft: 10, paddingBottom: 10, minHeight: 40)
+            containerButton.rightAnchor.constraint(lessThanOrEqualTo: privacyView.safeAreaLayoutGuide.rightAnchor, constant: -10).isActive = true
+            containerButton.isUserInteractionEnabled = true
+            let tapgestureAgree = UITapGestureRecognizer(target: self, action: #selector(tappedOnAgreePrivacy(_ :)))
+            tapgestureAgree.numberOfTapsRequired = 1
+            containerButton.addGestureRecognizer(tapgestureAgree)
+            
+            let imageAgree = UIImageView()
+            imageAgree.image = UIImage(systemName: "arrow.forward.circle")
+            imageAgree.tintColor = .black
+            containerButton.addSubview(imageAgree)
+            imageAgree.anchor(left: containerButton.leftAnchor, centerY: containerButton.centerYAnchor, width: 40, height: 40)
+            
+            let titleAgree = UILabel()
+            titleAgree.text = "Agree and Continue".localized()
+            titleAgree.textColor = .black
+            containerButton.addSubview(titleAgree)
+            titleAgree.anchor(left: imageAgree.rightAnchor, right: containerButton.rightAnchor, paddingLeft: 5, centerY: containerButton.centerYAnchor)
+            
+            let privacyWV = WKWebView()
+            privacyWV.isOpaque = false
+            privacyWV.backgroundColor = UIColor.clear
+            privacyWV.scrollView.backgroundColor = UIColor.clear
+            privacyWV.load(URLRequest(url: URL(string: PrefsUtil.getURLPrivacyPolicy())!))
+            privacyView.addSubview(privacyWV)
+            privacyWV.anchor(top: privacyView.safeAreaLayoutGuide.topAnchor, left: privacyView.leftAnchor, right: privacyView.rightAnchor, height: privacyView.bounds.height - 80)
+            
+        }
+        privacyPolicyVC.modalPresentationStyle = .fullScreen
+        privacyPolicyVC.modalTransitionStyle = .crossDissolve
+        self.present(privacyPolicyVC, animated: true)
+    }
+    
     func showWelocomeView() {
         if let viewWelcome = welcomeVC.view {
             let bgImage = UIImageView()
@@ -589,6 +653,11 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         welcomeVC.dismiss(animated: true)
     }
     
+    @objc func tappedOnAgreePrivacy(_ gesture: UITapGestureRecognizer) {
+        PrefsUtil.setAgreePrivacyPolicy(value: true)
+        privacyPolicyVC.dismiss(animated: true)
+    }
+    
     func checkRange(_ range: NSRange, contain index: Int) -> Bool {
         return index > range.location && index < range.location + range.length
     }