mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 20:01:53 +01:00
Fixes to unread badge color
This commit is contained in:
parent
84f21ebacc
commit
074f41ca7e
@ -7,9 +7,9 @@ import eu.kanade.tachiyomi.R
|
|||||||
import eu.kanade.tachiyomi.databinding.UnreadDownloadBadgeBinding
|
import eu.kanade.tachiyomi.databinding.UnreadDownloadBadgeBinding
|
||||||
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
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.gone
|
||||||
import eu.kanade.tachiyomi.util.view.isVisible
|
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.updatePaddingRelative
|
||||||
import eu.kanade.tachiyomi.util.view.visibleIf
|
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) {
|
fun setUnreadDownload(unread: Int, downloads: Int, showTotalChapters: Boolean) {
|
||||||
// Update the unread count and its visibility.
|
// Update the unread count and its visibility.
|
||||||
|
|
||||||
val unreadBadgeBackground = context.contextCompatColor(
|
val unreadBadgeBackground = if (showTotalChapters) {
|
||||||
if (showTotalChapters) R.color.total_badge else R.color.unread_badge
|
context.contextCompatColor(R.color.total_badge)
|
||||||
)
|
} else context.getResourceColor(R.attr.colorAccent)
|
||||||
|
|
||||||
with(binding.unreadText) {
|
with(binding.unreadText) {
|
||||||
visibleIf(unread > 0 || unread == -1 || showTotalChapters)
|
visibleIf(unread > 0 || unread == -1 || showTotalChapters)
|
||||||
@ -36,12 +36,12 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
|
|||||||
return@with
|
return@with
|
||||||
}
|
}
|
||||||
text = if (unread == -1) "0" else unread.toString()
|
text = if (unread == -1) "0" else unread.toString()
|
||||||
setTextColorRes(
|
setTextColor(
|
||||||
// hide the badge text when preference is only show badge
|
// hide the badge text when preference is only show badge
|
||||||
when {
|
when {
|
||||||
unread == -1 && !showTotalChapters -> R.color.unread_badge
|
unread == -1 && !showTotalChapters -> context.getResourceColor(R.attr.colorAccent)
|
||||||
showTotalChapters -> R.color.total_badge_text
|
showTotalChapters -> context.contextCompatColor(R.color.total_badge_text)
|
||||||
else -> R.color.unread_badge_text
|
else -> context.contextCompatColor(R.color.unread_badge_text)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
setBackgroundColor(unreadBadgeBackground)
|
setBackgroundColor(unreadBadgeBackground)
|
||||||
|
@ -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>
|
|
@ -3,5 +3,5 @@
|
|||||||
android:shape="rectangle">
|
android:shape="rectangle">
|
||||||
<corners
|
<corners
|
||||||
android:bottomRightRadius="10dp" />
|
android:bottomRightRadius="10dp" />
|
||||||
<solid android:color="@color/unread_badge" />
|
<solid android:color="?colorAccent" />
|
||||||
</shape>
|
</shape>
|
@ -8,8 +8,8 @@
|
|||||||
tools:background="@color/material_red_500">
|
tools:background="@color/material_red_500">
|
||||||
|
|
||||||
<path
|
<path
|
||||||
android:fillColor="@color/unread_badge"
|
android:fillColor="?colorAccent"
|
||||||
android:pathData="M0 20 L100 0 L100 20 Z"
|
android:pathData="M0 20 L100 0 L100 20 Z"
|
||||||
android:strokeColor="@color/unread_badge" />
|
android:strokeColor="?colorAccent" />
|
||||||
|
|
||||||
</vector>
|
</vector>
|
@ -49,7 +49,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:cardCornerRadius="10dp"
|
app:cardCornerRadius="10dp"
|
||||||
app:cardBackgroundColor="@color/unread_badge"
|
app:cardBackgroundColor="?colorAccent"
|
||||||
app:cardElevation="2dp"
|
app:cardElevation="2dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent">
|
app:layout_constraintStart_toStartOf="parent">
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
style="@style/TextAppearance.Regular.Caption.Light"
|
style="@style/TextAppearance.Regular.Caption.Light"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/unread_badge"
|
android:background="?colorAccent"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:paddingStart="5dp"
|
android:paddingStart="5dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user