From dcaec4b2a8cfd28769ed207a9f7f0ae658b2efd7 Mon Sep 17 00:00:00 2001 From: Ryan ZHAO <> Date: Wed, 15 Jan 2025 15:14:23 +1100 Subject: [PATCH] fix an keyboard issue of Calls --- .../Calls/Call Management/SessionCallManager+Action.swift | 4 ++-- Session/Calls/Call Management/SessionCallManager.swift | 1 + Session/Calls/Views & Modals/IncomingCallBanner.swift | 4 ++-- Session/Conversations/ConversationVC+Interaction.swift | 5 +++++ Session/Conversations/ConversationVC.swift | 1 + Session/Conversations/Input View/InputView.swift | 8 ++++++++ Session/Meta/AppDelegate.swift | 4 ++-- 7 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Session/Calls/Call Management/SessionCallManager+Action.swift b/Session/Calls/Call Management/SessionCallManager+Action.swift index 11c249ebe..684365071 100644 --- a/Session/Calls/Call Management/SessionCallManager+Action.swift +++ b/Session/Calls/Call Management/SessionCallManager+Action.swift @@ -28,8 +28,8 @@ extension SessionCallManager { let callVC = CallVC(for: call) if let conversationVC = presentingVC as? ConversationVC { callVC.conversationVC = conversationVC - conversationVC.inputAccessoryView?.isHidden = true - conversationVC.inputAccessoryView?.alpha = 0 + conversationVC.resignFirstResponder() + conversationVC.hideInputAccessoryView() } presentingVC.present(callVC, animated: true) { diff --git a/Session/Calls/Call Management/SessionCallManager.swift b/Session/Calls/Call Management/SessionCallManager.swift index 9f1718b88..cf8f9f2d9 100644 --- a/Session/Calls/Call Management/SessionCallManager.swift +++ b/Session/Calls/Call Management/SessionCallManager.swift @@ -246,6 +246,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol { { let callVC = CallVC(for: call) callVC.conversationVC = conversationVC + conversationVC.resignFirstResponder() conversationVC.hideInputAccessoryView() presentingVC.present(callVC, animated: true, completion: nil) } diff --git a/Session/Calls/Views & Modals/IncomingCallBanner.swift b/Session/Calls/Views & Modals/IncomingCallBanner.swift index 3c41890f0..296f96922 100644 --- a/Session/Calls/Views & Modals/IncomingCallBanner.swift +++ b/Session/Calls/Views & Modals/IncomingCallBanner.swift @@ -204,8 +204,8 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate { let callVC = CallVC(for: self.call) if let conversationVC = (presentingVC as? TopBannerController)?.wrappedViewController() as? ConversationVC { callVC.conversationVC = conversationVC - conversationVC.inputAccessoryView?.isHidden = true - conversationVC.inputAccessoryView?.alpha = 0 + conversationVC.resignFirstResponder() + conversationVC.hideInputAccessoryView() } presentingVC.present(callVC, animated: true) { [weak self] in diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index c1cf8409b..d53296a62 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -807,6 +807,8 @@ extension ConversationVC: } return } + self.isKeyboardVisible = self.snInputView.isKeyboardVisible + self.inputAccessoryView?.resignFirstResponder() self.inputAccessoryView?.isHidden = true self.inputAccessoryView?.alpha = 0 } @@ -821,6 +823,9 @@ extension ConversationVC: UIView.animate(withDuration: 0.25, animations: { self.inputAccessoryView?.isHidden = false self.inputAccessoryView?.alpha = 1 + if self.isKeyboardVisible { + self.inputAccessoryView?.becomeFirstResponder() + } }) } diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index eaa2c9e6c..620bdd63a 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -22,6 +22,7 @@ final class ConversationVC: BaseVC, LibSessionRespondingViewController, Conversa private var isAutoLoadingNextPage: Bool = false private var isLoadingMore: Bool = false var isReplacingThread: Bool = false + var isKeyboardVisible: Bool = false /// This flag indicates whether the thread data has been reloaded after a disappearance (it defaults to true as it will /// never have disappeared before - this is only needed for value observers since they run asynchronously) diff --git a/Session/Conversations/Input View/InputView.swift b/Session/Conversations/Input View/InputView.swift index 21bb2263c..2a47a44d2 100644 --- a/Session/Conversations/Input View/InputView.swift +++ b/Session/Conversations/Input View/InputView.swift @@ -141,6 +141,10 @@ final class InputView: UIView, InputViewButtonDelegate, InputTextViewDelegate, M }() private lazy var additionalContentContainer = UIView() + + public var isKeyboardVisible: Bool { + inputTextView.isFirstResponder + } // MARK: - Initialization @@ -446,6 +450,10 @@ final class InputView: UIView, InputViewButtonDelegate, InputTextViewDelegate, M override func resignFirstResponder() -> Bool { inputTextView.resignFirstResponder() } + + override func becomeFirstResponder() -> Bool { + inputTextView.becomeFirstResponder() + } func handleLongPress(_ gestureRecognizer: UITapGestureRecognizer) { // Not relevant in this case diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 0dc65b025..6415a28c5 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -904,8 +904,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD conversationVC.viewModel.threadData.threadId == call.sessionId { callVC.conversationVC = conversationVC - conversationVC.inputAccessoryView?.isHidden = true - conversationVC.inputAccessoryView?.alpha = 0 + conversationVC.resignFirstResponder() + conversationVC.hideInputAccessoryView() } presentingVC.present(callVC, animated: true, completion: nil)