From 8404b1c0c26fd4f17420b62e981622f24d9388d2 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 3 Oct 2020 12:41:33 -0400 Subject: [PATCH] Set activated states for manga info favorite/tracker buttons (cherry picked from commit 0904692f15179e420ea9140e2e31e556faa5164f) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt # app/src/main/res/layout/manga_info_header.xml --- .../ui/manga/info/MangaInfoHeaderAdapter.kt | 33 ++++--------------- .../main/res/color/button_action_selector.xml | 5 +++ app/src/main/res/color/outlined_button_bg.xml | 5 --- app/src/main/res/layout/manga_info_header.xml | 25 +++++++------- app/src/main/res/values/styles.xml | 15 ++++----- 5 files changed, 29 insertions(+), 54 deletions(-) create mode 100644 app/src/main/res/color/button_action_selector.xml delete mode 100644 app/src/main/res/color/outlined_button_bg.xml diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt index fcbdccf44..db49bf05e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoHeaderAdapter.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.manga.info import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.core.content.ContextCompat import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.load.engine.DiskCacheStrategy @@ -22,7 +21,6 @@ import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.all.MangaDex import eu.kanade.tachiyomi.ui.manga.MangaController import eu.kanade.tachiyomi.util.system.copyToClipboard -import eu.kanade.tachiyomi.util.view.setTooltip import exh.MERGED_SOURCE_ID import exh.source.EnhancedHttpSource.Companion.getMainSource import exh.util.SourceTagsUtil @@ -115,27 +113,17 @@ class MangaInfoHeaderAdapter( isVisible = true if (trackCount > 0) { - setCompoundDrawablesWithIntrinsicBounds( - null, - ContextCompat.getDrawable(context, R.drawable.ic_done_24dp), - null, - null - ) + setIconResource(R.drawable.ic_done_24dp) text = view.context.resources.getQuantityString( R.plurals.num_trackers, trackCount, trackCount ) - isSelected = true + isActivated = true } else { - setCompoundDrawablesWithIntrinsicBounds( - null, - ContextCompat.getDrawable(context, R.drawable.ic_sync_24dp), - null, - null - ) + setIconResource(R.drawable.ic_sync_24dp) text = view.context.getString(R.string.manga_tracking_tab) - isSelected = false + isActivated = false } clicks() @@ -151,7 +139,6 @@ class MangaInfoHeaderAdapter( binding.btnWebview.clicks() .onEach { controller.openMangaInWebView() } .launchIn(scope) - binding.btnWebview.setTooltip(R.string.action_open_in_web_view) } // SY --> @@ -320,18 +307,10 @@ class MangaInfoHeaderAdapter( // Set the Favorite drawable to the correct one. // Border drawable if false, filled drawable if true. binding.btnFavorite.apply { - setCompoundDrawablesWithIntrinsicBounds( - null, - ContextCompat.getDrawable( - context, - if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp - ), - null, - null - ) + setIconResource(if (isFavorite) R.drawable.ic_favorite_24dp else R.drawable.ic_favorite_border_24dp) text = context.getString(if (isFavorite) R.string.in_library else R.string.add_to_library) - isSelected = isFavorite + isActivated = isFavorite } } } diff --git a/app/src/main/res/color/button_action_selector.xml b/app/src/main/res/color/button_action_selector.xml new file mode 100644 index 000000000..e457c5a52 --- /dev/null +++ b/app/src/main/res/color/button_action_selector.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/color/outlined_button_bg.xml b/app/src/main/res/color/outlined_button_bg.xml deleted file mode 100644 index b95df40de..000000000 --- a/app/src/main/res/color/outlined_button_bg.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/app/src/main/res/layout/manga_info_header.xml b/app/src/main/res/layout/manga_info_header.xml index 2786c047b..803292b72 100644 --- a/app/src/main/res/layout/manga_info_header.xml +++ b/app/src/main/res/layout/manga_info_header.xml @@ -133,59 +133,56 @@ + android:layout_height="wrap_content" + android:paddingStart="16dp" + android:paddingEnd="16dp"> - - - - false -