Fixes to unread badge color

This commit is contained in:
Jays2Kings 2021-04-10 17:44:42 -04:00
parent 84f21ebacc
commit 074f41ca7e
6 changed files with 13 additions and 17 deletions

View File

@ -7,9 +7,9 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.databinding.UnreadDownloadBadgeBinding
import eu.kanade.tachiyomi.util.system.contextCompatColor
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.isVisible
import eu.kanade.tachiyomi.util.view.setTextColorRes
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
import eu.kanade.tachiyomi.util.view.visibleIf
@ -26,9 +26,9 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
fun setUnreadDownload(unread: Int, downloads: Int, showTotalChapters: Boolean) {
// Update the unread count and its visibility.
val unreadBadgeBackground = context.contextCompatColor(
if (showTotalChapters) R.color.total_badge else R.color.unread_badge
)
val unreadBadgeBackground = if (showTotalChapters) {
context.contextCompatColor(R.color.total_badge)
} else context.getResourceColor(R.attr.colorAccent)
with(binding.unreadText) {
visibleIf(unread > 0 || unread == -1 || showTotalChapters)
@ -36,12 +36,12 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
return@with
}
text = if (unread == -1) "0" else unread.toString()
setTextColorRes(
setTextColor(
// hide the badge text when preference is only show badge
when {
unread == -1 && !showTotalChapters -> R.color.unread_badge
showTotalChapters -> R.color.total_badge_text
else -> R.color.unread_badge_text
unread == -1 && !showTotalChapters -> context.getResourceColor(R.attr.colorAccent)
showTotalChapters -> context.contextCompatColor(R.color.total_badge_text)
else -> context.contextCompatColor(R.color.unread_badge_text)
}
)
setBackgroundColor(unreadBadgeBackground)

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorAccent"/>
</selector>

View File

@ -3,5 +3,5 @@
android:shape="rectangle">
<corners
android:bottomRightRadius="10dp" />
<solid android:color="@color/unread_badge" />
<solid android:color="?colorAccent" />
</shape>

View File

@ -8,8 +8,8 @@
tools:background="@color/material_red_500">
<path
android:fillColor="@color/unread_badge"
android:fillColor="?colorAccent"
android:pathData="M0 20 L100 0 L100 20 Z"
android:strokeColor="@color/unread_badge" />
android:strokeColor="?colorAccent" />
</vector>

View File

@ -49,7 +49,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:cardBackgroundColor="@color/unread_badge"
app:cardBackgroundColor="?colorAccent"
app:cardElevation="2dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent">

View File

@ -52,7 +52,7 @@
style="@style/TextAppearance.Regular.Caption.Light"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/unread_badge"
android:background="?colorAccent"
android:gravity="center"
android:maxLines="1"
android:paddingStart="5dp"