Add disable webtoon zoom setting
This commit is contained in:
@@ -218,6 +218,9 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
|
||||
get() = prefs.getEnumValue(KEY_LOCAL_LIST_ORDER, SortOrder.NEWEST)
|
||||
set(value) = prefs.edit { putEnumValue(KEY_LOCAL_LIST_ORDER, value) }
|
||||
|
||||
val isWebtoonZoomEnable: Boolean
|
||||
get() = prefs.getBoolean(KEY_WEBTOON_ZOOM, true)
|
||||
|
||||
fun isPagesPreloadAllowed(cm: ConnectivityManager): Boolean {
|
||||
return when (prefs.getString(KEY_PAGES_PRELOAD, null)?.toIntOrNull()) {
|
||||
NETWORK_ALWAYS -> true
|
||||
@@ -337,6 +340,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
|
||||
const val KEY_SHORTCUTS = "dynamic_shortcuts"
|
||||
const val KEY_READER_TAPS_LTR = "reader_taps_ltr"
|
||||
const val KEY_LOCAL_LIST_ORDER = "local_order"
|
||||
const val KEY_WEBTOON_ZOOM = "webtoon_zoom"
|
||||
|
||||
// About
|
||||
const val KEY_APP_UPDATE = "app_update"
|
||||
|
||||
@@ -27,6 +27,9 @@ class ReaderSettings(
|
||||
val isPagesNumbersEnabled: Boolean
|
||||
get() = settings.isPagesNumbersEnabled
|
||||
|
||||
val isWebtoonZoomEnable: Boolean
|
||||
get() = settings.isWebtoonZoomEnable
|
||||
|
||||
override fun onInactive() {
|
||||
super.onInactive()
|
||||
settings.unsubscribe(internalObserver)
|
||||
@@ -60,7 +63,7 @@ class ReaderSettings(
|
||||
}
|
||||
|
||||
override fun onSharedPreferenceChanged(sharedPreferences: SharedPreferences?, key: String?) {
|
||||
if (key == AppSettings.KEY_ZOOM_MODE || key == AppSettings.KEY_PAGES_NUMBERS) {
|
||||
if (key == AppSettings.KEY_ZOOM_MODE || key == AppSettings.KEY_PAGES_NUMBERS || key == AppSettings.KEY_WEBTOON_ZOOM) {
|
||||
notifyChanged()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ class WebtoonReaderFragment : BaseReader<FragmentReaderWebtoonBinding>() {
|
||||
adapter = webtoonAdapter
|
||||
addOnPageScrollListener(PageScrollListener())
|
||||
}
|
||||
|
||||
viewModel.readerSettings.observe(viewLifecycleOwner) { binding.frame.isZoomEnable = it.isWebtoonZoomEnable }
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
||||
@@ -39,12 +39,23 @@ class WebtoonScalingFrame @JvmOverloads constructor(
|
||||
private val targetHitRect = Rect()
|
||||
private var pendingScroll = 0
|
||||
|
||||
var isZoomEnable = true
|
||||
set(value) {
|
||||
field = value
|
||||
if (scale != 1f) {
|
||||
scaleChild(1f, halfWidth, halfHeight)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
syncMatrixValues()
|
||||
}
|
||||
|
||||
override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
|
||||
ev ?: return super.dispatchTouchEvent(ev)
|
||||
if (!isZoomEnable || ev == null) {
|
||||
return super.dispatchTouchEvent(ev)
|
||||
}
|
||||
|
||||
if (ev.action == MotionEvent.ACTION_DOWN && overScroller.computeScrollOffset()) {
|
||||
overScroller.forceFinished(true)
|
||||
}
|
||||
@@ -64,10 +75,6 @@ class WebtoonScalingFrame @JvmOverloads constructor(
|
||||
return super.dispatchTouchEvent(ev)
|
||||
}
|
||||
|
||||
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean {
|
||||
return super.onInterceptTouchEvent(ev) || scaleDetector.isInProgress
|
||||
}
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
halfWidth = measuredWidth / 2f
|
||||
|
||||
@@ -390,4 +390,5 @@
|
||||
<string name="discard">Discard</string>
|
||||
<string name="error_no_space_left">No space left on device</string>
|
||||
<string name="reader_slider">Show page switching slider</string>
|
||||
<string name="webtoon_zoom">Webtoon zoom</string>
|
||||
</resources>
|
||||
|
||||
@@ -40,6 +40,11 @@
|
||||
android:key="reader_animation"
|
||||
android:title="@string/pages_animation" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="webtoon_zoom"
|
||||
android:title="@string/webtoon_zoom" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="reader_bar"
|
||||
|
||||
Reference in New Issue
Block a user