From 18cd85b26c57dc707c1322ad8ff27185b2cff40a Mon Sep 17 00:00:00 2001 From: Carlos <2092019+CarlosEsco@users.noreply.github.com> Date: Sat, 17 Jul 2021 14:44:21 -0400 Subject: [PATCH] switch genre tags to material chips (#934) * switch genre tags to material chips * remove style --- app/build.gradle.kts | 2 +- .../tachiyomi/ui/manga/MangaHeaderHolder.kt | 33 +++++++++++++++---- .../layout-sw600dp-land/manga_header_item.xml | 7 +--- .../layout-sw600dp-port/manga_header_item.xml | 7 +--- app/src/main/res/layout/genre_chip.xml | 10 ++++++ app/src/main/res/layout/manga_header_item.xml | 7 +--- app/src/main/res/values/styles.xml | 8 +++++ 7 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 app/src/main/res/layout/genre_chip.xml diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 579b3f4d94..3fa83ef749 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -226,7 +226,7 @@ dependencies { implementation("com.github.kizitonwose:AndroidTagGroup:1.6.0") implementation("com.github.chrisbanes:PhotoView:2.3.0") - implementation("com.github.carlosesco:DirectionalViewPager:a844dbca0a") + implementation("com.github.tachiyomiorg:DirectionalViewPager:1.0.0") implementation("com.github.florent37:viewtooltip:1.2.2") implementation("com.getkeepsafe.taptargetview:taptargetview:1.13.0") 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 448a2b93fd..e7ed3903da 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 @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga import android.annotation.SuppressLint import android.content.res.ColorStateList import android.graphics.Color +import android.view.LayoutInflater import android.view.MotionEvent import android.view.View import androidx.constraintlayout.widget.ConstraintLayout @@ -12,6 +13,7 @@ import androidx.core.view.isInvisible import androidx.core.view.isVisible import coil.request.CachePolicy import com.google.android.material.button.MaterialButton +import com.google.android.material.chip.Chip import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.image.coil.loadManga @@ -98,9 +100,7 @@ class MangaHeaderHolder( moreBgGradient.rotation = 180f } lessButton.setOnClickListener { collapseDesc() } - mangaGenresTags.setOnTagClickListener { - adapter.delegate.tagClicked(it) - } + webviewButton.setOnClickListener { adapter.delegate.openInWebView() } shareButton.setOnClickListener { adapter.delegate.prepareToShareManga() } favoriteButton.setOnClickListener { @@ -190,10 +190,7 @@ class MangaHeaderHolder( } binding.title.text = manga.title - if (manga.genre.isNullOrBlank().not()) binding.mangaGenresTags.setTags( - manga.genre?.split(",")?.map(String::trim) - ) - else binding.mangaGenresTags.setTags(emptyList()) + setGenreTags(binding, manga) if (manga.author == manga.artist || manga.artist.isNullOrBlank()) { binding.mangaAuthor.text = manga.author?.trim() @@ -315,6 +312,28 @@ class MangaHeaderHolder( updateCover(manga) } + private fun setGenreTags(binding: MangaHeaderItemBinding, manga: Manga) { + with(binding.mangaGenresTags) { + removeAllViews() + if (manga.genre.isNullOrBlank().not()) { + (manga.getGenres() ?: emptyList()).map { genreText -> + val chip = LayoutInflater.from(binding.root.context).inflate( + R.layout.genre_chip, + this, + false + ) as Chip + val id = View.generateViewId() + chip.id = id + chip.text = genreText + chip.setOnClickListener { + adapter.delegate.tagClicked(genreText) + } + this.addView(chip) + } + } + } + } + fun clearDescFocus() { binding ?: return binding.mangaSummary.setTextIsSelectable(false) 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 81e7c6fdf6..de4af2018f 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 @@ -296,19 +296,14 @@ android:layout_height="wrap_content" app:constraint_referenced_ids="manga_summary,manga_summary_label,sub_button_scroll" /> - - + \ No newline at end of file diff --git a/app/src/main/res/layout/manga_header_item.xml b/app/src/main/res/layout/manga_header_item.xml index c5a340ee8e..a72cde5b28 100644 --- a/app/src/main/res/layout/manga_header_item.xml +++ b/app/src/main/res/layout/manga_header_item.xml @@ -295,19 +295,14 @@ android:layout_height="wrap_content" app:constraint_referenced_ids="manga_summary,manga_summary_label,sub_button_scroll" /> - ?colorAccent + +