Преглед изворни кода

update for HSA and force sign in

alqindiirsyam пре 2 месеци
родитељ
комит
54e49fa60a

+ 4 - 0
AppBuilder/AppBuilder/Info.plist

@@ -97,6 +97,10 @@
 	</dict>
 	<key>CFBundleIdentifier</key>
 	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+    <key>UIFileSharingEnabled</key>
+    <string>false</string>
+    <key>NSFileProtectionComplete</key>
+    <true/>
 	<key>CFBundleInfoDictionaryVersion</key>
 	<string>6.0</string>
 	<key>CFBundleName</key>

+ 15 - 4
AppBuilder/AppBuilder/ViewController.swift

@@ -37,6 +37,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
     var callTab : UINavigationController?
     var chatWATab : UINavigationController?
     var communityTab : UINavigationController?
+    var secureFolderTab : UINavigationController?
     let emptyTab = EmptyTabViewController()
     public static var isTab1 = true
     public static var isTab2 = false
@@ -98,6 +99,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         callTab = UINavigationController(rootViewController: CallLogVC())
         chatWATab = UINavigationController(rootViewController: ChatWALikeVC())
         communityTab = UINavigationController(rootViewController: CommunityList())
+        secureFolderTab = UINavigationController(rootViewController: SecureFolderViewController())
         
         self.delegate = self
         
@@ -108,6 +110,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         callTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_6_icon")!.withTintColor(.white) : UIImage(named: "tab_6_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_6_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .lightGray : .mainColor))
         chatWATab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_2_icon")!.withTintColor(.white) : UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .lightGray : .mainColor))
         communityTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_2_icon")!.withTintColor(.white) : UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .lightGray : .mainColor))
+        secureFolderTab?.tabBarItem = UITabBarItem(title: "", image: resizeImage(image: self.traitCollection.userInterfaceStyle == .dark ? UIImage(named: "tab_2_icon")!.withTintColor(.white) : UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal), selectedImage: resizeImage(image: UIImage(named: "tab_2_icon")!, targetSize: CGSize(width: 25, height: 25)).withRenderingMode(.alwaysOriginal).withTintColor(self.traitCollection.userInterfaceStyle == .dark ? .lightGray : .mainColor))
         var i = 0
         var j = 0
         while j < customTab.count {
@@ -125,6 +128,8 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
                     tabs.append(thirdTab!)
                 case "4":
                     tabs.append(fourthTab!)
+                case "5":
+                    tabs.append(secureFolderTab!)
                 case "6":
                     tabs.append(callTab!)
                 case "16":
@@ -647,12 +652,18 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         let acceptTerm = PrefsUtil.getTerms()
         let enable_privacy_policy = PrefsUtil.getEnablePrivacyPolicy()
         if !acceptTerm {
-            showWelocomeView()
+            if !Utils.getForceAnonymous() && !Utils.getSetProfile() {
+                Nexilis.showForceSignIn() {
+                    self.showWelocomeView()
+                }
+            } else {
+                showWelocomeView()
+            }
             return
         } else if enable_privacy_policy && !PrefsUtil.getAgreePrivacyPolicy() {
             showPrivacyPolicyView()
             return
-        } else {
+        } else if acceptTerm {
             if !Utils.getForceAnonymous() && !Utils.getSetProfile() {
                 Nexilis.showForceSignIn()
                 return
@@ -736,7 +747,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         }
         privacyPolicyVC.modalPresentationStyle = .fullScreen
         privacyPolicyVC.modalTransitionStyle = .crossDissolve
-        self.present(privacyPolicyVC, animated: true)
+        UIApplication.shared.visibleViewController?.present(privacyPolicyVC, animated: true)
     }
     
     func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
@@ -828,7 +839,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
         }
         welcomeVC.modalPresentationStyle = .fullScreen
         welcomeVC.modalTransitionStyle = .crossDissolve
