mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-25 03:51:49 +01:00
Manga details now auto hides the fast scroll
Also more fixes to the tablet layout of manga details
This commit is contained in:
parent
15d2cb9f36
commit
974eb90cd5
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.library
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.TypedValue
|
||||
@ -17,7 +16,6 @@ import android.view.inputmethod.InputMethodManager
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.ItemTouchHelper
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@ -60,9 +58,13 @@ import eu.kanade.tachiyomi.util.system.launchUI
|
||||
import eu.kanade.tachiyomi.util.view.applyWindowInsetsForRootController
|
||||
import eu.kanade.tachiyomi.util.view.getItemView
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.hide
|
||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||
import eu.kanade.tachiyomi.util.view.setBackground
|
||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||
import eu.kanade.tachiyomi.util.view.setStartTranslationX
|
||||
import eu.kanade.tachiyomi.util.view.setStyle
|
||||
import eu.kanade.tachiyomi.util.view.show
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
@ -185,14 +187,11 @@ class LibraryController(
|
||||
RecyclerView.SCROLL_STATE_DRAGGING -> {
|
||||
scrollAnim?.cancel()
|
||||
if (fast_scroller.translationX != 0f) {
|
||||
fast_scroller.animate().setStartDelay(0).setDuration(100).translationX(0f)
|
||||
.start()
|
||||
fast_scroller.show()
|
||||
}
|
||||
}
|
||||
RecyclerView.SCROLL_STATE_IDLE -> {
|
||||
scrollAnim = fast_scroller.animate().setStartDelay(1000).setDuration(250)
|
||||
.translationX(25f.dpToPxEnd)
|
||||
scrollAnim?.start()
|
||||
scrollAnim = fast_scroller.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -220,32 +219,12 @@ class LibraryController(
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideScroller(duration: Long = 1000) {
|
||||
if (alwaysShowScroller) return
|
||||
scrollAnim =
|
||||
fast_scroller.animate().setStartDelay(duration).setDuration(250)
|
||||
.translationX(25f.dpToPxEnd)
|
||||
scrollAnim?.start()
|
||||
}
|
||||
|
||||
private fun setFastScrollBackground() {
|
||||
val context = activity ?: return
|
||||
fast_scroller.background = if (!alwaysShowScroller) ContextCompat.getDrawable(
|
||||
context, R.drawable.fast_scroll_background
|
||||
) else null
|
||||
fast_scroller.textColor = ColorStateList.valueOf(
|
||||
if (!alwaysShowScroller) Color.WHITE
|
||||
else context.getResourceColor(android.R.attr.textColorPrimary)
|
||||
)
|
||||
fast_scroller.iconColor = fast_scroller.textColor
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View) {
|
||||
super.onViewCreated(view)
|
||||
view.applyWindowInsetsForRootController(activity!!.bottom_nav)
|
||||
if (!::presenter.isInitialized) presenter = LibraryPresenter(this)
|
||||
if (!alwaysShowScroller) fast_scroller.translationX = 25f.dpToPxEnd
|
||||
setFastScrollBackground()
|
||||
fast_scroller.setStartTranslationX(!alwaysShowScroller)
|
||||
fast_scroller.setBackground(!alwaysShowScroller)
|
||||
|
||||
adapter = LibraryCategoryAdapter(this)
|
||||
adapter.expandItemsAtStartUp()
|
||||
@ -279,7 +258,10 @@ class LibraryController(
|
||||
itemPosition: Int
|
||||
) {
|
||||
fast_scroller.translationX = 0f
|
||||
hideScroller(2000)
|
||||
if (!alwaysShowScroller) {
|
||||
scrollAnim?.cancel()
|
||||
scrollAnim = fast_scroller.hide(2000)
|
||||
}
|
||||
|
||||
textAnim?.cancel()
|
||||
textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(2000)
|
||||
@ -423,11 +405,11 @@ class LibraryController(
|
||||
|
||||
fun updateShowScrollbar(show: Boolean) {
|
||||
alwaysShowScroller = show
|
||||
setFastScrollBackground()
|
||||
fast_scroller.setBackground(!show)
|
||||
if (libraryLayout == 0) reattachAdapter()
|
||||
scrollAnim?.cancel()
|
||||
if (show) fast_scroller.translationX = 0f
|
||||
else hideScroller()
|
||||
else scrollAnim = fast_scroller.hide()
|
||||
setRecyclerLayout()
|
||||
}
|
||||
|
||||
@ -521,9 +503,11 @@ class LibraryController(
|
||||
} else recycler_layout.alpha = 1f
|
||||
if (justStarted && freshStart) {
|
||||
scrollToHeader(activeCategory)
|
||||
fast_scroller.translationX = 0f
|
||||
view?.post {
|
||||
hideScroller(2000)
|
||||
if (!alwaysShowScroller) {
|
||||
fast_scroller.show(false)
|
||||
view?.post {
|
||||
scrollAnim = fast_scroller.hide(2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
adapter.isLongPressDragEnabled = canDrag()
|
||||
|
@ -101,9 +101,13 @@ import eu.kanade.tachiyomi.util.system.pxToDp
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.view.doOnApplyWindowInsets
|
||||
import eu.kanade.tachiyomi.util.view.getText
|
||||
import eu.kanade.tachiyomi.util.view.hide
|
||||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||
import eu.kanade.tachiyomi.util.view.setBackground
|
||||
import eu.kanade.tachiyomi.util.view.setOnQueryTextChangeListener
|
||||
import eu.kanade.tachiyomi.util.view.setStartTranslationX
|
||||
import eu.kanade.tachiyomi.util.view.setStyle
|
||||
import eu.kanade.tachiyomi.util.view.show
|
||||
import eu.kanade.tachiyomi.util.view.snack
|
||||
import eu.kanade.tachiyomi.util.view.updateLayoutParams
|
||||
import eu.kanade.tachiyomi.util.view.updatePaddingRelative
|
||||
@ -185,7 +189,6 @@ class MangaDetailsController : BaseController,
|
||||
// Hold a reference to the current animator, so that it can be canceled mid-way.
|
||||
private var currentAnimator: Animator? = null
|
||||
|
||||
var showScroll = false
|
||||
var headerHeight = 0
|
||||
|
||||
override fun getTitle(): String? {
|
||||
@ -292,11 +295,22 @@ class MangaDetailsController : BaseController,
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
val atTop = !recycler.canScrollVertically(-1)
|
||||
if (atTop) getHeader()?.backdrop?.translationY = 0f
|
||||
when (newState) {
|
||||
RecyclerView.SCROLL_STATE_DRAGGING -> {
|
||||
scrollAnim?.cancel()
|
||||
if (fast_scroller.translationX != 0f) {
|
||||
showFastScroller()
|
||||
}
|
||||
}
|
||||
RecyclerView.SCROLL_STATE_IDLE -> {
|
||||
scrollAnim = fast_scroller.hide()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun setInsets(insets: WindowInsets, appbarHeight: Int, offset: Int) {
|
||||
private fun setInsets(insets: WindowInsets, appbarHeight: Int, offset: Int) {
|
||||
recycler.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||
tabletRecycler?.updatePaddingRelative(bottom = insets.systemWindowInsetBottom)
|
||||
headerHeight = appbarHeight + insets.systemWindowInsetTop
|
||||
@ -311,7 +325,8 @@ class MangaDetailsController : BaseController,
|
||||
}
|
||||
|
||||
private fun setFastScroller() {
|
||||
// fast_scroller.translationX = if (showScroll || isTablet) 0f else 25f.dpToPxEnd
|
||||
fast_scroller.setStartTranslationX(true)
|
||||
fast_scroller.setBackground(true)
|
||||
fast_scroller.setupWithRecyclerView(recycler, { position ->
|
||||
val letter = adapter?.getSectionText(position)
|
||||
when {
|
||||
@ -328,6 +343,9 @@ class MangaDetailsController : BaseController,
|
||||
indicatorCenterY: Int,
|
||||
itemPosition: Int
|
||||
) {
|
||||
scrollAnim?.cancel()
|
||||
scrollAnim = fast_scroller.hide(2000)
|
||||
|
||||
textAnim?.cancel()
|
||||
textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(1000)
|
||||
textAnim?.start()
|
||||
@ -340,7 +358,9 @@ class MangaDetailsController : BaseController,
|
||||
(recycler.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(
|
||||
itemPosition, headerHeight
|
||||
)
|
||||
colorToolbar(itemPosition > 0, false)
|
||||
if (!isTablet) {
|
||||
colorToolbar(itemPosition > 0, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -582,6 +602,12 @@ class MangaDetailsController : BaseController,
|
||||
activity?.invalidateOptionsMenu()
|
||||
}
|
||||
|
||||
private fun showFastScroller(animate: Boolean = true) {
|
||||
if (presenter.scrollType != 0) {
|
||||
fast_scroller.show(animate)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addMangaHeader() {
|
||||
if (tabletAdapter?.scrollableHeaders?.isEmpty() == true) {
|
||||
tabletAdapter?.removeAllScrollableHeaders()
|
||||
|
@ -67,7 +67,7 @@ class MangaDetailsPresenter(
|
||||
private val seasonRegex = Regex("""(Season |S)([0-9]+)?""")
|
||||
|
||||
private val loggedServices by lazy { Injekt.get<TrackManager>().services.filter { it.isLogged } }
|
||||
var tracks = emptyList<Track>()
|
||||
private var tracks = emptyList<Track>()
|
||||
|
||||
var trackList: List<TrackItem> = emptyList()
|
||||
|
||||
|
@ -5,6 +5,7 @@ import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
@ -19,6 +20,7 @@ import eu.kanade.tachiyomi.data.glide.GlideApp
|
||||
import eu.kanade.tachiyomi.source.LocalSource
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.ui.base.holder.BaseFlexibleViewHolder
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.system.isLTR
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
@ -61,8 +63,9 @@ class MangaHeaderHolder(
|
||||
true
|
||||
false
|
||||
}
|
||||
if (!itemView.resources.isLTR)
|
||||
if (!itemView.resources.isLTR) {
|
||||
more_bg_gradient.rotation = 180f
|
||||
}
|
||||
less_button.setOnClickListener { collapseDesc() }
|
||||
manga_genres_tags.setOnTagClickListener {
|
||||
adapter.delegate.tagClicked(it)
|
||||
@ -92,6 +95,10 @@ class MangaHeaderHolder(
|
||||
if (startExpanded) expandDesc()
|
||||
else collapseDesc()
|
||||
if (isTablet) chapter_layout.gone()
|
||||
} else {
|
||||
filter_button.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||
marginEnd = 12.dpToPx
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,37 @@
|
||||
package eu.kanade.tachiyomi.util.view
|
||||
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.view.ViewPropertyAnimator
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.reddit.indicatorfastscroll.FastScrollerView
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.system.dpToPxEnd
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
|
||||
fun FastScrollerView.setBackground(hasBackground: Boolean) {
|
||||
background = if (hasBackground) ContextCompat.getDrawable(
|
||||
context, R.drawable.fast_scroll_background
|
||||
) else null
|
||||
textColor = ColorStateList.valueOf(
|
||||
if (hasBackground) Color.WHITE
|
||||
else context.getResourceColor(android.R.attr.textColorPrimary)
|
||||
)
|
||||
iconColor = textColor
|
||||
}
|
||||
|
||||
fun FastScrollerView.setStartTranslationX(shouldHide: Boolean) {
|
||||
translationX = if (shouldHide) 25f.dpToPxEnd else 0f
|
||||
}
|
||||
|
||||
fun FastScrollerView.hide(duration: Long = 1000): ViewPropertyAnimator {
|
||||
val scrollAnim = animate().setStartDelay(duration).setDuration(250)
|
||||
.translationX(25f.dpToPxEnd)
|
||||
scrollAnim.start()
|
||||
return scrollAnim
|
||||
}
|
||||
|
||||
fun FastScrollerView.show(animate: Boolean = true) {
|
||||
if (animate) animate().setStartDelay(0).setDuration(100).translationX(0f).start()
|
||||
else translationX = 0f
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
<size
|
||||
android:width="25dp"
|
||||
android:height="25dp" />
|
||||
<solid android:color="@color/gray_button" />
|
||||
<solid android:color="@color/md_grey_800" />
|
||||
</shape>
|
||||
</item>
|
||||
<item
|
||||
@ -21,7 +21,7 @@
|
||||
<size
|
||||
android:width="0dp"
|
||||
android:height="25dp" />
|
||||
<solid android:color="@color/gray_button" />
|
||||
<solid android:color="@color/md_grey_800" />
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -94,7 +94,7 @@
|
||||
layout="@layout/download_button"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
@ -38,7 +38,6 @@
|
||||
android:elevation="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:background="@drawable/fast_scroll_background"
|
||||
android:backgroundTint="@color/md_grey_800"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingStart="3dp"
|
||||
|
@ -38,13 +38,14 @@
|
||||
<com.reddit.indicatorfastscroll.FastScrollerView
|
||||
android:id="@+id/fast_scroller"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:elevation="10dp"
|
||||
android:paddingStart="1dp"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingEnd="0dp"
|
||||
android:paddingBottom="8dp"
|
||||
app:layout_constrainedHeight="true"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
app:iconColor="?android:attr/textColorPrimary"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
@ -225,7 +225,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:maxLines="3"
|
||||
@ -268,7 +268,7 @@
|
||||
style="@style/Theme.Widget.Button.TextButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/more"
|
||||
android:textAlignment="viewEnd"
|
||||
app:layout_constraintBottom_toBottomOf="@id/more_guide"
|
||||
@ -314,7 +314,7 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="18dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/less"
|
||||
android:textAlignment="textEnd"
|
||||
android:visibility="gone"
|
||||
@ -331,9 +331,8 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="12dp"
|
||||
android:layout_marginEnd="24dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:text="@string/start_reading"
|
||||
app:layout_constraintBottom_toTopOf="@id/chapter_layout"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@ -373,7 +372,7 @@
|
||||
android:tint="?colorAccent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:background="@null"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/ic_filter_list_white_24dp"
|
||||
|
Loading…
Reference in New Issue
Block a user