alqindiirsyam 1 سال پیش
والد
کامیت
ff762b2f9a

+ 3 - 0
appbuilder-ios/AppBuilder/AppBuilder/FirstTabViewController.swift

@@ -88,6 +88,9 @@ class FirstTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
         if lang == "id" {
             intLang = 1
         }
+        if PrefsUtil.getURLFirstTab() != nil {
+            ViewController.sURL = PrefsUtil.getURLFirstTab()!
+        }
         switch(ViewController.sURL){
         case "0":
             address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main-only?f_pin=\(me ?? "")&lang=\(intLang)"

+ 3 - 0
appbuilder-ios/AppBuilder/AppBuilder/ThirdTabViewController.swift

@@ -94,6 +94,9 @@ class ThirdTabViewController: UIViewController, UIScrollViewDelegate, UIGestureR
             speechRecognizer = SFSpeechRecognizer(locale: Locale(identifier: "id"))
             intLang = 1
         }
+        if PrefsUtil.getURLThirdTab() != nil {
+            ViewController.tab3 = PrefsUtil.getURLThirdTab()!
+        }
         switch(ViewController.tab3){
         case "0":
             address = "\(PrefsUtil.getURLBase())nexilis/pages/tab1-main-only?f_pin=\(me ?? "")&lang=\(intLang)"

+ 1 - 58
appbuilder-ios/AppBuilder/AppBuilder/ViewController.swift

@@ -59,64 +59,7 @@ class ViewController: UITabBarController, UITabBarControllerDelegate, SettingMAB
     override func viewDidLoad() {
         super.viewDidLoad()
         DispatchQueue.main.async { [self] in
-            if let response = Nexilis.writeSync(message: getPrefs(key: ""), timeout: 5000) {
-                if response.mBodies[CoreMessage_TMessageKey.ERRCOD] == "00" {
-                    let data = response.getBody(key: CoreMessage_TMessageKey.DATA)
-                    if let json = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: []) as? [[String: Any?]] {
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_first_tab")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_third_tab")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_custom_tab")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_base")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_url_qms")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_icon_dock")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_icon_ss")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_background")
-                        UserDefaults.standard.removeObject(forKey: "app_builder_compressor")
-                        for j in json {
-                            if let firstTab = j["app_builder_url_first_tab"] as? String {
-                                PrefsUtil.setURLFirstTab(value: firstTab)
-                                ViewController.sURL = firstTab
-                            }
-                            if let thirdTab = j["app_builder_url_third_tab"] as? String {
-                                PrefsUtil.setURLThirdTab(value: thirdTab)
-                                ViewController.tab3 = thirdTab
-                            }
-                            if let customTab = j["app_builder_custom_tab"] as? String {
-                                PrefsUtil.setCustomTab(cust: customTab)
-                            }
-                            if let urlBase = j["app_builder_url_base"] as? String {
-                                PrefsUtil.setURLBase(value: urlBase)
-                            }
-                            if let urlQMS = j["app_builder_url_qms"] as? String {
-                                PrefsUtil.setURLQMS(value: urlQMS)
-                            }
-                            if let iconDock = j["app_builder_icon_dock"] as? String {
-                                PrefsUtil.setIconDock(value: iconDock)
-                            }
-                            if let iconSS = j["app_builder_icon_ss"] as? String {
-                                PrefsUtil.setIconSS(value: iconSS)
-                            }
-                            if let background = j["app_builder_background"] as? String {
-                                PrefsUtil.setBackground(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)
-                            }
-                            if let fb_icon_center_anim = j["fb_icon_center_anim"] as? String {
-                                Utils.setIconCenterAnim(value: fb_icon_center_anim)
-                            }
-                        }
-                        startView()
-                    }
-                } else {
-                    startView()
-                }
-            } else {
-                startView()
-            }
+            startView()
         }
     }
     

+ 65 - 67
appbuilder-ios/DigiXLite/DigiXLite/Source/DigiX.swift

