mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-24 22:25:53 +03: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(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
pref = readerPreferences.webtoonDoubleTapZoomEnabled(),
|
pref = readerPreferences.webtoonDoubleTapZoomEnabled(),
|
||||||
title = stringResource(MR.strings.pref_double_tap_zoom),
|
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),
|
label = stringResource(MR.strings.pref_double_tap_zoom),
|
||||||
pref = screenModel.preferences.webtoonDoubleTapZoomEnabled(),
|
pref = screenModel.preferences.webtoonDoubleTapZoomEnabled(),
|
||||||
)
|
)
|
||||||
|
CheckboxItem(
|
||||||
|
label = stringResource(MR.strings.pref_webtoon_disable_zoom_out),
|
||||||
|
pref = screenModel.preferences.webtoonDisableZoomOut(),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
@ -72,6 +72,8 @@ class ReaderPreferences(
|
||||||
|
|
||||||
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
|
fun skipDupe() = preferenceStore.getBoolean("skip_dupe", false)
|
||||||
|
|
||||||
|
fun webtoonDisableZoomOut() = preferenceStore.getBoolean("webtoon_disable_zoom_out", false)
|
||||||
|
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Split two page spread
|
// region Split two page spread
|
||||||
|
|
|
@ -29,6 +29,11 @@ class WebtoonConfig(
|
||||||
var imageCropBorders = false
|
var imageCropBorders = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
var zoomOutDisabled = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
var zoomPropertyChangedListener: ((Boolean) -> Unit)? = null
|
||||||
|
|
||||||
var sidePadding = 0
|
var sidePadding = 0
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
@ -74,6 +79,12 @@ class WebtoonConfig(
|
||||||
{ imagePropertyChangedListener?.invoke() },
|
{ imagePropertyChangedListener?.invoke() },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
readerPreferences.webtoonDisableZoomOut()
|
||||||
|
.register(
|
||||||
|
{ zoomOutDisabled = it },
|
||||||
|
{ zoomPropertyChangedListener?.invoke(it) }
|
||||||
|
)
|
||||||
|
|
||||||
readerPreferences.webtoonDoubleTapZoomEnabled()
|
readerPreferences.webtoonDoubleTapZoomEnabled()
|
||||||
.register(
|
.register(
|
||||||
{ doubleTapZoom = it },
|
{ doubleTapZoom = it },
|
||||||
|
|
|
@ -33,6 +33,12 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
|
||||||
scaleDetector.isQuickScaleEnabled = value
|
scaleDetector.isQuickScaleEnabled = value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var zoomOutDisabled = false
|
||||||
|
set(value) {
|
||||||
|
field = value
|
||||||
|
recycler?.zoomOutDisabled = value
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recycler view added in this frame.
|
* Recycler view added in this frame.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,6 +33,15 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||||
private var firstVisibleItemPosition = 0
|
private var firstVisibleItemPosition = 0
|
||||||
private var lastVisibleItemPosition = 0
|
private var lastVisibleItemPosition = 0
|
||||||
private var currentScale = DEFAULT_RATE
|
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 listener = GestureListener()
|
||||||
private val detector = Detector()
|
private val detector = Detector()
|
||||||
|
@ -166,7 +175,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||||
fun onScale(scaleFactor: Float) {
|
fun onScale(scaleFactor: Float) {
|
||||||
currentScale *= scaleFactor
|
currentScale *= scaleFactor
|
||||||
currentScale = currentScale.coerceIn(
|
currentScale = currentScale.coerceIn(
|
||||||
MIN_RATE,
|
minRate,
|
||||||
MAX_SCALE_RATE,
|
MAX_SCALE_RATE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -193,8 +202,8 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onScaleEnd() {
|
fun onScaleEnd() {
|
||||||
if (scaleX < MIN_RATE) {
|
if (scaleX < minRate) {
|
||||||
zoom(currentScale, MIN_RATE, x, 0f, y, 0f)
|
zoom(currentScale, minRate, x, 0f, y, 0f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||||
frame.doubleTapZoom = it
|
frame.doubleTapZoom = it
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.zoomPropertyChangedListener = {
|
||||||
|
frame.zoomOutDisabled = it
|
||||||
|
}
|
||||||
|
|
||||||
config.navigationModeChangedListener = {
|
config.navigationModeChangedListener = {
|
||||||
val showOnStart = config.navigationOverlayOnStart || config.forceNavigationOverlay
|
val showOnStart = config.navigationOverlayOnStart || config.forceNavigationOverlay
|
||||||
activity.binding.navigationOverlay.setNavigation(config.navigator, showOnStart)
|
activity.binding.navigationOverlay.setNavigation(config.navigator, showOnStart)
|
||||||
|
|
|
@ -453,6 +453,7 @@
|
||||||
<string name="pref_high">High</string>
|
<string name="pref_high">High</string>
|
||||||
<string name="pref_low">Low</string>
|
<string name="pref_low">Low</string>
|
||||||
<string name="pref_lowest">Lowest</string>
|
<string name="pref_lowest">Lowest</string>
|
||||||
|
<string name="pref_webtoon_disable_zoom_out">Disable zoom out</string>
|
||||||
|
|
||||||
<!-- Downloads section -->
|
<!-- Downloads section -->
|
||||||
<string name="pref_category_delete_chapters">Delete chapters</string>
|
<string name="pref_category_delete_chapters">Delete chapters</string>
|
||||||
|
|
Loading…
Reference in a new issue