mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 05:55:39 +03:00
adjust outcoming message view holders to use full available width in NoteToSelf chat
Signed-off-by: Christian Reiner <foss@christian-reiner.info>
This commit is contained in:
parent
315e263d31
commit
238532feb2
7 changed files with 113 additions and 41 deletions
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Christian Reiner <foss@christian-reiner.info>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
package com.nextcloud.talk.adapters.messages
|
||||
|
||||
import android.widget.RelativeLayout
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingDeckCardMessageBinding
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingLinkPreviewMessageBinding
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingLocationMessageBinding
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingPollMessageBinding
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingTextMessageBinding
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingVoiceMessageBinding
|
||||
import com.nextcloud.talk.models.domain.ConversationModel
|
||||
import com.nextcloud.talk.models.json.conversations.ConversationEnums.ConversationType
|
||||
|
||||
interface AdjustableMessageHolderInterface {
|
||||
|
||||
val binding: ViewBinding
|
||||
|
||||
fun adjustIfNoteToSelf(viewHolder: AdjustableMessageHolderInterface, currentConversation: ConversationModel?) {
|
||||
if (currentConversation?.type == ConversationType.NOTE_TO_SELF) {
|
||||
when (viewHolder.binding.javaClass) {
|
||||
ItemCustomOutcomingTextMessageBinding::class.java ->
|
||||
(viewHolder.binding as ItemCustomOutcomingTextMessageBinding).bubble
|
||||
ItemCustomOutcomingDeckCardMessageBinding::class.java ->
|
||||
(viewHolder.binding as ItemCustomOutcomingDeckCardMessageBinding).bubble
|
||||
ItemCustomOutcomingLinkPreviewMessageBinding::class.java ->
|
||||
(viewHolder.binding as ItemCustomOutcomingLinkPreviewMessageBinding).bubble
|
||||
ItemCustomOutcomingPollMessageBinding::class.java ->
|
||||
(viewHolder.binding as ItemCustomOutcomingPollMessageBinding).bubble
|
||||
ItemCustomOutcomingVoiceMessageBinding::class.java ->
|
||||
(viewHolder.binding as ItemCustomOutcomingVoiceMessageBinding).bubble
|
||||
ItemCustomOutcomingLocationMessageBinding::class.java ->
|
||||
(viewHolder.binding as ItemCustomOutcomingLocationMessageBinding).bubble
|
||||
else -> null
|
||||
}?.let {
|
||||
RelativeLayout.LayoutParams(binding.root.layoutParams).apply {
|
||||
marginStart = 0
|
||||
marginEnd = 0
|
||||
}.run {
|
||||
it.layoutParams = this
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Christian Reiner <foss@christian-reiner.info>
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota<sowjanya.kch@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
@ -43,9 +44,10 @@ import javax.inject.Inject
|
|||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class OutcomingDeckCardViewHolder(
|
||||
outcomingView: View
|
||||
) : MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(outcomingView) {
|
||||
) : MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(outcomingView),
|
||||
AdjustableMessageHolderInterface {
|
||||
|
||||
private val binding: ItemCustomOutcomingDeckCardMessageBinding = ItemCustomOutcomingDeckCardMessageBinding.bind(
|
||||
override val binding: ItemCustomOutcomingDeckCardMessageBinding = ItemCustomOutcomingDeckCardMessageBinding.bind(
|
||||
itemView
|
||||
)
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Christian Reiner <foss@christian-reiner.info>
|
||||
* SPDX-FileCopyrightText: 2022 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-FileCopyrightText: 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
@ -38,9 +39,10 @@ import javax.inject.Inject
|
|||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class OutcomingLinkPreviewMessageViewHolder(outcomingView: View, payload: Any) :
|
||||
MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(outcomingView, payload) {
|
||||
MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(outcomingView, payload),
|
||||
AdjustableMessageHolderInterface {
|
||||
|
||||
private val binding: ItemCustomOutcomingLinkPreviewMessageBinding =
|
||||
override val binding: ItemCustomOutcomingLinkPreviewMessageBinding =
|
||||
ItemCustomOutcomingLinkPreviewMessageBinding.bind(itemView)
|
||||
|
||||
@Inject
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Christian Reiner <foss@christian-reiner.info>
|
||||
* SPDX-FileCopyrightText: 2021 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-FileCopyrightText: 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
@ -47,8 +48,10 @@ import kotlin.math.roundToInt
|
|||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class OutcomingLocationMessageViewHolder(incomingView: View) :
|
||||
MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(incomingView) {
|
||||
private val binding: ItemCustomOutcomingLocationMessageBinding =
|
||||
MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(incomingView),
|
||||
AdjustableMessageHolderInterface {
|
||||
|
||||
override val binding: ItemCustomOutcomingLocationMessageBinding =
|
||||
ItemCustomOutcomingLocationMessageBinding.bind(itemView)
|
||||
private val realView: View = itemView
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Christian Reiner <foss@christian-reiner.info>
|
||||
* SPDX-FileCopyrightText: 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* SPDX-FileCopyrightText: 2021 Marcel Hibbe <dev@mhibbe.de>
|
||||
* SPDX-FileCopyrightText: 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
|
@ -38,8 +39,11 @@ import kotlinx.coroutines.withContext
|
|||
import javax.inject.Inject
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class OutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessageViewHolder<ChatMessage>(itemView) {
|
||||
private val binding: ItemCustomOutcomingTextMessageBinding = ItemCustomOutcomingTextMessageBinding.bind(itemView)
|
||||
class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
OutcomingTextMessageViewHolder<ChatMessage>(itemView),
|
||||
AdjustableMessageHolderInterface {
|
||||
|
||||
override val binding: ItemCustomOutcomingTextMessageBinding = ItemCustomOutcomingTextMessageBinding.bind(itemView)
|
||||
private val realView: View = itemView
|
||||
|
||||
@Inject
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Christian Reiner <foss@christian-reiner.info>
|
||||
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* SPDX-FileCopyrightText: 2023 Julius Linus <juliuslinus1@gmail.com>
|
||||
* SPDX-FileCopyrightText: 2021 Marcel Hibbe <dev@mhibbe.de>
|
||||
|
@ -45,9 +46,10 @@ import javax.inject.Inject
|
|||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class OutcomingVoiceMessageViewHolder(outcomingView: View) :
|
||||
MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(outcomingView) {
|
||||
MessageHolders.OutcomingTextMessageViewHolder<ChatMessage>(outcomingView),
|
||||
AdjustableMessageHolderInterface {
|
||||
|
||||
private val binding: ItemCustomOutcomingVoiceMessageBinding = ItemCustomOutcomingVoiceMessageBinding.bind(itemView)
|
||||
override val binding: ItemCustomOutcomingVoiceMessageBinding = ItemCustomOutcomingVoiceMessageBinding.bind(itemView)
|
||||
|
||||
@JvmField
|
||||
@Inject
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Christian Reiner <foss@christian-reiner.info>
|
||||
* SPDX-FileCopyrightText: 2020 Tobias Kaminsky <tobias.kaminsky@nextcloud.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
@ -34,43 +35,50 @@ public class TalkMessagesListAdapter<M extends IMessage> extends MessagesListAda
|
|||
@Override
|
||||
public void onBindViewHolder(ViewHolder holder, int position) {
|
||||
|
||||
if (holder instanceof IncomingTextMessageViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingTextMessageViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
holderInstance.adjustIfNoteToSelf(holderInstance, chatActivity.getCurrentConversation());
|
||||
|
||||
if (holder instanceof IncomingTextMessageViewHolder) {
|
||||
((IncomingTextMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingTextMessageViewHolder) {
|
||||
((OutcomingTextMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof IncomingLocationMessageViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingLocationMessageViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
holderInstance.adjustIfNoteToSelf(holderInstance, chatActivity.getCurrentConversation());
|
||||
|
||||
} else if (holder instanceof IncomingLocationMessageViewHolder) {
|
||||
((IncomingLocationMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingLocationMessageViewHolder) {
|
||||
((OutcomingLocationMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof IncomingLinkPreviewMessageViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingLinkPreviewMessageViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
holderInstance.adjustIfNoteToSelf(holderInstance, chatActivity.getCurrentConversation());
|
||||
|
||||
} else if (holder instanceof IncomingLinkPreviewMessageViewHolder) {
|
||||
((IncomingLinkPreviewMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingLinkPreviewMessageViewHolder) {
|
||||
((OutcomingLinkPreviewMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof IncomingVoiceMessageViewHolder holderInstance) {
|
||||
holderInstance.assignVoiceMessageInterface(chatActivity);
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingVoiceMessageViewHolder holderInstance) {
|
||||
holderInstance.assignVoiceMessageInterface(chatActivity);
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
holderInstance.adjustIfNoteToSelf(holderInstance, chatActivity.getCurrentConversation());
|
||||
|
||||
} else if (holder instanceof IncomingVoiceMessageViewHolder) {
|
||||
((IncomingVoiceMessageViewHolder) holder).assignVoiceMessageInterface(chatActivity);
|
||||
((IncomingVoiceMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingVoiceMessageViewHolder) {
|
||||
((OutcomingVoiceMessageViewHolder) holder).assignVoiceMessageInterface(chatActivity);
|
||||
((OutcomingVoiceMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof PreviewMessageViewHolder holderInstance) {
|
||||
holderInstance.assignPreviewMessageInterface(chatActivity);
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof PreviewMessageViewHolder) {
|
||||
((PreviewMessageViewHolder) holder).assignPreviewMessageInterface(chatActivity);
|
||||
((PreviewMessageViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof SystemMessageViewHolder holderInstance) {
|
||||
holderInstance.assignSystemMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof SystemMessageViewHolder) {
|
||||
((SystemMessageViewHolder) holder).assignSystemMessageInterface(chatActivity);
|
||||
} else if (holder instanceof CallStartedViewHolder) {
|
||||
((CallStartedViewHolder) holder).assignCallStartedMessageInterface(chatActivity);
|
||||
} else if (holder instanceof TemporaryMessageViewHolder) {
|
||||
((TemporaryMessageViewHolder) holder).assignTemporaryMessageInterface(chatActivity);
|
||||
}else if (holder instanceof IncomingDeckCardViewHolder){
|
||||
((IncomingDeckCardViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if(holder instanceof OutcomingDeckCardViewHolder){
|
||||
((OutcomingDeckCardViewHolder) holder).assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof CallStartedViewHolder holderInstance) {
|
||||
holderInstance.assignCallStartedMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof TemporaryMessageViewHolder holderInstance) {
|
||||
holderInstance.assignTemporaryMessageInterface(chatActivity);
|
||||
|
||||
} else if (holder instanceof IncomingDeckCardViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
} else if (holder instanceof OutcomingDeckCardViewHolder holderInstance) {
|
||||
holderInstance.assignCommonMessageInterface(chatActivity);
|
||||
holderInstance.adjustIfNoteToSelf(holderInstance, chatActivity.getCurrentConversation());
|
||||
}
|
||||
|
||||
super.onBindViewHolder(holder, position);
|
||||
|
|
Loading…
Reference in a new issue