소스 검색

change mechanism of FMS and HMS

alqindiirsyam 2 년 전
부모
커밋
3aec591ec8

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

@@ -117,7 +117,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
             if PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_FLOATING || PrefsUtil.getCpaasMode() == PrefsUtil.CPAAS_MODE_MIX {
                 showButton = true
             }
-            Nexilis.connect(apiKey: "***REPLACE***WITH***YOUR***ACCOUNT***", delegate: self, showButton: showButton, fromMAB: true) //AA6164AA13F0A6262677AC7443C37E3F6F0A342E8BEE84B700CB59C876166FE0(AWS) //36BCB99AA3885165E64ECC50591C4DA5072A25B2E7BAADA5A1B57E18737FF88C(CBN)
+            Nexilis.connect(apiKey: "AA6164AA13F0A6262677AC7443C37E3F6F0A342E8BEE84B700CB59C876166FE0", delegate: self, showButton: showButton, fromMAB: true) //AA6164AA13F0A6262677AC7443C37E3F6F0A342E8BEE84B700CB59C876166FE0(AWS) //36BCB99AA3885165E64ECC50591C4DA5072A25B2E7BAADA5A1B57E18737FF88C(CBN)
             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)

+ 1 - 1
appbuilder-ios/AppBuilder/AppBuilder/PrefsUtil.swift

