mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 05:45:06 +01:00
Download badge is now inverted for themes with black colorOnAccent
This commit is contained in:
parent
bf3cba380f
commit
0327accecb
@ -5,6 +5,7 @@ import android.util.AttributeSet
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.UnreadDownloadBadgeBinding
|
||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||
import eu.kanade.tachiyomi.util.system.contextCompatColor
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
@ -56,6 +57,13 @@ class LibraryBadge @JvmOverloads constructor(context: Context, attrs: AttributeS
|
||||
} else {
|
||||
downloads.toString()
|
||||
}
|
||||
if (ImageUtil.isDarkish(context.getResourceColor(R.attr.colorOnAccent))) {
|
||||
setTextColor(context.getColor(R.color.download_badge_light_text))
|
||||
setBackgroundColor(context.getColor(R.color.download_badge_light))
|
||||
} else {
|
||||
setTextColor(context.getColor(R.color.download_badge_text))
|
||||
setBackgroundColor(context.getColor(R.color.download_badge))
|
||||
}
|
||||
}
|
||||
|
||||
// Show the badge card if unread or downloads exists
|
||||
|
@ -296,6 +296,11 @@ object ImageUtil {
|
||||
Color.alpha(color) > 200
|
||||
}
|
||||
|
||||
fun isDarkish(color: Int): Boolean {
|
||||
return Color.red(color) < 80 && Color.blue(color) < 80 && Color.green(color) < 80 &&
|
||||
Color.alpha(color) > 150
|
||||
}
|
||||
|
||||
private fun pixelIsClose(color1: Int, color2: Int): Boolean {
|
||||
return abs(Color.red(color1) - Color.red(color2)) < 30 &&
|
||||
abs(Color.green(color1) - Color.green(color2)) < 30 &&
|
||||
|
@ -18,6 +18,8 @@
|
||||
<color name="unread_badge_text">@color/md_white_1000</color>
|
||||
<color name="download_badge">@color/pale_green</color>
|
||||
<color name="download_badge_text">@color/md_black_1000</color>
|
||||
<color name="download_badge_light">@color/strong_green</color>
|
||||
<color name="download_badge_light_text">@color/md_white_1000</color>
|
||||
<color name="total_badge">@color/material_deep_purple_500</color>
|
||||
<color name="total_badge_text">@color/md_white_1000</color>
|
||||
|
||||
@ -59,6 +61,7 @@
|
||||
<color name="primaryRed">#C14033</color>
|
||||
|
||||
<color name="pale_green">#99CC99</color>
|
||||
<color name="strong_green">#106010</color>
|
||||
|
||||
<!-- Navigation overlay colors -->
|
||||
<color name="navigation_menu">#CC95818D</color>
|
||||
|
Loading…
Reference in New Issue
Block a user