@@ -171,83 +171,81 @@ public class DigiX: NSObject {
             DigiX.dispatch = nil
             
 //            DigiX.initiateAudio()
-            DispatchQueue.main.async {
-                if(!id.isEmpty && (UserDefaults.standard.string(forKey: "me") == nil)){
-                    if let response = DigiX.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
-                        id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
-                        let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
-                        Utils.setForceAnonymous(value: enable_signup)
-                        if(!id.isEmpty) {
-                            DigiX.changeUser(f_pin: id)
-                            UserDefaults.standard.setValue(id, forKey: "me")
-                        }
+            if(!id.isEmpty && (UserDefaults.standard.string(forKey: "me") == nil)){
+                if let response = DigiX.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
+                    id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
+                    let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
+                    Utils.setForceAnonymous(value: enable_signup)
+                    if(!id.isEmpty) {
+                        DigiX.changeUser(f_pin: id)
+                        UserDefaults.standard.setValue(id, forKey: "me")
                     }
                 }
+            }
 
-                if UserDefaults.standard.string(forKey: "apiKey") == nil {
-                    UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
-                }
-                
-                if let me = UserDefaults.standard.string(forKey: "me") {
-                    if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
-                        Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                            if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT * FROM BUDDY where f_pin = '\(me)' ") {
-                                if !cursorData.next() {
-                                    _ = DigiX.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: me))
-                                }
-                                cursorData.close()
-                            }
-                        })
-                        Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                            if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT image_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorData.next() {
-                                do {
-                                    let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
-                                    let file = documentDir.appendingPathComponent(cursorData.string(forColumnIndex: 0)!)
-                                    if !FileManager().fileExists(atPath: file.path) {
-                                        Download().startHTTP(forKey: cursorData.string(forColumnIndex: 0)!) { (name, progress) in}
-                                    }
-                                } catch {}
-                                cursorData.close()
+            if UserDefaults.standard.string(forKey: "apiKey") == nil {
+                UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
+            }
+            
+            if let me = UserDefaults.standard.string(forKey: "me") {
+                if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
+                    Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                        if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT * FROM BUDDY where f_pin = '\(me)' ") {
+                            if !cursorData.next() {
+                                _ = DigiX.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: me))
                             }
-                        })
-                    }
-                    getServiceBank()
-                    getPullWorkingArea()
-                    getPullGroupNoMember()
-                    delegate.onSuccess(userId: me)
-                    getPullDefaultCC()
-                    if showButton {
-                        DispatchQueue.main.async {
-                            var viewController = UIApplication.shared.windows.first?.rootViewController
-                            var notNull = false
-                            while !notNull {
-                                viewController = UIApplication.shared.windows.first?.rootViewController
-                                if viewController != nil {
-                                    notNull = true
+                            cursorData.close()
+                        }
+                    })
+                    Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                        if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT image_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorData.next() {
+                            do {
+                                let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+                                let file = documentDir.appendingPathComponent(cursorData.string(forColumnIndex: 0)!)
+                                if !FileManager().fileExists(atPath: file.path) {
+                                    Download().startHTTP(forKey: cursorData.string(forColumnIndex: 0)!) { (name, progress) in}
                                 }
+                            } catch {}
+                            cursorData.close()
+                        }
+                    })
+                }
+                getServiceBank()
+                getPullWorkingArea()
+                getPullGroupNoMember()
+                delegate.onSuccess(userId: me)
+                getPullDefaultCC()
+                if showButton {
+                    DispatchQueue.main.async {
+                        var viewController = UIApplication.shared.windows.first?.rootViewController
+                        var notNull = false
+                        while !notNull {
+                            viewController = UIApplication.shared.windows.first?.rootViewController
+                            if viewController != nil {
+                                notNull = true
                             }
-                            let fb = FloatingButton()
-                            if fromMAB {
-                                var vc = viewController
-                                if viewController is UINavigationController {
-                                    vc = (viewController as! UINavigationController).rootViewController
-                                }
-                                vc?.view.addSubview(fb)
-                                fb.mySettingDelegate = vc as? any SettingMABDelegate
-                            } else {
-                                viewController?.view.addSubview(fb)
+                        }
+                        let fb = FloatingButton()
+                        if fromMAB {
+                            var vc = viewController
+                            if viewController is UINavigationController {
+                                vc = (viewController as! UINavigationController).rootViewController
                             }
+                            vc?.view.addSubview(fb)
+                            fb.mySettingDelegate = vc as? any SettingMABDelegate
+                        } else {
+                            viewController?.view.addSubview(fb)
                         }
                     }
                 }
-                DigiX.destroyAll()
-                OutgoingThread.default.run()
-                
-                InquiryThread.default.run()
-                
-                if UIFont.systemFont(ofSize: 12).familyName == ".AppleSystemUIFont" {
-                    UIFont.libOverrideInitialize()
-                }
+            }
+            DigiX.destroyAll()
+            OutgoingThread.default.run()
+            
+            InquiryThread.default.run()
+            
+            if UIFont.systemFont(ofSize: 12).familyName == ".AppleSystemUIFont" {
+                UIFont.libOverrideInitialize()
             }
             //print(("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
         }

