From 675bc9bec09efb1cbdf49bab90ac962fc4f5499e Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 28 Oct 2024 13:41:49 +0100 Subject: [PATCH 1/4] fix messages not shown + improve unread marker behavior this commit will avoid to fail to show messages in adapter. This was caused by the usage of messagesListAdapter.deleteById("-1"); in UnreadNoticeMessageViewHolder. The bug seems to exist in the past already but was never reported (Sometimes, when receiving a lot of messages it could happen that some message in between is not shown in UI). However with recent changes after release 20.0.2 the bug appeared more often. The root cause was not analyzed, but the handling was modified in general as the unread marker behavior was never really good. By not using deleteById but replace it with new unread marker logic, the bug of disappearing messages is solved and the unread messages marker behavior is improved. Signed-off-by: Marcel Hibbe --- .../UnreadNoticeMessageViewHolder.java | 2 +- .../com/nextcloud/talk/chat/ChatActivity.kt | 77 +++++++++---------- .../talk/chat/data/ChatMessageRepository.kt | 3 +- .../network/OfflineFirstChatRepository.kt | 32 ++++++-- 4 files changed, 66 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java index 6615b4f0d..6ae3d5003 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java @@ -24,7 +24,7 @@ public class UnreadNoticeMessageViewHolder extends MessageHolders.SystemMessageV @Override public void viewDetached() { - messagesListAdapter.deleteById("-1"); +// messagesListAdapter.deleteById("-1"); } @Override 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 df0adc0ec..552a14c8d 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -756,6 +756,8 @@ class ChatActivity : is MessageInputViewModel.SendChatMessageSuccessState -> { myFirstMessage = state.message + removeUnreadMessagesMarker() + if (binding.unreadMessagesPopup.isShown == true) { binding.unreadMessagesPopup.hide() } @@ -853,9 +855,10 @@ class ChatActivity : this.lifecycleScope.launch { chatViewModel.getMessageFlow - .onEach { pair -> - val lookIntoFuture = pair.first - var chatMessageList = pair.second + .onEach { triple -> + val lookIntoFuture = triple.first + val setUnreadMessagesMarker = triple.second + var chatMessageList = triple.third chatMessageList = handleSystemMessages(chatMessageList) @@ -871,7 +874,8 @@ class ChatActivity : } if (lookIntoFuture) { - processMessagesFromTheFuture(chatMessageList) + Log.d(TAG, "chatMessageList.size in getMessageFlow:" + chatMessageList.size) + processMessagesFromTheFuture(chatMessageList, setUnreadMessagesMarker) } else { processMessagesNotFromTheFuture(chatMessageList) collapseSystemMessages() @@ -1011,6 +1015,13 @@ class ChatActivity : } } + private fun removeUnreadMessagesMarker() { + val index = adapter?.getMessagePositionById("-1") + if (index != null && index != -1) { + adapter?.items?.removeAt(index) + } + } + @Suppress("Detekt.TooGenericExceptionCaught") override fun onResume() { super.onResume() @@ -2653,13 +2664,22 @@ class ChatActivity : } } - private fun processMessagesFromTheFuture(chatMessageList: List) { - val newMessagesAvailable = (adapter?.itemCount ?: 0) > 0 && chatMessageList.isNotEmpty() - val insertNewMessagesNotice = shouldInsertNewMessagesNotice(newMessagesAvailable, chatMessageList) - val scrollToEndOnUpdate = isScrolledToBottom() + private fun processMessagesFromTheFuture(chatMessageList: List, setUnreadMessagesMarker: Boolean) { + binding.scrollDownButton.visibility = View.GONE - if (insertNewMessagesNotice) { - updateUnreadMessageInfos(chatMessageList, scrollToEndOnUpdate) + val scrollToBottom: Boolean + + if (setUnreadMessagesMarker) { + scrollToBottom = false + setUnreadMessageMarker(chatMessageList) + } else { + if (isScrolledToBottom()) { + scrollToBottom = true + } else { + scrollToBottom = false + binding.unreadMessagesPopup.show() + // here we have the problem that the chat jumps for every update + } } for (chatMessage in chatMessageList) { @@ -2674,44 +2694,21 @@ class ChatActivity : (currentConversation?.type == ConversationEnums.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) chatMessage.isFormerOneToOneConversation = (currentConversation?.type == ConversationEnums.ConversationType.FORMER_ONE_TO_ONE) - it.addToStart(chatMessage, scrollToEndOnUpdate) + Log.d(TAG, "chatMessage to add:" + chatMessage.message) + it.addToStart(chatMessage, scrollToBottom) } } - - if (insertNewMessagesNotice && scrollToEndOnUpdate && adapter != null) { - scrollToFirstUnreadMessage() - } } private fun isScrolledToBottom() = layoutManager?.findFirstVisibleItemPosition() == 0 - private fun shouldInsertNewMessagesNotice(newMessagesAvailable: Boolean, chatMessageList: List) = - if (newMessagesAvailable) { - chatMessageList.any { it.actorId != conversationUser!!.userId } - } else { - false - } - - private fun updateUnreadMessageInfos(chatMessageList: List, scrollToEndOnUpdate: Boolean) { + private fun setUnreadMessageMarker(chatMessageList: List) { val unreadChatMessage = ChatMessage() unreadChatMessage.jsonMessageId = -1 unreadChatMessage.actorId = "-1" unreadChatMessage.timestamp = chatMessageList[0].timestamp unreadChatMessage.message = context.getString(R.string.nc_new_messages) adapter?.addToStart(unreadChatMessage, false) - - if (scrollToEndOnUpdate) { - binding.scrollDownButton.visibility = View.GONE - newMessagesCount = 0 - } else { - if (binding.unreadMessagesPopup.isShown) { - newMessagesCount++ - } else { - newMessagesCount = 1 - binding.scrollDownButton.visibility = View.GONE - binding.unreadMessagesPopup.show() - } - } } private fun processMessagesNotFromTheFuture(chatMessageList: List) { @@ -2754,7 +2751,8 @@ class ChatActivity : return false } - if (!message1IsSystem && ( + if (!message1IsSystem && + ( (message1.actorType != message2.actorType) || (message2.actorId != message1.actorId) ) @@ -2863,9 +2861,8 @@ class ChatActivity : TextUtils.isEmpty(messageRight.systemMessage) && DateFormatter.isSameDay(messageLeft.createdAt, messageRight.createdAt) - private fun isSameDayMessages(message1: ChatMessage, message2: ChatMessage): Boolean { - return DateFormatter.isSameDay(message1.createdAt, message2.createdAt) - } + private fun isSameDayMessages(message1: ChatMessage, message2: ChatMessage): Boolean = + DateFormatter.isSameDay(message1.createdAt, message2.createdAt) override fun onLoadMore(page: Int, totalItemsCount: Int) { val id = ( diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt index a55a45803..860da6c21 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/ChatMessageRepository.kt @@ -22,7 +22,8 @@ interface ChatMessageRepository : LifecycleAwareManager { */ val messageFlow: Flow< - Pair< + Triple< + Boolean, Boolean, List > diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt index 4c52f7f31..b0fc8d081 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt @@ -53,7 +53,8 @@ class OfflineFirstChatRepository @Inject constructor( override val messageFlow: Flow< - Pair< + Triple< + Boolean, Boolean, List > @@ -62,7 +63,8 @@ class OfflineFirstChatRepository @Inject constructor( private val _messageFlow: MutableSharedFlow< - Pair< + Triple< + Boolean, Boolean, List > @@ -142,6 +144,7 @@ class OfflineFirstChatRepository @Inject constructor( // set up field map to load the newest messages val fieldMap = getFieldMap( lookIntoFuture = false, + timeout = 0, includeLastKnown = true, setReadMarker = true, lastKnown = null @@ -229,6 +232,7 @@ class OfflineFirstChatRepository @Inject constructor( val fieldMap = getFieldMap( lookIntoFuture = false, + timeout = 0, includeLastKnown = false, setReadMarker = true, lastKnown = beforeMessageId.toInt() @@ -254,6 +258,9 @@ class OfflineFirstChatRepository @Inject constructor( var fieldMap = getFieldMap( lookIntoFuture = true, + // timeout for first longpoll is 0, so "unread message" info is not shown if there were + // initially no messages but someone writes us in the first 30 seconds. + timeout = 0, includeLastKnown = false, setReadMarker = true, lastKnown = initialMessageId.toInt() @@ -261,6 +268,8 @@ class OfflineFirstChatRepository @Inject constructor( val networkParams = Bundle() + var showUnreadMessagesMarker = true + while (true) { if (!monitor.isOnline.first() || itIsPaused) { Thread.sleep(HALF_SECOND) @@ -272,8 +281,14 @@ class OfflineFirstChatRepository @Inject constructor( val resultsFromSync = sync(networkParams) if (!resultsFromSync.isNullOrEmpty()) { val chatMessages = resultsFromSync.map(ChatMessageEntity::asModel) - val pair = Pair(true, chatMessages) + + val weHaveMessagesFromOurself = chatMessages.any { it.actorId == currentUser.userId } + showUnreadMessagesMarker = showUnreadMessagesMarker && !weHaveMessagesFromOurself + + val pair = Triple(true, showUnreadMessagesMarker, chatMessages) _messageFlow.emit(pair) + } else { + Log.d(TAG, "resultsFromSync are null or empty") } updateUiForLastCommonRead() @@ -283,10 +298,13 @@ class OfflineFirstChatRepository @Inject constructor( // update field map vars for next cycle fieldMap = getFieldMap( lookIntoFuture = true, + timeout = 30, includeLastKnown = false, setReadMarker = true, lastKnown = newestMessage ) + + showUnreadMessagesMarker = false } } } @@ -325,6 +343,7 @@ class OfflineFirstChatRepository @Inject constructor( private fun getFieldMap( lookIntoFuture: Boolean, + timeout: Int, includeLastKnown: Boolean, setReadMarker: Boolean, lastKnown: Int?, @@ -342,7 +361,7 @@ class OfflineFirstChatRepository @Inject constructor( fieldMap["lastCommonReadId"] = it } - fieldMap["timeout"] = if (lookIntoFuture) 30 else 0 + fieldMap["timeout"] = timeout fieldMap["limit"] = limit fieldMap["lookIntoFuture"] = if (lookIntoFuture) 1 else 0 fieldMap["setReadMarker"] = if (setReadMarker) 1 else 0 @@ -357,6 +376,7 @@ class OfflineFirstChatRepository @Inject constructor( if (loadFromServer) { val fieldMap = getFieldMap( lookIntoFuture = false, + timeout = 0, includeLastKnown = true, setReadMarker = false, lastKnown = messageId.toInt(), @@ -664,7 +684,7 @@ class OfflineFirstChatRepository @Inject constructor( ) if (list.isNotEmpty()) { - val pair = Pair(false, list) + val pair = Triple(false, false, list) _messageFlow.emit(pair) } } @@ -690,7 +710,7 @@ class OfflineFirstChatRepository @Inject constructor( ) if (list.isNotEmpty()) { - val pair = Pair(false, list) + val pair = Triple(false, false, list) _messageFlow.emit(pair) } } From 29f7265b198a755c46d6503621d1ad34d7160812 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 29 Oct 2024 14:20:25 +0100 Subject: [PATCH 2/4] implement "Unread messages" popup with normal button replace com.nextcloud.ui.popupbubble.PopupBubble with MaterialButton. com.nextcloud.ui.popupbubble.PopupBubble was forked from https://github.com/webianks/PopupBubble which is quite outdated. com.nextcloud.ui.popupbubble.PopupBubble is still used in ConversationsListActivity but there it should also be removed. Removing this recycler view stuff will also help a bit to switch to JetpackCompose Signed-off-by: Marcel Hibbe --- .../UnreadNoticeMessageViewHolder.java | 1 - .../com/nextcloud/talk/chat/ChatActivity.kt | 65 +++++++------------ app/src/main/res/layout/activity_chat.xml | 5 +- 3 files changed, 29 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java b/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java index 6ae3d5003..2628470c4 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/UnreadNoticeMessageViewHolder.java @@ -24,7 +24,6 @@ public class UnreadNoticeMessageViewHolder extends MessageHolders.SystemMessageV @Override public void viewDetached() { -// messagesListAdapter.deleteById("-1"); } @Override 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 552a14c8d..1ca68beb3 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -296,7 +296,6 @@ class ChatActivity : var mentionAutocomplete: Autocomplete<*>? = null var layoutManager: LinearLayoutManager? = null var pullChatMessagesPending = false - var newMessagesCount = 0 var startCallFromNotification: Boolean = false var startCallFromRoomSwitch: Boolean = false @@ -758,8 +757,8 @@ class ChatActivity : removeUnreadMessagesMarker() - if (binding.unreadMessagesPopup.isShown == true) { - binding.unreadMessagesPopup.hide() + if (binding.unreadMessagesPopup.isShown) { + binding.unreadMessagesPopup.visibility = View.GONE } binding.messagesListView.smoothScrollToPosition(0) } @@ -770,8 +769,8 @@ class ChatActivity : if (code.toString().startsWith("2")) { myFirstMessage = state.message - if (binding.unreadMessagesPopup.isShown == true) { - binding.unreadMessagesPopup.hide() + if (binding.unreadMessagesPopup.isShown) { + binding.unreadMessagesPopup.visibility = View.GONE } binding.messagesListView.smoothScrollToPosition(0) @@ -1016,7 +1015,7 @@ class ChatActivity : } private fun removeUnreadMessagesMarker() { - val index = adapter?.getMessagePositionById("-1") + val index = adapter?.getMessagePositionById(UNREAD_MESSAGES_MARKER_ID.toString()) if (index != null && index != -1) { adapter?.items?.removeAt(index) } @@ -1041,22 +1040,9 @@ class ChatActivity : setupSwipeToReply() - binding.unreadMessagesPopup.setRecyclerView(binding.messagesListView) - - binding.unreadMessagesPopup.setPopupBubbleListener { _ -> - if (newMessagesCount != 0) { - val scrollPosition = if (newMessagesCount - 1 < 0) { - 0 - } else { - newMessagesCount - 1 - } - Handler().postDelayed( - { - binding.messagesListView.smoothScrollToPosition(scrollPosition) - }, - NEW_MESSAGES_POPUP_BUBBLE_DELAY - ) - } + binding.unreadMessagesPopup.setOnClickListener { + binding.messagesListView.smoothScrollToPosition(0) + binding.unreadMessagesPopup.visibility = View.GONE } binding.scrollDownButton.setOnClickListener { @@ -1075,21 +1061,14 @@ class ChatActivity : super.onScrollStateChanged(recyclerView, newState) if (newState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) { - if (layoutManager!!.findFirstCompletelyVisibleItemPosition() > 0 && - !binding.unreadMessagesPopup.isShown - ) { - binding.scrollDownButton.visibility = View.VISIBLE - } else { + if (isScrolledToBottom()) { + binding.unreadMessagesPopup.visibility = View.GONE binding.scrollDownButton.visibility = View.GONE - } - - if (newMessagesCount != 0 && layoutManager != null) { - if (layoutManager!!.findFirstCompletelyVisibleItemPosition() < newMessagesCount) { - newMessagesCount = 0 - - if (binding.unreadMessagesPopup.isShown) { - binding.unreadMessagesPopup.hide() - } + } else { + if (binding.unreadMessagesPopup.isShown) { + binding.scrollDownButton.visibility = View.GONE + } else { + binding.scrollDownButton.visibility = View.VISIBLE } } } @@ -2677,7 +2656,7 @@ class ChatActivity : scrollToBottom = true } else { scrollToBottom = false - binding.unreadMessagesPopup.show() + binding.unreadMessagesPopup.visibility = View.VISIBLE // here we have the problem that the chat jumps for every update } } @@ -2698,13 +2677,18 @@ class ChatActivity : it.addToStart(chatMessage, scrollToBottom) } } + + // workaround to jump back to unread messages marker + if (setUnreadMessagesMarker) { + scrollToFirstUnreadMessage() + } } private fun isScrolledToBottom() = layoutManager?.findFirstVisibleItemPosition() == 0 private fun setUnreadMessageMarker(chatMessageList: List) { val unreadChatMessage = ChatMessage() - unreadChatMessage.jsonMessageId = -1 + unreadChatMessage.jsonMessageId = UNREAD_MESSAGES_MARKER_ID unreadChatMessage.actorId = "-1" unreadChatMessage.timestamp = chatMessageList[0].timestamp unreadChatMessage.message = context.getString(R.string.nc_new_messages) @@ -2736,7 +2720,7 @@ class ChatActivity : private fun scrollToFirstUnreadMessage() { adapter?.let { - scrollToAndCenterMessageWithId("-1") + scrollToAndCenterMessageWithId(UNREAD_MESSAGES_MARKER_ID.toString()) } } @@ -3552,7 +3536,7 @@ class ChatActivity : CONTENT_TYPE_POLL -> message.isPoll() CONTENT_TYPE_LINK_PREVIEW -> message.isLinkPreview() CONTENT_TYPE_SYSTEM_MESSAGE -> !TextUtils.isEmpty(message.systemMessage) - CONTENT_TYPE_UNREAD_NOTICE_MESSAGE -> message.id == "-1" + CONTENT_TYPE_UNREAD_NOTICE_MESSAGE -> message.id == UNREAD_MESSAGES_MARKER_ID.toString() CONTENT_TYPE_CALL_STARTED -> message.id == "-2" CONTENT_TYPE_TEMP -> message.id == "-3" CONTENT_TYPE_DECK_CARD -> message.isDeckCard() @@ -3762,6 +3746,7 @@ class ChatActivity : private const val CONTENT_TYPE_LINK_PREVIEW: Byte = 7 private const val CONTENT_TYPE_DECK_CARD: Byte = 8 private const val CONTENT_TYPE_TEMP: Byte = 9 + private const val UNREAD_MESSAGES_MARKER_ID = -1 private const val NEW_MESSAGES_POPUP_BUBBLE_DELAY: Long = 200 private const val GET_ROOM_INFO_DELAY_NORMAL: Long = 30000 private const val GET_ROOM_INFO_DELAY_LOBBY: Long = 5000 diff --git a/app/src/main/res/layout/activity_chat.xml b/app/src/main/res/layout/activity_chat.xml index b73e404d9..c6d5e791b 100644 --- a/app/src/main/res/layout/activity_chat.xml +++ b/app/src/main/res/layout/activity_chat.xml @@ -157,8 +157,9 @@ app:textAutoLink="all" tools:visibility="visible" /> - From 662ddd275e8baf4ae5738b27eb6f0de4505e8af9 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 29 Oct 2024 14:47:20 +0100 Subject: [PATCH 3/4] remove unused constants from ChatActivity Signed-off-by: Marcel Hibbe --- .../com/nextcloud/talk/chat/ChatActivity.kt | 34 +------------------ 1 file changed, 1 insertion(+), 33 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 1ca68beb3..0845caddd 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -3747,28 +3747,15 @@ class ChatActivity : private const val CONTENT_TYPE_DECK_CARD: Byte = 8 private const val CONTENT_TYPE_TEMP: Byte = 9 private const val UNREAD_MESSAGES_MARKER_ID = -1 - private const val NEW_MESSAGES_POPUP_BUBBLE_DELAY: Long = 200 + private const val CALL_STARTED_ID = -2 private const val GET_ROOM_INFO_DELAY_NORMAL: Long = 30000 private const val GET_ROOM_INFO_DELAY_LOBBY: Long = 5000 - private const val HTTP_CODE_OK: Int = 200 private const val AGE_THRESHOLD_FOR_DELETE_MESSAGE: Int = 21600000 // (6 hours in millis = 6 * 3600 * 1000) private const val REQUEST_SHARE_FILE_PERMISSION: Int = 221 private const val REQUEST_RECORD_AUDIO_PERMISSION = 222 private const val REQUEST_READ_CONTACT_PERMISSION = 234 private const val REQUEST_CAMERA_PERMISSION = 223 - private const val OBJECT_MESSAGE: String = "{object}" - private const val MINIMUM_VOICE_RECORD_DURATION: Int = 1000 - private const val MINIMUM_VOICE_RECORD_TO_STOP: Int = 200 - private const val VOICE_RECORD_CANCEL_SLIDER_X: Int = -50 - private const val VOICE_RECORD_LOCK_BUTTON_Y: Int = -130 private const val VOICE_MESSAGE_META_DATA = "{\"messageType\":\"voice-message\"}" - private const val VOICE_MESSAGE_FILE_SUFFIX = ".mp3" - - // Samplingrate 22050 was chosen because somehow 44100 failed to playback on safari when recorded on android. - // Please test with firefox, chrome, safari and mobile clients if changing anything regarding the sound. - private const val VOICE_MESSAGE_SAMPLING_RATE = 22050 - private const val VOICE_MESSAGE_ENCODING_BIT_RATE = 32000 - private const val VOICE_MESSAGE_CHANNELS = 1 private const val FILE_DATE_PATTERN = "yyyy-MM-dd HH-mm-ss" private const val VIDEO_SUFFIX = ".mp4" private const val FULLY_OPAQUE_INT: Int = 255 @@ -3777,40 +3764,21 @@ class ChatActivity : private const val NO_PREVIOUS_MESSAGE_ID: Int = -1 private const val TOOLBAR_AVATAR_RATIO = 1.5 private const val STATUS_SIZE_IN_DP = 9f - private const val HTTP_CODE_NOT_MODIFIED = 304 - private const val HTTP_CODE_PRECONDITION_FAILED = 412 private const val HTTP_BAD_REQUEST = 400 private const val HTTP_FORBIDDEN = 403 private const val HTTP_NOT_FOUND = 404 - private const val QUOTED_MESSAGE_IMAGE_MAX_HEIGHT = 96f - private const val MENTION_AUTO_COMPLETE_ELEVATION = 6f private const val MESSAGE_PULL_LIMIT = 100 - private const val PAGE_SIZE = 100 private const val INVITE_LENGTH = 6 private const val ACTOR_LENGTH = 6 - private const val ANIMATION_DURATION: Long = 750 - private const val LOOKING_INTO_FUTURE_TIMEOUT = 30 private const val CHUNK_SIZE: Int = 10 private const val ONE_SECOND_IN_MILLIS = 1000 - private const val SAMPLE_RATE = 8000 - private const val VOICE_RECORDING_LOCK_ANIMATION_DURATION = 500 - private const val AUDIO_VALUE_MAX = 40 - private const val AUDIO_VALUE_MIN = 20 - private const val AUDIO_VALUE_SLEEP: Long = 50 private const val WHITESPACE = " " private const val COMMA = ", " private const val TYPING_INDICATOR_ANIMATION_DURATION = 200L private const val TYPING_INDICATOR_MAX_NAME_LENGTH = 14 private const val TYPING_INDICATOR_POSITION_VISIBLE = -18f private const val TYPING_INDICATOR_POSITION_HIDDEN = -1f - private const val TYPING_DURATION_TO_SEND_NEXT_TYPING_MESSAGE = 10000L - private const val TYPING_INTERVAL_TO_SEND_NEXT_TYPING_MESSAGE = 1000L - private const val TYPING_STARTED_SIGNALING_MESSAGE_TYPE = "startedTyping" - private const val TYPING_STOPPED_SIGNALING_MESSAGE_TYPE = "stoppedTyping" - private const val CALL_STARTED_ID = -2 private const val MILISEC_15: Long = 15 - private const val LINEBREAK = "\n" - private const val CURSOR_KEY = "_cursor" private const val CURRENT_AUDIO_MESSAGE_KEY = "CURRENT_AUDIO_MESSAGE" private const val CURRENT_AUDIO_POSITION_KEY = "CURRENT_AUDIO_POSITION" private const val CURRENT_AUDIO_WAS_PLAYING_KEY = "CURRENT_AUDIO_PLAYING" From ff9055252755ac312d55dfec640bd314dcc6bf39 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Tue, 5 Nov 2024 13:31:42 +0100 Subject: [PATCH 4/4] rename pair to triple Signed-off-by: Marcel Hibbe --- .../chat/data/network/OfflineFirstChatRepository.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt index b0fc8d081..7be5caaed 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/data/network/OfflineFirstChatRepository.kt @@ -285,8 +285,8 @@ class OfflineFirstChatRepository @Inject constructor( val weHaveMessagesFromOurself = chatMessages.any { it.actorId == currentUser.userId } showUnreadMessagesMarker = showUnreadMessagesMarker && !weHaveMessagesFromOurself - val pair = Triple(true, showUnreadMessagesMarker, chatMessages) - _messageFlow.emit(pair) + val triple = Triple(true, showUnreadMessagesMarker, chatMessages) + _messageFlow.emit(triple) } else { Log.d(TAG, "resultsFromSync are null or empty") } @@ -684,8 +684,8 @@ class OfflineFirstChatRepository @Inject constructor( ) if (list.isNotEmpty()) { - val pair = Triple(false, false, list) - _messageFlow.emit(pair) + val triple = Triple(false, false, list) + _messageFlow.emit(triple) } } @@ -710,8 +710,8 @@ class OfflineFirstChatRepository @Inject constructor( ) if (list.isNotEmpty()) { - val pair = Triple(false, false, list) - _messageFlow.emit(pair) + val triple = Triple(false, false, list) + _messageFlow.emit(triple) } }