From 07bf65460b074b6863c4afb11bd2d93fb36c2dd8 Mon Sep 17 00:00:00 2001 From: Julius Linus Date: Thu, 21 Mar 2024 12:59:08 -0500 Subject: [PATCH] Fixed some bugs with formatting and message handling Signed-off-by: Julius Linus Signed-off-by: Marcel Hibbe --- .../com/nextcloud/talk/chat/ChatActivity.kt | 31 +- .../res/layout/dialog_message_actions.xml | 937 +++++++++--------- 2 files changed, 482 insertions(+), 486 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt index 899b9bbee..fa763516d 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -846,14 +846,6 @@ class ChatActivity : Snackbar.LENGTH_LONG ).show() } - - chatViewModel.refreshChatParams( - setupFieldsForPullChatMessages( - true, - globalLastKnownFutureMessageId, - true - ) - ) } is ChatViewModel.DeleteChatMessageErrorState -> { @@ -933,10 +925,11 @@ class ChatActivity : } var lastAdapterId = getLastAdapterId() + val oneNewMessage = (lastAdapterId != 0 || chatMessageList.size == 1) if ( state.lookIntoFuture && - lastAdapterId != 0 && + oneNewMessage && chatMessageList[0].jsonMessageId > lastAdapterId ) { processMessagesFromTheFuture(chatMessageList) @@ -970,8 +963,7 @@ class ChatActivity : true, globalLastKnownFutureMessageId, true - ), - true + ) ) } @@ -981,8 +973,7 @@ class ChatActivity : true, globalLastKnownFutureMessageId, true - ), - true + ) ) } @@ -1104,7 +1095,7 @@ class ChatActivity : binding.popupBubbleView.setRecyclerView(binding.messagesListView) - binding.popupBubbleView.setPopupBubbleListener { context -> + binding.popupBubbleView.setPopupBubbleListener { _ -> if (newMessagesCount != 0) { val scrollPosition = if (newMessagesCount - 1 < 0) { 0 @@ -1584,8 +1575,8 @@ class ChatActivity : var sliderInitX = 0F var downX = 0f var originY = 0f - var deltaX = 0f - var deltaY = 0f + var deltaX: Float + var deltaY: Float var voiceRecordStartTime = 0L var voiceRecordEndTime = 0L @@ -3606,11 +3597,12 @@ class ChatActivity : for (i in mentionSpans.indices) { mentionSpan = mentionSpans[i] var mentionId = mentionSpan.id - if (mentionId.contains(" ") || + val needsQuotes = mentionId.contains(" ") || mentionId.contains("@") || mentionId.startsWith("guest/") || mentionId.startsWith("group/") - ) { + + if (needsQuotes) { mentionId = "\"" + mentionId + "\"" } editable.replace(editable.getSpanStart(mentionSpan), editable.getSpanEnd(mentionSpan), "@$mentionId") @@ -3996,7 +3988,8 @@ class ChatActivity : } override fun onLoadMore(page: Int, totalItemsCount: Int) { - if (page > 1) { + val calculatedPage = page / MESSAGE_PULL_LIMIT + if (calculatedPage > 0) { chatViewModel.refreshChatParams( setupFieldsForPullChatMessages( false, diff --git a/app/src/main/res/layout/dialog_message_actions.xml b/app/src/main/res/layout/dialog_message_actions.xml index 502e2af88..dda9cea8f 100644 --- a/app/src/main/res/layout/dialog_message_actions.xml +++ b/app/src/main/res/layout/dialog_message_actions.xml @@ -1,5 +1,4 @@ - -