mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 19:38:08 +00:00
Fixed scrolling issue due to MessageModel staying not read + scroll to bottom when keyboard is opened if no scrolling was initiated by user
This commit is contained in:
parent
eb5f985712
commit
10b9044aa8
2 changed files with 20 additions and 1 deletions
|
|
@ -46,7 +46,9 @@ import androidx.lifecycle.lifecycleScope
|
|||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
|
||||
import androidx.recyclerview.widget.RecyclerView.OnScrollListener
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
|
|
@ -101,6 +103,8 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
|
||||
private val args: ConversationFragmentArgs by navArgs()
|
||||
|
||||
private var isUserScrollingUp: Boolean = false
|
||||
|
||||
private val pickMedia = registerForActivityResult(
|
||||
ActivityResultContracts.PickMultipleVisualMedia()
|
||||
) { list ->
|
||||
|
|
@ -512,8 +516,20 @@ class ConversationFragment : SlidingPaneChildFragment() {
|
|||
binding.root.setKeyboardInsetListener { keyboardVisible ->
|
||||
if (keyboardVisible) {
|
||||
sendMessageViewModel.isEmojiPickerOpen.value = false
|
||||
|
||||
// Scroll to bottom if was already at the bottom
|
||||
if (!isUserScrollingUp) {
|
||||
binding.eventsList.scrollToPosition(adapter.itemCount - 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
binding.eventsList.addOnScrollListener(object : OnScrollListener() {
|
||||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
val layoutManager = binding.eventsList.layoutManager as LinearLayoutManager
|
||||
isUserScrollingUp = layoutManager.findLastCompletelyVisibleItemPosition() != adapter.itemCount - 1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class MessageModel @WorkerThread constructor(
|
|||
|
||||
val id = chatMessage.messageId
|
||||
|
||||
val isRead = chatMessage.isRead
|
||||
var isRead = chatMessage.isRead
|
||||
|
||||
val isOutgoing = chatMessage.isOutgoing
|
||||
|
||||
|
|
@ -174,6 +174,9 @@ class MessageModel @WorkerThread constructor(
|
|||
downloadingFileModel = null
|
||||
}
|
||||
computeContentsList()
|
||||
} else if (messageState == ChatMessage.State.Displayed) {
|
||||
Log.i("$TAG Message was marked as read")
|
||||
isRead = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue