Browse Source

fix force close and bugs FB

alqindiirsyam 7 months ago
parent
commit
e6aeb6bf5d

BIN
.DS_Store


+ 1 - 0
.gitignore

@@ -46,3 +46,4 @@ Podfile.lock
 
 # Carthage/Build
 
+.DS_Store

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

@@ -373,7 +373,7 @@ public class APIS: NSObject {
         }
     }
     
-    public static func startConversation() {
+    public static func openConversation() {
         let isChangeProfile = Utils.getSetProfile()
         if !isChangeProfile {
             APIS.showChangeProfile()

+ 1 - 0
NexilisLite/NexilisLite/Source/CoreMessage_TMessageBank.swift

@@ -2519,6 +2519,7 @@ public class CoreMessage_TMessageBank {
         tMessage.mCode = CoreMessage_TMessageCode.PULL_PREFS
         tMessage.mStatus = CoreMessage_TMessageUtil.getTID()
         tMessage.mBodies[CoreMessage_TMessageKey.F_PIN] = me
+        tMessage.mBodies[CoreMessage_TMessageKey.ANDROID_APP_NAME] = APIS.getAppNm()
         if !key.isEmpty {
             tMessage.mBodies[CoreMessage_TMessageKey.KEY] = key
         }

+ 8 - 3
NexilisLite/NexilisLite/Source/Database.swift

@@ -13,7 +13,12 @@ import KeychainAccess
 
 public class Database {
     
-    public init() {}
+    public init() {
+        let databasePath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] + "/encrypted_db_es.db"
+        if FileManager.default.fileExists(atPath: databasePath) {
+            database = setupDatabaseQueue(withPath: databasePath)
+        }
+    }
     
     public static let shared = Database()
     
@@ -48,12 +53,12 @@ public class Database {
             
             database?.inDatabase({(fmdb) in
                 fmdb.setKey(key)
-    //            print("Open Done")
+                print("Open Done")
             })
             database?.inTransaction({(fmdb, rollback) in
                 do {
                     try createDatabase(fmdb: fmdb)
-    //                print("Create Done")
+                    print("Create Done")
                 } catch {
                 }
             })

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

@@ -374,7 +374,7 @@ extension NSObject {
                             tableView!.reloadRows(at: [indexPath!], with: .none)
                             tableView!.endUpdates()
                         }
-                        if type(of: self).urlStore[tmpAddress] == name {
+                        if type(of: self).urlStore[tmpAddress] == name && tableView == nil {
                             if FileManager().fileExists(atPath: file.path) {
                                 let image = UIImage(contentsOfFile: file.path)?.sd_resizedImage(with: CGSize(width: 400, height: 400), scaleMode: .aspectFill)
                                 completion(true, true, isCircle ? image?.circleMasked : image)

+ 70 - 54
NexilisLite/NexilisLite/Source/FloatingButton/FloatingButton.swift

@@ -57,6 +57,8 @@ public class FloatingButton: UIView {
     final let MODE_HORIZONTAL_SIDE_TAB = "4"
     final let MODE_VERTICAL_SIDE_TAB = "5"
     
+    var configModeFB = "1"
+    
     var countMenuFB: CGFloat = 6 {
         didSet {
             if isShow {
@@ -83,20 +85,22 @@ public class FloatingButton: UIView {
         panGesture = UIPanGestureRecognizer(target: self, action: #selector(draggedView(_:)))
         addGestureRecognizer(panGesture!)
         
+        configModeFB = Utils.getConfigModeFB()
+        
         nexilis_button = UIImageView()
         nexilis_button.translatesAutoresizingMaskIntoConstraints = false
         nexilis_button.isUserInteractionEnabled = true
         var dataImage: Data?
-        if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION || Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
+        if configModeFB == MODE_VERTICAL_ANIMATION || configModeFB == MODE_HORIZONTAL_ANIMATION {
             defaultWidthFB = widthFBAnim
-            if Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
+            if configModeFB == MODE_HORIZONTAL_ANIMATION {
                 defaultHeightFB = heightFBAnim + 30
             } else {
                 defaultHeightFB = heightFBAnim
             }
-            var urlGif = URL(string: Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? Utils.getIconCenterAnim2() : Utils.getIconCenterAnim4())
+            var urlGif = URL(string: configModeFB == MODE_VERTICAL_ANIMATION ? Utils.getIconCenterAnim2() : Utils.getIconCenterAnim4())
             if (urlGif == nil) {
-                urlGif = Bundle.resourceBundle(for: Nexilis.self).url(forResource: Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? "pb_def_icon_mode2" : "pb_def_icon_mode4", withExtension: "gif")! //resourcesMediaBundle
+                urlGif = Bundle.resourceBundle(for: Nexilis.self).url(forResource: configModeFB == MODE_VERTICAL_ANIMATION ? "pb_def_icon_mode2" : "pb_def_icon_mode4", withExtension: "gif")! //resourcesMediaBundle
             }
             nexilis_button.sd_setImage(with: urlGif) { [self] (image, error, cacheType, imageURL) in
                 if error == nil {
@@ -107,30 +111,39 @@ public class FloatingButton: UIView {
                 }
             }
         } else {
-            if !Utils.getIconDock().isEmpty && Utils.getConfigModeFB() == MODE_VERTICAL_FLOATING_BUTTON {
-                dataImage = try? Data(contentsOf: URL(string: Utils.getUrlDock()!)!)
-                if dataImage != nil {
-                    if let image = UIImage(data: dataImage!) {
-                        nexilis_button.image = image
-                    } else {
-                        nexilis_button.image = UIImage(named: Utils.getFBIconBg() == "1" ? "pb_button" : "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
-                    }
-                } else {
-                    nexilis_button.image = UIImage(named: Utils.getFBIconBg() == "1" ? "pb_button" : "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
-                }
+            if !Utils.getIconDock().isEmpty && configModeFB == MODE_VERTICAL_FLOATING_BUTTON && Nexilis.fromMAB {
+                setImageWithURL(Utils.getIconDock())
             } else {
-                if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB || Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
+                if configModeFB == MODE_HORIZONTAL_SIDE_TAB || configModeFB == MODE_VERTICAL_SIDE_TAB {
                     defaultWidthFB = widthFBSideTab
                     defaultHeightFB = heightFBSideTab
                 }
-                nexilis_button.image = UIImage(named: Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? "pb_side_tab_vtc" : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? "pb_side_tab" : "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
+                if !Utils.getIconCenter().isEmpty {
+                    print("HUHU GG \(Utils.getIconCenter())")
+                    setImageWithURL(Utils.getIconCenter())
+                } else {
+                    nexilis_button.image = UIImage(named: configModeFB == MODE_VERTICAL_SIDE_TAB ? "pb_side_tab_vtc" : configModeFB == MODE_HORIZONTAL_SIDE_TAB ? "pb_side_tab" : "pb_button", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
+                }
+            }
+        }
+        
+        func setImageWithURL(_ url: String) {
+            dataImage = try? Data(contentsOf: URL(string: url)!)
+            if dataImage != nil {
+                if let image = UIImage(data: dataImage!) {
+                    nexilis_button.image = image
+                } else {
+                    nexilis_button.image = UIImage(named: Utils.getFBIconBg() == "1" ? "pb_button" : "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
+                }
+            } else {
+                nexilis_button.image = UIImage(named: Utils.getFBIconBg() == "1" ? "pb_button" : "pb_ball", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)
             }
         }
         
         backgroundColor = .clear
-        frame = CGRect(x: UIScreen.main.bounds.width - defaultWidthFB, y: (UIScreen.main.bounds.height / 2) - defaultHeightFB, width: Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? 50 + defaultWidthFB : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? UIScreen.main.bounds.width - defaultWidthFB : defaultWidthFB, height: Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? heightVerticalSideTab : defaultHeightFB)
+        frame = CGRect(x: UIScreen.main.bounds.width - defaultWidthFB, y: (UIScreen.main.bounds.height / 2) - defaultHeightFB, width: configModeFB == MODE_VERTICAL_SIDE_TAB ? 50 + defaultWidthFB : configModeFB == MODE_HORIZONTAL_SIDE_TAB ? UIScreen.main.bounds.width - defaultWidthFB : defaultWidthFB, height: configModeFB == MODE_VERTICAL_SIDE_TAB ? heightVerticalSideTab : defaultHeightFB)
         
-        if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION || Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
+        if configModeFB == MODE_VERTICAL_ANIMATION || configModeFB == MODE_HORIZONTAL_ANIMATION {
             if configAnim == 0 { //left to right
                 lastRunAnimationHrz = 1
             } else if configAnim == 1 { //right to left
@@ -157,7 +170,7 @@ public class FloatingButton: UIView {
         nexilis_button.widthAnchor.constraint(equalToConstant: defaultWidthFB).isActive = true
         nexilis_button.heightAnchor.constraint(equalToConstant: defaultHeightFB).isActive = true
         nexilis_button.leftAnchor.constraint(equalTo: leftAnchor).isActive = true
-        if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
+        if configModeFB == MODE_VERTICAL_SIDE_TAB {
             nexilis_button.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true
         } else {
             nexilis_button.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
@@ -165,7 +178,7 @@ public class FloatingButton: UIView {
         
         scrollView = UIScrollView()
         scrollView.translatesAutoresizingMaskIntoConstraints = false
-        if Utils.getFBItemBg() == "1" && Utils.getConfigModeFB() == MODE_VERTICAL_FLOATING_BUTTON {
+        if Utils.getFBItemBg() == "1" && configModeFB == MODE_VERTICAL_FLOATING_BUTTON {
             scrollView.layer.borderWidth = 1.0
             scrollView.layer.borderColor = UIColor.white.cgColor
             scrollView.layer.cornerRadius = 8.0
@@ -174,7 +187,7 @@ public class FloatingButton: UIView {
         }
         addSubview(scrollView)
         
-        if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
+        if configModeFB == MODE_VERTICAL_SIDE_TAB {
             let bgImage = resizeImage(image: UIImage(named: "pb_button_background_vtcst", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!, targetSize: CGSize(width: widthVerticalSideTab, height: heightVerticalSideTab))
             scrollView.backgroundColor = UIColor.init(patternImage: bgImage)
             
@@ -182,14 +195,14 @@ public class FloatingButton: UIView {
             scrollView.centerYAnchor.constraint(equalTo: nexilis_button.centerYAnchor).isActive = true
             scrollView.widthAnchor.constraint(equalToConstant: widthVerticalSideTab).isActive = true
             scrollView.heightAnchor.constraint(equalToConstant: heightVerticalSideTab).isActive = true
-        } else if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB {
+        } else if configModeFB != MODE_HORIZONTAL_SIDE_TAB {
             scrollView.topAnchor.constraint(equalTo: topAnchor).isActive = true
-            if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION {
+            if configModeFB == MODE_VERTICAL_ANIMATION {
                 scrollView.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true
                 scrollView.leftAnchor.constraint(equalTo: nexilis_button.rightAnchor, constant: -20).isActive = true
                 scrollView.widthAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB + 10).isActive = true
                 scrollView.isHidden = true
-            } else if Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
+            } else if configModeFB == MODE_HORIZONTAL_ANIMATION {
                 scrollView.bottomAnchor.constraint(equalTo: nexilis_button.topAnchor).isActive = true
                 scrollView.leftAnchor.constraint(equalTo: nexilis_button.leftAnchor).isActive = true
                 scrollView.widthAnchor.constraint(equalToConstant: defaultWidthHeightMenuFB * (countMenuFB - 1)).isActive = true
@@ -208,29 +221,29 @@ public class FloatingButton: UIView {
         
         groupView = UIStackView()
         groupView.translatesAutoresizingMaskIntoConstraints = false
-        groupView.axis = (Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB || Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION) ? .horizontal : .vertical
-        if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB && Utils.getConfigModeFB() != MODE_HORIZONTAL_ANIMATION {
+        groupView.axis = (configModeFB == MODE_HORIZONTAL_SIDE_TAB || configModeFB == MODE_HORIZONTAL_ANIMATION) ? .horizontal : .vertical
+        if configModeFB != MODE_HORIZONTAL_SIDE_TAB && configModeFB != MODE_HORIZONTAL_ANIMATION {
             groupView.distribution = .fillEqually
         }
 
         scrollView.addSubview(groupView)
 
-        if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
+        if configModeFB == MODE_VERTICAL_SIDE_TAB {
             groupView.spacing = 10.0
             groupView.centerYAnchor.constraint(equalTo: scrollView.centerYAnchor).isActive = true
             groupView.centerXAnchor.constraint(equalTo: scrollView.centerXAnchor).isActive = true
             groupView.heightAnchor.constraint(equalToConstant: heightVerticalSideTab - 20).isActive = true
             groupView.widthAnchor.constraint(equalToConstant: 30).isActive = true
-        } else if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB {
+        } else if configModeFB == MODE_HORIZONTAL_SIDE_TAB {
             groupView.leftAnchor.constraint(equalTo: scrollView.leftAnchor).isActive = true
             groupView.rightAnchor.constraint(equalTo: scrollView.rightAnchor).isActive = true
             groupView.centerYAnchor.constraint(equalTo: scrollView.centerYAnchor).isActive = true
             groupView.heightAnchor.constraint(equalToConstant: defaultHeightFB - 10).isActive = true
         } else {
-            groupView.widthAnchor.constraint(equalToConstant: Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? defaultWidthHeightMenuFB * (countMenuFB - 1) : defaultWidthHeightMenuFB).isActive = true
-            groupView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? 0 : 5).isActive = true
-            groupView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? 0 : -5).isActive = true
-            groupView.leftAnchor.constraint(equalTo: scrollView.leftAnchor, constant: Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? 0 : 6).isActive = true
+            groupView.widthAnchor.constraint(equalToConstant: configModeFB == MODE_HORIZONTAL_ANIMATION ? defaultWidthHeightMenuFB * (countMenuFB - 1) : defaultWidthHeightMenuFB).isActive = true
+            groupView.topAnchor.constraint(equalTo: scrollView.topAnchor, constant: configModeFB == MODE_HORIZONTAL_ANIMATION ? 0 : 5).isActive = true
+            groupView.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor, constant: configModeFB == MODE_HORIZONTAL_ANIMATION ? 0 : -5).isActive = true
+            groupView.leftAnchor.constraint(equalTo: scrollView.leftAnchor, constant: configModeFB == MODE_HORIZONTAL_ANIMATION ? 0 : 6).isActive = true
         }
         
         pullButton()
@@ -308,7 +321,7 @@ public class FloatingButton: UIView {
             getDefaultButton()
         }
         DispatchQueue.global().async { [self] in
-            if !Utils.getCustomButtons().isEmpty && Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB && Utils.getConfigModeFB() != MODE_HORIZONTAL_ANIMATION && Utils.getConfigModeFB() != MODE_VERTICAL_SIDE_TAB {
+            if !Utils.getCustomButtons().isEmpty && configModeFB != MODE_HORIZONTAL_SIDE_TAB && configModeFB != MODE_HORIZONTAL_ANIMATION && configModeFB != MODE_VERTICAL_SIDE_TAB && Nexilis.fromMAB {
                 DispatchQueue.main.async { [self] in
                     groupView.subviews.forEach({ $0.removeFromSuperview() })
                     let customButtons = Utils.getCustomButtons().components(separatedBy: ",")
@@ -345,7 +358,7 @@ public class FloatingButton: UIView {
                     if !data.isEmpty {
                         if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
                             DispatchQueue.main.async { [self] in
-                                let filteredData = jsonArray.filter({ $0["mode"] as? Int == Int(Utils.getConfigModeFB()) })
+                                let filteredData = jsonArray.filter({ $0["mode"] as? Int == Int(configModeFB) })
                                 if filteredData.count != 0 {
                                     groupView.subviews.forEach({ $0.removeFromSuperview() })
                                     countMenuFB = CGFloat(filteredData.count > 5 ? 5 : filteredData.count)
@@ -355,7 +368,7 @@ public class FloatingButton: UIView {
                                         let icon = (json["icon"] as? String) ?? ""
                                         let mode = "\((json["mode"] as? Int) ?? 1)"
                                         let newButton = UIButton()
-                                        if mode != Utils.getConfigModeFB() {
+                                        if mode != configModeFB {
                                             continue
                                         }
                                         if mode == MODE_HORIZONTAL_SIDE_TAB {
@@ -373,8 +386,9 @@ public class FloatingButton: UIView {
                                         var indexTap = 0
                                         if package_id.contains("_fb"){
                                             let listSplit = package_id.split(separator: "_", maxSplits: 1)
-                                            let numIdx = listSplit[listSplit.firstIndex(where: { $0.contains("fb") }) ?? 0]
-                                            indexTap = Int(String(numIdx).substring(from: 2, to: numIdx.count))!
+                                            let idxFB = listSplit.firstIndex(where: { $0.contains("fb") }) ?? 0
+                                            let numIdx = listSplit[idxFB]
+                                            indexTap = Int(String(numIdx).substring(from: 2, to: numIdx.count)) ?? 0
                                         }
                                         if indexTap == Nexilis.IDX_CHAT {
                                             newButton.setImage(UIImage(named: mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_chat" : mode == MODE_HORIZONTAL_SIDE_TAB ? "pb_button_hrz_chat" : mode == MODE_HORIZONTAL_ANIMATION ? "pb_button_hrz_anim_chat" : "pb_button_chat", in: Bundle.resourceBundle(for: Nexilis.self), with: nil), for: .normal)
@@ -429,7 +443,7 @@ public class FloatingButton: UIView {
     }
     
     func getDefaultButton() {
-        let mode = Utils.getConfigModeFB()
+        let mode = configModeFB
         var data = [Nexilis.IDX_NOTIF_CENTER, Nexilis.IDX_CC, Nexilis.IDX_CONVERSATION, Nexilis.IDX_CALL, Nexilis.IDX_STREAM]
         if Nexilis.defaultFloatingButton.count > 0 {
             data = Nexilis.defaultFloatingButton
@@ -490,14 +504,14 @@ public class FloatingButton: UIView {
         let size = UIScreen.main.bounds
         let widthScreen = size.width
         let heightScreen = size.height
-        let minimumx: CGFloat = Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION && isShow ? widthFBAnim + defaultWidthHeightMenuFB : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION && isShow ? 60 : 40
-        let maximumx = Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION && isShow ? widthScreen - widthFBAnim - defaultWidthHeightMenuFB : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION && isShow ? widthScreen - 10 - defaultWidthHeightMenuFB : widthScreen - 40
+        let minimumx: CGFloat = configModeFB == MODE_HORIZONTAL_ANIMATION && isShow ? widthFBAnim + defaultWidthHeightMenuFB : configModeFB == MODE_VERTICAL_ANIMATION && isShow ? 60 : 40
+        let maximumx = configModeFB == MODE_HORIZONTAL_ANIMATION && isShow ? widthScreen - widthFBAnim - defaultWidthHeightMenuFB : configModeFB == MODE_VERTICAL_ANIMATION && isShow ? widthScreen - 10 - defaultWidthHeightMenuFB : widthScreen - 40
         let maxMinXSideTab = isShow ? center.x : widthScreen + (center.x - widthScreen)
         let translation = sender.translation(in: self)
         var xPos = center.x + translation.x
         var yPos = center.y + translation.y
         bringSubviewToFront(self)
-        if Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB || Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
+        if configModeFB == MODE_HORIZONTAL_SIDE_TAB || configModeFB == MODE_VERTICAL_SIDE_TAB {
             xPos = maxMinXSideTab
         } else {
             if (xPos < minimumx) {
@@ -508,8 +522,8 @@ public class FloatingButton: UIView {
             }
         }
         if(isShow) {
-            let minimumy = Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? heightVerticalSideTab - 100 : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? 50 : Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? defaultWidthHeightMenuFB * 2 + 10 : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? defaultHeightFB + defaultWidthHeightMenuFB : self.frame.size.height - 120 + ((5 - countMenuFB) * 25)
-            let maximumy = Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB ? heightScreen - (heightVerticalSideTab - 100) : Utils.getConfigModeFB() == MODE_HORIZONTAL_SIDE_TAB ? heightScreen - 50 : Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION ? heightScreen - defaultWidthHeightMenuFB - 30 : Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION ? heightScreen - defaultHeightFB - 30 : heightScreen - 50
+            let minimumy = configModeFB == MODE_VERTICAL_SIDE_TAB ? heightVerticalSideTab - 100 : configModeFB == MODE_HORIZONTAL_SIDE_TAB ? 50 : configModeFB == MODE_HORIZONTAL_ANIMATION ? defaultWidthHeightMenuFB * 2 + 10 : configModeFB == MODE_VERTICAL_ANIMATION ? defaultHeightFB + defaultWidthHeightMenuFB : self.frame.size.height - 120 + ((5 - countMenuFB) * 25)
+            let maximumy = configModeFB == MODE_VERTICAL_SIDE_TAB ? heightScreen - (heightVerticalSideTab - 100) : configModeFB == MODE_HORIZONTAL_SIDE_TAB ? heightScreen - 50 : configModeFB == MODE_HORIZONTAL_ANIMATION ? heightScreen - defaultWidthHeightMenuFB - 30 : configModeFB == MODE_VERTICAL_ANIMATION ? heightScreen - defaultHeightFB - 30 : heightScreen - 50
             if(yPos < minimumy) {
                 yPos = minimumy
             }
@@ -531,8 +545,8 @@ public class FloatingButton: UIView {
         if lastPosY != nil {
             lastPosY = nil
         }
-        SecureUserDefaults.shared.set(center.x, forKey: "xlastPosFB")
-        SecureUserDefaults.shared.set(center.y, forKey: "ylastPosFB")
+//        SecureUserDefaults.shared.set(center.x, forKey: "xlastPosFB")
+//        SecureUserDefaults.shared.set(center.y, forKey: "ylastPosFB")
     }
     
     @objc func imageFBUpdate(notification: NSNotification) {
@@ -618,6 +632,8 @@ public class FloatingButton: UIView {
                 mySettingDelegate?.settingDelegate()
             } else {
                 let navigationController = AppStoryBoard.Palio.instance.instantiateViewController(withIdentifier: "settingNav") as! UINavigationController
+                let vc = navigationController.rootViewController as! SettingTableViewController
+                vc.fromAPI = true
                 Utils.addBackground(view: navigationController.view)
                 navigationController.modalPresentationStyle = .fullScreen
                 navigationController.navigationBar.tintColor = .white
@@ -658,14 +674,14 @@ public class FloatingButton: UIView {
             var height = CGFloat((defaultWidthHeightMenuFB * countMenuFB) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
             var width = frame.width
             var xPosition = frame.origin.x
-            if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION {
+            if configModeFB == MODE_VERTICAL_ANIMATION {
                 height = CGFloat((defaultWidthHeightMenuFB * (countMenuFB - 2)) + defaultHeightFB - 5)
                 width = frame.width + defaultWidthHeightMenuFB
                 if xPosition > UIScreen.main.bounds.width - defaultWidthFB - defaultWidthHeightMenuFB {
                     xPosition = UIScreen.main.bounds.width - defaultWidthFB - defaultWidthHeightMenuFB
                 }
                 scrollView.isHidden = false
-            } else if Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
+            } else if configModeFB == MODE_HORIZONTAL_ANIMATION {
                 height = defaultHeightFB + defaultWidthHeightMenuFB
                 width = defaultWidthHeightMenuFB * (countMenuFB - 1)
                 if xPosition > UIScreen.main.bounds.width - width {
@@ -677,12 +693,12 @@ public class FloatingButton: UIView {
                 lastPosY = frame.origin.y
                 yPosition = 25
             }
-            if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB &&  Utils.getConfigModeFB() != MODE_VERTICAL_SIDE_TAB {
+            if configModeFB != MODE_HORIZONTAL_SIDE_TAB &&  configModeFB != MODE_VERTICAL_SIDE_TAB {
                 frame = CGRect(x: xPosition, y: yPosition, width: width, height: height)
             } else {
                 UIView.animate(withDuration: 0.5, animations: { [self] in
                     var vst: CGFloat = 0.0
-                    if Utils.getConfigModeFB() == MODE_VERTICAL_SIDE_TAB {
+                    if configModeFB == MODE_VERTICAL_SIDE_TAB {
                         vst = UIScreen.main.bounds.width - defaultWidthFB - widthVerticalSideTab
                         let size = UIScreen.main.bounds
                         let heightScreen = size.height
@@ -709,10 +725,10 @@ public class FloatingButton: UIView {
             }
             var height = CGFloat((defaultWidthHeightMenuFB * countMenuFB) + defaultHeightFB + 5) //defaultWidthHeightMenuFB
             var width = defaultWidthFB
-            if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION {
+            if configModeFB == MODE_VERTICAL_ANIMATION {
                 height = CGFloat((defaultWidthHeightMenuFB * 3) + defaultHeightFB - 5)
                 scrollView.isHidden = true
-            } else if Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
+            } else if configModeFB == MODE_HORIZONTAL_ANIMATION {
                 height = defaultHeightFB + defaultWidthHeightMenuFB
                 width = defaultWidthFB
             }
@@ -720,14 +736,14 @@ public class FloatingButton: UIView {
             if lastPosY != nil {
                 yPosition = lastPosY!
             }
-            if Utils.getConfigModeFB() != MODE_HORIZONTAL_SIDE_TAB && Utils.getConfigModeFB() != MODE_VERTICAL_SIDE_TAB {
+            if configModeFB != MODE_HORIZONTAL_SIDE_TAB && configModeFB != MODE_VERTICAL_SIDE_TAB {
                 frame = CGRect(x: frame.origin.x, y: yPosition, width: width, height: defaultHeightFB)
             } else {
                 UIView.animate(withDuration: 0.5, animations: { [self] in
                     frame.origin.x = UIScreen.main.bounds.width - defaultWidthFB
                 })
             }
-            if Utils.getConfigModeFB() == MODE_VERTICAL_ANIMATION || Utils.getConfigModeFB() == MODE_HORIZONTAL_ANIMATION {
+            if configModeFB == MODE_VERTICAL_ANIMATION || configModeFB == MODE_HORIZONTAL_ANIMATION {
                 checkDelayAnimation()
             }
         }

+ 27 - 2
NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -40,6 +40,7 @@ public class Nexilis: NSObject {
     static var dispatch: DispatchGroup?
     
     public static var showFB = false
+    public static var fromMAB = false
     
     let callManager = CallManager()
     
@@ -132,6 +133,7 @@ public class Nexilis: NSObject {
     
     public static func connect(apiKey: String, delegate: ConnectDelegate, showButton: Bool = true, fromMAB: Bool = false) {
         showFB = showButton
+        Nexilis.fromMAB = fromMAB
         
         Nexilis.shared.createDelegate()
         
@@ -336,7 +338,30 @@ public class Nexilis: NSObject {
     
     private static func getPullPrefs() {
         DispatchQueue.global().async {
-            _ = Nexilis.write(message: CoreMessage_TMessageBank.getPrefs())
+            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())"
+            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?] {
+                        do {
+                            let dataArray: [[String: Any?]] = [json]
+                            if !dataArray.isEmpty && !Utils.getIsLoadThemeFromOther() {
+                                if let jsonData = try? JSONSerialization.data(withJSONObject: dataArray, options: .prettyPrinted) {
+                                    // Convert to JSON String
+                                    let jsonString = String(data: jsonData, encoding: .utf8)
+                                    Utils.setPrefTheme(value: jsonString ?? "")
+                                    Utils.setValueInitialApp(data: jsonString ?? "")
+                                } else {
+                                }
+                            }
+                            Utils.setFinishInitPrefs(value: true)
+                            if Utils.getBEId().isEmpty {
+                                Utils.setBEId(value: "\(json["be_id"]!!)")
+                            }
+                        } catch {
+                        }
+                    }
+                }
+            }
         }
     }
     
@@ -982,7 +1007,7 @@ public class Nexilis: NSObject {
         } else if index == IDX_POST {
             
         } else if index == IDX_CONVERSATION {
-            APIS.startConversation()
+            APIS.openConversation()
         } else if index == IDX_FAVORITEMESSAGE {
             APIS.openFavoriteMessage()
         } else {

+ 88 - 62
NexilisLite/NexilisLite/Source/Utils.swift

@@ -67,6 +67,17 @@ public final class Utils {
         SecureUserDefaults.shared.set(value, forKey: "is_change_profile")
     }
     
+    static func setIconCenter(value: String){
+        SecureUserDefaults.shared.set(value, forKey: "pb_fb_icon_center_self")
+    }
+    
+    static func getIconCenter() -> String {
+        if let value: String = SecureUserDefaults.shared.value(forKey: "pb_fb_icon_center_self") {
+            return value
+        }
+        return ""
+    }
+    
     static func setIconCenterAnim2(value: String){
         SecureUserDefaults.shared.set(value, forKey: "pb_fb_icon_center_self_mode2")
     }
@@ -470,7 +481,7 @@ public final class Utils {
         if let value: String = SecureUserDefaults.shared.value(forKey: "fb_icon_with_bg") {
             return value
         }
-        return "1"
+        return "0"
     }
     
     static func setFBItemBg(value: String){
@@ -484,6 +495,17 @@ public final class Utils {
         return "1"
     }
     
+    static func setBEId(value: String){
+        SecureUserDefaults.shared.set(value, forKey: "be_id")
+    }
+    
+    static func getBEId() -> String {
+        if let value: String = SecureUserDefaults.shared.value(forKey: "be_id") {
+            return value
+        }
+        return ""
+    }
+    
     static func setDomainOpr(value: String){
         SecureUserDefaults.shared.set(value, forKey: "domain_opr")
     }
@@ -603,96 +625,100 @@ public final class Utils {
     public static func setValueInitialApp(data: String) {
         if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [[String: Any?]] {
             do {
-                for json in jsonArray {
-                    if Array(json.keys)[0] == "app_builder_url_first_tab" {
-                        Utils.setURLFirstTab(value: Array(json.values)[0] as! String)
+                let json = Array(jsonArray)[0]
+                for i in 0..<json.keys.count {
+                    if Array(json.keys)[i] == "app_builder_url_first_tab" {
+                        Utils.setURLFirstTab(value: Array(json.values)[i] as! String)
+                    }
+                    if Array(json.keys)[i] == "app_builder_url_third_tab" {
+                        Utils.setURLThirdTab(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_url_third_tab" {
-                        Utils.setURLThirdTab(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_custom_tab" {
+                        Utils.setCustomTab(cust: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_custom_tab" {
-                        Utils.setCustomTab(cust: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_url_base" {
+                        Utils.setURLBase(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_url_base" {
-                        Utils.setURLBase(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_url_qms" {
+                        Utils.setURLQMS(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_url_qms" {
-                        Utils.setURLQMS(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_icon_dock" {
+                        Utils.setIconDock(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_icon_dock" {
-                        Utils.setIconDock(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_icon_ss" {
+                        Utils.setIconSS(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_icon_ss" {
-                        Utils.setIconSS(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_background" {
+                        Utils.setBackground(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_background" {
-                        Utils.setBackground(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_url_privacy_policy" {
+                        Utils.setURLPrivacyPolicy(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_url_privacy_policy" {
-                        Utils.setURLPrivacyPolicy(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_enable_privacy_policy" {
+                        Utils.setEnablePrivacyPolicy(value: Array(json.values)[i] as! String == "1" ? true : false)
                     }
-                    if Array(json.keys)[0] == "app_builder_enable_privacy_policy" {
-                        Utils.setEnablePrivacyPolicy(value: Array(json.values)[0] as! String == "1" ? true : false)
+                    if Array(json.keys)[i] == "pb_fb_icon_center_self_mode2" {
+                        Utils.setIconCenterAnim2(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "pb_fb_icon_center_self_mode2" {
-                        Utils.setIconCenterAnim2(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "pb_fb_icon_center_self_mode4" {
+                        Utils.setIconCenterAnim4(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "pb_fb_icon_center_self_mode4" {
-                        Utils.setIconCenterAnim4(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_ac_theme" {
+                        Utils.setACTheme(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_ac_theme" {
-                        Utils.setACTheme(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_button_url" {
+                        Utils.setButtonURL(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_button_url" {
-                        Utils.setButtonURL(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_custom_buttons" {
+                        Utils.setCustomButtons(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_custom_buttons" {
-                        Utils.setCustomButtons(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_enable_mobile_builder" {
-                        Utils.setEnableMobileBuilder(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_enable_mobile_builder" {
+                        Utils.setEnableMobileBuilder(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_enable_mobile_builder" {
-                        Utils.setEnableMobileBuilder(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "fb_config_mode" {
+                        Utils.setConfigModeFB(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "fb_config_mode" {
-                        Utils.setConfigModeFB(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_button_icon" {
+                        Utils.setCustomFBIcon(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_button_icon" {
-                        Utils.setCustomFBIcon(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "fb_floating_anim" {
+                        Utils.setFloatingAnim(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "fb_floating_anim" {
-                        Utils.setFloatingAnim(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "fb_icon_with_bg" {
+                        Utils.setFBIconBg(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "fb_icon_with_bg" {
-                        Utils.setFBIconBg(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "fb_item_with_bg" {
+                        Utils.setFBItemBg(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "fb_item_with_bg" {
-                        Utils.setFBItemBg(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "user_agent" {
+                        Utils.setUserAgent(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "user_agent" {
-                        Utils.setUserAgent(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_background_light" {
+                        Utils.setBackgroundLight(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_background_light" {
-                        Utils.setBackgroundLight(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "app_builder_background_dark" {
+                        Utils.setBackgroundDark(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "app_builder_background_dark" {
-                        Utils.setBackgroundDark(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "sms_center" {
+                        Utils.setSMSCenter(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "sms_center" {
-                        Utils.setSMSCenter(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "whatsapp_center" {
+                        Utils.setWhatsappCenter(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "whatsapp_center" {
-                        Utils.setWhatsappCenter(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "call_center" {
+                        Utils.setCallCenter(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "call_center" {
-                        Utils.setCallCenter(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "enable_valid_trans" {
+                        Utils.setValidTrans(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "enable_valid_trans" {
-                        Utils.setValidTrans(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "chatbot_greetings" {
+                        Utils.setValidTrans(value: Array(json.values)[i] as! String)
                     }
-                    if Array(json.keys)[0] == "chatbot_greetings" {
-                        Utils.setValidTrans(value: Array(json.values)[0] as! String)
+                    if Array(json.keys)[i] == "fb_icon_center" {
+                        Utils.setIconCenter(value: Array(json.values)[i] as! String)
                     }
                 }
             } catch {

+ 2 - 1
NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift

@@ -405,7 +405,7 @@ class QmeraVideoViewController: UIViewController {
                         }
                     }
                 } else {
-                    Nexilis.ringtonePlayer?.play()
+                    Nexilis.ringbacktonePlayer?.play()
                     API.initiateCCall(sParty: dataPerson[0]["f_pin"]!, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView)
                 }
             } else {
@@ -590,6 +590,7 @@ class QmeraVideoViewController: UIViewController {
             } else {
                 API.csa(sTicketID: ticketId, nCamIdx: 1, nResIdx: 2, nVQuality: 4, ivRemoteView: listRemoteViewFix, ivLocalView: cameraView, ivRemoteZ: zoomView, bCameraOn: true)
             }
+            Nexilis.ringtonePlayer?.stop()
         }
         DispatchQueue.main.async {
             self.myImage.removeFromSuperview()

+ 1 - 1
NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -337,7 +337,7 @@ public class EditorGroup: UIViewController {
         
         if !isHistoryCC {
             let groupId = dataGroup["group_id"] as! String
-            let chatId = dataGroup["chat_id"] as! String
+            let chatId = dataTopic["chat_id"] as! String
             let dataGT: [String] = [groupId, chatId]
             SecureUserDefaults.shared.set(dataGT, forKey: "inEditorGroup")
             

+ 12 - 0
NexilisLite/NexilisLite/Source/View/Contact/ContactCallViewController.swift

@@ -145,6 +145,18 @@ class ContactCallViewController: UIViewController {
         
     }
     
+    override func viewDidAppear(_ animated: Bool) {
+        if (!isAddParticipantVideo) {
+            let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 16.0), NSAttributedString.Key.foregroundColor: UIColor.white]
+            let navBarAppearance = UINavigationBarAppearance()
+            navBarAppearance.configureWithOpaqueBackground()
+            navBarAppearance.backgroundColor = self.traitCollection.userInterfaceStyle == .dark ? .blackDarkMode : UIColor.mainColor
+            navBarAppearance.titleTextAttributes = attributes
+            navigationController?.navigationBar.standardAppearance = navBarAppearance
+            navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
+        }
+    }
+    
     func getData() {
         dataPerson.removeAll()
         let idMe = User.getMyPin() as String?

+ 3 - 6
StreamShield/StreamShield/Source/SecurityShield.swift

@@ -17,7 +17,7 @@ public class SecurityShield: NSObject {
     
     static var dispatch: DispatchGroup?
     
-    public static func check(appName: String, apiKey: String, activity: UIViewController) {
+    public static func check(appName: String, apiKey: String) {
         Preference.setAppId(value: appName)
         Preference.setAccount(value: apiKey)
         pull()
@@ -36,7 +36,6 @@ public class SecurityShield: NSObject {
             if let response = Service.writeSync(message: tmessage) {
                 if response.isOk() {
                     let dataResp = response.getBody(key: "A112")
-                    print("dataResp = \(dataResp)")
                     Process.check(dataSS: dataResp)
                 } else {
                     Process.check(dataSS: "")
@@ -339,11 +338,11 @@ private class Process: NSObject {
                 return
             }
             subCheck(12)
-        } else if typeSecurity == 11 {
+        } else if typeSecurity == 12 {
             if checkBehaviourAnalysis() {
                 return
             }
-            subCheck(12)
+            subCheck(13)
         }
     }
     
@@ -822,10 +821,8 @@ private class Process: NSObject {
 private class Service {
     static func writeSync(message: TMessageSS, timeout: Int = 15 * 1000) -> TMessageSS? {
         do {
-            print(">> SENDING MESSAGE >> ", message.toLogString())
             if let data = try API.sGetResponse(sRequest: message.pack(), lTimeout: timeout, bKeepTOResp: true) {
                 let response = TMessageSS(data: data)
-                print("<< RESPONSE MESSAGE << ", response.toLogString())
                 return response
             }
         } catch {