From c80050d8f5f47b8e2e94a7d885fdb96a54869820 Mon Sep 17 00:00:00 2001 From: sowjanyakch Date: Thu, 10 Oct 2024 15:25:56 +0200 Subject: [PATCH] Display card deck with parameters Signed-off-by: sowjanyakch --- .../messages/IncomingDeckCardViewHolder.kt | 5 +- .../messages/OutgoingDeckCardViewHolder.kt | 22 ++--- .../com/nextcloud/talk/chat/ChatActivity.kt | 14 +++ ...item_custom_incoming_deck_card_message.xml | 21 ++-- ...tem_custom_outcoming_deck_card_message.xml | 96 ++++++++----------- app/src/main/res/values/strings.xml | 2 +- 6 files changed, 77 insertions(+), 83 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt index 212a91765..2f8731426 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/IncomingDeckCardViewHolder.kt @@ -83,6 +83,7 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold binding.messageTime.text = dateUtils.getLocalTimeStringFromTimestamp(message.timestamp) setAvatarAndAuthorOnMessageItem(message) + showDeckCard(message) colorizeMessageBubble(message) @@ -91,8 +92,6 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold // parent message handling setParentMessageDataOnMessageItem(message) - showDeckCard(message) - binding.cardView.setOnLongClickListener { l: View? -> commonMessageInterface.onOpenMessageActionsDialog(message) true @@ -136,6 +135,8 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold stackName, boardName ) + binding.cardName.visibility = View.VISIBLE + binding.cardDescription.visibility = View.VISIBLE binding.cardName.text = cardName binding.cardDescription.text = cardDescription } diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutgoingDeckCardViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutgoingDeckCardViewHolder.kt index cd9a46501..cab902dbd 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutgoingDeckCardViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutgoingDeckCardViewHolder.kt @@ -87,6 +87,8 @@ class OutgoingDeckCardViewHolder( itemView.isSelected = false + showDeckCard(message) + // parent message handling setParentMessageDataOnMessageItem(message) @@ -111,8 +113,6 @@ class OutgoingDeckCardViewHolder( binding.checkMark.contentDescription = readStatusContentDescriptionString - showDeckCard(message) - binding.cardView.setOnClickListener { val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(cardLink)) browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) @@ -142,16 +142,16 @@ class OutgoingDeckCardViewHolder( } } } + val cardDescription = String.format( + context.resources.getString(R.string.deck_card_description), + stackName, + boardName + ) - if (cardName?.isNotEmpty() == true) { - val cardDescription = String.format( - context.resources.getString(R.string.deck_card_description), - stackName, - boardName - ) - binding.cardName.text = cardName - binding.cardDescription.text = cardDescription - } + binding.cardName.visibility = View.VISIBLE + binding.cardDescription.visibility = View.VISIBLE + binding.cardName.text = cardName + binding.cardDescription.text = cardDescription } private fun longClickOnReaction(chatMessage: ChatMessage) { 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 f5637769f..b737ad459 100644 --- a/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt +++ b/app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt @@ -83,6 +83,7 @@ import com.nextcloud.talk.activities.TakePhotoActivity import com.nextcloud.talk.adapters.messages.CallStartedMessageInterface import com.nextcloud.talk.adapters.messages.CallStartedViewHolder import com.nextcloud.talk.adapters.messages.CommonMessageInterface +import com.nextcloud.talk.adapters.messages.IncomingDeckCardViewHolder import com.nextcloud.talk.adapters.messages.IncomingLinkPreviewMessageViewHolder import com.nextcloud.talk.adapters.messages.IncomingLocationMessageViewHolder import com.nextcloud.talk.adapters.messages.IncomingPollMessageViewHolder @@ -96,6 +97,7 @@ import com.nextcloud.talk.adapters.messages.OutcomingPollMessageViewHolder import com.nextcloud.talk.adapters.messages.OutcomingPreviewMessageViewHolder import com.nextcloud.talk.adapters.messages.OutcomingTextMessageViewHolder import com.nextcloud.talk.adapters.messages.OutcomingVoiceMessageViewHolder +import com.nextcloud.talk.adapters.messages.OutgoingDeckCardViewHolder import com.nextcloud.talk.adapters.messages.PreviewMessageInterface import com.nextcloud.talk.adapters.messages.PreviewMessageViewHolder import com.nextcloud.talk.adapters.messages.SystemMessageInterface @@ -1291,6 +1293,18 @@ class ChatActivity : R.layout.item_custom_outcoming_link_preview_message, this ) + + messageHolders.registerContentType( + CONTENT_TYPE_DECK_CARD, + IncomingDeckCardViewHolder::class.java, + payload, + R.layout.item_custom_incoming_deck_card_message, + OutgoingDeckCardViewHolder::class.java, + payload, + R.layout.item_custom_outcoming_deck_card_message, + this + ) + return messageHolders } diff --git a/app/src/main/res/layout/item_custom_incoming_deck_card_message.xml b/app/src/main/res/layout/item_custom_incoming_deck_card_message.xml index 70a15e7da..b1f85e85a 100644 --- a/app/src/main/res/layout/item_custom_incoming_deck_card_message.xml +++ b/app/src/main/res/layout/item_custom_incoming_deck_card_message.xml @@ -53,6 +53,11 @@ android:textSize="12sp" tools:text="Jane Doe" /> + + - - - +--> - - + app:flexWrap="wrap" + app:justifyContent="flex_end"> - - - - - - - - - + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 22086cace..fb5464bcf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -515,7 +515,7 @@ How to translate with transifex: are typing … and 1 other is typing … and %1$s others are typing … - %1$s in 2$s + %1$s in %2$s Add to conversation Take photo