-        self.present(welcomeVC, animated: true)
+        UIApplication.shared.visibleViewController?.present(welcomeVC, animated: true)
     }
     
     func getHighResolutionAppIconName() -> String? {

+ 1 - 1
NexilisLite/NexilisLite/Source/MasterKeyUtil.swift

@@ -85,7 +85,7 @@ public class MasterKeyUtil {
     }
     
     func getMasterKey() throws -> SymmetricKey {
-        if (Nexilis.checkingAccess(key: "authentication") && isDeviceNotSecure()) {
+        if Nexilis.checkingAccess(key: "authentication") && isDeviceNotSecure() && Nexilis.dispatch == nil {
             var result = false
             Nexilis.dispatch = DispatchGroup()
             Nexilis.dispatch?.enter()

+ 5 - 3
NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -149,6 +149,8 @@ public class Nexilis: NSObject {
         
         Nexilis.showButtonFB = showButton
         
+        SecureUserDefaults.shared.removeValue(forKey: "lastAuthenticationTime")
+        
         do {
             try MasterKeyUtil.shared.generateAndStoreMasterKey()
             try MasterKeyUtil.shared.generateAndStorePrefsKey()
@@ -410,7 +412,7 @@ public class Nexilis: NSObject {
     
     private static func getPullPrefs() {
         DispatchQueue.global().async {
-            let urlString = Utils.getBEId().isEmpty ? Utils.getDomainOpr() + "nexilis/logics/get_baseurl_new?key=\(Nexilis.sAPIKey)" : Utils.getDomainOpr() + "nexilis/logics/get_prefs?be=\(Utils.getBEId())&appId=\(APIS.getAppNm())"
+            let urlString = Utils.getBEId().isEmpty ? Utils.getDomainOpr() + "nexilis/logics/get_baseurl_new?key=\(Nexilis.sAPIKey)" : Utils.getDomainOpr() + "nexilis/logics/get_prefs?be=\(Utils.getBEId())&appId=\(APIS.getAppNm().toStupidString())"
             Utils.fetchDataWithCookiesAndUserAgent(from: URL(string: urlString)!) { data, response, error in
                 if let data = data, let responseString = String(data: data, encoding: .utf8) {
                     if let json = try? JSONSerialization.jsonObject(with: responseString.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [String: Any?] {
@@ -687,7 +689,7 @@ public class Nexilis: NSObject {
         }
     }
     
-    public static func showForceSignIn() {
+    public static func showForceSignIn(completion: (() -> Void)? = nil) {
         let controller = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "changeDevice") as! ChangeDeviceViewController
         controller.forceLogin = true
         let navigationController = CustomNavigationController(rootViewController: controller)
@@ -703,7 +705,7 @@ public class Nexilis: NSObject {
         navigationController.navigationBar.titleTextAttributes = textAttributes
         navigationController.modalPresentationStyle = .fullScreen
         navigationController.modalTransitionStyle = .crossDissolve
-        UIApplication.shared.visibleViewController?.present(navigationController, animated: true)
+        UIApplication.shared.visibleViewController?.present(navigationController, animated: true, completion: completion)
     }
     
     public static func destroyAll() {

+ 4 - 1
NexilisLite/NexilisLite/Source/Utils.swift

@@ -895,6 +895,9 @@ public final class Utils {
                     if Array(json.keys)[i] == "default_sound_rbt" {
                         Utils.setDefaultIncomingRBT(value: Array(json.values)[i] as? String ?? "")
                     }
+                    if Array(json.keys)[i] == "icon_size" {
+                        Utils.setIconDockSize(value: Array(json.values)[i] as? String ?? "")
+                    }
                 }
                 Utils.setFinishInitPrefs(value: true)
                 DispatchQueue.main.async {
@@ -1490,7 +1493,7 @@ public final class Utils {
         if let lastAuthTime: Date = SecureUserDefaults.shared.value(forKey: "lastAuthenticationTime") {
             let elapsedTime = Date().timeIntervalSince(lastAuthTime)
             let durationAuth = Double(Utils.getAuthenticationDuration()) ?? 5
-            print("durationAuth \(durationAuth)")
+//            print("durationAuth \(durationAuth)")
             return elapsedTime > durationAuth
         }
         return true

+ 44 - 19
NexilisLite/NexilisLite/Source/View/Chat/SecureFolderView.swift

@@ -10,7 +10,7 @@ import AVFoundation
 import AVKit
 import QuickLook
 
-class SecureFolderViewController: UIViewController, UISearchBarDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, QLPreviewControllerDataSource {
+public class SecureFolderViewController: UIViewController, UISearchBarDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, QLPreviewControllerDataSource {
     
     var directoryPath: URL!
     var files: [SecureFolderItem] = []
@@ -29,28 +29,53 @@ class SecureFolderViewController: UIViewController, UISearchBarDelegate, UIColle
         layout.minimumInteritemSpacing = 10
         
         let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)
-        cv.backgroundColor = .white
+        cv.backgroundColor = .clear
         cv.register(FileCell.self, forCellWithReuseIdentifier: "FileCell")
         return cv
     }()
     
-    override func viewDidLoad() {
+    public override func viewDidLoad() {
         super.viewDidLoad()
-        self.title = "Secure Folder"
-        view.backgroundColor = .white
-        let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 16.0), NSAttributedString.Key.foregroundColor: UIColor.white]
+        self.navigationController?.navigationController?.setNavigationBarHidden(true, animated: false)
+//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(cancel(sender:)))
+        let tapGesture = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
+        tapGesture.cancelsTouchesInView = false
+        view.addGestureRecognizer(tapGesture)
+        setupSubviews()
+        loadFiles()
+        filteredFiles = files
+    }
+    
+    @objc func dismissKeyboard() {
+        searchBar.resignFirstResponder()
+    }
+    
+    public override func viewWillAppear(_ animated: Bool) {
+        self.navigationController?.navigationController?.setNavigationBarHidden(true, animated: false)
+        self.navigationController?.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black]
+        let attributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black, NSAttributedString.Key.font : UIFont.boldSystemFont(ofSize: 16)]
         let navBarAppearance = UINavigationBarAppearance()
-        navBarAppearance.configureWithOpaqueBackground()
-        navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
+        navBarAppearance.configureWithTransparentBackground()
         navBarAppearance.titleTextAttributes = attributes
         navigationController?.navigationBar.standardAppearance = navBarAppearance
         navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
-        
-        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Cancel".localized(), style: .plain, target: self, action: #selector(cancel(sender:)))
-        
-        setupSubviews()
-        loadFiles()
-        filteredFiles = files
+        let cancelButtonAttributes: [NSAttributedString.Key: Any] = [NSAttributedString.Key.foregroundColor: self.traitCollection.userInterfaceStyle == .dark ? .white : UIColor.black, NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16)]
+        UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, for: .normal)
+        navigationController?.navigationBar.backgroundColor = .clear
+        navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
+        navigationController?.navigationBar.shadowImage = UIImage()
+        navigationController?.navigationBar.isTranslucent = true
+        navigationController?.setNavigationBarHidden(false, animated: false)
+        navigationController?.navigationBar.overrideUserInterfaceStyle = self.traitCollection.userInterfaceStyle == .dark ? .dark : .light
+        navigationController?.navigationBar.barStyle = .default
+        navigationController?.navigationBar.tintColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
+        tabBarController?.navigationItem.leftBarButtonItem = nil
+        tabBarController?.navigationItem.searchController = nil
+    }
+    
+    public override func viewDidAppear(_ animated: Bool) {
+        self.navigationController?.navigationBar.topItem?.title = "Secure Folder".localized()
+        self.navigationController?.navigationBar.setNeedsLayout()
     }
     
     @objc func cancel(sender: Any) {
@@ -143,18 +168,18 @@ class SecureFolderViewController: UIViewController, UISearchBarDelegate, UIColle
 
     // MARK: Search Bar Delegate
     
-    func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
+    public func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
         filteredFiles = searchText.isEmpty ? files : files.filter { $0.filename.contains(searchText) }
         collectionView.reloadData()
     }
     
     // MARK: Collection View Data Source
     
-    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+    public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
         return filteredFiles.count
     }
     
-    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+    public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
         let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "FileCell", for: indexPath) as! FileCell
         let fileItem = filteredFiles[indexPath.item]
         cell.label.text = fileItem.filename
@@ -173,14 +198,14 @@ class SecureFolderViewController: UIViewController, UISearchBarDelegate, UIColle
     
     // MARK: Collection View Delegate Flow Layout
     
-    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
+    public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
         let padding: CGFloat = 10
         let collectionViewSize = collectionView.frame.size.width - padding
         let width = collectionViewSize / 2
         return CGSize(width: width, height: width)
     }
     
-    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+    public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
         let fileItem = filteredFiles[indexPath.item]
         if fileItem.imageId != "" {
             print("this image")