diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index 38bdb30055..cb98768781 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -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" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index fc74e46b0f..869edbfc57 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt index f9b9577596..8e09aa9ff0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsSheet.kt @@ -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()) } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt index 8002683489..5070c63cf0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonConfig.kt @@ -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) }) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt index 9cfa485771..3e6080f497 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonFrame.kt @@ -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 } /** diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt index dc65cead64..d69418b6b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonRecyclerView.kt @@ -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) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt index 999fc83fe8..df7f8854ea 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonViewer.kt @@ -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) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index 64206b0f67..38d92b02f0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -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 diff --git a/app/src/main/res/layout/reader_settings_sheet.xml b/app/src/main/res/layout/reader_settings_sheet.xml index 94e4c687bb..b48c8a27af 100644 --- a/app/src/main/res/layout/reader_settings_sheet.xml +++ b/app/src/main/res/layout/reader_settings_sheet.xml @@ -264,11 +264,11 @@ app:layout_constraintTop_toBottomOf="@id/crop_borders_webtoon" /> @@ -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" /> Fullscreen Page transitions - Disable zoom + Enable zoom out Double tap animation speed Show page number 32-bit color