mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 14:27:24 +00:00
extend outgoing messages' theming
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
0f94b8c473
commit
641744ec56
@ -30,7 +30,6 @@ import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.ViewCompat
|
||||
@ -157,9 +156,15 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
|
||||
?: context!!.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = parentChatMessage.text
|
||||
binding.messageQuote.quotedMessage.setTextColor(serverTheme.colorText)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(ContextCompat.getColor(context, R.color.nc_grey))
|
||||
|
||||
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.white)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(
|
||||
ColorUtils.setAlphaComponent(
|
||||
serverTheme.colorText,
|
||||
ALPHA_80_INT
|
||||
)
|
||||
)
|
||||
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(serverTheme.colorText)
|
||||
}
|
||||
|
||||
private fun setBubbleOnChatMessage(message: ChatMessage) {
|
||||
@ -230,5 +235,6 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
|
||||
const val TEXT_SIZE_MULTIPLIER = 2.5
|
||||
private const val HALF_ALPHA_INT: Int = 255 / 2
|
||||
private val ALPHA_60_INT: Int = (255 * 0.6).roundToInt()
|
||||
private val ALPHA_80_INT: Int = (255 * 0.8).roundToInt()
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ package com.nextcloud.talk.adapters.messages
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.PorterDuff
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.util.TypedValue
|
||||
@ -35,6 +34,8 @@ import android.webkit.WebView
|
||||
import android.webkit.WebViewClient
|
||||
import android.widget.Toast
|
||||
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
|
||||
@ -45,12 +46,15 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingLocationMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||
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.UriUtils
|
||||
import com.stfalcon.chatkit.messages.MessageHolders
|
||||
import java.net.URLEncoder
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
@ -68,6 +72,12 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
@Inject
|
||||
var context: Context? = null
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
@Inject
|
||||
lateinit var serverTheme: ServerTheme
|
||||
|
||||
lateinit var reactionsInterface: ReactionsInterface
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@ -76,7 +86,6 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
sharedApplication!!.componentApplication.inject(this)
|
||||
|
||||
realView.isSelected = false
|
||||
binding.messageTime.setTextColor(context!!.resources.getColor(R.color.white60))
|
||||
val layoutParams = binding.messageTime.layoutParams as FlexboxLayout.LayoutParams
|
||||
layoutParams.isWrapBefore = false
|
||||
|
||||
@ -85,7 +94,10 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
colorizeMessageBubble(message)
|
||||
binding.messageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
|
||||
binding.messageTime.layoutParams = layoutParams
|
||||
binding.messageTime.setTextColor(ColorUtils.setAlphaComponent(serverTheme.colorText, ALPHA_60_INT))
|
||||
|
||||
binding.messageText.text = message.text
|
||||
binding.messageText.setTextColor(serverTheme.colorText)
|
||||
|
||||
// parent message handling
|
||||
setParentMessageDataOnMessageItem(message)
|
||||
@ -104,8 +116,8 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,12 +212,12 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
|
||||
?: context!!.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = parentChatMessage.text
|
||||
binding.messageQuote.quotedMessage.setTextColor(
|
||||
context!!.resources.getColor(R.color.nc_outcoming_text_default)
|
||||
binding.messageQuote.quotedMessage.setTextColor(serverTheme.colorText)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(
|
||||
ColorUtils.setAlphaComponent(serverTheme.colorText, ALPHA_80_INT)
|
||||
)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(context!!.resources.getColor(R.color.nc_grey))
|
||||
|
||||
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.white)
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(serverTheme.colorText)
|
||||
|
||||
binding.messageQuote.quotedChatMessageView.visibility = View.VISIBLE
|
||||
} else {
|
||||
@ -215,15 +227,16 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
|
||||
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
|
||||
)
|
||||
@ -231,7 +244,7 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
} else {
|
||||
val bubbleDrawable = DisplayUtils.getMessageSelector(
|
||||
bgBubbleColor,
|
||||
resources.getColor(R.color.transparent),
|
||||
ResourcesCompat.getColor(resources, R.color.transparent, null),
|
||||
bgBubbleColor,
|
||||
R.drawable.shape_outcoming_message
|
||||
)
|
||||
@ -261,5 +274,8 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
||||
|
||||
companion object {
|
||||
private const val TAG = "LocOutMessageView"
|
||||
private const val HALF_ALPHA_INT: Int = 255 / 2
|
||||
private val ALPHA_60_INT: Int = (255 * 0.6).roundToInt()
|
||||
private val ALPHA_80_INT: Int = (255 * 0.8).roundToInt()
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ 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
|
||||
@ -185,12 +184,14 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag
|
||||
binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
|
||||
?: context.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = parentChatMessage.text
|
||||
binding.messageQuote.quotedMessage.setTextColor(
|
||||
context.resources.getColor(R.color.nc_outcoming_text_default)
|
||||
binding.messageQuote.quotedMessage.setTextColor(serverTheme.colorText)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(
|
||||
ColorUtils.setAlphaComponent(serverTheme.colorText,
|
||||
ALPHA_80_INT
|
||||
)
|
||||
)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(context.resources.getColor(R.color.nc_grey))
|
||||
|
||||
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.white)
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(serverTheme.colorText)
|
||||
|
||||
binding.messageQuote.quotedChatMessageView.visibility = View.VISIBLE
|
||||
} else {
|
||||
@ -232,6 +233,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 val ALPHA_80_INT: Int = (255 * 0.8).roundToInt()
|
||||
private const val HALF_ALPHA_INT: Int = 255 / 2
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,8 @@ import android.view.View
|
||||
import android.widget.SeekBar
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.work.WorkInfo
|
||||
import androidx.work.WorkManager
|
||||
@ -42,12 +44,15 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
|
||||
import com.nextcloud.talk.databinding.ItemCustomOutcomingVoiceMessageBinding
|
||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||
import com.nextcloud.talk.models.json.chat.ReadStatus
|
||||
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 java.util.concurrent.ExecutionException
|
||||
import javax.inject.Inject
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication::class)
|
||||
class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||
@ -60,6 +65,12 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||
@Inject
|
||||
var context: Context? = null
|
||||
|
||||
@Inject
|
||||
lateinit var viewThemeUtils: ViewThemeUtils
|
||||
|
||||
@Inject
|
||||
lateinit var serverTheme: ServerTheme
|
||||
|
||||
@JvmField
|
||||
@Inject
|
||||
var appPreferences: AppPreferences? = null
|
||||
@ -250,12 +261,14 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||
binding.messageQuote.quotedMessageAuthor.text = parentChatMessage.actorDisplayName
|
||||
?: context!!.getText(R.string.nc_nick_guest)
|
||||
binding.messageQuote.quotedMessage.text = parentChatMessage.text
|
||||
binding.messageQuote.quotedMessage.setTextColor(
|
||||
context!!.resources.getColor(R.color.nc_outcoming_text_default)
|
||||
binding.messageQuote.quotedMessage.setTextColor(serverTheme.colorText)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(
|
||||
ColorUtils.setAlphaComponent(serverTheme.colorText,
|
||||
ALPHA_80_INT
|
||||
)
|
||||
)
|
||||
binding.messageQuote.quotedMessageAuthor.setTextColor(context!!.resources.getColor(R.color.nc_grey))
|
||||
|
||||
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.white)
|
||||
binding.messageQuote.quoteColoredView.setBackgroundColor(serverTheme.colorText)
|
||||
|
||||
binding.messageQuote.quotedChatMessageView.visibility = View.VISIBLE
|
||||
} else {
|
||||
@ -265,15 +278,16 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||
|
||||
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
|
||||
)
|
||||
@ -281,7 +295,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||
} else {
|
||||
val bubbleDrawable = DisplayUtils.getMessageSelector(
|
||||
bgBubbleColor,
|
||||
resources.getColor(R.color.transparent),
|
||||
ResourcesCompat.getColor(resources, R.color.transparent, null),
|
||||
bgBubbleColor,
|
||||
R.drawable.shape_outcoming_message
|
||||
)
|
||||
@ -300,5 +314,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
||||
companion object {
|
||||
private const val TAG = "VoiceOutMessageView"
|
||||
private const val SEEKBAR_START: Int = 0
|
||||
private const val HALF_ALPHA_INT: Int = 255 / 2
|
||||
private val ALPHA_80_INT: Int = (255 * 0.8).roundToInt()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user