From 17628599776814908cfa3a6ca3a6fe4f35563197 Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Sat, 17 Jul 2021 18:55:57 -0400 Subject: [PATCH] Update colors, spacing, size of chips no outline --- .../tachiyomi/ui/manga/MangaHeaderHolder.kt | 27 +++++++++++++++++++ .../layout-sw600dp-land/manga_header_item.xml | 1 + .../layout-sw600dp-port/manga_header_item.xml | 1 + app/src/main/res/layout/manga_header_item.xml | 1 + app/src/main/res/values/styles.xml | 15 +++++++---- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt index e7ed3903da..3f045d2cee 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaHeaderHolder.kt @@ -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) diff --git a/app/src/main/res/layout-sw600dp-land/manga_header_item.xml b/app/src/main/res/layout-sw600dp-land/manga_header_item.xml index de4af2018f..e060b0c8ff 100644 --- a/app/src/main/res/layout-sw600dp-land/manga_header_item.xml +++ b/app/src/main/res/layout-sw600dp-land/manga_header_item.xml @@ -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" diff --git a/app/src/main/res/layout-sw600dp-port/manga_header_item.xml b/app/src/main/res/layout-sw600dp-port/manga_header_item.xml index a77b5f9b3e..0c69f68147 100644 --- a/app/src/main/res/layout-sw600dp-port/manga_header_item.xml +++ b/app/src/main/res/layout-sw600dp-port/manga_header_item.xml @@ -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" diff --git a/app/src/main/res/layout/manga_header_item.xml b/app/src/main/res/layout/manga_header_item.xml index a72cde5b28..fe8e3986c2 100644 --- a/app/src/main/res/layout/manga_header_item.xml +++ b/app/src/main/res/layout/manga_header_item.xml @@ -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" diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 689d156b51..c8311e84c2 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -298,13 +298,18 @@ - + + +