mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-20 04:59:17 +01:00
Update colors, spacing, size of chips
no outline
This commit is contained in:
parent
18cd85b26c
commit
1762859977
@ -12,6 +12,7 @@ import androidx.core.graphics.ColorUtils
|
|||||||
import androidx.core.view.isInvisible
|
import androidx.core.view.isInvisible
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import coil.request.CachePolicy
|
import coil.request.CachePolicy
|
||||||
|
import eu.kanade.tachiyomi.util.system.isInNightMode
|
||||||
import com.google.android.material.button.MaterialButton
|
import com.google.android.material.button.MaterialButton
|
||||||
import com.google.android.material.chip.Chip
|
import com.google.android.material.chip.Chip
|
||||||
import eu.kanade.tachiyomi.R
|
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.system.isLTR
|
||||||
import eu.kanade.tachiyomi.util.view.resetStrokeColor
|
import eu.kanade.tachiyomi.util.view.resetStrokeColor
|
||||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||||
|
import kotlin.math.abs
|
||||||
|
|
||||||
@SuppressLint("ClickableViewAccessibility")
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
class MangaHeaderHolder(
|
class MangaHeaderHolder(
|
||||||
@ -315,6 +317,29 @@ class MangaHeaderHolder(
|
|||||||
private fun setGenreTags(binding: MangaHeaderItemBinding, manga: Manga) {
|
private fun setGenreTags(binding: MangaHeaderItemBinding, manga: Manga) {
|
||||||
with(binding.mangaGenresTags) {
|
with(binding.mangaGenresTags) {
|
||||||
removeAllViews()
|
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()) {
|
if (manga.genre.isNullOrBlank().not()) {
|
||||||
(manga.getGenres() ?: emptyList()).map { genreText ->
|
(manga.getGenres() ?: emptyList()).map { genreText ->
|
||||||
val chip = LayoutInflater.from(binding.root.context).inflate(
|
val chip = LayoutInflater.from(binding.root.context).inflate(
|
||||||
@ -324,6 +349,8 @@ class MangaHeaderHolder(
|
|||||||
) as Chip
|
) as Chip
|
||||||
val id = View.generateViewId()
|
val id = View.generateViewId()
|
||||||
chip.id = id
|
chip.id = id
|
||||||
|
chip.chipBackgroundColor = ColorStateList.valueOf(downloadedColor)
|
||||||
|
chip.setTextColor(textColor)
|
||||||
chip.text = genreText
|
chip.text = genreText
|
||||||
chip.setOnClickListener {
|
chip.setOnClickListener {
|
||||||
adapter.delegate.tagClicked(genreText)
|
adapter.delegate.tagClicked(genreText)
|
||||||
|
@ -301,6 +301,7 @@
|
|||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
|
app:chipSpacingVertical="-12dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
|
@ -299,6 +299,7 @@
|
|||||||
android:id="@+id/manga_genres_tags"
|
android:id="@+id/manga_genres_tags"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:chipSpacingVertical="-12dp"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
|
@ -301,6 +301,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="16dp"
|
android:layout_marginStart="16dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
|
app:chipSpacingVertical="-12dp"
|
||||||
android:layout_marginEnd="16dp"
|
android:layout_marginEnd="16dp"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:layout_constrainedHeight="true"
|
app:layout_constrainedHeight="true"
|
||||||
|
@ -298,13 +298,18 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Widget.Chip.Outline" parent="Widget.MaterialComponents.Chip.Action">
|
<style name="Theme.Widget.Chip.Outline" parent="Widget.MaterialComponents.Chip.Action">
|
||||||
<item name="chipBackgroundColor">?attr/colorSecondary</item>
|
<item name="chipBackgroundColor">@color/accent_alpha</item>
|
||||||
<item name="android:textColor">?attr/colorAccent</item>
|
<item name="chipMinHeight">28dp</item>
|
||||||
<item name="chipStrokeColor">?attr/colorAccent</item>
|
<item name="android:textColor">?colorAccentText</item>
|
||||||
<item name="chipStrokeWidth">1dp</item>
|
<item name="android:textAppearance">@style/Theme.TextAppearance.Chip</item>
|
||||||
|
<item name="chipStrokeWidth">0dp</item>
|
||||||
<item name="android:checkable">false</item>
|
<item name="android:checkable">false</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<style name="Theme.TextAppearance.Chip" parent="TextAppearance.MaterialComponents.Chip">
|
||||||
|
<item name="android:textSize">13sp</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<!--===-->
|
<!--===-->
|
||||||
<!--OLD-->
|
<!--OLD-->
|
||||||
|
Loading…
Reference in New Issue
Block a user