mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-18 03:48:08 +00:00
Added unread message indicator when scrolling up in conversation
This commit is contained in:
parent
acfabaae23
commit
a00409e003
2 changed files with 26 additions and 1 deletions
|
|
@ -72,6 +72,8 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
val noMatchingResultForFilter = MutableLiveData<Boolean>()
|
||||
|
||||
val unreadMessagesCount = MutableLiveData<Int>()
|
||||
|
||||
var scrollingPosition: Int = SCROLLING_POSITION_NOT_SET
|
||||
|
||||
val focusSearchBarEvent: MutableLiveData<Event<Boolean>> by lazy {
|
||||
|
|
@ -115,6 +117,12 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onChatRoomRead(chatRoom: ChatRoom) {
|
||||
unreadMessagesCount.postValue(0)
|
||||
Log.i("$TAG Conversation was marked as read")
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
override fun onChatMessageSending(chatRoom: ChatRoom, eventLog: EventLog) {
|
||||
val message = eventLog.chatMessage
|
||||
|
|
@ -185,6 +193,8 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
|
|||
|
||||
list.addAll(newList)
|
||||
events.postValue(list)
|
||||
|
||||
unreadMessagesCount.postValue(chatRoom.unreadMessagesCount)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
@ -431,8 +441,9 @@ class ConversationViewModel @UiThread constructor() : ViewModel() {
|
|||
computeConversationInfo()
|
||||
|
||||
computeEvents()
|
||||
|
||||
Log.i("$TAG Marking chat room as read")
|
||||
chatRoom.markAsRead()
|
||||
Log.i("$TAG Conversation was marked as read")
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
|
|||
|
|
@ -272,6 +272,20 @@
|
|||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/send_area" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style"
|
||||
android:id="@+id/unread_messages"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/shape_red_round"
|
||||
android:text="@{String.valueOf(viewModel.unreadMessagesCount), default=`1`}"
|
||||
android:textColor="?attr/color_main2_000"
|
||||
android:textSize="13sp"
|
||||
android:visibility="@{viewModel.isUserScrollingUp && viewModel.unreadMessagesCount > 0 ? View.VISIBLE : View.GONE}"
|
||||
app:layout_constraintBottom_toTopOf="@id/scroll_to_bottom"
|
||||
app:layout_constraintEnd_toEndOf="@id/scroll_to_bottom"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<include
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue