Hide either IMDN or reactions bottom sheet with back gesture instead of directly going back

This commit is contained in:
Sylvain Berfini 2024-09-12 10:13:20 +02:00
parent 1a35a7048d
commit 41721e3994
2 changed files with 14 additions and 7 deletions

View file

@ -34,7 +34,6 @@ import androidx.core.app.ActivityCompat
import androidx.core.app.Person
import androidx.core.graphics.drawable.IconCompat
import androidx.loader.app.LoaderManager
import java.io.IOException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@ -690,10 +689,8 @@ fun Friend.getNativeContactPictureUri(): Uri? {
fd.close()
return pictureUri
}
} catch (ioe: IOException) {
Log.e("[Contacts Manager] Can't open [$pictureUri]: $ioe")
} catch (se: SecurityException) {
Log.e("[Contacts Manager] Can't open [$pictureUri]: $se")
} catch (e: Exception) {
Log.e("[Contacts Manager] Can't open [$pictureUri] for contact [$name]: $e")
}
// Fallback to thumbnail

View file

@ -303,8 +303,9 @@ open class ConversationFragment : SlidingPaneChildFragment() {
private val bottomSheetCallback = object : BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
if (newState == BottomSheetBehavior.STATE_COLLAPSED) {
if (newState == BottomSheetBehavior.STATE_COLLAPSED || newState == BottomSheetBehavior.STATE_HIDDEN) {
currentChatMessageModelForBottomSheet?.isSelected?.value = false
backPressedCallback.isEnabled = false
}
}
@ -318,11 +319,19 @@ open class ConversationFragment : SlidingPaneChildFragment() {
private val backPressedCallback = object : OnBackPressedCallback(false) {
override fun handleOnBackPressed() {
if (viewModel.searchBarVisible.value == true) {
Log.i("$TAG Search bar is visible, closing it instead of going back")
viewModel.closeSearchBar()
return
}
Log.i("$TAG Search bar is closed, going back")
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")
bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
return
}
Log.i("$TAG Search bar is closed & no bottom sheet is opened, going back")
isEnabled = false
try {
requireActivity().onBackPressedDispatcher.onBackPressed()
@ -1123,6 +1132,7 @@ open class ConversationFragment : SlidingPaneChildFragment() {
showReactions: Boolean = false
) {
binding.sendArea.messageToSend.hideKeyboard()
backPressedCallback.isEnabled = true
val bottomSheetBehavior = BottomSheetBehavior.from(binding.messageBottomSheet.root)
bottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED