mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 23:41:50 +01:00
Use enum instead of boolean
This commit is contained in:
parent
0ea0eba4f0
commit
c8a6a2653f
@ -30,4 +30,11 @@ object PreferenceValues {
|
||||
COMFORTABLE_GRID,
|
||||
LIST,
|
||||
}
|
||||
|
||||
enum class TappingInvertMode {
|
||||
NONE,
|
||||
HORIZONTAL,
|
||||
VERTICAL,
|
||||
BOTH
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
|
||||
|
||||
fun readWithTappingInverted() = flowPrefs.getBoolean(Keys.readWithTappingInverted, false)
|
||||
fun readWithTappingInverted() = flowPrefs.getEnum(Keys.readWithTappingInverted, Values.TappingInvertMode.NONE)
|
||||
|
||||
fun readWithLongTap() = flowPrefs.getBoolean(Keys.readWithLongTap, true)
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package eu.kanade.tachiyomi.ui.reader.viewer
|
||||
|
||||
import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@ -20,7 +21,7 @@ abstract class ViewerConfig(preferences: PreferencesHelper) {
|
||||
|
||||
var tappingEnabled = true
|
||||
var longTapEnabled = true
|
||||
var tappingInverted = false
|
||||
var tappingInverted = TappingInvertMode.NONE
|
||||
var doubleTapAnimDuration = 500
|
||||
var volumeKeysEnabled = false
|
||||
var volumeKeysInverted = false
|
||||
|
@ -7,6 +7,7 @@ import android.view.View
|
||||
import android.view.ViewGroup.LayoutParams
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
@ -80,10 +81,11 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
}
|
||||
})
|
||||
pager.tapListener = { event ->
|
||||
val tappingInverted = config.tappingInverted
|
||||
val invertMode = config.tappingInverted
|
||||
|
||||
if (this is VerticalPagerViewer) {
|
||||
val positionY = event.y
|
||||
val tappingInverted = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH
|
||||
val topSideTap = positionY < pager.height * 0.33f && config.tappingEnabled
|
||||
val bottomSideTap = positionY > pager.height * 0.66f && config.tappingEnabled
|
||||
|
||||
@ -94,6 +96,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
}
|
||||
} else {
|
||||
val positionX = event.x
|
||||
val tappingInverted = invertMode == TappingInvertMode.HORIZONTAL || invertMode == TappingInvertMode.BOTH
|
||||
val leftSideTap = positionX < pager.width * 0.33f && config.tappingEnabled
|
||||
val rightSideTap = positionX > pager.width * 0.66f && config.tappingEnabled
|
||||
|
||||
|
@ -7,6 +7,7 @@ import android.view.ViewGroup
|
||||
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.WebtoonLayoutManager
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ChapterTransition
|
||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||
@ -14,10 +15,10 @@ import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
||||
import eu.kanade.tachiyomi.util.view.gone
|
||||
import eu.kanade.tachiyomi.util.view.visible
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
||||
/**
|
||||
* Implementation of a [BaseViewer] to display pages with a [RecyclerView].
|
||||
@ -94,10 +95,12 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
})
|
||||
recycler.tapListener = { event ->
|
||||
val positionY = event.rawY
|
||||
val tappingInverted = config.tappingInverted
|
||||
val invertMode = config.tappingInverted
|
||||
val topSideTap = positionY < recycler.height * 0.33f && config.tappingEnabled
|
||||
val bottomSideTap = positionY > recycler.height * 0.66f && config.tappingEnabled
|
||||
|
||||
val tappingInverted = invertMode == TappingInvertMode.VERTICAL || invertMode == TappingInvertMode.BOTH
|
||||
|
||||
when {
|
||||
topSideTap && !tappingInverted || bottomSideTap && tappingInverted -> scrollUp()
|
||||
bottomSideTap && !tappingInverted || topSideTap && tappingInverted -> scrollDown()
|
||||
|
@ -4,9 +4,11 @@ import android.os.Build
|
||||
import androidx.preference.PreferenceScreen
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues.TappingInvertMode
|
||||
import eu.kanade.tachiyomi.util.preference.defaultValue
|
||||
import eu.kanade.tachiyomi.util.preference.entriesRes
|
||||
import eu.kanade.tachiyomi.util.preference.intListPreference
|
||||
import eu.kanade.tachiyomi.util.preference.listPreference
|
||||
import eu.kanade.tachiyomi.util.preference.preferenceCategory
|
||||
import eu.kanade.tachiyomi.util.preference.summaryRes
|
||||
import eu.kanade.tachiyomi.util.preference.switchPreference
|
||||
@ -190,10 +192,23 @@ class SettingsReaderController : SettingsController() {
|
||||
titleRes = R.string.pref_read_with_tapping
|
||||
defaultValue = true
|
||||
}
|
||||
switchPreference {
|
||||
listPreference {
|
||||
key = Keys.readWithTappingInverted
|
||||
titleRes = R.string.pref_read_with_tapping_inverted
|
||||
defaultValue = false
|
||||
entriesRes = arrayOf(
|
||||
R.string.tapping_inverted_none,
|
||||
R.string.tapping_inverted_horizontal,
|
||||
R.string.tapping_inverted_vertical,
|
||||
R.string.tapping_inverted_both
|
||||
)
|
||||
entryValues = arrayOf(
|
||||
TappingInvertMode.NONE.name,
|
||||
TappingInvertMode.HORIZONTAL.name,
|
||||
TappingInvertMode.VERTICAL.name,
|
||||
TappingInvertMode.BOTH.name
|
||||
)
|
||||
defaultValue = TappingInvertMode.NONE.name
|
||||
summary = "%s"
|
||||
}.apply { dependency = Keys.readWithTapping }
|
||||
switchPreference {
|
||||
key = Keys.readWithLongTap
|
||||
|
@ -665,5 +665,9 @@
|
||||
<string name="channel_backup_restore_progress">Progress</string>
|
||||
<string name="channel_backup_restore_complete">Complete</string>
|
||||
<string name="pref_read_with_tapping_inverted">Invert tapping</string>
|
||||
<string name="tapping_inverted_none">None</string>
|
||||
<string name="tapping_inverted_horizontal">Horizontal</string>
|
||||
<string name="tapping_inverted_vertical">Vertical</string>
|
||||
<string name="tapping_inverted_both">Both</string>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user