mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Allow disabling reader's zoom out (#302)
* 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
This commit is contained in:
parent
21020e1797
commit
c15f3f2fd5
8 changed files with 44 additions and 4 deletions
|
@ -341,7 +341,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),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
|
@ -197,6 +197,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
|
||||
|
|
|
@ -72,6 +72,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()
|
||||
|
@ -166,7 +175,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||
fun onScale(scaleFactor: Float) {
|
||||
currentScale *= scaleFactor
|
||||
currentScale = currentScale.coerceIn(
|
||||
MIN_RATE,
|
||||
minRate,
|
||||
MAX_SCALE_RATE,
|
||||
)
|
||||
|
||||
|
@ -193,8 +202,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)
|
||||
|
|
|
@ -453,6 +453,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>
|
||||
|
||||
<!-- Downloads section -->
|
||||
<string name="pref_category_delete_chapters">Delete chapters</string>
|
||||
|
|
Loading…
Reference in a new issue