Copy enable/disable zoom out in webtoon reader from J2k
This commit is contained in:
parent
0125f326b4
commit
c340884adb
@ -276,4 +276,6 @@ object PreferenceKeys {
|
||||
const val hitomiAlwaysWebp = "hitomi_always_webp"
|
||||
|
||||
const val enhancedEHentaiView = "enhanced_e_hentai_view"
|
||||
|
||||
const val webtoonEnableZoomOut = "webtoon_enable_zoom_out"
|
||||
}
|
||||
|
@ -380,4 +380,6 @@ class PreferencesHelper(val context: Context) {
|
||||
fun hitomiAlwaysWebp() = flowPrefs.getBoolean(Keys.hitomiAlwaysWebp, true)
|
||||
|
||||
fun enhancedEHentaiView() = flowPrefs.getBoolean(Keys.enhancedEHentaiView, true)
|
||||
|
||||
fun webtoonEnableZoomOut() = flowPrefs.getBoolean(Keys.webtoonEnableZoomOut, false)
|
||||
}
|
||||
|
@ -104,6 +104,9 @@ class ReaderSettingsSheet(private val activity: ReaderActivity) : BottomSheetDia
|
||||
|
||||
binding.cropBordersWebtoon.bindToPreference(preferences.cropBordersWebtoon())
|
||||
binding.webtoonSidePadding.bindToIntPreference(preferences.webtoonSidePadding(), R.array.webtoon_side_padding_values)
|
||||
// SY -->
|
||||
binding.zoomOutWebtoon.bindToPreference(preferences.webtoonEnableZoomOut())
|
||||
// SY <--
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,11 +16,21 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfi
|
||||
var sidePadding = 0
|
||||
private set
|
||||
|
||||
// SY -->
|
||||
var enableZoomOut = false
|
||||
private set
|
||||
var zoomPropertyChangedListener: ((Boolean) -> Unit)? = null
|
||||
// SY <--
|
||||
init {
|
||||
preferences.cropBordersWebtoon()
|
||||
.register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
preferences.webtoonSidePadding()
|
||||
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
||||
|
||||
// SY -->
|
||||
preferences.webtoonEnableZoomOut()
|
||||
.register({ enableZoomOut = it }, { zoomPropertyChangedListener?.invoke(it) })
|
||||
// SY <--
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,14 @@ class WebtoonFrame(context: Context) : FrameLayout(context) {
|
||||
*/
|
||||
private val flingDetector = GestureDetector(context, FlingListener())
|
||||
|
||||
// SY -->
|
||||
var enableZoomOut = false
|
||||
set(value) {
|
||||
field = value
|
||||
recycler?.canZoomOut = value
|
||||
}
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
* Recycler view added in this frame.
|
||||
*/
|
||||
|
@ -33,6 +33,18 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
private var firstVisibleItemPosition = 0
|
||||
private var lastVisibleItemPosition = 0
|
||||
private var currentScale = DEFAULT_RATE
|
||||
// SY -->
|
||||
var canZoomOut = false
|
||||
set(value) {
|
||||
field = value
|
||||
if (!value) {
|
||||
zoom(currentScale, DEFAULT_RATE, x, 0f, y, 0f)
|
||||
}
|
||||
}
|
||||
|
||||
private val minRate
|
||||
get() = if (canZoomOut) MIN_RATE else DEFAULT_RATE
|
||||
// SY <--
|
||||
|
||||
private val listener = GestureListener()
|
||||
private val detector = Detector()
|
||||
@ -163,7 +175,9 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
fun onScale(scaleFactor: Float) {
|
||||
currentScale *= scaleFactor
|
||||
currentScale = currentScale.coerceIn(
|
||||
MIN_RATE,
|
||||
// SY -->
|
||||
minRate,
|
||||
// SY <--
|
||||
MAX_SCALE_RATE
|
||||
)
|
||||
|
||||
@ -190,8 +204,8 @@ open class WebtoonRecyclerView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
fun onScaleEnd() {
|
||||
if (scaleX < MIN_RATE) {
|
||||
zoom(currentScale, MIN_RATE, x, 0f, y, 0f)
|
||||
if (scaleX < /* SY --> */ minRate /* SY <-- */) {
|
||||
zoom(currentScale, /* SY --> */ minRate /* SY <-- */, x, 0f, y, 0f)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,12 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
||||
refreshAdapter()
|
||||
}
|
||||
|
||||
// SY -->
|
||||
config.zoomPropertyChangedListener = {
|
||||
frame.enableZoomOut = it
|
||||
}
|
||||
// SY <--
|
||||
|
||||
frame.layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
|
||||
frame.addView(recycler)
|
||||
}
|
||||
|
@ -294,6 +294,11 @@ class SettingsReaderController : SettingsController() {
|
||||
titleRes = R.string.pref_crop_borders
|
||||
defaultValue = false
|
||||
}
|
||||
switchPreference {
|
||||
key = Keys.webtoonEnableZoomOut
|
||||
titleRes = R.string.enable_zoom_out
|
||||
defaultValue = false
|
||||
}
|
||||
}
|
||||
|
||||
preferenceCategory {
|
||||
|
@ -343,6 +343,14 @@
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/webtoon_side_padding" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/zoom_out_webtoon"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/enable_zoom_out"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
app:layout_constraintTop_toBottomOf="@id/crop_borders_webtoon" />
|
||||
|
||||
<!-- Groups of preferences -->
|
||||
|
||||
<androidx.constraintlayout.widget.Group
|
||||
|
Loading…
x
Reference in New Issue
Block a user