mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-22 21:02:16 +03:00
Allow disabling reader's zoom out
* Allow disabling reader's zoom out (#62) * Renamed disable zoom out pref and string * Zoom to default rate if the scale is inferior * Fixed null value check and formatting * Fixed detekt Co-authored-by: Splintor <55398298+Splintorien@users.noreply.github.com>
This commit is contained in:
parent
1b7080f5b4
commit
09966bad71
8 changed files with 44 additions and 4 deletions
|
@ -345,7 +345,10 @@ object SettingsReaderScreen : SearchableSettings {
|
|||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = readerPreferences.webtoonDoubleTapZoomEnabled(),
|
||||
title = stringResource(MR.strings.pref_double_tap_zoom),
|
||||
enabled = true,
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = readerPreferences.webtoonDisableZoomOut(),
|
||||
title = stringResource(MR.strings.pref_webtoon_disable_zoom_out),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
@ -205,6 +205,10 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM
|
|||
label = stringResource(MR.strings.pref_double_tap_zoom),
|
||||
pref = screenModel.preferences.webtoonDoubleTapZoomEnabled(),
|
||||
)
|
||||
CheckboxItem(
|
||||
label = stringResource(MR.strings.pref_webtoon_disable_zoom_out),
|
||||
pref = screenModel.preferences.webtoonDisableZoomOut(),
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
|
@ -83,6 +83,8 @@ class ReaderPreferences(
|
|||
|
||||
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
|
||||
|
||||
fun webtoonDisableZoomOut() = preferenceStore.getBoolean("webtoon_disable_zoom_out", false)
|
||||
|
||||
// endregion
|
||||
|
||||
// region Split two page spread
|
||||
|
|
|
@ -29,6 +29,11 @@ class WebtoonConfig(
|
|||
var imageCropBorders = false
|
||||
private set
|
||||
|
||||
var zoomOutDisabled = false
|
||||
private set
|
||||
|
||||
var zoomPropertyChangedListener: ((Boolean) -> Unit)? = null
|
||||
|
||||
var sidePadding = 0
|
||||
private set
|
||||
|
||||
|
@ -74,6 +79,12 @@ class WebtoonConfig(
|
|||
{ imagePropertyChangedListener?.invoke() },
|
||||
)
|
||||
|
||||
readerPreferences.webtoonDisableZoomOut()
|
||||
.register(
|
||||
{ zoomOutDisabled = it },
|
||||
{ zoomPropertyChangedListener?.invoke(it) }
|
||||
)
|
||||
|
||||
readerPreferences.webtoonDoubleTapZoomEnabled()
|
||||
.register(
|
||||
{ doubleTapZoom = it },
|
||||
|
|
|
@ -33,6 +33,12 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
|
|||
scaleDetector.isQuickScaleEnabled = value
|
||||
}
|
||||
|
||||
var zoomOutDisabled = false
|
||||
set(value) {
|
||||
field = value
|
||||
recycler?.zoomOutDisabled = value
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycler view added in this frame.
|
||||
*/
|
||||
|
|
|
@ -33,6 +33,15 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||
private var firstVisibleItemPosition = 0
|
||||
private var lastVisibleItemPosition = 0
|
||||
private var currentScale = DEFAULT_RATE
|
||||
var zoomOutDisabled = false
|
||||
set(value) {
|
||||
field = value
|
||||
if (value && currentScale < DEFAULT_RATE) {
|
||||
zoom(currentScale, DEFAULT_RATE, x, 0f, y, 0f)
|
||||
}
|
||||
}
|
||||
private val minRate
|
||||
get() = if (zoomOutDisabled) DEFAULT_RATE else MIN_RATE
|
||||
|
||||
private val listener = GestureListener()
|
||||
private val detector = Detector()
|
||||
|
@ -174,7 +183,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||
fun onScale(scaleFactor: Float) {
|
||||
currentScale *= scaleFactor
|
||||
currentScale = currentScale.coerceIn(
|
||||
MIN_RATE,
|
||||
minRate,
|
||||
MAX_SCALE_RATE,
|
||||
)
|
||||
|
||||
|
@ -201,8 +210,8 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
fun onScaleEnd() {
|
||||
if (scaleX < MIN_RATE) {
|
||||
zoom(currentScale, MIN_RATE, x, 0f, y, 0f)
|
||||
if (scaleX < minRate) {
|
||||
zoom(currentScale, minRate, x, 0f, y, 0f)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,6 +152,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||
frame.doubleTapZoom = it
|
||||
}
|
||||
|
||||
config.zoomPropertyChangedListener = {
|
||||
frame.zoomOutDisabled = it
|
||||
}
|
||||
|
||||
config.navigationModeChangedListener = {
|
||||
val showOnStart = config.navigationOverlayOnStart || config.forceNavigationOverlay
|
||||
activity.binding.navigationOverlay.setNavigation(config.navigator, showOnStart)
|
||||
|
|
|
@ -416,6 +416,7 @@
|
|||
<string name="pref_high">High</string>
|
||||
<string name="pref_low">Low</string>
|
||||
<string name="pref_lowest">Lowest</string>
|
||||
<string name="pref_webtoon_disable_zoom_out">Disable zoom out</string>
|
||||
<string name="pref_remove_exclude_categories">Excluded categories</string>
|
||||
<string name="no_location_set">No storage location set</string>
|
||||
<string name="invalid_location">Invalid location: %s</string>
|
||||
|
|
Loading…
Reference in a new issue