theme outgoing poll bubble

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-07-27 22:50:54 +02:00
parent a907b1ba51
commit 0f94b8c473
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 33 additions and 10 deletions

View file

@ -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
}
}

View file

@ -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?" />
</LinearLayout>
@ -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" />
<ImageView
@ -93,9 +93,9 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageTime"
android:layout_marginStart="8dp"
android:contentDescription="@null"
android:textColor="@color/nc_outcoming_text_default"
app:layout_alignSelf="center"
android:contentDescription="@null" />
app:layout_alignSelf="center" />
<include
android:id="@+id/reactions"