further optimize material coloring for messages, especially time, quotes and read status

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2022-08-04 18:14:30 +02:00
parent 006c893318
commit 2e8ea52e89
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
25 changed files with 90 additions and 62 deletions

View File

@ -90,7 +90,6 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess
colorizeMessageBubble(message)
itemView.isSelected = false
binding.messageTime.setTextColor(context?.resources!!.getColor(R.color.warm_grey_four))
val textSize = context?.resources!!.getDimension(R.dimen.chat_text_size)
binding.messageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
@ -188,7 +187,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) : Mess
.setTextColor(context!!.resources.getColor(R.color.textColorMaxContrast))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.colorPrimary)
viewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
}

View File

@ -81,7 +81,6 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH
colorizeMessageBubble(message)
itemView.isSelected = false
binding.messageTime.setTextColor(ResourcesCompat.getColor(context?.resources!!, R.color.warm_grey_four, null))
// parent message handling
setParentMessageDataOnMessageItem(message)
@ -218,7 +217,7 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) : MessageH
.setTextColor(ContextCompat.getColor(context, R.color.textColorMaxContrast))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.colorPrimary)
viewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
}

View File

@ -26,9 +26,12 @@ import android.view.View;
import android.widget.ProgressBar;
import com.facebook.drawee.view.SimpleDraweeView;
import com.nextcloud.talk.R;
import com.nextcloud.talk.databinding.ItemCustomIncomingPreviewMessageBinding;
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding;
import com.nextcloud.talk.models.json.chat.ChatMessage;
import androidx.core.content.ContextCompat;
import androidx.emoji.widget.EmojiTextView;
public class IncomingPreviewMessageViewHolder extends MagicPreviewMessageViewHolder {
@ -39,6 +42,16 @@ public class IncomingPreviewMessageViewHolder extends MagicPreviewMessageViewHol
binding = ItemCustomIncomingPreviewMessageBinding.bind(itemView);
}
@Override
public void onBind(ChatMessage message) {
super.onBind(message);
binding.messageText.setTextColor(ContextCompat.getColor(binding.messageText.getContext(),
R.color.no_emphasis_text));
binding.messageTime.setTextColor(ContextCompat.getColor(binding.messageText.getContext(),
R.color.no_emphasis_text));
}
@Override
public EmojiTextView getMessageText() {
return binding.messageText;

View File

@ -89,7 +89,6 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
colorizeMessageBubble(message)
itemView.isSelected = false
binding.messageTime.setTextColor(ResourcesCompat.getColor(context?.resources!!, R.color.warm_grey_four, null))
// parent message handling
setParentMessageDataOnMessageItem(message)
@ -292,7 +291,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) : Message
.setTextColor(ContextCompat.getColor(context!!, R.color.textColorMaxContrast))
if (parentChatMessage.actorId?.equals(message.activeUser!!.userId) == true) {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.colorPrimary)
viewThemeUtils.colorPrimaryView(binding.messageQuote.quoteColoredView)
} else {
binding.messageQuote.quoteColoredView.setBackgroundResource(R.color.textColorMaxContrast)
}

View File

