Add ability to tweak auto hide sensitivity in Webtoon Reader (#5650)
* Tweak threshold * Put setting under Webtoon instead Because it only affects Webtoon related viewers
Cette révision appartient à :
Parent
2f94f62a56
révision
7907a4fc24
6 fichiers modifiés avec 42 ajouts et 1 suppressions
|
@ -87,6 +87,8 @@ object PreferenceKeys {
|
|||
|
||||
const val showNavigationOverlayOnStart = "reader_navigation_overlay_on_start"
|
||||
|
||||
const val readerHideThreshold = "reader_hide_threshold"
|
||||
|
||||
const val webtoonSidePadding = "webtoon_side_padding"
|
||||
|
||||
const val portraitColumns = "pref_library_columns_portrait_key"
|
||||
|
|
|
@ -43,4 +43,11 @@ object PreferenceValues {
|
|||
VERTICAL(shouldInvertVertical = true),
|
||||
BOTH(shouldInvertHorizontal = true, shouldInvertVertical = true),
|
||||
}
|
||||
|
||||
enum class ReaderHideThreshold(val threshold: Int) {
|
||||
HIGHEST(5),
|
||||
HIGH(13),
|
||||
LOW(31),
|
||||
LOWEST(47)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,6 +167,8 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun showNavigationOverlayOnStart() = flowPrefs.getBoolean(Keys.showNavigationOverlayOnStart, false)
|
||||
|
||||
fun readerHideTreshold() = flowPrefs.getEnum(Keys.readerHideThreshold, Values.ReaderHideThreshold.LOW)
|
||||
|
||||
fun portraitColumns() = flowPrefs.getInt(Keys.portraitColumns, 0)
|
||||
|
||||
fun landscapeColumns() = flowPrefs.getInt(Keys.landscapeColumns, 0)
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.core.view.isGone
|
|||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.WebtoonLayoutManager
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
|
@ -20,6 +21,8 @@ import kotlinx.coroutines.MainScope
|
|||
import kotlinx.coroutines.cancel
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
|
@ -70,6 +73,12 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||
*/
|
||||
val subscriptions = CompositeSubscription()
|
||||
|
||||
private val threshold: Int =
|
||||
Injekt.get<PreferencesHelper>()
|
||||
.readerHideTreshold()
|
||||
.get()
|
||||
.threshold
|
||||
|
||||
init {
|
||||
recycler.isVisible = false // Don't let the recycler layout yet
|
||||
recycler.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
||||
|
@ -81,7 +90,7 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
|
||||
onScrolled()
|
||||
|
||||
if ((dy > 37 || dy < -37) && activity.menuVisible) {
|
||||
if ((dy > threshold || dy < -threshold) && activity.menuVisible) {
|
||||
activity.hideMenu()
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.ui.setting
|
|||
import android.os.Build
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||
|
@ -274,6 +275,21 @@ class SettingsReaderController : SettingsController() {
|
|||
defaultValue = "0"
|
||||
summary = "%s"
|
||||
}
|
||||
listPreference {
|
||||
key = Keys.readerHideThreshold
|
||||
titleRes = R.string.pref_hide_threshold
|
||||
entriesRes = arrayOf(
|
||||
R.string.pref_highest,
|
||||
R.string.pref_high,
|
||||
R.string.pref_low,
|
||||
R.string.pref_lowest
|
||||
)
|
||||
entryValues = PreferenceValues.ReaderHideThreshold.values()
|
||||
.map { it.name }
|
||||
.toTypedArray()
|
||||
defaultValue = "${PreferenceValues.ReaderHideThreshold.LOW}"
|
||||
summary = "%s"
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.cropBordersWebtoon
|
||||
titleRes = R.string.pref_crop_borders
|
||||
|
|
|
@ -358,6 +358,11 @@
|
|||
<string name="webtoon_side_padding_15">15%</string>
|
||||
<string name="webtoon_side_padding_20">20%</string>
|
||||
<string name="webtoon_side_padding_25">25%</string>
|
||||
<string name="pref_hide_threshold">Auto hide menu on scroll sensitivity</string>
|
||||
<string name="pref_highest">Highest</string>
|
||||
<string name="pref_high">High</string>
|
||||
<string name="pref_low">Low</string>
|
||||
<string name="pref_lowest">Lowest</string>
|
||||
|
||||
<!-- Downloads section -->
|
||||
<string name="pref_download_directory">Download location</string>
|
||||
|
|
Référencer dans un nouveau ticket