diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt index b7e3984909..7c39f4bd97 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt @@ -650,6 +650,7 @@ class ConversationFragment : } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + viewModel.resetBackPressedState() binding.toolbar.isBackInvokedCallbackEnabled = false binding.root.setUseWindowTypes(args.conversationScreenType == ConversationScreenType.NORMAL && !resources.getWindowSizeClass().isSplitPane()) if (args.conversationScreenType == ConversationScreenType.BUBBLE) { @@ -1042,7 +1043,14 @@ class ConversationFragment : state.isInActionMode -> finishActionMode() - state.isMediaKeyboardShowing -> container.hideInput() + state.isMediaKeyboardShowing -> { + if (container.isInputShowing) { + container.hideInput() + } else { + Log.d(TAG, "handleBackPressed() - media keyboard state was stale, clearing") + viewModel.setIsMediaKeyboardShowing(false) + } + } else -> { // State has changed since the back handler was enabled. Let the back press proceed diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModel.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModel.kt index 8c82440628..d77ec8dd51 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModel.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationViewModel.kt @@ -733,6 +733,10 @@ class ConversationViewModel( } } + fun resetBackPressedState() { + internalBackPressedState.value = BackPressedState() + } + fun toggleVote(poll: PollRecord, pollOption: PollOption, isChecked: Boolean) { viewModelScope.launch(Dispatchers.IO) { val voteCount = if (isChecked) {