Tapping manga info summary collapses summary

Fixes #673

Co-Authored-By: Carlos <2092019+CarlosEsco@users.noreply.github.com>
This commit is contained in:
Jays2Kings 2021-03-21 00:35:39 -04:00
parent 434926351c
commit c50c1f9b10

View File

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