imporvements

This commit is contained in:
ryanzhao 2021-10-14 16:01:50 +11:00
parent a8b8207154
commit 3de81ef2a0
3 changed files with 9 additions and 15 deletions

View File

@ -12,6 +12,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
var shouldAnswer = false
var isMuted = false
var isVideoEnabled = false
var shouldRestartCamera = true
var conversationVC: ConversationVC? = nil
lazy var cameraManager: CameraManager = {
@ -181,7 +182,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
view.backgroundColor = .black
WebRTCSession.current = webRTCSession
setUpViewHierarchy()
cameraManager.prepare()
if shouldRestartCamera { cameraManager.prepare() }
touch(videoCapturer)
var contact: Contact?
Storage.read { transaction in
@ -192,9 +193,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
callInfoLabel.text = "Ringing..."
Storage.write { transaction in
self.webRTCSession.sendPreOffer(to: self.sessionID, using: transaction).done {
self.webRTCSession.sendOffer(to: self.sessionID, using: transaction).done {
self.minimizeButton.isHidden = false
}.retainUntilComplete()
self.webRTCSession.sendOffer(to: self.sessionID, using: transaction).retainUntilComplete()
}.retainUntilComplete()
}
answerButton.isHidden = true
@ -272,18 +271,20 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if (isVideoEnabled) { cameraManager.start() }
if (isVideoEnabled && shouldRestartCamera) { cameraManager.start() }
shouldRestartCamera = true
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
if (isVideoEnabled) { cameraManager.stop() }
if (isVideoEnabled && shouldRestartCamera) { cameraManager.stop() }
}
// MARK: Delegate
func webRTCIsConnected() {
DispatchQueue.main.async {
self.callInfoLabel.text = "Connected"
self.minimizeButton.isHidden = false
UIView.animate(withDuration: 0.5, delay: 1, options: [], animations: {
self.callInfoLabel.alpha = 0
}, completion: { _ in
@ -339,6 +340,7 @@ final class CallVC : UIViewController, WebRTCSessionDelegate {
}
@objc private func minimize() {
self.shouldRestartCamera = false
let miniCallView = MiniCallView(from: self)
miniCallView.show()
self.conversationVC?.showInputAccessoryView()

View File

@ -216,14 +216,6 @@ public final class NotificationServiceExtension : UNNotificationServiceExtension
private func handleSuccessForIncomingCall(for content: UNMutableNotificationContent) {
// TODO: poll for the real offer, play incoming call ring
if #available(iOSApplicationExtension 13.0, *) {
let request = BGAppRefreshTaskRequest(identifier: "com.loki-project.loki-messenger.refresh")
do {
try BGTaskScheduler.shared.submit(request)
} catch {
print("Could not schedule app refresh: \(error)")
}
}
contentHandler!(content)
}

View File

@ -7,7 +7,7 @@ public final class Vibration {
private var vibrationTimer: Timer?
public func startVibration() {
vibrationTimer = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: true) { _ in
vibrationTimer = Timer.scheduledTimer(withTimeInterval: 2, repeats: true) { _ in
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate)
}
}