@ -89,12 +89,9 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message
binding.messageAuthor.visibility = View.GONE
}
val resources = itemView.resources
setBubbleOnChatMessage(message, resources)
viewThemeUtils.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
itemView.isSelected = false
binding.messageTime.setTextColor(ResourcesCompat.getColor(resources, R.color.warm_grey_four, null))
var messageString: Spannable = SpannableString(message.text)
@ -149,30 +146,6 @@ class MagicIncomingTextMessageViewHolder(itemView: View, payload: Any) : Message
}
}
private fun setBubbleOnChatMessage(
message: ChatMessage,
resources: Resources
) {
val bgBubbleColor = if (message.isDeleted) {
ResourcesCompat.getColor(resources, R.color.bg_message_list_incoming_bubble_deleted, null)
} else {
ResourcesCompat.getColor(resources, R.color.bg_message_list_incoming_bubble, null)
}
var bubbleResource = R.drawable.shape_incoming_message
if (message.isGrouped) {
bubbleResource = R.drawable.shape_grouped_incoming_message
}
val bubbleDrawable = DisplayUtils.getMessageSelector(
bgBubbleColor,
ResourcesCompat.getColor(resources, R.color.transparent, null),
bgBubbleColor, bubbleResource
)
ViewCompat.setBackground(bubble, bubbleDrawable)
}
private fun processParentMessage(message: ChatMessage) {
val parentChatMessage = message.parentMessage
parentChatMessage!!.activeUser = message.activeUser

View File

@ -77,15 +77,13 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
val layoutParams = binding.messageTime.layoutParams as FlexboxLayout.LayoutParams
layoutParams.isWrapBefore = false
var textSize = context!!.resources.getDimension(R.dimen.chat_text_size)
binding.messageTime.setTextColor(viewThemeUtils.getScheme(binding.messageText.context).onSurfaceVariant)
val textColor = viewThemeUtils.getScheme(binding.messageText.context).onSurfaceVariant
binding.messageTime.setTextColor(textColor)
if (messageParameters != null && messageParameters.size > 0) {
messageString = processMessageParameters(messageParameters, message, messageString)
} else if (TextMatchers.isMessageWithSingleEmoticonOnly(message.text)) {
textSize = (textSize * TEXT_SIZE_MULTIPLIER).toFloat()
layoutParams.isWrapBefore = true
binding.messageTime.setTextColor(
ResourcesCompat.getColor(context!!.resources, R.color.warm_grey_four, null)
)
realView.isSelected = true
}
@ -93,7 +91,7 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
binding.messageText.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize)
binding.messageTime.layoutParams = layoutParams
binding.messageText.setTextColor(viewThemeUtils.getScheme(binding.messageText.context).onSurfaceVariant)
binding.messageText.setTextColor(textColor)
binding.messageText.text = messageString
// parent message handling
@ -141,6 +139,7 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
private fun processParentMessage(message: ChatMessage) {
val parentChatMessage = message.parentMessage
val textColor = viewThemeUtils.getScheme(binding.messageQuote.quotedMessage.context).onSurfaceVariant
parentChatMessage!!.activeUser = message.activeUser
parentChatMessage.imageUrl?.let {
binding.messageQuote.quotedMessageImage.visibility = View.VISIBLE
@ -157,9 +156,9 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
?: context!!.getText(R.string.nc_nick_guest)
binding.messageQuote.quotedMessage.text = parentChatMessage.text
binding.messageQuote.quoteColoredView.setBackgroundColor(
ContextCompat.getColor(binding.messageQuote.quoteColoredView.context, R.color.high_emphasis_text)
)
binding.messageQuote.quotedMessageAuthor.setTextColor(textColor)
binding.messageQuote.quotedMessage.setTextColor(textColor)
binding.messageQuote.quoteColoredView.setBackgroundColor(textColor)
}
private fun setBubbleOnChatMessage(message: ChatMessage) {
@ -206,8 +205,5 @@ class MagicOutcomingTextMessageViewHolder(itemView: View) : OutcomingTextMessage
companion object {
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()
}
}

View File

@ -188,7 +188,8 @@ public abstract class MagicPreviewMessageViewHolder extends MessageHolders.Incom
if (drawable != null &&
(drawableResourceId == R.drawable.ic_mimetype_folder ||
drawableResourceId == R.drawable.ic_mimetype_package_x_generic)) {
drawable.setColorFilter(serverTheme.getPrimaryColor(), PorterDuff.Mode.SRC_ATOP);
drawable.setColorFilter(viewThemeUtils.getScheme(image.getContext()).getPrimary(),
PorterDuff.Mode.SRC_ATOP);
}
image.getHierarchy().setPlaceholderImage(drawable);

View File

@ -25,6 +25,7 @@ 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
@ -81,6 +82,8 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
override fun onBind(message: ChatMessage) {
super.onBind(message)
sharedApplication!!.componentApplication.inject(this)
val textColor = viewThemeUtils.getScheme(binding.messageTime.context).onSurfaceVariant
binding.messageTime.setTextColor(textColor)
realView.isSelected = false
val layoutParams = binding.messageTime.layoutParams as FlexboxLayout.LayoutParams
@ -112,6 +115,9 @@ class OutcomingLocationMessageViewHolder(incomingView: View) : MessageHolders
readStatusDrawableInt?.let { drawableInt ->
AppCompatResources.getDrawable(context!!, drawableInt)?.let {
binding.checkMark.setImageDrawable(it)
binding.checkMark.setColorFilter(
viewThemeUtils.getScheme(binding.checkMark.context).onSurfaceVariant, PorterDuff.Mode.SRC_ATOP
)
}
}

View File

@ -23,6 +23,7 @@ package com.nextcloud.talk.adapters.messages
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.PorterDuff
import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.graphics.ColorUtils
@ -76,6 +77,8 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag
super.onBind(message)
this.message = message
sharedApplication!!.componentApplication.inject(this)
val textColor = viewThemeUtils.getScheme(binding.messageTime.context).onSurfaceVariant
binding.messageTime.setTextColor(textColor)
colorizeMessageBubble(message)
@ -99,6 +102,9 @@ class OutcomingPollMessageViewHolder(outcomingView: View, payload: Any) : Messag
readStatusDrawableInt?.let { drawableInt ->
AppCompatResources.getDrawable(context, drawableInt)?.let {
binding.checkMark.setImageDrawable(it)
binding.checkMark.setColorFilter(
viewThemeUtils.getScheme(binding.checkMark.context).onSurfaceVariant, PorterDuff.Mode.SRC_ATOP
)
}
}

View File

@ -26,12 +26,16 @@ import android.view.View;
import android.widget.ProgressBar;
import com.facebook.drawee.view.SimpleDraweeView;
import com.nextcloud.talk.R;
import com.nextcloud.talk.databinding.ItemCustomOutcomingPreviewMessageBinding;
import com.nextcloud.talk.databinding.ReactionsInsideMessageBinding;
import com.nextcloud.talk.models.json.chat.ChatMessage;
import androidx.core.content.ContextCompat;
import androidx.emoji.widget.EmojiTextView;
public class OutcomingPreviewMessageViewHolder extends MagicPreviewMessageViewHolder {
private final ItemCustomOutcomingPreviewMessageBinding binding;
public OutcomingPreviewMessageViewHolder(View itemView) {
@ -39,6 +43,16 @@ public class OutcomingPreviewMessageViewHolder extends MagicPreviewMessageViewHo
binding = ItemCustomOutcomingPreviewMessageBinding.bind(itemView);
}
@Override
public void onBind(ChatMessage message) {
super.onBind(message);
binding.messageText.setTextColor(ContextCompat.getColor(binding.messageText.getContext(),
R.color.no_emphasis_text));
binding.messageTime.setTextColor(ContextCompat.getColor(binding.messageText.getContext(),
R.color.no_emphasis_text));
}
@Override
public EmojiTextView getMessageText() {
return binding.messageText;

View File

@ -24,6 +24,7 @@ package com.nextcloud.talk.adapters.messages
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.PorterDuff
import android.os.Handler
import android.util.Log
import android.view.View
@ -83,6 +84,8 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
super.onBind(message)
this.message = message
sharedApplication!!.componentApplication.inject(this)
val textColor = viewThemeUtils.getScheme(binding.messageTime.context).onSurfaceVariant
binding.messageTime.setTextColor(textColor)
colorizeMessageBubble(message)
@ -132,6 +135,9 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) : MessageHolders
readStatusDrawableInt?.let { drawableInt ->
AppCompatResources.getDrawable(context!!, drawableInt)?.let {
binding.checkMark.setImageDrawable(it)
binding.checkMark.setColorFilter(
viewThemeUtils.getScheme(binding.checkMark.context).onSurfaceVariant, PorterDuff.Mode.SRC_ATOP
)
}
}

View File

@ -74,6 +74,7 @@
app:incomingImageTimeTextSize="12sp"
app:incomingTextColor="@color/nc_incoming_text_default"
app:incomingTextLinkColor="@color/nc_incoming_text_default"
app:incomingTimeTextColor="@color/no_emphasis_text"
app:incomingTextSize="@dimen/chat_text_size"
app:incomingTimeTextSize="12sp"
app:outcomingBubblePaddingBottom="@dimen/message_bubble_corners_padding"

View File

@ -87,7 +87,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:textColor="@color/medium_emphasis_text"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center" />
<include

View File

@ -99,7 +99,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:textColor="@color/medium_emphasis_text"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center"
tools:text="12:38" />

View File

@ -152,10 +152,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:alpha="0.6"
android:autoLink="none"
android:textAlignment="viewStart"
android:textColor="@color/warm_grey_four"
android:textColorLink="@color/warm_grey_four"
android:textColor="@color/no_emphasis_text"
android:textColorLink="@color/no_emphasis_text"
android:textIsSelectable="true"
android:textSize="12sp"
app:layout_alignSelf="flex_start"
@ -170,7 +171,8 @@
android:layout_alignParentEnd="true"
android:layout_marginStart="8dp"
android:layout_marginEnd="2dp"
android:textColor="@color/warm_grey_four"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center"
tools:text="12:38" />

View File

@ -59,8 +59,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:alpha="0.6"
android:textAlignment="viewStart"
android:textColor="@color/textColorMaxContrast"
android:textColor="@color/no_emphasis_text"
android:textIsSelectable="false"
android:textSize="12sp"
tools:text="Jane Doe" />
@ -83,7 +84,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:textColor="@color/medium_emphasis_text"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
android:textIsSelectable="false"
app:layout_alignSelf="center" />

View File

@ -105,7 +105,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:textColor="@color/medium_emphasis_text"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center"
tools:text="12:38" />

View File

@ -69,7 +69,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:textColor="@color/medium_emphasis_text"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center"
tools:text="10:35" />

View File

@ -82,7 +82,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:textColor="@color/medium_emphasis_text"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center"
tools:text="10:35" />

View File

@ -142,9 +142,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="2dp"
android:alpha="0.6"
android:autoLink="none"
android:textColor="@color/warm_grey_four"
android:textColorLink="@color/warm_grey_four"
android:textColor="@color/no_emphasis_text"
android:textColorLink="@color/no_emphasis_text"
android:textIsSelectable="true"
android:textSize="12sp"
android:visibility="invisible"
@ -160,7 +161,8 @@
android:layout_alignParentEnd="true"
android:layout_marginStart="8dp"
android:layout_marginEnd="2dp"
android:textColor="@color/warm_grey_four"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center"
tools:text="12:34" />

View File

@ -64,7 +64,7 @@
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:alpha="0.6"
android:textColor="@color/medium_emphasis_text"
android:textColor="@color/no_emphasis_text"
android:textIsSelectable="false"
app:layout_alignSelf="center"
tools:text="10:35" />

View File

@ -92,7 +92,8 @@
android:layout_height="wrap_content"
android:layout_below="@id/messageText"
android:layout_marginStart="8dp"
android:textColor="@color/medium_emphasis_text"
android:alpha="0.6"
android:textColor="@color/no_emphasis_text"
app:layout_alignSelf="center"
tools:text="10:35" />

View File

@ -45,9 +45,10 @@
android:layout_alignParentTop="true"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/quoteColoredView"
android:alpha="0.6"
android:ellipsize="end"
android:textAlignment="viewStart"
android:textColor="@color/medium_emphasis_text"
android:textColor="@color/no_emphasis_text"
android:textIsSelectable="false"
android:textSize="12sp"
tools:text="Jane Doe" />

View File

@ -35,6 +35,7 @@
<color name="refresh_spinner_background">#222222</color>
<!-- general text colors -->
<color name="no_emphasis_text">#ffffff</color>
<color name="high_emphasis_text">#deffffff</color>
<color name="medium_emphasis_text">#99ffffff</color>
<color name="low_emphasis_text">#61ffffff</color>

View File

@ -36,6 +36,7 @@
<color name="refresh_spinner_background">#ffffff</color>
<!-- general text colors -->
<color name="no_emphasis_text">#000000</color>
<color name="high_emphasis_text">#de000000</color>
<color name="medium_emphasis_text">#99000000</color>
<color name="low_emphasis_text">#61000000</color>