ConversationItem: theme unread message bubbles

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
This commit is contained in:
Álvaro Brey 2022-07-22 16:51:38 +02:00 committed by Andy Scherzinger
parent 4de7d06e8e
commit 3283e5b4f6
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
2 changed files with 21 additions and 15 deletions

View file

@ -168,29 +168,18 @@ public class ConversationItem extends AbstractFlexibleItem<ConversationItem.Conv
int lightBubbleTextColor = ContextCompat.getColor( int lightBubbleTextColor = ContextCompat.getColor(
context, context,
R.color.conversation_unread_bubble_text); R.color.conversation_unread_bubble_text);
ColorStateList lightBubbleStrokeColor = ColorStateList.valueOf(
ContextCompat.getColor(context,
R.color.colorPrimary));
if (conversation.getType() == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) { if (conversation.getType() == Conversation.ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
holder.binding.dialogUnreadBubble.setChipBackgroundColorResource(R.color.colorPrimary); viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble);
holder.binding.dialogUnreadBubble.setTextColor(Color.WHITE);
} else if (conversation.getUnreadMention()) { } else if (conversation.getUnreadMention()) {
if (CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "direct-mention-flag")) { if (CapabilitiesUtilNew.hasSpreedFeatureCapability(user, "direct-mention-flag")) {
if (conversation.getUnreadMentionDirect()) { if (conversation.getUnreadMentionDirect()) {
holder.binding.dialogUnreadBubble.setChipBackgroundColorResource(R.color.colorPrimary); viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble);
holder.binding.dialogUnreadBubble.setTextColor(Color.WHITE);
} else { } else {
holder.binding.dialogUnreadBubble.setChipBackgroundColorResource(R.color.bg_default); viewThemeUtils.colorChipOutlined(holder.binding.dialogUnreadBubble, 6.0f);
holder.binding.dialogUnreadBubble.setTextColor(ContextCompat.getColor(
context,
R.color.colorPrimary));
holder.binding.dialogUnreadBubble.setChipStrokeWidth(6.0f);
holder.binding.dialogUnreadBubble.setChipStrokeColor(lightBubbleStrokeColor);
} }
} else { } else {
holder.binding.dialogUnreadBubble.setChipBackgroundColorResource(R.color.colorPrimary); viewThemeUtils.colorChipBackground(holder.binding.dialogUnreadBubble);
holder.binding.dialogUnreadBubble.setTextColor(Color.WHITE);
} }
} else { } else {
holder.binding.dialogUnreadBubble.setChipBackgroundColor(lightBubbleFillColor); holder.binding.dialogUnreadBubble.setChipBackgroundColor(lightBubbleFillColor);

View file

@ -37,6 +37,7 @@ import androidx.core.view.children
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.google.android.material.card.MaterialCardView import com.google.android.material.card.MaterialCardView
import com.google.android.material.chip.Chip
import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.android.material.floatingactionbutton.FloatingActionButton
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
import com.google.android.material.textfield.TextInputLayout import com.google.android.material.textfield.TextInputLayout
@ -219,6 +220,22 @@ class ViewThemeUtils @Inject constructor(val theme: ServerTheme) {
return drawable return drawable
} }
fun colorChipBackground(chip: Chip) {
withElementColor(chip) { color ->
chip.chipBackgroundColor = ColorStateList.valueOf(color)
chip.setTextColor(theme.colorText)
}
}
fun colorChipOutlined(chip: Chip, strokeWidth: Float) {
withElementColor(chip) { color ->
chip.chipBackgroundColor = ColorStateList.valueOf(Color.TRANSPARENT)
chip.chipStrokeWidth = strokeWidth
chip.chipStrokeColor = ColorStateList.valueOf(color)
chip.setTextColor(color)
}
}
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,