+ 46 - 0
appbuilder-ios/DigiXLite/DigiXLite/Source/IncomingThread.swift

@@ -171,6 +171,8 @@ class IncomingThread {
             askingForEndCall(message: message)
         } else if message.getCode() == CoreMessage_TMessageCode.GET_BATCH_GROUP_NO_MEMBERS {
             pushGroupNoMembers(message: message)
+        } else if message.getCode() == CoreMessage_TMessageCode.INIT_PREFS {
+            initPrefs(message: message)
         } else {
             //print(("unprocessed code", message.getCode())
             ack(message: message)
@@ -183,6 +185,50 @@ class IncomingThread {
     /**
      *
      */
+    private func initPrefs(message: TMessage) -> Void {
+        let data = message.getBody(key: CoreMessage_TMessageKey.DATA)
+        if !data.isEmpty {
+            if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
+                for json in jsonArray {
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_first_tab" {
+                        Utils.setURLFirstTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_third_tab" {
+                        Utils.setURLThirdTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_tab" {
+                        Utils.setCustomTab(cust: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_base" {
+                        Utils.setURLBase(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_qms" {
+                        Utils.setURLQMS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_dock" {
+                        Utils.setIconDock(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_ss" {
+                        Utils.setIconSS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background" {
+                        Utils.setBackground(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_privacy_policy" {
+                        Utils.setURLPrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_privacy_policy" {
+                        Utils.setEnablePrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String == "1" ? true : false)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_icon_center_anim" {
+                        Utils.setIconCenterAnim(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                }
+            }
+        }
+        ack(message: message)
+    }
+    
     private func askingForEndCall(message: TMessage) -> Void {
         if let packetId = message.mBodies[CoreMessage_TMessageKey.PACKET_ID] {
             _ = DigiX.responseString(packetId: packetId, message: "00")

+ 40 - 0
appbuilder-ios/DigiXLite/DigiXLite/Source/Utils.swift

@@ -61,6 +61,46 @@ public final class Utils {
         return dateFormatter.string(from: todaysDate as Date)
     }
     
+    static func setIconCenterAnim(value: String){
+        UserDefaults.standard.set(value, forKey: "fb_icon_center_anim")
+    }
+    
+    static func getIconCenterAnim() -> String? {
+        UserDefaults.standard.string(forKey: "fb_icon_center_anim")
+    }
+    
+    static func setURLFirstTab(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_first_tab")
+    }
+    
+    static func setURLThirdTab(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_third_tab")
+    }
+    static func setURLBase(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_base")
+    }
+    static func setURLQMS(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_qms")
+    }
+    static func setIconDock(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_icon_dock")
+    }
+    static func setIconSS(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_icon_ss")
+    }
+    static func setBackground(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_background")
+    }
+    static func setURLPrivacyPolicy(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_url_privacy_policy")
+    }
+    static func setEnablePrivacyPolicy(value: Bool){
+        UserDefaults.standard.set(value, forKey: "app_builder_enable_privacy_policy")
+    }
+    static func setCustomTab(cust: String){
+        UserDefaults.standard.set(cust, forKey: "custom_tab")
+    }
+    
 //    public static func getMD5(string: String) -> Data {
 //        let length = Int(CC_MD5_DIGEST_LENGTH)
 //        let messageData = string.data(using:.utf8)!

+ 8 - 4
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Chat/EditorGroup.swift

@@ -2955,7 +2955,9 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
         lastY = scrollView.contentOffset.y
-        checkNewMessage(tableView: self.tableChatView)
+        DispatchQueue.main.async { [self] in
+            checkNewMessage(tableView: self.tableChatView)
+        }
     }
     
     public func numberOfSections(in tableView: UITableView) -> Int {
@@ -3729,11 +3731,13 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
                     countRestImages.textColor = .white
                 }
             } else {
-                topMarginText.constant = topMarginText.constant + ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getHeightImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getWidthImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width
+                topMarginText.constant = topMarginText.constant + (getHeightImage < 40 ? 40 : getHeightImage)
                 
                 containerMessage.addSubview(imageThumb)
                 imageThumb.translatesAutoresizingMaskIntoConstraints = false
-                imageThumb.frame = CGRect(x: 0, y: 0, width: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width, height: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height)
+                imageThumb.frame = CGRect(x: 0, y: 0, width: getWidthImage, height: getHeightImage)
                 let data = queryMessageReply(message_id: reffChat)
                 if reffChat.isEmpty || data.count == 0 {
                     imageThumb.topAnchor.constraint(equalTo: containerMessage.topAnchor, constant: 37).isActive = true
@@ -3741,7 +3745,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
                 imageThumb.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 15).isActive = true
                 imageThumb.bottomAnchor.constraint(equalTo: messageText.topAnchor, constant: -5).isActive = true
                 imageThumb.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
-                imageThumb.widthAnchor.constraint(equalToConstant: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width).isActive = true
+                imageThumb.widthAnchor.constraint(equalToConstant: getWidthImage).isActive = true
                 imageThumb.layer.cornerRadius = 5.0
                 imageThumb.clipsToBounds = true
                 imageThumb.contentMode = .scaleAspectFill

+ 8 - 4
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Chat/EditorPersonal.swift

@@ -4104,7 +4104,9 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
         lastY = scrollView.contentOffset.y
-        checkNewMessage(tableView: self.tableChatView)
+        DispatchQueue.main.async { [self] in
+            checkNewMessage(tableView: self.tableChatView)
+        }
     }
     
     public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@@ -5010,11 +5012,13 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                     countRestImages.textColor = .white
                 }
             } else {
-                topMarginText.constant = topMarginText.constant + ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getHeightImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getWidthImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width
+                topMarginText.constant = topMarginText.constant + (getHeightImage < 40 ? 40 : getHeightImage)
                 
                 containerMessage.addSubview(imageThumb)
                 imageThumb.translatesAutoresizingMaskIntoConstraints = false
-                imageThumb.frame = CGRect(x: 0, y: 0, width: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width, height: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height)
+                imageThumb.frame = CGRect(x: 0, y: 0, width: getWidthImage, height: getHeightImage)
                 let data = queryMessageReply(message_id: reffChat)
                 if reffChat.isEmpty || data.count == 0 {
                     imageThumb.topAnchor.constraint(equalTo: containerMessage.topAnchor, constant: 15).isActive = true
@@ -5022,7 +5026,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                 imageThumb.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 15).isActive = true
                 imageThumb.bottomAnchor.constraint(equalTo: messageText.topAnchor, constant: -5).isActive = true
                 imageThumb.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
-                imageThumb.widthAnchor.constraint(equalToConstant: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width).isActive = true
+                imageThumb.widthAnchor.constraint(equalToConstant: getWidthImage).isActive = true
                 imageThumb.layer.cornerRadius = 5.0
                 imageThumb.clipsToBounds = true
                 imageThumb.contentMode = .scaleAspectFill

+ 4 - 2
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Chat/MessageInfo.swift

@@ -679,7 +679,9 @@ class MessageInfo: UIViewController, UITableViewDelegate, UITableViewDataSource
             let containerViewFile = UIView()
             
             if (!thumbChat.isEmpty) {
-                topMarginText.constant = topMarginText.constant + ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getHeightImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getWidthImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width
+                topMarginText.constant = topMarginText.constant + (getHeightImage < 40 ? 40 : getHeightImage)
                 
                 containerMessage.addSubview(imageThumb)
                 imageThumb.translatesAutoresizingMaskIntoConstraints = false
@@ -690,7 +692,7 @@ class MessageInfo: UIViewController, UITableViewDelegate, UITableViewDataSource
                 imageThumb.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 15).isActive = true
                 imageThumb.bottomAnchor.constraint(equalTo: messageText.topAnchor, constant: -5).isActive = true
                 imageThumb.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
-                imageThumb.widthAnchor.constraint(equalToConstant: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width).isActive = true
+                imageThumb.widthAnchor.constraint(equalToConstant: getWidthImage).isActive = true
                 imageThumb.layer.cornerRadius = 5.0
                 imageThumb.clipsToBounds = true
                 imageThumb.contentMode = .scaleAspectFill

+ 46 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/IncomingThread.swift

@@ -171,6 +171,8 @@ class IncomingThread {
             askingForEndCall(message: message)
         } else if message.getCode() == CoreMessage_TMessageCode.GET_BATCH_GROUP_NO_MEMBERS {
             pushGroupNoMembers(message: message)
+        } else if message.getCode() == CoreMessage_TMessageCode.INIT_PREFS {
+            initPrefs(message: message)
         } else {
             //print("unprocessed code", message.getCode())
             ack(message: message)
@@ -183,6 +185,50 @@ class IncomingThread {
     /**
      *
      */
+    private func initPrefs(message: TMessage) -> Void {
+        let data = message.getBody(key: CoreMessage_TMessageKey.DATA)
+        if !data.isEmpty {
+            if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
+                for json in jsonArray {
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_first_tab" {
+                        Utils.setURLFirstTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_third_tab" {
+                        Utils.setURLThirdTab(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_custom_tab" {
+                        Utils.setCustomTab(cust: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_base" {
+                        Utils.setURLBase(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_qms" {
+                        Utils.setURLQMS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_dock" {
+                        Utils.setIconDock(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_icon_ss" {
+                        Utils.setIconSS(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_background" {
+                        Utils.setBackground(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_url_privacy_policy" {
+                        Utils.setURLPrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "app_builder_enable_privacy_policy" {
+                        Utils.setEnablePrivacyPolicy(value: json[CoreMessage_TMessageKey.VALUE] as! String == "1" ? true : false)
+                    }
+                    if json[CoreMessage_TMessageKey.KEY] as! String == "fb_icon_center_anim" {
+                        Utils.setIconCenterAnim(value: json[CoreMessage_TMessageKey.VALUE] as! String)
+                    }
+                }
+            }
+        }
+        ack(message: message)
+    }
+    
     private func askingForEndCall(message: TMessage) -> Void {
         if let packetId = message.mBodies[CoreMessage_TMessageKey.PACKET_ID] {
             _ = Nexilis.responseString(packetId: packetId, message: "00")

+ 58 - 59
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -171,72 +171,70 @@ public class Nexilis: NSObject {
             Nexilis.dispatch = nil
             
 //            Nexilis.initiateAudio()
-            DispatchQueue.main.async {
-                if(!id.isEmpty && (UserDefaults.standard.string(forKey: "me") == nil)){
-                    if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
-                        id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
-                        let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
-                        Utils.setForceAnonymous(value: enable_signup)
-                        if(!id.isEmpty) {
-                            Nexilis.changeUser(f_pin: id)
-                            UserDefaults.standard.setValue(id, forKey: "me")
-                        }
+            if(!id.isEmpty && (UserDefaults.standard.string(forKey: "me") == nil)){
+                if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getSignUpApi(api: apiKey, p_pin: id), timeout: 30 * 1000){
+                    id = response.getBody(key: CoreMessage_TMessageKey.F_PIN, default_value: "")
+                    let enable_signup = (response.getBody(key: CoreMessage_TMessageKey.IS_ENABLED_ANONYMOUS, default_value: "0")) == "1"
+                    Utils.setForceAnonymous(value: enable_signup)
+                    if(!id.isEmpty) {
+                        Nexilis.changeUser(f_pin: id)
+                        UserDefaults.standard.setValue(id, forKey: "me")
                     }
                 }
+            }
 
-                if UserDefaults.standard.string(forKey: "apiKey") == nil {
-                    UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
-                }
-                
-                if let me = UserDefaults.standard.string(forKey: "me") {
-                    if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
-                        Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                            if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT * FROM BUDDY where f_pin = '\(me)' ") {
-                                if !cursorData.next() {
-                                    _ = Nexilis.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: me))
-                                }
-                                cursorData.close()
-                            }
-                        })
-                        Database.shared.database?.inTransaction({ (fmdb, rollback) in
-                            if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT image_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorData.next() {
-                                do {
-                                    let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
-                                    let file = documentDir.appendingPathComponent(cursorData.string(forColumnIndex: 0)!)
-                                    if !FileManager().fileExists(atPath: file.path) {
-                                        Download().startHTTP(forKey: cursorData.string(forColumnIndex: 0)!) { (name, progress) in}
-                                    }
-                                } catch {}
-                                cursorData.close()
+            if UserDefaults.standard.string(forKey: "apiKey") == nil {
+                UserDefaults.standard.setValue(apiKey, forKey: "apiKey")
+            }
+            
+            if let me = UserDefaults.standard.string(forKey: "me") {
+                if Utils.getForceAnonymous() || (!Utils.getForceAnonymous() && Utils.getSetProfile()) {
+                    Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                        if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT * FROM BUDDY where f_pin = '\(me)' ") {
+                            if !cursorData.next() {
+                                _ = Nexilis.write(message: CoreMessage_TMessageBank.getPostRegistration(p_pin: me))
                             }
-                        })
-                    }
-                    getServiceBank()
-                    getPullWorkingArea()
-                    getPullGroupNoMember()
-                    delegate.onSuccess(userId: me)
-                    getPullDefaultCC()
-                    if showButton {
-                        DispatchQueue.main.async {
-                            var viewController = UIApplication.shared.windows.first?.rootViewController
-                            var notNull = false
-                            while !notNull {
-                                viewController = UIApplication.shared.windows.first?.rootViewController
-                                if viewController != nil {
-                                    notNull = true
+                            cursorData.close()
+                        }
+                    })
+                    Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                        if let cursorData = Database.shared.getRecords(fmdb: fmdb, query: "SELECT image_id FROM GROUPZ where group_type = 1 AND official = 1"), cursorData.next() {
+                            do {
+                                let documentDir = try FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
+                                let file = documentDir.appendingPathComponent(cursorData.string(forColumnIndex: 0)!)
+                                if !FileManager().fileExists(atPath: file.path) {
+                                    Download().startHTTP(forKey: cursorData.string(forColumnIndex: 0)!) { (name, progress) in}
                                 }
+                            } catch {}
+                            cursorData.close()
+                        }
+                    })
+                }
+                getServiceBank()
+                getPullWorkingArea()
+                getPullGroupNoMember()
+                delegate.onSuccess(userId: me)
+                getPullDefaultCC()
+                if showButton {
+                    DispatchQueue.main.async {
+                        var viewController = UIApplication.shared.windows.first?.rootViewController
+                        var notNull = false
+                        while !notNull {
+                            viewController = UIApplication.shared.windows.first?.rootViewController
+                            if viewController != nil {
+                                notNull = true
                             }
-                            let fb = FloatingButton()
-                            if fromMAB {
-                                var vc = viewController
-                                if viewController is UINavigationController {
-                                    vc = (viewController as! UINavigationController).rootViewController
-                                }
-                                vc?.view.addSubview(fb)
-                                fb.mySettingDelegate = vc as? any SettingMABDelegate
-                            } else {
-                                viewController?.view.addSubview(fb)
+                        }
+                        let fb = FloatingButton()
+                        if fromMAB {
+                            var vc = viewController
+                            if viewController is UINavigationController {
+                                vc = (viewController as! UINavigationController).rootViewController
                             }
+                            vc?.view.addSubview(fb)
+                            fb.mySettingDelegate = vc as? any SettingMABDelegate
+                        } else {
+                            viewController?.view.addSubview(fb)
                         }
                     }
                 }
@@ -249,6 +247,7 @@ public class Nexilis: NSObject {
             if UIFont.systemFont(ofSize: 12).familyName == ".AppleSystemUIFont" {
                 UIFont.libOverrideInitialize()
             }
+            
             //print("MANIA \(UIFont.systemFont(ofSize: 12)) <> \(UIFont.italicSystemFont(ofSize: 12)) <> \(UIFont.boldSystemFont(ofSize: 12))")
         }
         catch {

+ 34 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/Utils.swift

@@ -54,14 +54,46 @@ public final class Utils {
         UserDefaults.standard.set(value, forKey: "is_change_profile")
     }
     
-    public static func setIconCenterAnim(value: String){
+    static func setIconCenterAnim(value: String){
         UserDefaults.standard.set(value, forKey: "fb_icon_center_anim")
     }
     
-    public static func getIconCenterAnim() -> String? {
+    static func getIconCenterAnim() -> String? {
         UserDefaults.standard.string(forKey: "fb_icon_center_anim")
     }
     
+    static func setURLFirstTab(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_first_tab")
+    }
+    
+    static func setURLThirdTab(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_third_tab")
+    }
+    static func setURLBase(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_base")
+    }
+    static func setURLQMS(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_url_qms")
+    }
+    static func setIconDock(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_icon_dock")
+    }
+    static func setIconSS(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_icon_ss")
+    }
+    static func setBackground(value: String) {
+        UserDefaults.standard.set(value, forKey: "app_builder_background")
+    }
+    static func setURLPrivacyPolicy(value: String){
+        UserDefaults.standard.set(value, forKey: "app_builder_url_privacy_policy")
+    }
+    static func setEnablePrivacyPolicy(value: Bool){
+        UserDefaults.standard.set(value, forKey: "app_builder_enable_privacy_policy")
+    }
+    static func setCustomTab(cust: String){
+        UserDefaults.standard.set(cust, forKey: "custom_tab")
+    }
+    
     public static func sGetCurrentDateTime(sFormat: String!) -> String! {
         let todaysDate = NSDate()
         let dateFormatter = DateFormatter()

+ 8 - 4
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -2955,7 +2955,9 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
         lastY = scrollView.contentOffset.y
-        checkNewMessage(tableView: self.tableChatView)
+        DispatchQueue.main.async { [self] in
+            checkNewMessage(tableView: self.tableChatView)
+        }
     }
     
     public func numberOfSections(in tableView: UITableView) -> Int {
@@ -3729,11 +3731,13 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
                     countRestImages.textColor = .white
                 }
             } else {
-                topMarginText.constant = topMarginText.constant + ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getHeightImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getWidthImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width
+                topMarginText.constant = topMarginText.constant + (getHeightImage < 40 ? 40 : getHeightImage)
                 
                 containerMessage.addSubview(imageThumb)
                 imageThumb.translatesAutoresizingMaskIntoConstraints = false
-                imageThumb.frame = CGRect(x: 0, y: 0, width: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width, height: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height)
+                imageThumb.frame = CGRect(x: 0, y: 0, width: getWidthImage, height: getHeightImage)
                 let data = queryMessageReply(message_id: reffChat)
                 if reffChat.isEmpty || data.count == 0 {
                     imageThumb.topAnchor.constraint(equalTo: containerMessage.topAnchor, constant: 37).isActive = true
@@ -3741,7 +3745,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
                 imageThumb.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 15).isActive = true
                 imageThumb.bottomAnchor.constraint(equalTo: messageText.topAnchor, constant: -5).isActive = true
                 imageThumb.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
-                imageThumb.widthAnchor.constraint(equalToConstant: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width).isActive = true
+                imageThumb.widthAnchor.constraint(equalToConstant: getWidthImage).isActive = true
                 imageThumb.layer.cornerRadius = 5.0
                 imageThumb.clipsToBounds = true
                 imageThumb.contentMode = .scaleAspectFill

+ 8 - 4
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -4104,7 +4104,9 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
     
     public func scrollViewDidScroll(_ scrollView: UIScrollView) {
         lastY = scrollView.contentOffset.y
-        checkNewMessage(tableView: self.tableChatView)
+        DispatchQueue.main.async { [self] in
+            checkNewMessage(tableView: self.tableChatView)
+        }
     }
     
     public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@@ -5010,11 +5012,13 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                     countRestImages.textColor = .white
                 }
             } else {
-                topMarginText.constant = topMarginText.constant + ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getHeightImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getWidthImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width
+                topMarginText.constant = topMarginText.constant + (getHeightImage < 40 ? 40 : getHeightImage)
                 
                 containerMessage.addSubview(imageThumb)
                 imageThumb.translatesAutoresizingMaskIntoConstraints = false
-                imageThumb.frame = CGRect(x: 0, y: 0, width: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width, height: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height)
+                imageThumb.frame = CGRect(x: 0, y: 0, width: getWidthImage, height: getHeightImage)
                 let data = queryMessageReply(message_id: reffChat)
                 if reffChat.isEmpty || data.count == 0 {
                     imageThumb.topAnchor.constraint(equalTo: containerMessage.topAnchor, constant: 15).isActive = true
@@ -5022,7 +5026,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
                 imageThumb.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 15).isActive = true
                 imageThumb.bottomAnchor.constraint(equalTo: messageText.topAnchor, constant: -5).isActive = true
                 imageThumb.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
-                imageThumb.widthAnchor.constraint(equalToConstant: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width).isActive = true
+                imageThumb.widthAnchor.constraint(equalToConstant: getWidthImage).isActive = true
                 imageThumb.layer.cornerRadius = 5.0
                 imageThumb.clipsToBounds = true
                 imageThumb.contentMode = .scaleAspectFill

+ 4 - 2
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/MessageInfo.swift

@@ -679,7 +679,9 @@ class MessageInfo: UIViewController, UITableViewDelegate, UITableViewDataSource
             let containerViewFile = UIView()
             
             if (!thumbChat.isEmpty) {
-                topMarginText.constant = topMarginText.constant + ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getHeightImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.height
+                let getWidthImage = ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width
+                topMarginText.constant = topMarginText.constant + (getHeightImage < 40 ? 40 : getHeightImage)
                 
                 containerMessage.addSubview(imageThumb)
                 imageThumb.translatesAutoresizingMaskIntoConstraints = false
@@ -690,7 +692,7 @@ class MessageInfo: UIViewController, UITableViewDelegate, UITableViewDataSource
                 imageThumb.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 15).isActive = true
                 imageThumb.bottomAnchor.constraint(equalTo: messageText.topAnchor, constant: -5).isActive = true
                 imageThumb.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
-                imageThumb.widthAnchor.constraint(equalToConstant: ListGroupImages.getImageSize(image: thumbChat, screenWidth: self.view.frame.size.width * 0.6, screenHeight: 305)!.width).isActive = true
+                imageThumb.widthAnchor.constraint(equalToConstant: getWidthImage).isActive = true
                 imageThumb.layer.cornerRadius = 5.0
                 imageThumb.clipsToBounds = true
                 imageThumb.contentMode = .scaleAspectFill