diff --git a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingPollMessageViewHolder.kt b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingPollMessageViewHolder.kt index 2d1726d57..497e2841a 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingPollMessageViewHolder.kt +++ b/app/src/main/java/com/nextcloud/talk/adapters/messages/OutcomingPollMessageViewHolder.kt @@ -23,9 +23,12 @@ package com.nextcloud.talk.adapters.messages import android.annotation.SuppressLint import android.content.Context +import android.content.res.ColorStateList import android.graphics.PorterDuff import android.view.View import androidx.appcompat.content.res.AppCompatResources +import androidx.core.content.res.ResourcesCompat +import androidx.core.graphics.ColorUtils import androidx.core.view.ViewCompat import autodagger.AutoInjector import coil.load @@ -38,11 +41,14 @@ import com.nextcloud.talk.databinding.ItemCustomOutcomingPollMessageBinding import com.nextcloud.talk.models.json.chat.ChatMessage import com.nextcloud.talk.models.json.chat.ReadStatus import com.nextcloud.talk.polls.ui.PollMainDialogFragment +import com.nextcloud.talk.ui.theme.ServerTheme +import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.DisplayUtils import com.nextcloud.talk.utils.preferences.AppPreferences import com.stfalcon.chatkit.messages.MessageHolders import javax.inject.Inject +import kotlin.math.roundToInt @AutoInjector(NextcloudTalkApplication::class) class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : MessageHolders @@ -54,6 +60,12 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag @Inject lateinit var context: Context + @Inject + lateinit var viewThemeUtils: ViewThemeUtils + + @Inject + lateinit var serverTheme: ServerTheme + @Inject lateinit var appPreferences: AppPreferences @@ -73,7 +85,12 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag colorizeMessageBubble(message) itemView.isSelected = false - binding.messageTime.setTextColor(context.resources.getColor(R.color.white60)) + binding.messageTime.setTextColor( + ColorUtils.setAlphaComponent( + serverTheme.colorText, + ALPHA_60_INT + ) + ) // parent message handling setParentMessageDataOnMessageItem(message) @@ -92,8 +109,8 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag readStatusDrawableInt?.let { drawableInt -> AppCompatResources.getDrawable(context, drawableInt)?.let { - it.setColorFilter(context.resources!!.getColor(R.color.white60), PorterDuff.Mode.SRC_ATOP) binding.checkMark.setImageDrawable(it) + viewThemeUtils.colorImageViewText(binding.checkMark) } } @@ -126,6 +143,9 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag } if (pollId != null && pollName != null) { + binding.messagePollTitle.setTextColor(serverTheme.colorText) + binding.messagePollSubtitle.setTextColor(serverTheme.colorText) + binding.messagePollIcon.imageTintList = ColorStateList.valueOf(serverTheme.colorText) binding.messagePollTitle.text = pollName val roomToken = (payload as? MessagePayload)!!.roomToken @@ -180,15 +200,16 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag private fun colorizeMessageBubble(message: ChatMessage) { val resources = sharedApplication!!.resources + val elementColor = viewThemeUtils.getElementColor(binding.root.context) val bgBubbleColor = if (message.isDeleted) { - resources.getColor(R.color.bg_message_list_outcoming_bubble_deleted) + ColorUtils.setAlphaComponent(elementColor, HALF_ALPHA_INT) } else { - resources.getColor(R.color.bg_message_list_outcoming_bubble) + elementColor } if (message.isGrouped) { val bubbleDrawable = DisplayUtils.getMessageSelector( bgBubbleColor, - resources.getColor(R.color.transparent), + ResourcesCompat.getColor(resources, R.color.transparent, null), bgBubbleColor, R.drawable.shape_grouped_outcoming_message ) @@ -196,7 +217,7 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag } else { val bubbleDrawable = DisplayUtils.getMessageSelector( bgBubbleColor, - resources.getColor(R.color.transparent), + ResourcesCompat.getColor(resources, R.color.transparent, null), bgBubbleColor, R.drawable.shape_outcoming_message ) @@ -210,5 +231,7 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag companion object { private val TAG = NextcloudTalkApplication::class.java.simpleName + private val ALPHA_60_INT: Int = (255 * 0.6).roundToInt() + private const val HALF_ALPHA_INT: Int = 255 / 2 } } diff --git a/app/src/main/res/layout/item_custom_outcoming_poll_message.xml b/app/src/main/res/layout/item_custom_outcoming_poll_message.xml index 1f3cfbdfb..d19fc3282 100644 --- a/app/src/main/res/layout/item_custom_outcoming_poll_message.xml +++ b/app/src/main/res/layout/item_custom_outcoming_poll_message.xml @@ -63,8 +63,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="viewStart" - android:textStyle="bold" android:textColor="@color/nc_outcoming_text_default" + android:textStyle="bold" tools:text="This is the poll title?" /> @@ -83,8 +83,8 @@ android:layout_height="wrap_content" android:layout_below="@id/messageText" android:layout_marginStart="8dp" - app:layout_alignSelf="center" android:textColor="@color/nc_outcoming_text_default" + app:layout_alignSelf="center" tools:text="10:35" /> + app:layout_alignSelf="center" />