Dismiss chat message long press view if visible when doing a back gesture

This commit is contained in:
Sylvain Berfini 2024-10-10 15:20:35 +02:00
parent 8a39529fd1
commit 6826a51307

View file

@ -325,12 +325,20 @@ open class ConversationFragment : SlidingPaneChildFragment() {
}
val bottomSheetBehavior = BottomSheetBehavior.from(binding.messageBottomSheet.root)
if (bottomSheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN) {
Log.i("$TAG Bottom sheet is visible, hiding it instead of going back")
if (bottomSheetBehavior.state != BottomSheetBehavior.STATE_HIDDEN && bottomSheetBehavior.state != BottomSheetBehavior.STATE_COLLAPSED) {
Log.i(
"$TAG Bottom sheet isn't hidden nor collapsed, hiding it instead of going back"
)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
return
}
if (messageLongPressViewModel.visible.value == true) {
Log.i("$TAG Message long press menu is visible, hiding it instead of going back")
messageLongPressViewModel.dismiss()
return
}
Log.i("$TAG Search bar is closed & no bottom sheet is opened, going back")
isEnabled = false
try {
@ -1151,6 +1159,7 @@ open class ConversationFragment : SlidingPaneChildFragment() {
}
}
messageLongPressViewModel.visible.value = true
backPressedCallback.isEnabled = true
}
@UiThread