mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 04:37:25 +01:00
Double tap zoom toggle (#9384)
* Double tap zoom toggle Implements a toggle that allows users to disable double tap zoom including QuickScaling for webtoons. Partially resolves #4145 * Update i18n/src/main/res/values/strings.xml --------- Co-authored-by: arkon <arkon@users.noreply.github.com>
This commit is contained in:
parent
a8f17a3fab
commit
3ce9a9ff97
@ -317,6 +317,11 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
subtitle = stringResource(R.string.split_tall_images_summary),
|
||||
enabled = !isReleaseBuildType, // TODO: Show in release build when the feature is stable
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
pref = readerPreferences.webtoonDoubleTapZoomEnabled(),
|
||||
title = stringResource(R.string.pref_double_tap_zoom),
|
||||
enabled = true,
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -34,6 +34,8 @@ class ReaderPreferences(
|
||||
// TODO: Enable in release build when the feature is stable
|
||||
fun longStripSplitWebtoon() = preferenceStore.getBoolean("pref_long_strip_split_webtoon", !isReleaseBuildType)
|
||||
|
||||
fun webtoonDoubleTapZoomEnabled() = preferenceStore.getBoolean("pref_enable_double_tap_zoom_webtoon", true)
|
||||
|
||||
fun imageScaleType() = preferenceStore.getInt("pref_image_scale_type_key", 1)
|
||||
|
||||
fun zoomStart() = preferenceStore.getInt("pref_zoom_start_key", 1)
|
||||
|
@ -140,5 +140,7 @@ class ReaderReadingModeSettings @JvmOverloads constructor(context: Context, attr
|
||||
|
||||
binding.webtoonPrefsGroup.longStripSplit.isVisible = !isReleaseBuildType
|
||||
binding.webtoonPrefsGroup.longStripSplit.bindToPreference(readerPreferences.longStripSplitWebtoon())
|
||||
|
||||
binding.webtoonPrefsGroup.doubleTapZoom.bindToPreference(readerPreferences.webtoonDoubleTapZoomEnabled())
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,11 @@ class WebtoonConfig(
|
||||
|
||||
var longStripSplitChangedListener: ((Boolean) -> Unit)? = null
|
||||
|
||||
var doubleTapZoom = true
|
||||
private set
|
||||
|
||||
var doubleTapZoomChangedListener: ((Boolean) -> Unit)? = null
|
||||
|
||||
val theme = readerPreferences.readerTheme().get()
|
||||
|
||||
init {
|
||||
@ -71,6 +76,12 @@ class WebtoonConfig(
|
||||
},
|
||||
)
|
||||
|
||||
readerPreferences.webtoonDoubleTapZoomEnabled()
|
||||
.register(
|
||||
{ doubleTapZoom = it },
|
||||
{ doubleTapZoomChangedListener?.invoke(it) },
|
||||
)
|
||||
|
||||
readerPreferences.readerTheme().changes()
|
||||
.drop(1)
|
||||
.distinctUntilChanged()
|
||||
|
@ -25,6 +25,13 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
|
||||
*/
|
||||
private val flingDetector = GestureDetector(context, FlingListener())
|
||||
|
||||
var doubleTapZoom = true
|
||||
set(value) {
|
||||
field = value
|
||||
recycler?.doubleTapZoom = value
|
||||
scaleDetector.isQuickScaleEnabled = value
|
||||
}
|
||||
|
||||
/**
|
||||
* Recycler view added in this frame.
|
||||
*/
|
||||
|
@ -37,6 +37,8 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
private val listener = GestureListener()
|
||||
private val detector = Detector()
|
||||
|
||||
var doubleTapZoom = true
|
||||
|
||||
var tapListener: ((MotionEvent) -> Unit)? = null
|
||||
var longTapListener: ((MotionEvent) -> Boolean)? = null
|
||||
|
||||
@ -209,7 +211,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun onDoubleTapConfirmed(ev: MotionEvent) {
|
||||
if (!isZooming) {
|
||||
if (!isZooming && doubleTapZoom) {
|
||||
if (scaleX != DEFAULT_RATE) {
|
||||
zoom(currentScale, DEFAULT_RATE, x, 0f, y, 0f)
|
||||
} else {
|
||||
|
@ -142,6 +142,10 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
ActivityCompat.recreate(activity)
|
||||
}
|
||||
|
||||
config.doubleTapZoomChangedListener = {
|
||||
frame.doubleTapZoom = it
|
||||
}
|
||||
|
||||
config.navigationModeChangedListener = {
|
||||
val showOnStart = config.navigationOverlayOnStart || config.forceNavigationOverlay
|
||||
activity.binding.navigationOverlay.setNavigation(config.navigator, showOnStart)
|
||||
|
@ -75,6 +75,15 @@
|
||||
android:text="@string/pref_long_strip_split"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/double_tap_zoom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:text="@string/pref_double_tap_zoom"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
android:id="@+id/tapping_prefs_group"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -321,6 +321,7 @@
|
||||
<string name="pref_page_rotate">Rotate wide pages to fit</string>
|
||||
<string name="pref_page_rotate_invert">Flip orientation of rotated wide pages</string>
|
||||
<string name="pref_long_strip_split">Split tall images (BETA)</string>
|
||||
<string name="pref_double_tap_zoom">Double tap to zoom</string>
|
||||
<string name="pref_cutout_short">Show content in cutout area</string>
|
||||
<string name="pref_page_transitions">Animate page transitions</string>
|
||||
<string name="pref_double_tap_anim_speed">Double tap animation speed</string>
|
||||
|
Loading…
Reference in New Issue
Block a user