Made description text selectable

+ fixes to when set default chapter sort should show
This commit is contained in:
Jay 2020-04-06 13:27:06 -04:00
parent 3ccaf92770
commit 0bcd8f2f68
6 changed files with 25 additions and 8 deletions

View File

@ -36,9 +36,9 @@ interface Manga : SManga {
chapter_flags = chapter_flags and mask.inv() or (flag and mask)
}
fun sortDescending(): Boolean {
return chapter_flags and SORT_MASK == SORT_DESC
}
fun sortDescending(): Boolean = chapter_flags and SORT_MASK == SORT_DESC
fun usesLocalSort(): Boolean = chapter_flags and SORT_SELF_MASK == SORT_LOCAL
fun sortDescending(defaultDesc: Boolean): Boolean {
return if (chapter_flags and SORT_SELF_MASK == SORT_GLOBAL) defaultDesc

View File

@ -218,6 +218,7 @@ class MangaDetailsController : BaseController,
array.recycle()
val offset = 10.dpToPx
var statusBarHeight = -1
swipe_refresh.setDistanceToTriggerSync(70.dpToPx)
recycler.doOnApplyWindowInsets { v, insets, _ ->
headerHeight = appbarHeight + insets.systemWindowInsetTop

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.manga
import android.annotation.SuppressLint
import android.content.res.ColorStateList
import android.graphics.Color
import android.view.MotionEvent
import android.view.View
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.content.ContextCompat
@ -25,6 +26,7 @@ import eu.kanade.tachiyomi.util.view.resetStrokeColor
import eu.kanade.tachiyomi.util.view.updateLayoutParams
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.util.view.visibleIf
import kotlinx.android.synthetic.main.manga_details_controller.*
import kotlinx.android.synthetic.main.manga_header_item.*
import java.util.Locale
@ -41,8 +43,21 @@ class MangaHeaderHolder(
}
more_button.setOnClickListener { expandDesc() }
manga_summary.setOnClickListener { expandDesc() }
manga_summary.setOnLongClickListener {
if (manga_summary.isTextSelectable && !adapter.recyclerView.canScrollVertically(-1)) {
(adapter.delegate as MangaDetailsController).swipe_refresh.isEnabled = false
}
false
}
manga_summary.setOnTouchListener { _, event ->
if (event.actionMasked == MotionEvent.ACTION_UP)
(adapter.delegate as MangaDetailsController).swipe_refresh.isEnabled = true
false
}
less_button.setOnClickListener {
manga_summary.setTextIsSelectable(false)
manga_summary.maxLines = 3
manga_summary.setOnClickListener { expandDesc() }
manga_genres_tags.gone()
less_button.gone()
more_button_group.visible()
@ -77,6 +92,7 @@ class MangaHeaderHolder(
private fun expandDesc() {
if (more_button.visibility == View.VISIBLE) {
manga_summary.maxLines = Integer.MAX_VALUE
manga_summary.setTextIsSelectable(true)
manga_genres_tags.visible()
less_button.visible()
more_button_group.gone()

View File

@ -34,7 +34,7 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
sheetBehavior = BottomSheetBehavior.from(view.parent as ViewGroup)
setEdgeToEdge(activity, view)
val height = activity.window.decorView.rootWindowInsets.systemWindowInsetBottom
sheetBehavior.peekHeight = 380.dpToPx + height
sheetBehavior.peekHeight = 415.dpToPx + height
sheetBehavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, progress: Float) { }
@ -94,10 +94,12 @@ class ChaptersSortBottomSheet(controller: MangaDetailsController) : BottomSheetD
sort_method_group.check(if (presenter.manga.sorting == Manga.SORTING_SOURCE) R.id.sort_by_source else
R.id.sort_by_number)
set_as_default_sort.visInvisIf(defPref != presenter.manga.sortDescending())
set_as_default_sort.visInvisIf(defPref != presenter.manga.sortDescending() &&
presenter.manga.usesLocalSort())
sort_group.setOnCheckedChangeListener { _, checkedId ->
presenter.setSortOrder(checkedId == R.id.sort_newest)
set_as_default_sort.visInvisIf(defPref != presenter.manga.sortDescending())
set_as_default_sort.visInvisIf(defPref != presenter.manga.sortDescending() &&
presenter.manga.usesLocalSort())
}
set_as_default_sort.setOnClickListener {

View File

@ -18,7 +18,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:descendantFocusability="blocksDescendants"
android:nestedScrollingEnabled="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"

View File

@ -228,7 +228,6 @@
android:clickable="true"
android:focusable="true"
android:maxLines="3"
android:textIsSelectable="false"
app:layout_constraintBottom_toTopOf="@id/manga_genres_tags"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"