Reader bottom sheet transparency, as well as a half fix for the fullscreen reader bug
This commit is contained in:
parent
0abee585fc
commit
1240cc5232
@ -509,7 +509,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
|
||||
val loader = page.chapter.pageLoader
|
||||
if (page.index == exh_currentPage()?.index && loader is HttpPageLoader) {
|
||||
if (page.index == exhCurrentpage()?.index && loader is HttpPageLoader) {
|
||||
loader.boostPage(page)
|
||||
} else {
|
||||
loader?.retryPage(page)
|
||||
@ -535,7 +535,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
binding.ehBoostPage.clicks()
|
||||
.onEach {
|
||||
viewer?.let { _ ->
|
||||
val curPage = exh_currentPage() ?: run {
|
||||
val curPage = exhCurrentpage() ?: run {
|
||||
toast("This page cannot be boosted (invalid page)!")
|
||||
return@let
|
||||
}
|
||||
@ -581,13 +581,8 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
|
||||
// EXH -->
|
||||
private fun exh_currentPage(): ReaderPage? {
|
||||
val currentPage = (
|
||||
(
|
||||
(viewer as? PagerViewer)?.currentPage
|
||||
?: (viewer as? WebtoonViewer)?.currentPage
|
||||
) as? ReaderPage
|
||||
)?.index
|
||||
private fun exhCurrentpage(): ReaderPage? {
|
||||
val currentPage = (((viewer as? PagerViewer)?.currentPage ?: (viewer as? WebtoonViewer)?.currentPage) as? ReaderPage)?.index
|
||||
return currentPage?.let { presenter.viewerChaptersRelay.value.currChapter.pages?.getOrNull(it) }
|
||||
}
|
||||
// EXH <--
|
||||
@ -606,6 +601,10 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
binding.readerMenu.isVisible = true
|
||||
|
||||
if (readerBottomSheetBinding.chaptersBottomSheet.sheetBehavior.isExpanded()) {
|
||||
readerBottomSheetBinding.chaptersBottomSheet.sheetBehavior?.isHideable = false
|
||||
}
|
||||
|
||||
if (animate) {
|
||||
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top)
|
||||
toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() {
|
||||
|
@ -1,9 +1,12 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.chapter
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.ColorStateList
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@ -12,15 +15,20 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.mikepenz.fastadapter.FastAdapter
|
||||
import com.mikepenz.fastadapter.adapters.ItemAdapter
|
||||
import com.mikepenz.fastadapter.listeners.ClickEventHook
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.ReaderChaptersSheetBinding
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderPresenter
|
||||
import eu.kanade.tachiyomi.util.lang.launchUI
|
||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||
import eu.kanade.tachiyomi.util.system.getResourceColor
|
||||
import exh.util.collapse
|
||||
import exh.util.expand
|
||||
import exh.util.isExpanded
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
import kotlinx.android.synthetic.main.reader_chapters_sheet.view.pill
|
||||
|
||||
class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
LinearLayout(context, attrs) {
|
||||
@ -37,6 +45,8 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
fun setup(activity: ReaderActivity) {
|
||||
presenter = activity.presenter
|
||||
binding = activity.readerBottomSheetBinding
|
||||
val fullPrimary = context.getResourceColor(R.attr.colorSurface)
|
||||
val primary = ColorUtils.setAlphaComponent(fullPrimary, 200)
|
||||
|
||||
sheetBehavior = BottomSheetBehavior.from(this)
|
||||
binding.chaptersButton.setOnClickListener {
|
||||
@ -52,6 +62,7 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
}
|
||||
|
||||
post {
|
||||
binding.chapterRecycler.alpha = if (sheetBehavior.isExpanded()) 1f else 0f
|
||||
binding.chapterRecycler.isClickable = sheetBehavior.isExpanded()
|
||||
binding.chapterRecycler.isFocusable = sheetBehavior.isExpanded()
|
||||
}
|
||||
@ -59,10 +70,14 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
|
||||
override fun onSlide(bottomSheet: View, progress: Float) {
|
||||
val trueProgress = max(progress, 0f)
|
||||
binding.pill.alpha = (1 - trueProgress) * 0.25f
|
||||
binding.chaptersButton.alpha = 1 - trueProgress
|
||||
binding.webviewButton.alpha = trueProgress
|
||||
binding.webviewButton.isVisible = binding.webviewButton.alpha > 0
|
||||
binding.chaptersButton.isInvisible = binding.chaptersButton.alpha <= 0
|
||||
backgroundTintList =
|
||||
ColorStateList.valueOf(lerpColor(primary, fullPrimary, trueProgress))
|
||||
binding.chapterRecycler.alpha = trueProgress
|
||||
}
|
||||
|
||||
override fun onStateChanged(p0: View, state: Int) {
|
||||
@ -77,6 +92,7 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
binding.webviewButton.alpha = 0f
|
||||
}
|
||||
if (state == BottomSheetBehavior.STATE_EXPANDED) {
|
||||
binding.chapterRecycler.alpha = 1F
|
||||
binding.chaptersButton.alpha = 0f
|
||||
binding.webviewButton.alpha = 1f
|
||||
}
|
||||
@ -120,6 +136,11 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
}
|
||||
})
|
||||
|
||||
backgroundTintList = ColorStateList.valueOf(
|
||||
if (!sheetBehavior.isExpanded()) primary
|
||||
else fullPrimary
|
||||
)
|
||||
|
||||
binding.chapterRecycler.layoutManager = LinearLayoutManager(context)
|
||||
refreshList()
|
||||
}
|
||||
@ -138,4 +159,22 @@ class ReaderChapterSheet @JvmOverloads constructor(context: Context, attrs: Attr
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun lerpColor(colorStart: Int, colorEnd: Int, percent: Float): Int {
|
||||
val perc = (percent * 100).roundToInt()
|
||||
return Color.argb(
|
||||
lerpColorCalc(Color.alpha(colorStart), Color.alpha(colorEnd), perc),
|
||||
lerpColorCalc(Color.red(colorStart), Color.red(colorEnd), perc),
|
||||
lerpColorCalc(Color.green(colorStart), Color.green(colorEnd), perc),
|
||||
lerpColorCalc(Color.blue(colorStart), Color.blue(colorEnd), perc)
|
||||
)
|
||||
}
|
||||
|
||||
fun lerpColorCalc(colorStart: Int, colorEnd: Int, percent: Int): Int {
|
||||
return (
|
||||
min(colorStart, colorEnd) * (100 - percent) + max(
|
||||
colorStart, colorEnd
|
||||
) * percent
|
||||
) / 100
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/reader_layout"
|
||||
@ -42,7 +42,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
|
||||
<FrameLayout
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
android:id="@+id/reader_menu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
@ -151,11 +151,11 @@
|
||||
app:srcCompat="@drawable/ic_keyboard_arrow_down_white_32dp" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
</FrameLayout>
|
||||
<include
|
||||
android:id="@+id/reader_chapters_sheet"
|
||||
layout="@layout/reader_chapters_sheet" />
|
||||
|
||||
<include
|
||||
android:id="@+id/reader_chapters_sheet"
|
||||
layout="@layout/reader_chapters_sheet" />
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/brightness_overlay"
|
||||
@ -163,4 +163,4 @@
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
</FrameLayout>
|
||||
|
@ -7,6 +7,7 @@
|
||||
android:layout_height="300dp"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical"
|
||||
android:alpha="1"
|
||||
app:behavior_peekHeight="?attr/actionBarSize"
|
||||
app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
|
||||
|
||||
@ -22,6 +23,7 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:alpha="0.25"
|
||||
android:contentDescription="@string/action_sort_drag_and_drop"
|
||||
android:src="@drawable/ic_drag_pill_24dp"
|
||||
android:tint="?attr/colorOnSurface"
|
||||
@ -84,5 +86,6 @@
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:clipToPadding="false"
|
||||
android:alpha="0"
|
||||
tools:listitem="@layout/reader_chapter_item" />
|
||||
</eu.kanade.tachiyomi.ui.reader.chapter.ReaderChapterSheet>
|
Loading…
x
Reference in New Issue
Block a user