From a9bed90d028bc93bfae49edd10e7ede71decd6a7 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 22 Sep 2020 22:20:29 -0400 Subject: [PATCH] Move manga info summary more/less button toggle --- .../ui/manga/info/MangaInfoHeaderAdapter.kt | 57 +++----- .../res/drawable/manga_info_more_gradient.xml | 13 ++ app/src/main/res/layout/manga_info_header.xml | 126 ++++++++++-------- app/src/main/res/values/styles.xml | 17 +++ 4 files changed, 117 insertions(+), 96 deletions(-) create mode 100644 app/src/main/res/drawable/manga_info_more_gradient.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 88b1eeca25..0c3f82be06 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 @@ -1,7 +1,5 @@ package eu.kanade.tachiyomi.ui.manga.info -import android.content.Context -import android.text.TextUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -302,21 +300,23 @@ class MangaInfoHeaderAdapter( controller::performSearch ) } else { - binding.mangaGenresTagsWrapper.isVisible = false + binding.mangaGenresTagsCompactChips.isVisible = false + binding.mangaGenresTagsFullChips.isVisible = false } // Handle showing more or less info merge( binding.mangaSummarySection.clicks(), binding.mangaSummaryText.clicks(), - binding.mangaInfoToggle.clicks() + binding.mangaInfoToggleMore.clicks(), + binding.mangaInfoToggleLess.clicks() ) - .onEach { toggleMangaInfo(view.context) } + .onEach { toggleMangaInfo() } .launchIn(scope) // Expand manga info if navigated from source listing if (initialLoad && fromSource) { - toggleMangaInfo(view.context) + toggleMangaInfo() initialLoad = false } } @@ -326,44 +326,21 @@ class MangaInfoHeaderAdapter( binding.mangaSummarySection.isVisible = visible } - private fun toggleMangaInfo(context: Context) { - val isExpanded = - binding.mangaInfoToggle.contentDescription == context.getString(R.string.manga_info_collapse) + private fun toggleMangaInfo() { + val isCurrentlyExpanded = binding.mangaSummaryText.maxLines != 2 - with(binding.mangaInfoToggle) { - contentDescription = if (isExpanded) { - context.getString(R.string.manga_info_expand) - } else { - context.getString(R.string.manga_info_collapse) - } + binding.mangaInfoToggleMoreScrim.isVisible = isCurrentlyExpanded + binding.mangaInfoToggleMore.isVisible = isCurrentlyExpanded + binding.mangaInfoToggleLess.isVisible = !isCurrentlyExpanded - setImageDrawable( - if (isExpanded) { - context.getDrawable(R.drawable.ic_baseline_expand_more_24dp) - } else { - context.getDrawable(R.drawable.ic_baseline_expand_less_24dp) - } - ) + binding.mangaSummaryText.maxLines = if (isCurrentlyExpanded) { + 2 + } else { + Int.MAX_VALUE } - with(binding.mangaSummaryText) { - maxLines = - if (isExpanded) { - 2 - } else { - Int.MAX_VALUE - } - - ellipsize = - if (isExpanded) { - TextUtils.TruncateAt.END - } else { - null - } - } - - binding.mangaGenresTagsCompact.isVisible = isExpanded - binding.mangaGenresTagsFullChips.isVisible = !isExpanded + binding.mangaGenresTagsCompact.isVisible = isCurrentlyExpanded + binding.mangaGenresTagsFullChips.isVisible = !isCurrentlyExpanded } /** diff --git a/app/src/main/res/drawable/manga_info_more_gradient.xml b/app/src/main/res/drawable/manga_info_more_gradient.xml new file mode 100644 index 0000000000..f3a077d041 --- /dev/null +++ b/app/src/main/res/drawable/manga_info_more_gradient.xml @@ -0,0 +1,13 @@ + + + + + + + + diff --git a/app/src/main/res/layout/manga_info_header.xml b/app/src/main/res/layout/manga_info_header.xml index 80ceb2b4e7..48adc6a867 100644 --- a/app/src/main/res/layout/manga_info_header.xml +++ b/app/src/main/res/layout/manga_info_header.xml @@ -38,7 +38,7 @@ android:paddingStart="16dp" android:paddingTop="64dp" android:paddingEnd="16dp" - android:paddingBottom="16dp" + android:paddingBottom="8dp" app:layout_constraintTop_toTopOf="parent"> - - - - - - - + android:background="?attr/selectableItemBackground"> + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:text="Collapsed summary content Collapsed summary content Collapsed summary content Collapsed summary content Collapsed summary content Collapsed summary content" /> - + + + + + + + android:layout_height="wrap_content" + android:requiresFadingEdge="horizontal" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/manga_summary_text"> + app:chipSpacingHorizontal="4dp" + app:singleLine="true" /> - + - + - - - - - + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 51874a7af8..95c642f035 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -265,6 +265,23 @@ @color/outlined_button_bg + +