@@ -13,7 +13,7 @@ class PrefsUtil {
     static let CPAAS_MODE_DOCKED = 1
     static let CPAAS_MODE_BURGER = 2
     static let CPAAS_MODE_MIX = 4
-    static let DEFAULT_CPAAS_MODE = CPAAS_MODE_DOCKED
+    static let DEFAULT_CPAAS_MODE = CPAAS_MODE_FLOATING
     
     static func getCpaasMode() -> Int {
         let mode = UserDefaults.standard.integer(forKey: "cpaas_mode")

+ 5 - 0
appbuilder-ios/NexilisLite/NexilisLite/Resource/id.lproj/Localizable.strings

@@ -199,3 +199,8 @@
 "Old Password" = "Kata sandi lama";
 "New Password" = "Kata sandi baru";
 "added you as friend" = "menambahkan anda sebagai teman";
+"Old password can't be empty" = "Kata sandi lama tidak boloh kosong";
+"Old password min 6 character" = "Kata sandi lama min 6 karakter";
+"New password can't be empty" = "Kata sandi baru tidak boleh kosong";
+"New password min 6 character" = "Kata sandi baru min 6 karakter";
+"Successfully changed password" = "Berhasil mengubah kata sandi";

+ 11 - 10
appbuilder-ios/NexilisLite/NexilisLite/Source/IncomingThread.swift

@@ -157,13 +157,12 @@ class IncomingThread {
     /**
      *
      */
-    var floating: FloatingNotificationBanner!
     
     private func makeNotifAddFriend(message: TMessage) {
         let data  = message.getBody(key: CoreMessage_TMessageKey.DATA)
         if let jsonArray = try! JSONSerialization.jsonObject(with: data.data(using: String.Encoding.utf8)!, options: JSONSerialization.ReadingOptions()) as? [AnyObject] {
             for json in jsonArray {
-                DispatchQueue.main.async { [self] in
+                DispatchQueue.main.async {
                     let container = UIView()
                     container.backgroundColor = .gray
                     let profileImage = UIImageView()
@@ -183,19 +182,21 @@ class IncomingThread {
                     NSLayoutConstraint.activate([
                         title.leadingAnchor.constraint(equalTo: profileImage.trailingAnchor, constant: 8.0),
                         title.centerYAnchor.constraint(equalTo: container.centerYAnchor),
+                        title.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant: -8.0)
                     ])
                     title.font = UIFont.systemFont(ofSize: 14)
                     let firstname = CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.FIRST_NAME)
                     let lastname = CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.LAST_NAME)
                     title.text = (firstname + " " + lastname).trimmingCharacters(in: .whitespaces) + " " + "added you as friend".localized()
                     title.textColor = .white
+                    title.numberOfLines = 0
                     
-                    if floating != nil {
-                        floating.dismiss()
+                    if Nexilis.shared.floating != nil {
+                        Nexilis.shared.floating.dismiss()
                     }
-                    floating = FloatingNotificationBanner(customView: container)
-                    floating.bannerHeight = 100.0
-                    floating.transparency = 0.9
+                    Nexilis.shared.floating = FloatingNotificationBanner(customView: container)
+                    Nexilis.shared.floating.bannerHeight = 100.0
+                    Nexilis.shared.floating.transparency = 0.9
                     
                     let profile = CoreMessage_TMessageUtil.getString(json: json, key: CoreMessage_TMessageKey.THUMB_ID)
                     if profile != "" {
@@ -212,10 +213,10 @@ class IncomingThread {
                                         return
                                     }
                                     
-                                    DispatchQueue.main.async { [self] in
+                                    DispatchQueue.main.async {
                                         profileImage.image = UIImage(contentsOfFile: file.path)
                                         profileImage.backgroundColor = .clear
-                                        floating.show(queuePosition: .front, bannerPosition: .top, queue: NotificationBannerQueue(maxBannersOnScreenSimultaneously: 1), on: nil, edgeInsets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 0, right: 8.0), cornerRadius: 8.0, shadowColor: .clear, shadowOpacity: .zero, shadowBlurRadius: .zero, shadowCornerRadius: .zero, shadowOffset: .zero, shadowEdgeInsets: nil)
+                                        Nexilis.shared.floating.show(queuePosition: .front, bannerPosition: .top, queue: NotificationBannerQueue(maxBannersOnScreenSimultaneously: 1), on: nil, edgeInsets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 0, right: 8.0), cornerRadius: 8.0, shadowColor: .clear, shadowOpacity: .zero, shadowBlurRadius: .zero, shadowCornerRadius: .zero, shadowOffset: .zero, shadowEdgeInsets: nil)
                                         return
                                     }
                                 }
@@ -229,7 +230,7 @@ class IncomingThread {
                         profileImage.backgroundColor = .lightGray
                         profileImage.tintColor = .white
                     }
-                    floating.show(queuePosition: .front, bannerPosition: .top, queue: NotificationBannerQueue(maxBannersOnScreenSimultaneously: 1), on: nil, edgeInsets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 0, right: 8.0), cornerRadius: 8.0, shadowColor: .clear, shadowOpacity: .zero, shadowBlurRadius: .zero, shadowCornerRadius: .zero, shadowOffset: .zero, shadowEdgeInsets: nil)
+                    Nexilis.shared.floating.show(queuePosition: .front, bannerPosition: .top, queue: NotificationBannerQueue(maxBannersOnScreenSimultaneously: 1), on: nil, edgeInsets: UIEdgeInsets(top: 8.0, left: 8.0, bottom: 0, right: 8.0), cornerRadius: 8.0, shadowColor: .clear, shadowOpacity: .zero, shadowBlurRadius: .zero, shadowCornerRadius: .zero, shadowOffset: .zero, shadowEdgeInsets: nil)
                 }
             }
         }

+ 8 - 5
appbuilder-ios/NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -1440,6 +1440,10 @@ public class Nexilis: NSObject {
     
     weak open var connectionDelegate: ConnectionDelegate?
     
+    var floating: FloatingNotificationBanner!
+    
+    var stateUnfriend = ""
+    
 }
 
 public protocol LoginDelegate: NSObjectProtocol {
@@ -1535,14 +1539,14 @@ extension Nexilis: CallDelegate {
             let idMe = UserDefaults.standard.string(forKey: "me")!
             let myData = User.getData(pin: idMe)
             let onGoingCC = UserDefaults.standard.string(forKey: "onGoingCC") ?? ""
-            if myData?.offline_mode == "1" {
+            let deviceId = message.split(separator: ",")[0]
+            if myData?.offline_mode == "1" || self.stateUnfriend == deviceId {
                 Nexilis.startAudio(nMode: 1, bSpeakerOn: false)
                 DispatchQueue.main.asyncAfter(deadline: .now() + 0.5, execute: {
                     API.terminateCall(sParty: nil)
                 })
                 return
             }
-            let deviceId = message.split(separator: ",")[0]
             var isShowAlert: Double?
             let canShow = UIApplication.shared.visibleViewController
             if canShow != nil && !(canShow is UINavigationController) {
@@ -1689,7 +1693,6 @@ extension Nexilis: CallDelegate {
 }
 
 var previewItem : NSURL?
-var floating: FloatingNotificationBanner!
 
 extension Nexilis: MessageDelegate {
     public func onReceiveComment(message: TMessage) {
@@ -2733,7 +2736,7 @@ extension Nexilis: MessageDelegate {
                 if nameUser == nil && threadIdentifier == "-999" {
                     nameUser = "Bot"
                 }
-                DispatchQueue.main.async {
+                DispatchQueue.main.async { [self] in
                     let container = UIView()
                     container.backgroundColor = .gray
                     let profileImage = UIImageView()
@@ -2800,7 +2803,7 @@ extension Nexilis: MessageDelegate {
                                         return
                                     }
                                     
-                                    DispatchQueue.main.async {
+                                    DispatchQueue.main.async { [self] in
                                         profileImage.image = UIImage(contentsOfFile: file.path)
                                         profileImage.backgroundColor = .clear
                                         if !onGoingCC.isEmpty {

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraAudioViewController.swift

@@ -642,7 +642,7 @@ class QmeraAudioViewController: UIViewController {
                             self.end.isEnabled = false
                             self.invite.isEnabled = false
                             self.speaker.isEnabled = false
-                            let controller = self.presentingViewController?.presentedViewController
+                            let controller = self.presentedViewController
                             if controller != nil {
                                 controller!.dismiss(animated: true)
                             }

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift

@@ -1054,7 +1054,7 @@ class QmeraVideoViewController: UIViewController {
                     self.vcTimer.invalidate()
                     self.labelTimerVC.text = "Video call is over".localized()
                     _ = Nexilis.getWhiteboardDelegate()?.terminate()
-                    let controller = self.presentingViewController?.presentedViewController
+                    let controller = self.presentedViewController
                     if controller != nil {
                         controller!.dismiss(animated: true)
                     }

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Contact/ContactCallViewController.swift

@@ -98,7 +98,7 @@ class ContactCallViewController: UIViewController {
         searchController.searchBar.placeholder = "Search".localized()
         
         navigationItem.searchController = searchController
-        navigationItem.hidesSearchBarWhenScrolling = true
+        navigationItem.hidesSearchBarWhenScrolling = false
         
         definesPresentationContext = true
         

+ 1 - 1
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController.swift

@@ -143,7 +143,7 @@ class ContactChatViewController: UITableViewController {
         searchController.searchBar.placeholder = "Search".localized()
         
         navigationItem.searchController = searchController
-        navigationItem.hidesSearchBarWhenScrolling = true
+        navigationItem.hidesSearchBarWhenScrolling = false
         
         definesPresentationContext = true
         

+ 4 - 0
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ProfileViewController.swift

@@ -489,6 +489,7 @@ public class ProfileViewController: UITableViewController {
             video.isEnabled = false
             message.isEnabled = false
         }
+        Nexilis.shared.stateUnfriend = self.data
         let alert = UIAlertController(title: "", message: "Are you sure to unfriend".localized() + " \(self.user!.fullName)", preferredStyle: .alert)
         alert.addAction(UIAlertAction(title: "Cancel".localized(), style: UIAlertAction.Style.default, handler: {(_) in
             if self.call != nil {
@@ -496,6 +497,7 @@ public class ProfileViewController: UITableViewController {
                 self.video.isEnabled = true
                 self.message.isEnabled = true
             }
+            Nexilis.shared.stateUnfriend = ""
         } ))
         alert.addAction(UIAlertAction(title: "Delete".localized(), style: .destructive, handler: {(_) in
             Nexilis.showLoader()
@@ -521,6 +523,7 @@ public class ProfileViewController: UITableViewController {
                                     }
                                     self.navigationController?.popToRootViewController(animated: true)
                                 }
+                                Nexilis.shared.stateUnfriend = ""
                             })
                         })
                     } else {
@@ -529,6 +532,7 @@ public class ProfileViewController: UITableViewController {
                             self.video.isEnabled = true
                             self.message.isEnabled = true
                         }
+                        Nexilis.shared.stateUnfriend = ""
                         Nexilis.hideLoader(completion: {})
                         let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
                         imageView.tintColor = .white

+ 24 - 66
src/mainPalio4.py

@@ -439,11 +439,19 @@ def change_certificate(path_dest, key, keyfile, keytool):
     with open(build_gradle, "w") as f:
         f.write(replaced)
 
-def change_huawei_file(path_dest, huawei_file, package):
+def change_huawei_file(path_dest, huawei_file, package_id):
     huaweifile_name = "agconnect-services.json"
     huaweifile_path = os.path.join(path_dest, "app/{}".format(huaweifile_name))
     if huawei_file:
         huawei_file.save(huaweifile_path)
+        path_package_id = package_id.replace(".", "/")
+        code_path = "app/src/main/java/"
+        main_code_path = os.path.join(path_dest, code_path, path_package_id, "MAB.java")
+        with open(main_code_path, "r") as f:
+            file_source = f.read()
+        replaced = file_source.replace('isHMSEnabled = false', 'isHMSEnabled = true')
+        with open(main_code_path, "w") as f:
+            f.write(replaced)
     else:
         gradle = os.path.join(path_dest, "build.gradle")
         with open(gradle, "r") as f:
@@ -463,65 +471,17 @@ def change_huawei_file(path_dest, huawei_file, package):
                     continue
                 else:
                     f.write(line)
-        manifest_path = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
-        with open(manifest_path, "r") as f:
-            lines = f.readlines()
-        with open(manifest_path, "w") as f:
-            counter = 0
-            for line in lines:
-                if counter == 0:
-                    if "<!-- huawei -->" in line:
-                        counter = 11
-                        continue
-                    else:
-                        f.write(line)
-                else:
-                    counter = counter - 1
-        path_package_id = package.replace(".", "/")
-        push_service_file = os.path.join(path_dest, "app/src/main/java",path_package_id,"MyPushService.java")
-        os.remove(push_service_file)
-
-def change_fms_file(path_dest, fms_file, package):
-    fmsfile_name = "google-services.json"
-    fmsfile_path = os.path.join(path_dest, "app/{}".format(fmsfile_name))
-    if fms_file:
-        fms_file.save(fmsfile_path)
-    else:
-        gradle = os.path.join(path_dest, "build.gradle")
-        with open(gradle, "r") as f:
-            lines = f.readlines()
-        with open(gradle, "w") as f:
-            for line in lines:
-                if "//FMS" in line:
-                    continue
-                else:
-                    f.write(line)
-        gradle_app = os.path.join(path_dest, "app/build.gradle")
-        with open(gradle_app, "r") as f:
-            lines = f.readlines()
-        with open(gradle_app, "w") as f:
-            for line in lines:
-                if "//FMS" in line:
-                    continue
-                else:
-                    f.write(line)
-        manifest_path = os.path.join(path_dest, "app/src/main/AndroidManifest.xml")
-        with open(manifest_path, "r") as f:
-            lines = f.readlines()
-        with open(manifest_path, "w") as f:
-            counter = 0
-            for line in lines:
-                if counter == 0:
-                    if "<!-- FMS -->" in line:
-                        counter = 13
-                        continue
-                    else:
-                        f.write(line)
-                else:
-                    counter = counter - 1
-        path_package_id = package.replace(".", "/")
-        push_service_file = os.path.join(path_dest, "app/src/main/java",path_package_id,"MyPushServiceFMS.java")
-        os.remove(push_service_file)
+
+def change_fms_file(path_dest, fms_enable, package_id):
+    if fms_enable == 1:
+        path_package_id = package_id.replace(".", "/")
+        code_path = "app/src/main/java/"
+        main_code_path = os.path.join(path_dest, code_path, path_package_id, "MAB.java")
+        with open(main_code_path, "r") as f:
+            file_source = f.read()
+        replaced = file_source.replace('isFMSEnabled = false', 'isFMSEnabled = true')
+        with open(main_code_path, "w") as f:
+            f.write(replaced)
 
 def run_build(path_dest):
     gradlew = os.path.join(path_dest, "gradlew")
@@ -590,7 +550,7 @@ def build_apk():
         url = None
         keystore = None
         huawei_file = None
-        fms_file = None
+        fms_enable = 0
         key_exists = False
         # tabs = ["1", "2", "3", "4"]
         fb_order = "1,2,3,4,5"
@@ -661,10 +621,8 @@ def build_apk():
             elif 'huawei_file' in request.form:
                 huawei_file = request.form['huawei_file']
 
-            if 'fms_file' in request.files:
-                fms_file = request.files['fms_file']
-            elif 'fms_file' in request.form:
-                fms_file = request.form['fms_file']
+            if 'fms_enable' in request.form:
+                fms_enable = int(request.form['fms_enable'])
 
             if 'alias' in request.form:
                 if request.form['alias']:
@@ -784,7 +742,7 @@ def build_apk():
             change_access(path_dest, access_model, package_id)
             change_tab(path_dest, tabs, tab_icon, package_id, tab3_mode, tab_amount)
             change_huawei_file(path_dest, huawei_file, package_id)
-            change_fms_file(path_dest, fms_file, package_id)
+            change_fms_file(path_dest, fms_enable, package_id)
         except BaseException as e:
             vprint(traceback.format_exc())
             return {"status": "2", "message": "Process failure\n{}\n".format(str(e))}