alqindiirsyam пре 3 месеци
родитељ
комит
32a9e5ffae

+ 7 - 4
NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -1358,7 +1358,7 @@ public class Nexilis: NSObject {
                     }
                 })
                 if !messageExist {
-                    Nexilis.saveMessageBot(textMessage: "*\(nameReq.trimmingCharacters(in: .whitespaces))*" + " " + "has requested to be your friend", blog_id: nameFpin, attachment_type: "61")
+                    Nexilis.saveMessageBot(textMessage: "*\(nameReq.trimmingCharacters(in: .whitespaces))*" + "~" + "has requested to be your friend", blog_id: nameFpin, attachment_type: "61")
                     NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
                 }
             }
@@ -1702,7 +1702,7 @@ public class Nexilis: NSObject {
                         if t == "-1" || t == "-2" {
                             continue
                         }
-                        if let cursorStatus = Database.shared.getRecords(fmdb: fmdb, query: "SELECT status FROM MESSAGE_STATUS where message_id = '\(t)'"), cursorStatus.next() {
+                        if let cursorStatus = Database.shared.getRecords(fmdb: fmdb, query: "SELECT status FROM MESSAGE_STATUS where message_id = '\(t)' and f_pin = '\(l_pin)'"), cursorStatus.next() {
                             let lastStatus = cursorStatus.int(forColumnIndex: 0)
                             if lastStatus < Int(status)! {
                                 if status == "3" {
@@ -1732,14 +1732,17 @@ public class Nexilis: NSObject {
                                 } else {
                                     _ = Database.shared.updateRecord(fmdb: fmdb, table: "MESSAGE_STATUS", cvalues: [
                                         "status" : status,
-                                        "last_update" : String(Date().currentTimeMillis())], _where: "message_id = '\(t)' and f_pin = '\(l_pin)'")
+                                        "longitude" : longitude,
+                                        "latitude" : latitude,
+                                        "location" : desc,
+                                        "last_update" : String(Date().currentTimeMillis())], _where: "message_id = '\(message_id)' and f_pin = '\(l_pin)'")
                                 }
                             }
                             cursorStatus.close()
                         }
                     }
                 } else {
-                    if let cursorStatus = Database.shared.getRecords(fmdb: fmdb, query: "SELECT status FROM MESSAGE_STATUS where message_id = '\(message_id)'"), cursorStatus.next() {
+                    if let cursorStatus = Database.shared.getRecords(fmdb: fmdb, query: "SELECT status FROM MESSAGE_STATUS where message_id = '\(message_id)' and f_pin = '\(l_pin)'"), cursorStatus.next() {
                         let lastStatus = cursorStatus.int(forColumnIndex: 0)
                         if lastStatus < Int(status)! {
                             if status == "3" {

+ 2 - 2
NexilisLite/NexilisLite/Source/Utils.swift

@@ -466,8 +466,8 @@ public final class Utils {
         } else if chat.attachmentFlag == "27" {
             return showNSMutableAttributedString(("📄 " + "Live Streaming".localized()))
         } else if chat.attachmentFlag == "61" {
-            let textName = chat.messageText.components(separatedBy: " ")[0]
-            let textAfterName = chat.messageText.components(separatedBy: "* ")[1]
+            let textName = chat.messageText.components(separatedBy: "~")[0]
+            let textAfterName = chat.messageText.components(separatedBy: "~")[1]
             return (textName + " " + textAfterName.localized()).richText(group_id: chat.pin)
         } else if chat.attachmentFlag == "26" {
             return showNSMutableAttributedString(("📄 " + "Seminar".localized()))

+ 56 - 6
NexilisLite/NexilisLite/Source/View/Call/QmeraAudioViewController.swift

@@ -18,6 +18,9 @@ class QmeraAudioViewController: UIViewController {
     static private var volumeView: MPVolumeView!
     static private var lastVolume: Float! = AVAudioSession.sharedInstance().outputVolume
     static private var bSpeakerPhone: Bool! = false
+    private var tempSpeaker = false
+    private var timerSpeaker: Timer?
+    private var canChangeSpeaker = false
     static private var isLoop = false
     
     
@@ -363,6 +366,12 @@ class QmeraAudioViewController: UIViewController {
         NotificationCenter.default.addObserver(self, selector: #selector(onStatusCall(_:)), name: NSNotification.Name(rawValue: Nexilis.listenerStatusCall), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(onReceiveMessage(notification:)), name: NSNotification.Name(rawValue: Nexilis.listenerReceiveChat), object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(onCallFCM(notification:)), name: NSNotification.Name(rawValue: Nexilis.callFCM), object: nil)
+        NotificationCenter.default.addObserver(
+                    self,
+                    selector: #selector(handleRouteChange),
+                    name: AVAudioSession.routeChangeNotification,
+                    object: nil
+                )
         
         if let u = self.user {
             self.users.append(u)
@@ -450,6 +459,39 @@ class QmeraAudioViewController: UIViewController {
         self.idCall = (User.getMyPin() ?? "") + CoreMessage_TMessageUtil.getTID()
     }
     
+    @objc func handleRouteChange(notification: Notification) {
+        guard let userInfo = notification.userInfo,
+              let reasonValue = userInfo[AVAudioSessionRouteChangeReasonKey] as? UInt,
+              let reason = AVAudioSession.RouteChangeReason(rawValue: reasonValue) else { return }
+
+        switch reason {
+        case .newDeviceAvailable:
+            print("🎧 Headphones plugged in")
+        case .oldDeviceUnavailable:
+            print("🎧 Headphones unplugged")
+        case .categoryChange:
+            DispatchQueue.main.async { [self] in
+                if !canChangeSpeaker {
+                    canChangeSpeaker = true
+                } else if APIS.checkAppStateisBackground() {
+                    if canChangeSpeaker {
+                        didSpeaker(sender: nil)
+                    }
+                }
+            }
+        case .override:
+            DispatchQueue.main.async { [self] in
+                if APIS.checkAppStateisBackground() {
+                    if canChangeSpeaker {
+                        didSpeaker(sender: nil)
+                    }
+                }
+            }
+        default:
+            print("🔄 Audio route changed: \(reason)")
+        }
+    }
+    
     override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
             if (keyPath! == "outputVolume") {
                 if let newKey = change?[NSKeyValueChangeKey.newKey] as? NSNumber {
@@ -776,11 +818,18 @@ class QmeraAudioViewController: UIViewController {
     }
     
     @objc func didSpeaker(sender: Any?) {
-        QmeraAudioViewController.bSpeakerPhone = !QmeraAudioViewController.bSpeakerPhone
-        speaker.isSelected = QmeraAudioViewController.bSpeakerPhone
-        DispatchQueue.global().async {
-            QmeraAudioViewController.turnSpeakerOn()
-        }
+        timerSpeaker?.invalidate()
+        tempSpeaker = !tempSpeaker
+        speaker.isSelected = tempSpeaker
+        timerSpeaker = Timer.scheduledTimer(withTimeInterval: 1, repeats: false, block: {_ in
+            if QmeraAudioViewController.bSpeakerPhone != self.tempSpeaker {
+                QmeraAudioViewController.bSpeakerPhone = !QmeraAudioViewController.bSpeakerPhone
+                self.tempSpeaker = QmeraAudioViewController.bSpeakerPhone
+                DispatchQueue.global().async {
+                    QmeraAudioViewController.turnSpeakerOn()
+                }
+            }
+        })
     }
     
     @objc func didMute(sender: Any?) {
@@ -1071,7 +1120,8 @@ class QmeraAudioViewController: UIViewController {
 //                    } while (QmeraAudioViewController.isLoop)
 //                }
                 DispatchQueue.main.async { [self] in
-                    QmeraAudioViewController.bSpeakerPhone = APIS.checkAppStateisBackground() ? false : true
+                    QmeraAudioViewController.bSpeakerPhone = true
+                    self.tempSpeaker = true
                     didSpeaker(sender: nil)
                 }
             } else if state == Nexilis.AUDIO_CALL_RINGING || (!ticketId.isEmpty && state == Nexilis.VIDEO_CALL_RINGING) {

+ 14 - 5
NexilisLite/NexilisLite/Source/View/Call/QmeraVideoViewController.swift

@@ -23,6 +23,8 @@ class QmeraVideoViewController: UIViewController {
     static private var volumeView: MPVolumeView!
     static private var lastVolume: Float! = AVAudioSession.sharedInstance().outputVolume
     static private var bSpeakerPhone: Bool! = false
+    private var tempSpeaker = false
+    private var timerSpeaker: Timer?
     static private var isLoop = false
     
     
@@ -1136,8 +1138,9 @@ class QmeraVideoViewController: UIViewController {
     
     func setSpeaker() {
         DispatchQueue.main.async {
-            QmeraVideoViewController.bSpeakerPhone = !QmeraVideoViewController.bSpeakerPhone
-            if (QmeraVideoViewController.bSpeakerPhone) {
+            self.timerSpeaker?.invalidate()
+            self.tempSpeaker = !self.tempSpeaker
+            if (self.tempSpeaker) {
                 self.buttonSpeaker.backgroundColor = .lightGray
                 self.buttonSpeaker.tintColor = .mainColor
                 self.buttonSpeaker.setImage(UIImage(systemName: "speaker.wave.2", withConfiguration: UIImage.SymbolConfiguration(pointSize: 30, weight: .medium, scale: .default)), for: .normal)
@@ -1146,9 +1149,15 @@ class QmeraVideoViewController: UIViewController {
                 self.buttonSpeaker.tintColor = .mainColor
                 self.buttonSpeaker.setImage(UIImage(systemName: "speaker.slash", withConfiguration: UIImage.SymbolConfiguration(pointSize: 30, weight: .medium, scale: .default)), for: .normal)
             }
-            DispatchQueue.global().async {
-                QmeraVideoViewController.turnSpeakerOn()
-            }
+            self.timerSpeaker = Timer.scheduledTimer(withTimeInterval: 1, repeats: false, block: {_ in
+                if QmeraVideoViewController.bSpeakerPhone != self.tempSpeaker {
+                    QmeraVideoViewController.bSpeakerPhone = !QmeraVideoViewController.bSpeakerPhone
+                    self.tempSpeaker = QmeraVideoViewController.bSpeakerPhone
+                    DispatchQueue.global().async {
+                        QmeraVideoViewController.turnSpeakerOn()
+                    }
+                }
+            })
         }
     }
     

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

@@ -1712,7 +1712,7 @@ public class EditorGroup: UIViewController, CLLocationManagerDelegate {
             
             self.constraintViewTextField.constant = 0
             self.constraintBottomContainerMultpileSelectSession.constant = 0
-            if self.contraintBottomMention.constant > 0 {
+            if self.contraintBottomMention.constant > 0 && self.keyboardHeightForMention != nil {
                 self.contraintBottomMention.constant = self.contraintBottomMention.constant - self.keyboardHeightForMention! + 60
             }
             keyboardHeightForMention = nil

+ 2 - 2
NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -6219,8 +6219,8 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource, AVAudioPla
             buttonDecline.heightAnchor.constraint(equalToConstant: 30).isActive = true
             buttonDecline.addTarget(self, action: #selector(addFriendReqAction), for: .touchUpInside)
             
-            let textName = textChat.components(separatedBy: " ")[0]
-            let textAfterName = textChat.components(separatedBy: "* ")[1]
+            let textName = textChat.components(separatedBy: "~")[0]
+            let textAfterName = textChat.components(separatedBy: "~")[1]
             messageRequestFriend = textName + " " + textAfterName.localized()
         } else {
             messageText.bottomAnchor.constraint(equalTo: containerMessage.bottomAnchor, constant: -15).isActive = true