mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 05:25:08 +01:00
Switching "disable zoom" setting to "enable zoom out"
which will be off by default
This commit is contained in:
parent
f7b10463f7
commit
cac18f16ab
@ -53,7 +53,7 @@ object PreferenceKeys {
|
||||
|
||||
const val webtoonSidePadding = "webtoon_side_padding"
|
||||
|
||||
const val webtoonDisableZoom = "webtoon_disable_zoom"
|
||||
const val webtoonEnableZoomOut = "webtoon_enable_zoom_out"
|
||||
|
||||
const val updateOnlyNonCompleted = "pref_update_only_non_completed_key"
|
||||
|
||||
|
@ -99,7 +99,7 @@ class PreferencesHelper(val context: Context) {
|
||||
|
||||
fun webtoonSidePadding() = flowPrefs.getInt(Keys.webtoonSidePadding, 0)
|
||||
|
||||
fun webtoonDisableZoom() = flowPrefs.getBoolean(Keys.webtoonDisableZoom, false)
|
||||
fun webtoonEnableZoomOut() = flowPrefs.getBoolean(Keys.webtoonEnableZoomOut, false)
|
||||
|
||||
fun readWithTapping() = flowPrefs.getBoolean(Keys.readWithTapping, true)
|
||||
|
||||
|
@ -150,7 +150,7 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) :
|
||||
pager_prefs_group.gone()
|
||||
crop_borders_webtoon.bindToPreference(if (hasMargins) preferences.cropBorders() else preferences.cropBordersWebtoon())
|
||||
webtoon_side_padding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||
webtoon_disable_zoom.bindToPreference(preferences.webtoonDisableZoom())
|
||||
webtoon_enable_zoom_out.bindToPreference(preferences.webtoonEnableZoomOut())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfi
|
||||
var sidePadding = 0
|
||||
private set
|
||||
|
||||
var disableZoom = false
|
||||
var enableZoomOut = false
|
||||
private set
|
||||
var zoomPropertyChangedListener: ((Boolean) -> Unit)? = null
|
||||
|
||||
@ -33,7 +33,7 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfi
|
||||
preferences.webtoonSidePadding()
|
||||
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
preferences.webtoonDisableZoom()
|
||||
.register({ disableZoom = it }, { zoomPropertyChangedListener?.invoke(it) })
|
||||
preferences.webtoonEnableZoomOut()
|
||||
.register({ enableZoomOut = it }, { zoomPropertyChangedListener?.invoke(it) })
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,10 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
|
||||
*/
|
||||
private val flingDetector = GestureDetector(context, FlingListener())
|
||||
|
||||
var disableZoom = true
|
||||
var enableZoomOut = false
|
||||
set(value) {
|
||||
field = value
|
||||
recycler?.canZoom = !value
|
||||
recycler?.canZoomOut = value
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,14 +32,17 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
private var firstVisibleItemPosition = 0
|
||||
private var lastVisibleItemPosition = 0
|
||||
private var currentScale = DEFAULT_RATE
|
||||
var canZoom = false
|
||||
var canZoomOut = false
|
||||
set(value) {
|
||||
field = value
|
||||
if (!value) {
|
||||
zoom(currentScale, DEFAULT_RATE, x, 0f, y, 0f, true)
|
||||
zoom(currentScale, DEFAULT_RATE, x, 0f, y, 0f)
|
||||
}
|
||||
}
|
||||
|
||||
private val minRate
|
||||
get() = if (canZoomOut) MIN_RATE else DEFAULT_RATE
|
||||
|
||||
private val listener = GestureListener()
|
||||
private val detector = Detector()
|
||||
|
||||
@ -100,10 +103,8 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
fromX: Float,
|
||||
toX: Float,
|
||||
fromY: Float,
|
||||
toY: Float,
|
||||
force: Boolean = false
|
||||
toY: Float
|
||||
) {
|
||||
if (!canZoom && !force) return
|
||||
isZooming = true
|
||||
val animatorSet = AnimatorSet()
|
||||
val translationXAnimator = ValueAnimator.ofFloat(fromX, toX)
|
||||
@ -138,7 +139,6 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun zoomFling(velocityX: Int, velocityY: Int): Boolean {
|
||||
if (!canZoom) return false
|
||||
if (currentScale <= 1f) return false
|
||||
|
||||
val distanceTimeFactor = 0.4f
|
||||
@ -167,7 +167,6 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun zoomScrollBy(dx: Int, dy: Int) {
|
||||
if (!canZoom) return
|
||||
if (dx != 0) {
|
||||
x = getPositionX(x + dx)
|
||||
}
|
||||
@ -182,10 +181,9 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun onScale(scaleFactor: Float) {
|
||||
if (!canZoom) return
|
||||
currentScale *= scaleFactor
|
||||
currentScale = currentScale.coerceIn(
|
||||
MIN_RATE,
|
||||
minRate,
|
||||
MAX_SCALE_RATE)
|
||||
|
||||
setScaleRate(currentScale)
|
||||
@ -205,14 +203,14 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun onScaleBegin() {
|
||||
if (detector.isDoubleTapping && canZoom) {
|
||||
if (detector.isDoubleTapping) {
|
||||
detector.isQuickScaling = true
|
||||
}
|
||||
}
|
||||
|
||||
fun onScaleEnd() {
|
||||
if (scaleX < MIN_RATE && canZoom) {
|
||||
zoom(currentScale, MIN_RATE, x, 0f, y, 0f)
|
||||
if (scaleX < minRate) {
|
||||
zoom(currentScale, minRate, x, 0f, y, 0f)
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,7 +227,7 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun onDoubleTapConfirmed(ev: MotionEvent) {
|
||||
if (!isZooming && canZoom) {
|
||||
if (!isZooming) {
|
||||
if (scaleX != DEFAULT_RATE) {
|
||||
zoom(currentScale, DEFAULT_RATE, x, 0f, y, 0f)
|
||||
} else {
|
||||
@ -262,7 +260,6 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
override fun onTouchEvent(ev: MotionEvent): Boolean {
|
||||
val action = ev.actionMasked
|
||||
val actionIndex = ev.actionIndex
|
||||
if (!canZoom) return super.onTouchEvent(ev)
|
||||
when (action) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
scrollPointerId = ev.getPointerId(0)
|
||||
@ -309,12 +306,12 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
startScroll = true
|
||||
}
|
||||
|
||||
if (startScroll && canZoom) {
|
||||
if (startScroll) {
|
||||
isZoomDragging = true
|
||||
}
|
||||
}
|
||||
|
||||
if (isZoomDragging && canZoom) {
|
||||
if (isZoomDragging) {
|
||||
zoomScrollBy(dx, dy)
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals
|
||||
}
|
||||
|
||||
config.zoomPropertyChangedListener = {
|
||||
frame.disableZoom = it
|
||||
frame.enableZoomOut = it
|
||||
}
|
||||
|
||||
frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
||||
|
@ -163,6 +163,12 @@ class SettingsReaderController : SettingsController() {
|
||||
entryValues = listOf(0, 10, 15, 20, 25)
|
||||
defaultValue = "0"
|
||||
}
|
||||
|
||||
switchPreference {
|
||||
key = Keys.webtoonEnableZoomOut
|
||||
titleRes = R.string.enable_zoom_out
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
preferenceCategory {
|
||||
titleRes = R.string.navigation
|
||||
|
@ -264,11 +264,11 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/crop_borders_webtoon" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/webtoon_disable_zoom"
|
||||
android:id="@+id/webtoon_enable_zoom_out"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:text="@string/disable_zoom"
|
||||
android:text="@string/enable_zoom_out"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/webtoon_side_padding" />
|
||||
|
||||
@ -289,7 +289,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:constraint_referenced_ids="webtoon_prefs,crop_borders_webtoon,
|
||||
webtoon_side_padding_text,webtoon_side_padding,webtoon_disable_zoom" />
|
||||
webtoon_side_padding_text,webtoon_side_padding,webtoon_enable_zoom_out" />
|
||||
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/bottom_line"
|
||||
|
@ -288,7 +288,7 @@
|
||||
<!-- Reader settings -->
|
||||
<string name="fullscreen">Fullscreen</string>
|
||||
<string name="page_transitions">Page transitions</string>
|
||||
<string name="disable_zoom">Disable zoom</string>
|
||||
<string name="enable_zoom_out">Enable zoom out</string>
|
||||
<string name="double_tap_anim_speed">Double tap animation speed</string>
|
||||
<string name="show_page_number">Show page number</string>
|
||||
<string name="true_32bit_color">32-bit color</string>
|
||||
|
Loading…
Reference in New Issue
Block a user