mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Add option to disable navigation layout
closes #1210 Co-Authored-By: manatails <4215028+manatails@users.noreply.github.com>
This commit is contained in:
parent
e3311e8ed9
commit
baba5500c2
14 changed files with 37 additions and 46 deletions
|
@ -183,6 +183,13 @@ object Migrations {
|
|||
LibraryUpdateJob.setupTask(context, 12)
|
||||
}
|
||||
}
|
||||
if (oldVersion < 88) {
|
||||
val oldReaderTap = prefs.getBoolean("reader_tap", false)
|
||||
if (!oldReaderTap) {
|
||||
preferences.navigationModePager().set(5)
|
||||
preferences.navigationModeWebtoon().set(5)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ object PreferenceKeys {
|
|||
|
||||
const val cropBordersWebtoon = "crop_borders_webtoon"
|
||||
|
||||
const val readWithTapping = "reader_tap"
|
||||
|
||||
const val readWithLongTap = "reader_long_tap"
|
||||
|
||||
const val readWithVolumeKeys = "reader_volume_keys"
|
||||
|
|
|
@ -155,8 +155,6 @@ class PreferencesHelper(val context: Context) {
|
|||
|
||||
fun webtoonEnableZoomOut() = flowPrefs.getBoolean(Keys.webtoonEnableZoomOut, false)
|
||||
|
||||
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
|
||||
|
||||
fun readWithLongTap() = flowPrefs.getBoolean(Keys.readWithLongTap, true)
|
||||
|
||||
fun readWithVolumeKeys() = flowPrefs.getBoolean(Keys.readWithVolumeKeys, false)
|
||||
|
|
|
@ -1603,10 +1603,6 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||
.launchIn(scope)
|
||||
|
||||
preferences.readerBottomButtons().asImmediateFlowIn(scope) { updateBottomShortcuts() }
|
||||
|
||||
preferences.readWithTapping().asImmediateFlowIn(scope) {
|
||||
binding.navigationOverlay.tappingEnabled = it
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.view.ViewPropertyAnimator
|
|||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.DisabledNavigation
|
||||
import kotlin.math.abs
|
||||
|
||||
class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet) : View(context, attributeSet) {
|
||||
|
@ -20,7 +21,6 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
|
|||
private var navigation: ViewerNavigation? = null
|
||||
|
||||
var isLTR = true
|
||||
var tappingEnabled = true
|
||||
|
||||
fun setNavigation(navigation: ViewerNavigation, showOnStart: Boolean) {
|
||||
if (!showOnStart && (this.navigation == null || this.navigation === navigation)) {
|
||||
|
@ -38,7 +38,7 @@ class ReaderNavigationOverlayView(context: Context, attributeSet: AttributeSet)
|
|||
fun showNavigationAgain() {
|
||||
invalidate()
|
||||
|
||||
if (isVisible || !tappingEnabled) return
|
||||
if (isVisible || navigation is DisabledNavigation) return
|
||||
|
||||
viewPropertyAnimator = animate()
|
||||
.alpha(1f)
|
||||
|
|
|
@ -17,7 +17,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper, protected val scope:
|
|||
var navigationModeChangedListener: (() -> Unit)? = null
|
||||
var navigationModeInvertedListener: (() -> Unit)? = null
|
||||
|
||||
var tappingEnabled = true
|
||||
var longTapEnabled = true
|
||||
var tappingInverted = ViewerNavigation.TappingInvertMode.NONE
|
||||
var doubleTapAnimDuration = 500
|
||||
|
@ -33,9 +32,6 @@ abstract class ViewerConfig(preferences: PreferencesHelper, protected val scope:
|
|||
protected set
|
||||
|
||||
init {
|
||||
preferences.readWithTapping()
|
||||
.register({ tappingEnabled = it })
|
||||
|
||||
preferences.readWithLongTap()
|
||||
.register({ longTapEnabled = it })
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package eu.kanade.tachiyomi.ui.reader.viewer.navigation
|
||||
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
|
||||
/**
|
||||
* Visualization of default state without any inversion
|
||||
* +---+---+---+
|
||||
* | M | M | M | P: Previous
|
||||
* +---+---+---+
|
||||
* | M | M | M | M: Menu
|
||||
* +---+---+---+
|
||||
* | M | M | M | N: Next
|
||||
* +---+---+---+
|
||||
*/
|
||||
class DisabledNavigation : ViewerNavigation() {
|
||||
|
||||
override var regions: List<Region> = emptyList()
|
||||
}
|
|
@ -5,6 +5,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.DisabledNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.EdgeNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.KindlishNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.LNavigation
|
||||
|
@ -191,6 +192,7 @@ class PagerConfig(
|
|||
2 -> KindlishNavigation()
|
||||
3 -> EdgeNavigation()
|
||||
4 -> RightAndLeftNavigation()
|
||||
5 -> DisabledNavigation()
|
||||
else -> defaultNavigation()
|
||||
}
|
||||
navigationModeChangedListener?.invoke()
|
||||
|
|
|
@ -90,11 +90,6 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
|||
pager.adapter = adapter
|
||||
pager.addOnPageChangeListener(pagerListener)
|
||||
pager.tapListener = f@{ event ->
|
||||
if (!config.tappingEnabled) {
|
||||
activity.toggleMenu()
|
||||
return@f
|
||||
}
|
||||
|
||||
val pos = PointF(event.rawX / pager.width, event.rawY / pager.height)
|
||||
val navigator = config.navigator
|
||||
when (navigator.getAction(pos)) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|||
import eu.kanade.tachiyomi.ui.reader.settings.PageLayout
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.DisabledNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.EdgeNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.KindlishNavigation
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.navigation.LNavigation
|
||||
|
@ -103,6 +104,7 @@ class WebtoonConfig(
|
|||
2 -> KindlishNavigation()
|
||||
3 -> EdgeNavigation()
|
||||
4 -> RightAndLeftNavigation()
|
||||
5 -> DisabledNavigation()
|
||||
else -> defaultNavigation()
|
||||
}
|
||||
navigationModeChangedListener?.invoke()
|
||||
|
|
|
@ -94,20 +94,12 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals
|
|||
}
|
||||
)
|
||||
recycler.tapListener = f@{ event ->
|
||||
if (!config.tappingEnabled) {
|
||||
activity.toggleMenu()
|
||||
return@f
|
||||
}
|
||||
|
||||
val pos = PointF(event.rawX / recycler.width, event.rawY / recycler.height)
|
||||
if (!config.tappingEnabled) activity.toggleMenu()
|
||||
else {
|
||||
val navigator = config.navigator
|
||||
when (navigator.getAction(pos)) {
|
||||
ViewerNavigation.NavigationRegion.MENU -> activity.toggleMenu()
|
||||
ViewerNavigation.NavigationRegion.NEXT, ViewerNavigation.NavigationRegion.RIGHT -> moveToNext()
|
||||
ViewerNavigation.NavigationRegion.PREV, ViewerNavigation.NavigationRegion.LEFT -> moveToPrevious()
|
||||
}
|
||||
val navigator = config.navigator
|
||||
when (navigator.getAction(pos)) {
|
||||
ViewerNavigation.NavigationRegion.MENU -> activity.toggleMenu()
|
||||
ViewerNavigation.NavigationRegion.NEXT, ViewerNavigation.NavigationRegion.RIGHT -> moveToNext()
|
||||
ViewerNavigation.NavigationRegion.PREV, ViewerNavigation.NavigationRegion.LEFT -> moveToPrevious()
|
||||
}
|
||||
}
|
||||
recycler.longTapListener = f@{ event ->
|
||||
|
|
|
@ -157,8 +157,6 @@ class SettingsReaderController : SettingsController() {
|
|||
entryRange = 0..values.size
|
||||
}.toList()
|
||||
defaultValue = "0"
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
listPreference(activity) {
|
||||
key = Keys.pagerNavInverted
|
||||
|
@ -176,8 +174,6 @@ class SettingsReaderController : SettingsController() {
|
|||
ViewerNavigation.TappingInvertMode.BOTH.name
|
||||
)
|
||||
defaultValue = ViewerNavigation.TappingInvertMode.NONE.name
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
|
||||
intListPreference(activity) {
|
||||
|
@ -286,8 +282,6 @@ class SettingsReaderController : SettingsController() {
|
|||
entryRange = 0..values.size
|
||||
}.toList()
|
||||
defaultValue = "0"
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
listPreference(activity) {
|
||||
key = Keys.webtoonNavInverted
|
||||
|
@ -305,8 +299,6 @@ class SettingsReaderController : SettingsController() {
|
|||
ViewerNavigation.TappingInvertMode.BOTH.name
|
||||
)
|
||||
defaultValue = ViewerNavigation.TappingInvertMode.NONE.name
|
||||
|
||||
preferences.readWithTapping().asImmediateFlow { isVisible = it }.launchIn(viewScope)
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
|
@ -354,11 +346,6 @@ class SettingsReaderController : SettingsController() {
|
|||
preferenceCategory {
|
||||
titleRes = R.string.navigation
|
||||
|
||||
switchPreference {
|
||||
key = Keys.readWithTapping
|
||||
titleRes = R.string.tapping
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.readWithVolumeKeys
|
||||
titleRes = R.string.volume_keys
|
||||
|
|
|
@ -110,6 +110,7 @@
|
|||
<item>@string/kindlish_nav</item>
|
||||
<item>@string/edge_nav</item>
|
||||
<item>@string/right_and_left_nav</item>
|
||||
<item>@string/disabled</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="page_layouts">
|
||||
|
|
|
@ -417,7 +417,6 @@
|
|||
<string name="navigation">Navigation</string>
|
||||
<string name="volume_keys">Volume keys</string>
|
||||
<string name="invert_volume_keys">Invert volume keys</string>
|
||||
<string name="tapping">Tapping</string>
|
||||
<string name="background_color">Background color</string>
|
||||
<string name="white">White</string>
|
||||
<string name="black">Black</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue