From d90861b5f3c32d6bbf552d0abd3b58956dcd96cf Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 6 Jan 2026 16:20:00 +0100 Subject: [PATCH] Cancel search when making reply/edit/forward action on a message --- .../ui/main/chat/fragment/ConversationFragment.kt | 14 ++++++++++---- .../layout/chat_conversation_participants_area.xml | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt index 5ff131e7d..f29e9ae6c 100644 --- a/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt +++ b/app/src/main/java/org/linphone/ui/main/chat/fragment/ConversationFragment.kt @@ -470,9 +470,9 @@ open class ConversationFragment : SlidingPaneChildFragment() { layoutManager.stackFromEnd = true binding.eventsList.layoutManager = layoutManager - binding.sendArea.participants.participants.setHasFixedSize(true) + binding.sendArea.participants.participantsList.setHasFixedSize(true) val participantsLayoutManager = LinearLayoutManager(requireContext()) - binding.sendArea.participants.participants.layoutManager = participantsLayoutManager + binding.sendArea.participants.participantsList.layoutManager = participantsLayoutManager val callbacks = RecyclerViewSwipeUtilsCallback( R.drawable.reply, @@ -494,6 +494,7 @@ open class ConversationFragment : SlidingPaneChildFragment() { if (chatMessageModel.hasBeenRetracted.value == true) { // Don't allow to reply to retracted messages // TODO: notify user? } else { + viewModel.closeSearchBar() sendMessageViewModel.replyToMessage(chatMessageModel) // Open keyboard & focus edit text binding.sendArea.messageToSend.showKeyboard() @@ -775,8 +776,8 @@ open class ConversationFragment : SlidingPaneChildFragment() { sendMessageViewModel.participants.observe(viewLifecycleOwner) { participantsAdapter.submitList(it) - if (binding.sendArea.participants.participants.adapter != participantsAdapter) { - binding.sendArea.participants.participants.adapter = participantsAdapter + if (binding.sendArea.participants.participantsList.adapter != participantsAdapter) { + binding.sendArea.participants.participantsList.adapter = participantsAdapter } } @@ -896,6 +897,7 @@ open class ConversationFragment : SlidingPaneChildFragment() { it.consume { val model = messageLongPressViewModel.messageModel.value if (model != null) { + viewModel.closeSearchBar() sendMessageViewModel.editMessage(model) // Open keyboard & focus edit text @@ -912,6 +914,7 @@ open class ConversationFragment : SlidingPaneChildFragment() { it.consume { val model = messageLongPressViewModel.messageModel.value if (model != null) { + viewModel.closeSearchBar() sendMessageViewModel.replyToMessage(model) // Open keyboard & focus edit text binding.sendArea.messageToSend.showKeyboard() @@ -938,6 +941,9 @@ open class ConversationFragment : SlidingPaneChildFragment() { it.consume { val model = messageLongPressViewModel.messageModel.value if (model != null) { + viewModel.closeSearchBar() + sendMessageViewModel.cancelReply() + // Remove observer before setting the message to forward // as we don't want to forward it in this chat room sharedViewModel.messageToForwardEvent.removeObservers(viewLifecycleOwner) diff --git a/app/src/main/res/layout/chat_conversation_participants_area.xml b/app/src/main/res/layout/chat_conversation_participants_area.xml index cfb8c21f5..86e353e04 100644 --- a/app/src/main/res/layout/chat_conversation_participants_area.xml +++ b/app/src/main/res/layout/chat_conversation_participants_area.xml @@ -36,7 +36,7 @@ app:layout_constraintStart_toStartOf="parent" />