mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-10 06:14:10 +01:00
proper material 3 reactions theming
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
fd49b13b14
commit
4c9f5bec2e
@ -102,7 +102,13 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess
|
|||||||
// geo-location
|
// geo-location
|
||||||
setLocationDataOnMessageItem(message)
|
setLocationDataOnMessageItem(message)
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, binding.messageText.context, false)
|
Reaction().showReactions(
|
||||||
|
message,
|
||||||
|
binding.reactions,
|
||||||
|
binding.messageText.context,
|
||||||
|
false,
|
||||||
|
viewThemeUtils
|
||||||
|
)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,13 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH
|
|||||||
|
|
||||||
setPollPreview(message)
|
setPollPreview(message)
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, binding.messageTime.context, false)
|
Reaction().showReactions(
|
||||||
|
message,
|
||||||
|
binding.reactions,
|
||||||
|
binding.messageTime.context,
|
||||||
|
false,
|
||||||
|
viewThemeUtils
|
||||||
|
)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,13 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, binding.messageTime.context, false)
|
Reaction().showReactions(
|
||||||
|
message,
|
||||||
|
binding.reactions,
|
||||||
|
binding.messageTime.context,
|
||||||
|
false,
|
||||||
|
viewThemeUtils
|
||||||
|
)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,13 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message
|
|||||||
|
|
||||||
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, binding.messageText.context, false)
|
Reaction().showReactions(
|
||||||
|
message,
|
||||||
|
binding.reactions,
|
||||||
|
binding.messageText.context,
|
||||||
|
false,
|
||||||
|
viewThemeUtils
|
||||||
|
)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
|
|||||||
|
|
||||||
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
itemView.setTag(MessageSwipeCallback.REPLYABLE_VIEW_TAG, message.replyable)
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, context!!, true)
|
Reaction().showReactions(message, binding.reactions, context, true, viewThemeUtils)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ import com.nextcloud.talk.data.user.model.User;
|
|||||||
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding;
|
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding;
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
import com.nextcloud.talk.models.json.chat.ChatMessage;
|
||||||
import com.nextcloud.talk.ui.theme.ServerTheme;
|
import com.nextcloud.talk.ui.theme.ServerTheme;
|
||||||
|
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
|
||||||
import com.nextcloud.talk.utils.DisplayUtils;
|
import com.nextcloud.talk.utils.DisplayUtils;
|
||||||
import com.nextcloud.talk.utils.DrawableUtils;
|
import com.nextcloud.talk.utils.DrawableUtils;
|
||||||
import com.nextcloud.talk.utils.FileViewerUtils;
|
import com.nextcloud.talk.utils.FileViewerUtils;
|
||||||
@ -96,6 +97,9 @@ public abstract class MagicPreviewMessageViewHolder extends MessageHolders.Incom
|
|||||||
@Inject
|
@Inject
|
||||||
ServerTheme serverTheme;
|
ServerTheme serverTheme;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ViewThemeUtils viewThemeUtils;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OkHttpClient okHttpClient;
|
OkHttpClient okHttpClient;
|
||||||
|
|
||||||
@ -239,7 +243,11 @@ public abstract class MagicPreviewMessageViewHolder extends MessageHolders.Incom
|
|||||||
itemView.setTag(REPLYABLE_VIEW_TAG, message.getReplyable());
|
itemView.setTag(REPLYABLE_VIEW_TAG, message.getReplyable());
|
||||||
|
|
||||||
reactionsBinding = getReactionsBinding();
|
reactionsBinding = getReactionsBinding();
|
||||||
new Reaction().showReactions(message, reactionsBinding, getMessageText().getContext(), true);
|
new Reaction().showReactions(message,
|
||||||
|
reactionsBinding,
|
||||||
|
getMessageText().getContext(),
|
||||||
|
true,
|
||||||
|
viewThemeUtils);
|
||||||
reactionsBinding.reactionsEmojiWrapper.setOnClickListener(l -> {
|
reactionsBinding.reactionsEmojiWrapper.setOnClickListener(l -> {
|
||||||
reactionsInterface.onClickReactions(message);
|
reactionsInterface.onClickReactions(message);
|
||||||
});
|
});
|
||||||
|
@ -120,7 +120,13 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
|
|||||||
// geo-location
|
// geo-location
|
||||||
setLocationDataOnMessageItem(message)
|
setLocationDataOnMessageItem(message)
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, binding.messageText.context, true)
|
Reaction().showReactions(
|
||||||
|
message,
|
||||||
|
binding.reactions,
|
||||||
|
binding.messageText.context,
|
||||||
|
true,
|
||||||
|
viewThemeUtils
|
||||||
|
)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,13 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag
|
|||||||
|
|
||||||
setPollPreview(message)
|
setPollPreview(message)
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, binding.messageTime.context, true)
|
Reaction().showReactions(
|
||||||
|
message,
|
||||||
|
binding.reactions,
|
||||||
|
binding.messageTime.context,
|
||||||
|
true,
|
||||||
|
viewThemeUtils
|
||||||
|
)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,13 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
|
|||||||
|
|
||||||
binding.checkMark.setContentDescription(readStatusContentDescriptionString)
|
binding.checkMark.setContentDescription(readStatusContentDescriptionString)
|
||||||
|
|
||||||
Reaction().showReactions(message, binding.reactions, binding.messageTime.context, true)
|
Reaction().showReactions(
|
||||||
|
message,
|
||||||
|
binding.reactions,
|
||||||
|
binding.messageTime.context,
|
||||||
|
true,
|
||||||
|
viewThemeUtils
|
||||||
|
)
|
||||||
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
binding.reactions.reactionsEmojiWrapper.setOnClickListener {
|
||||||
reactionsInterface.onClickReactions(message)
|
reactionsInterface.onClickReactions(message)
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,11 @@ import android.content.Context
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.LinearLayout
|
import android.widget.LinearLayout
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.content.res.AppCompatResources
|
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import com.nextcloud.talk.R
|
import com.nextcloud.talk.R
|
||||||
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
|
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding
|
||||||
import com.nextcloud.talk.models.json.chat.ChatMessage
|
import com.nextcloud.talk.models.json.chat.ChatMessage
|
||||||
|
import com.nextcloud.talk.ui.theme.ViewThemeUtils
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
import com.vanniktech.emoji.EmojiTextView
|
import com.vanniktech.emoji.EmojiTextView
|
||||||
|
|
||||||
@ -41,7 +41,8 @@ class Reaction {
|
|||||||
message: ChatMessage,
|
message: ChatMessage,
|
||||||
binding: ReactionsInsideMessageBinding,
|
binding: ReactionsInsideMessageBinding,
|
||||||
context: Context,
|
context: Context,
|
||||||
isOutgoingMessage: Boolean
|
isOutgoingMessage: Boolean,
|
||||||
|
viewThemeUtils: ViewThemeUtils
|
||||||
) {
|
) {
|
||||||
binding.reactionsEmojiWrapper.removeAllViews()
|
binding.reactionsEmojiWrapper.removeAllViews()
|
||||||
if (message.reactions != null && message.reactions!!.isNotEmpty()) {
|
if (message.reactions != null && message.reactions!!.isNotEmpty()) {
|
||||||
@ -49,7 +50,6 @@ class Reaction {
|
|||||||
var remainingEmojisToDisplay = MAX_EMOJIS_TO_DISPLAY
|
var remainingEmojisToDisplay = MAX_EMOJIS_TO_DISPLAY
|
||||||
val showInfoAboutMoreEmojis = message.reactions!!.size > MAX_EMOJIS_TO_DISPLAY
|
val showInfoAboutMoreEmojis = message.reactions!!.size > MAX_EMOJIS_TO_DISPLAY
|
||||||
|
|
||||||
val textColor = getTextColor(context, isOutgoingMessage, binding)
|
|
||||||
val amountParams = getAmountLayoutParams(context)
|
val amountParams = getAmountLayoutParams(context)
|
||||||
val wrapperParams = getWrapperLayoutParams(context)
|
val wrapperParams = getWrapperLayoutParams(context)
|
||||||
|
|
||||||
@ -58,9 +58,12 @@ class Reaction {
|
|||||||
val paddingBottom = DisplayUtils.convertDpToPixel(WRAPPER_PADDING_BOTTOM, context).toInt()
|
val paddingBottom = DisplayUtils.convertDpToPixel(WRAPPER_PADDING_BOTTOM, context).toInt()
|
||||||
|
|
||||||
for ((emoji, amount) in message.reactions!!) {
|
for ((emoji, amount) in message.reactions!!) {
|
||||||
|
val isSelfReaction = message.reactionsSelf != null &&
|
||||||
|
message.reactionsSelf!!.isNotEmpty() &&
|
||||||
|
message.reactionsSelf!!.contains(emoji)
|
||||||
|
val textColor = getTextColor(isOutgoingMessage, isSelfReaction, binding, viewThemeUtils)
|
||||||
val emojiWithAmountWrapper = getEmojiWithAmountWrapperLayout(
|
val emojiWithAmountWrapper = getEmojiWithAmountWrapperLayout(
|
||||||
context,
|
binding.reactionsEmojiWrapper.context,
|
||||||
message,
|
|
||||||
emoji,
|
emoji,
|
||||||
amount,
|
amount,
|
||||||
EmojiWithAmountWrapperLayoutInfo(
|
EmojiWithAmountWrapperLayoutInfo(
|
||||||
@ -69,7 +72,10 @@ class Reaction {
|
|||||||
wrapperParams,
|
wrapperParams,
|
||||||
paddingSide,
|
paddingSide,
|
||||||
paddingTop,
|
paddingTop,
|
||||||
paddingBottom
|
paddingBottom,
|
||||||
|
viewThemeUtils,
|
||||||
|
isOutgoingMessage,
|
||||||
|
isSelfReaction
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -86,7 +92,6 @@ class Reaction {
|
|||||||
|
|
||||||
private fun getEmojiWithAmountWrapperLayout(
|
private fun getEmojiWithAmountWrapperLayout(
|
||||||
context: Context,
|
context: Context,
|
||||||
message: ChatMessage,
|
|
||||||
emoji: String,
|
emoji: String,
|
||||||
amount: Int,
|
amount: Int,
|
||||||
layoutInfo: EmojiWithAmountWrapperLayoutInfo
|
layoutInfo: EmojiWithAmountWrapperLayoutInfo
|
||||||
@ -98,12 +103,17 @@ class Reaction {
|
|||||||
emojiWithAmountWrapper.addView(getReactionCount(context, layoutInfo.textColor, amount, layoutInfo.amountParams))
|
emojiWithAmountWrapper.addView(getReactionCount(context, layoutInfo.textColor, amount, layoutInfo.amountParams))
|
||||||
emojiWithAmountWrapper.layoutParams = layoutInfo.wrapperParams
|
emojiWithAmountWrapper.layoutParams = layoutInfo.wrapperParams
|
||||||
|
|
||||||
if (message.reactionsSelf != null &&
|
if (layoutInfo.isSelfReaction) {
|
||||||
message.reactionsSelf!!.isNotEmpty() &&
|
val color = if (layoutInfo.isOutgoingMessage) {
|
||||||
message.reactionsSelf!!.contains(emoji)
|
ContextCompat.getColor(
|
||||||
) {
|
emojiWithAmountWrapper.context,
|
||||||
emojiWithAmountWrapper.background =
|
R.color.bg_message_list_incoming_bubble
|
||||||
AppCompatResources.getDrawable(context, R.drawable.reaction_self_background)
|
)
|
||||||
|
} else {
|
||||||
|
layoutInfo.viewThemeUtils.getScheme(emojiWithAmountWrapper.context).primaryContainer
|
||||||
|
}
|
||||||
|
layoutInfo.viewThemeUtils.setCheckedBackground(emojiWithAmountWrapper, color)
|
||||||
|
|
||||||
emojiWithAmountWrapper.setPaddingRelative(
|
emojiWithAmountWrapper.setPaddingRelative(
|
||||||
layoutInfo.paddingSide,
|
layoutInfo.paddingSide,
|
||||||
layoutInfo.paddingTop,
|
layoutInfo.paddingTop,
|
||||||
@ -166,12 +176,13 @@ class Reaction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getTextColor(
|
private fun getTextColor(
|
||||||
context: Context,
|
|
||||||
isOutgoingMessage: Boolean,
|
isOutgoingMessage: Boolean,
|
||||||
binding: ReactionsInsideMessageBinding
|
isSelfReaction: Boolean,
|
||||||
|
binding: ReactionsInsideMessageBinding,
|
||||||
|
viewThemeUtils: ViewThemeUtils
|
||||||
): Int {
|
): Int {
|
||||||
var textColor = ContextCompat.getColor(context, R.color.white)
|
var textColor = viewThemeUtils.getScheme(binding.root.context).onSurfaceVariant
|
||||||
if (!isOutgoingMessage) {
|
if (!isOutgoingMessage || isSelfReaction) {
|
||||||
textColor = ContextCompat.getColor(binding.root.context, R.color.high_emphasis_text)
|
textColor = ContextCompat.getColor(binding.root.context, R.color.high_emphasis_text)
|
||||||
}
|
}
|
||||||
return textColor
|
return textColor
|
||||||
@ -183,7 +194,10 @@ class Reaction {
|
|||||||
val wrapperParams: LinearLayout.LayoutParams,
|
val wrapperParams: LinearLayout.LayoutParams,
|
||||||
val paddingSide: Int,
|
val paddingSide: Int,
|
||||||
val paddingTop: Int,
|
val paddingTop: Int,
|
||||||
val paddingBottom: Int
|
val paddingBottom: Int,
|
||||||
|
val viewThemeUtils: ViewThemeUtils,
|
||||||
|
val isOutgoingMessage: Boolean,
|
||||||
|
val isSelfReaction: Boolean
|
||||||
)
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -690,6 +690,19 @@ class ViewThemeUtils @Inject constructor(private val theme: ServerTheme, private
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setCheckedBackground(linearLayout: LinearLayout, @ColorInt backgroundColor: Int) {
|
||||||
|
withScheme(linearLayout) { scheme ->
|
||||||
|
val drawable = AppCompatResources
|
||||||
|
.getDrawable(linearLayout.context, R.drawable.reaction_self_background)!!
|
||||||
|
.mutate()
|
||||||
|
DrawableCompat.setTintList(
|
||||||
|
drawable,
|
||||||
|
ColorStateList.valueOf(backgroundColor)
|
||||||
|
)
|
||||||
|
linearLayout.background = drawable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
|
private val THEMEABLE_PLACEHOLDER_IDS = listOf(
|
||||||
R.drawable.ic_mimetype_package_x_generic,
|
R.drawable.ic_mimetype_package_x_generic,
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
<stroke
|
<stroke
|
||||||
android:width="1dp"
|
android:width="1dp"
|
||||||
android:color="@color/colorPrimary" />
|
android:color="@color/high_emphasis_text" />
|
||||||
|
|
||||||
<solid
|
<solid
|
||||||
android:color="@color/bg_message_own_reaction" />
|
android:color="#FFFFFF" />
|
||||||
|
|
||||||
<padding
|
<padding
|
||||||
android:left="1dp"
|
android:left="1dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user