Fixed some bugs with formatting and message handling

Signed-off-by: Julius Linus <julius.linus@nextcloud.com>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Julius Linus 2024-03-21 12:59:08 -05:00 committed by Marcel Hibbe
parent 4c7ddae084
commit 07bf65460b
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 482 additions and 486 deletions

View File

@ -846,14 +846,6 @@ class ChatActivity :
Snackbar.LENGTH_LONG Snackbar.LENGTH_LONG
).show() ).show()
} }
chatViewModel.refreshChatParams(
setupFieldsForPullChatMessages(
true,
globalLastKnownFutureMessageId,
true
)
)
} }
is ChatViewModel.DeleteChatMessageErrorState -> { is ChatViewModel.DeleteChatMessageErrorState -> {
@ -933,10 +925,11 @@ class ChatActivity :
} }
var lastAdapterId = getLastAdapterId() var lastAdapterId = getLastAdapterId()
val oneNewMessage = (lastAdapterId != 0 || chatMessageList.size == 1)
if ( if (
state.lookIntoFuture && state.lookIntoFuture &&
lastAdapterId != 0 && oneNewMessage &&
chatMessageList[0].jsonMessageId > lastAdapterId chatMessageList[0].jsonMessageId > lastAdapterId
) { ) {
processMessagesFromTheFuture(chatMessageList) processMessagesFromTheFuture(chatMessageList)
@ -970,8 +963,7 @@ class ChatActivity :
true, true,
globalLastKnownFutureMessageId, globalLastKnownFutureMessageId,
true true
), )
true
) )
} }
@ -981,8 +973,7 @@ class ChatActivity :
true, true,
globalLastKnownFutureMessageId, globalLastKnownFutureMessageId,
true true
), )
true
) )
} }
@ -1104,7 +1095,7 @@ class ChatActivity :
binding.popupBubbleView.setRecyclerView(binding.messagesListView) binding.popupBubbleView.setRecyclerView(binding.messagesListView)
binding.popupBubbleView.setPopupBubbleListener { context -> binding.popupBubbleView.setPopupBubbleListener { _ ->
if (newMessagesCount != 0) { if (newMessagesCount != 0) {
val scrollPosition = if (newMessagesCount - 1 < 0) { val scrollPosition = if (newMessagesCount - 1 < 0) {
0 0
@ -1584,8 +1575,8 @@ class ChatActivity :
var sliderInitX = 0F var sliderInitX = 0F
var downX = 0f var downX = 0f
var originY = 0f var originY = 0f
var deltaX = 0f var deltaX: Float
var deltaY = 0f var deltaY: Float
var voiceRecordStartTime = 0L var voiceRecordStartTime = 0L
var voiceRecordEndTime = 0L var voiceRecordEndTime = 0L
@ -3606,11 +3597,12 @@ class ChatActivity :
for (i in mentionSpans.indices) { for (i in mentionSpans.indices) {
mentionSpan = mentionSpans[i] mentionSpan = mentionSpans[i]
var mentionId = mentionSpan.id var mentionId = mentionSpan.id
if (mentionId.contains(" ") || val needsQuotes = mentionId.contains(" ") ||
mentionId.contains("@") || mentionId.contains("@") ||
mentionId.startsWith("guest/") || mentionId.startsWith("guest/") ||
mentionId.startsWith("group/") mentionId.startsWith("group/")
) {
if (needsQuotes) {
mentionId = "\"" + mentionId + "\"" mentionId = "\"" + mentionId + "\""
} }
editable.replace(editable.getSpanStart(mentionSpan), editable.getSpanEnd(mentionSpan), "@$mentionId") editable.replace(editable.getSpanStart(mentionSpan), editable.getSpanEnd(mentionSpan), "@$mentionId")
@ -3996,7 +3988,8 @@ class ChatActivity :
} }
override fun onLoadMore(page: Int, totalItemsCount: Int) { override fun onLoadMore(page: Int, totalItemsCount: Int) {
if (page > 1) { val calculatedPage = page / MESSAGE_PULL_LIMIT
if (calculatedPage > 0) {
chatViewModel.refreshChatParams( chatViewModel.refreshChatParams(
setupFieldsForPullChatMessages( setupFieldsForPullChatMessages(
false, false,

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!--
<!--
~ Nextcloud Talk - Android Client ~ Nextcloud Talk - Android Client
~ ~
~ SPDX-FileCopyrightText: 2022 Andy Scherzinger <info@andy-scherzinger.de> ~ SPDX-FileCopyrightText: 2022 Andy Scherzinger <info@andy-scherzinger.de>
@ -108,6 +107,10 @@
android:paddingEnd="@dimen/standard_padding" /> android:paddingEnd="@dimen/standard_padding" />
</LinearLayout> </LinearLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:id="@+id/message_actions" android:id="@+id/message_actions"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -128,14 +131,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:ellipsize="end"
android:maxLines="1"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="@dimen/standard_padding" android:paddingEnd="@dimen/standard_padding"
tools:text="@string/nc_edited_by_admin"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:maxLines="1" android:textColor="@color/grey_600"
android:ellipsize="end"
android:textSize="15sp" android:textSize="15sp"
android:textColor = "@color/grey_600"/> tools:text="@string/nc_edited_by_admin" />
<TextView <TextView
android:id="@+id/edited_time" android:id="@+id/edited_time"
@ -144,10 +147,10 @@
android:layout_gravity="start|center_vertical" android:layout_gravity="start|center_vertical"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="@dimen/standard_padding" android:paddingEnd="@dimen/standard_padding"
tools:text="12:30 AM"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/grey_600"
android:textSize="15sp" android:textSize="15sp"
android:textColor ="@color/grey_600"/> tools:text="12:30 AM" />
</LinearLayout> </LinearLayout>
@ -482,7 +485,6 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/menu_edit_message" android:id="@+id/menu_edit_message"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -583,5 +585,6 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout> </LinearLayout>