From 152c0b7ece4c1f314f09e710d7781c5b5ea682b0 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Mon, 13 Feb 2023 18:09:33 +0100 Subject: [PATCH] add support for FORMER_ONE_TO_ONE conversations resolve #8517 Signed-off-by: Marcel Hibbe --- .../nextcloud/talk/adapters/items/ConversationItem.kt | 2 ++ .../messages/IncomingLinkPreviewMessageViewHolder.kt | 4 ++-- .../messages/IncomingLocationMessageViewHolder.kt | 4 ++-- .../messages/IncomingPollMessageViewHolder.kt | 4 ++-- .../messages/IncomingTextMessageViewHolder.kt | 4 ++-- .../messages/IncomingVoiceMessageViewHolder.kt | 4 ++-- .../com/nextcloud/talk/controllers/ChatController.kt | 4 ++++ .../nextcloud/talk/models/json/chat/ChatMessage.kt | 3 +++ .../talk/models/json/conversations/Conversation.kt | 11 +++++++++-- .../models/json/converters/EnumRoomTypeConverter.java | 4 ++++ 10 files changed, 32 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt index 4b16ed6af..6be1362eb 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/ConversationItem.kt @@ -175,6 +175,8 @@ class ConversationItem( } ConversationType.ROOM_GROUP_CALL -> holder.binding.dialogAvatar.loadGroupCallAvatar(viewThemeUtils) + ConversationType.FORMER_ONE_TO_ONE -> + holder.binding.dialogAvatar.loadGroupCallAvatar(viewThemeUtils) ConversationType.ROOM_PUBLIC_CALL -> holder.binding.dialogAvatar.loadPublicCallAvatar(viewThemeUtils) else -> holder.binding.dialogAvatar.visibility = View.GONE diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt index c1855ac53..147ae5a82 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLinkPreviewMessageViewHolder.kt @@ -131,10 +131,10 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) : M binding.messageAuthor.setText(R.string.nc_nick_guest) } - if (!message.isGrouped && !message.isOneToOneConversation) { + if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) { setAvatarOnMessage(message) } else { - if (message.isOneToOneConversation) { + if (message.isOneToOneConversation || message.isFormerOneToOneConversation) { binding.messageUserAvatar.visibility = View.GONE } else { binding.messageUserAvatar.visibility = View.INVISIBLE diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt index 548a927c6..214ad12f4 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingLocationMessageViewHolder.kt @@ -135,7 +135,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess binding.messageAuthor.setText(R.string.nc_nick_guest) } - if (!message.isGrouped && !message.isOneToOneConversation) { + if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) { binding.messageUserAvatar.visibility = View.VISIBLE if (message.actorType == "guests") { // do nothing, avatar is set @@ -145,7 +145,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess binding.messageUserAvatar.loadBotsAvatar() } } else { - if (message.isOneToOneConversation) { + if (message.isOneToOneConversation || message.isFormerOneToOneConversation) { binding.messageUserAvatar.visibility = View.GONE } else { binding.messageUserAvatar.visibility = View.INVISIBLE diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt index 249107ffe..125ddae46 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingPollMessageViewHolder.kt @@ -155,10 +155,10 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH binding.messageAuthor.setText(R.string.nc_nick_guest) } - if (!message.isGrouped && !message.isOneToOneConversation) { + if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) { setAvatarOnMessage(message) } else { - if (message.isOneToOneConversation) { + if (message.isOneToOneConversation || message.isFormerOneToOneConversation) { binding.messageUserAvatar.visibility = View.GONE } else { binding.messageUserAvatar.visibility = View.INVISIBLE diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt index 2d2aeb14c..435a2dc78 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingTextMessageViewHolder.kt @@ -143,10 +143,10 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) : MessageHolde binding.messageAuthor.setText(R.string.nc_nick_guest) } - if (!message.isGrouped && !message.isOneToOneConversation) { + if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) { setAvatarOnMessage(message) } else { - if (message.isOneToOneConversation) { + if (message.isOneToOneConversation || message.isFormerOneToOneConversation) { binding.messageUserAvatar.visibility = View.GONE } else { binding.messageUserAvatar.visibility = View.INVISIBLE diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt index c5fdf4ca9..439d88964 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingVoiceMessageViewHolder.kt @@ -232,10 +232,10 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message binding.messageAuthor.setText(R.string.nc_nick_guest) } - if (!message.isGrouped && !message.isOneToOneConversation) { + if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) { setAvatarOnMessage(message) } else { - if (message.isOneToOneConversation) { + if (message.isOneToOneConversation || message.isFormerOneToOneConversation) { binding.messageUserAvatar.visibility = View.GONE } else { binding.messageUserAvatar.visibility = View.INVISIBLE diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index c6460827d..313a53ffe 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt @@ -2460,6 +2460,8 @@ class ChatController(args: Bundle) : ) chatMessage.isOneToOneConversation = (currentConversation?.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) + chatMessage.isFormerOneToOneConversation = + (currentConversation?.type == Conversation.ConversationType.FORMER_ONE_TO_ONE) it.addToStart(chatMessage, shouldScroll) } } @@ -2499,6 +2501,8 @@ class ChatController(args: Bundle) : val chatMessage = chatMessageList[i] chatMessage.isOneToOneConversation = currentConversation?.type == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL + chatMessage.isFormerOneToOneConversation = + (currentConversation?.type == Conversation.ConversationType.FORMER_ONE_TO_ONE) chatMessage.activeUser = conversationUser } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt index a8cbd8f36..4321e38fe 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/chat/ChatMessage.kt @@ -54,6 +54,9 @@ data class ChatMessage( @JsonIgnore var isOneToOneConversation: Boolean = false, + @JsonIgnore + var isFormerOneToOneConversation: Boolean = false, + @JsonIgnore var activeUser: User? = null, diff --git a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt index 63a1822a8..0028ae427 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt +++ b/app/src/main/java/com/nextcloud/talk/models/json/conversations/Conversation.kt @@ -167,7 +167,9 @@ data class Conversation( } fun canModerate(conversationUser: User): Boolean { - return isParticipantOwnerOrModerator && !isLockedOneToOne(conversationUser) + return isParticipantOwnerOrModerator && + !isLockedOneToOne(conversationUser) && + type != ConversationType.FORMER_ONE_TO_ONE } fun isLobbyViewApplicable(conversationUser: User): Boolean { @@ -210,6 +212,11 @@ data class Conversation( @Parcelize enum class ConversationType : Parcelable { - DUMMY, ROOM_TYPE_ONE_TO_ONE_CALL, ROOM_GROUP_CALL, ROOM_PUBLIC_CALL, ROOM_SYSTEM + DUMMY, + ROOM_TYPE_ONE_TO_ONE_CALL, + ROOM_GROUP_CALL, + ROOM_PUBLIC_CALL, + ROOM_SYSTEM, + FORMER_ONE_TO_ONE } } diff --git a/app/src/main/java/com/nextcloud/talk/models/json/converters/EnumRoomTypeConverter.java b/app/src/main/java/com/nextcloud/talk/models/json/converters/EnumRoomTypeConverter.java index ed4e02513..ce0445593 100644 --- a/app/src/main/java/com/nextcloud/talk/models/json/converters/EnumRoomTypeConverter.java +++ b/app/src/main/java/com/nextcloud/talk/models/json/converters/EnumRoomTypeConverter.java @@ -35,6 +35,8 @@ public class EnumRoomTypeConverter extends IntBasedTypeConverter