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 43562d4677..4080f7bf28 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 @@ -30,6 +30,7 @@ import eu.kanade.tachiyomi.util.view.visibleIf import kotlinx.android.synthetic.main.manga_details_controller.* import kotlinx.android.synthetic.main.manga_header_item.* +@SuppressLint("ClickableViewAccessibility") class MangaHeaderHolder( private val view: View, private val adapter: MangaDetailsAdapter, @@ -38,6 +39,7 @@ class MangaHeaderHolder( private var showReadingButton = true private var showMoreButton = true + var hadSelection = false init { chapter_layout.setOnClickListener { adapter.delegate.showChapterFilter() } @@ -47,7 +49,15 @@ class MangaHeaderHolder( height = adapter.delegate.topCoverHeight() } more_button.setOnClickListener { expandDesc() } - manga_summary.setOnClickListener { expandDesc() } + manga_summary.setOnClickListener { + if (more_button.isVisible()) { + expandDesc() + } else if (!hadSelection) { + collapseDesc() + } else { + hadSelection = false + } + } manga_summary.setOnLongClickListener { if (manga_summary.isTextSelectable && !adapter.recyclerView.canScrollVertically(-1)) { (adapter.delegate as MangaDetailsController).swipe_refresh.isEnabled = false @@ -55,8 +65,14 @@ class MangaHeaderHolder( false } manga_summary.setOnTouchListener { _, event -> - if (event.actionMasked == MotionEvent.ACTION_UP) (adapter.delegate as MangaDetailsController).swipe_refresh.isEnabled = - true + if (event.action == MotionEvent.ACTION_DOWN) { + view.requestFocus() + } + if (event.actionMasked == MotionEvent.ACTION_UP) { + hadSelection = manga_summary.hasSelection() + (adapter.delegate as MangaDetailsController).swipe_refresh.isEnabled = + true + } false } if (!itemView.resources.isLTR) { @@ -109,8 +125,8 @@ class MangaHeaderHolder( private fun collapseDesc() { manga_summary.setTextIsSelectable(false) + manga_summary.isClickable = true manga_summary.maxLines = 3 - manga_summary.setOnClickListener { expandDesc() } manga_genres_tags.gone() less_button.gone() more_button_group.visible()