Update colors, spacing, size of chips

no outline
This commit is contained in:
Jays2Kings 2021-07-17 18:55:57 -04:00
parent 18cd85b26c
commit 1762859977
5 changed files with 40 additions and 5 deletions

View File

@ -12,6 +12,7 @@ import androidx.core.graphics.ColorUtils
import androidx.core.view.isInvisible
import androidx.core.view.isVisible
import coil.request.CachePolicy
import eu.kanade.tachiyomi.util.system.isInNightMode
import com.google.android.material.button.MaterialButton
import com.google.android.material.chip.Chip
import eu.kanade.tachiyomi.R
@ -26,6 +27,7 @@ import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.isLTR
import eu.kanade.tachiyomi.util.view.resetStrokeColor
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import kotlin.math.abs
@SuppressLint("ClickableViewAccessibility")
class MangaHeaderHolder(
@ -315,6 +317,29 @@ class MangaHeaderHolder(
private fun setGenreTags(binding: MangaHeaderItemBinding, manga: Manga) {
with(binding.mangaGenresTags) {
removeAllViews()
val dark = context.isInNightMode()
val accentArray = FloatArray(3)
val onAccentArray = FloatArray(3)
ColorUtils.colorToHSL(context.getResourceColor(R.attr.colorAccent), accentArray)
ColorUtils.colorToHSL(context.getResourceColor(R.attr.colorOnAccent), onAccentArray)
val downloadedColor = ColorUtils.setAlphaComponent(
ColorUtils.HSLToColor(
floatArrayOf(
accentArray[0],
accentArray[1],
// fun math just for good contrast
((if (dark) 0.35f else 0.87f) + (abs(onAccentArray[2] - 0.5f) * .7f)) / 2f
)
),
165
)
val textColor = ColorUtils.HSLToColor(
floatArrayOf(
accentArray[0],
0.8f,
if (dark) 0.925f else 0.15f
)
)
if (manga.genre.isNullOrBlank().not()) {
(manga.getGenres() ?: emptyList()).map { genreText ->
val chip = LayoutInflater.from(binding.root.context).inflate(
@ -324,6 +349,8 @@ class MangaHeaderHolder(
) as Chip
val id = View.generateViewId()
chip.id = id
chip.chipBackgroundColor = ColorStateList.valueOf(downloadedColor)
chip.setTextColor(textColor)
chip.text = genreText
chip.setOnClickListener {
adapter.delegate.tagClicked(genreText)

View File

@ -301,6 +301,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:chipSpacingVertical="-12dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:visibility="gone"

View File

@ -299,6 +299,7 @@
android:id="@+id/manga_genres_tags"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:chipSpacingVertical="-12dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"

View File

@ -301,6 +301,7 @@
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
app:chipSpacingVertical="-12dp"
android:layout_marginEnd="16dp"
android:visibility="gone"
app:layout_constrainedHeight="true"

View File

@ -298,13 +298,18 @@
</style>
<style name="Theme.Widget.Chip.Outline" parent="Widget.MaterialComponents.Chip.Action">
<item name="chipBackgroundColor">?attr/colorSecondary</item>
<item name="android:textColor">?attr/colorAccent</item>
<item name="chipStrokeColor">?attr/colorAccent</item>
<item name="chipStrokeWidth">1dp</item>
<item name="chipBackgroundColor">@color/accent_alpha</item>
<item name="chipMinHeight">28dp</item>
<item name="android:textColor">?colorAccentText</item>
<item name="android:textAppearance">@style/Theme.TextAppearance.Chip</item>
<item name="chipStrokeWidth">0dp</item>
<item name="android:checkable">false</item>
</style>
<style name="Theme.TextAppearance.Chip" parent="TextAppearance.MaterialComponents.Chip">
<item name="android:textSize">13sp</item>
</style>
<!--===-->
<!--OLD-->