From 88fd799a3069ac28dd667e84383662a103c0c12a Mon Sep 17 00:00:00 2001 From: Soitora Date: Wed, 23 Jun 2021 00:22:59 +0200 Subject: [PATCH] Add favorited badge to browse and search (#5440) --- .../browse/SourceComfortableGridHolder.kt | 7 +++++ .../browse/source/browse/SourceGridHolder.kt | 7 +++++ .../browse/source/browse/SourceListHolder.kt | 7 +++++ .../globalsearch/GlobalSearchCardHolder.kt | 9 +++++++ .../global_search_controller_card_item.xml | 26 +++++++++++++++++++ .../layout/source_comfortable_grid_item.xml | 16 ++++++++++++ .../res/layout/source_compact_grid_item.xml | 16 ++++++++++++ app/src/main/res/layout/source_list_item.xml | 16 ++++++++++++ 8 files changed, 104 insertions(+) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceComfortableGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceComfortableGridHolder.kt index cd4f42f21..6bbe76b8c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceComfortableGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceComfortableGridHolder.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.browse.source.browse import android.view.View +import androidx.core.view.isVisible import coil.clear import coil.imageLoader import coil.request.ImageRequest @@ -37,6 +38,12 @@ class SourceComfortableGridHolder(private val view: View, private val adapter: F // Set alpha of thumbnail. binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f + // For rounded corners + binding.badges.clipToOutline = true + + // Set favorite badge + binding.favoriteText.isVisible = manga.favorite + setImage(manga) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceGridHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceGridHolder.kt index a238003b5..38b536371 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceGridHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceGridHolder.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.browse.source.browse import android.view.View +import androidx.core.view.isVisible import coil.clear import coil.imageLoader import coil.request.ImageRequest @@ -37,6 +38,12 @@ open class SourceGridHolder(private val view: View, private val adapter: Flexibl // Set alpha of thumbnail. binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f + // For rounded corners + binding.badges.clipToOutline = true + + // Set favorite badge + binding.favoriteText.isVisible = manga.favorite + setImage(manga) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt index a509c71e8..c6d020fe8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/browse/SourceListHolder.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.browse.source.browse import android.view.View +import androidx.core.view.isVisible import coil.clear import coil.loadAny import coil.transform.RoundedCornersTransformation @@ -40,6 +41,12 @@ class SourceListHolder(private val view: View, adapter: FlexibleAdapter<*>) : // Set alpha of thumbnail. binding.thumbnail.alpha = if (manga.favorite) 0.3f else 1.0f + // For rounded corners + binding.badges.clipToOutline = true + + // Set favorite badge + binding.favoriteText.isVisible = manga.favorite + setImage(manga) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchCardHolder.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchCardHolder.kt index 4c5c23d28..a67e9785b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchCardHolder.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/browse/source/globalsearch/GlobalSearchCardHolder.kt @@ -1,6 +1,7 @@ package eu.kanade.tachiyomi.ui.browse.source.globalsearch import android.view.View +import androidx.core.view.isVisible import coil.clear import coil.imageLoader import coil.request.ImageRequest @@ -36,10 +37,18 @@ class GlobalSearchCardHolder(view: View, adapter: GlobalSearchCardAdapter) : fun bind(manga: Manga) { binding.card.clipToOutline = true + // Set manga title binding.title.text = manga.title + // Set alpha of thumbnail. binding.cover.alpha = if (manga.favorite) 0.3f else 1.0f + // For rounded corners + binding.badges.clipToOutline = true + + // Set favorite badge + binding.favoriteText.isVisible = manga.favorite + setImage(manga) } diff --git a/app/src/main/res/layout/global_search_controller_card_item.xml b/app/src/main/res/layout/global_search_controller_card_item.xml index 5ab5c88cd..50515dcdd 100644 --- a/app/src/main/res/layout/global_search_controller_card_item.xml +++ b/app/src/main/res/layout/global_search_controller_card_item.xml @@ -38,6 +38,32 @@ tools:ignore="ContentDescription" tools:src="@mipmap/ic_launcher" /> + + + + + + + + + + + +