|
@@ -1,31 +1,14 @@
|
|
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
|
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
|
|
|
|
|
|
-import com.f2prateek.rx.preferences.Preference
|
|
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
|
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerConfig
|
|
-import eu.kanade.tachiyomi.util.lang.addTo
|
|
|
|
-import rx.subscriptions.CompositeSubscription
|
|
|
|
import uy.kohesive.injekt.Injekt
|
|
import uy.kohesive.injekt.Injekt
|
|
import uy.kohesive.injekt.api.get
|
|
import uy.kohesive.injekt.api.get
|
|
|
|
|
|
/**
|
|
/**
|
|
* Configuration used by webtoon viewers.
|
|
* Configuration used by webtoon viewers.
|
|
*/
|
|
*/
|
|
-
|
|
|
|
- private val subscriptions = CompositeSubscription()
|
|
|
|
-class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfig() {
|
|
|
|
-
|
|
|
|
- var tappingEnabled = true
|
|
|
|
- private set
|
|
|
|
-
|
|
|
|
- var longTapEnabled = true
|
|
|
|
- private set
|
|
|
|
-
|
|
|
|
- var volumeKeysEnabled = false
|
|
|
|
- private set
|
|
|
|
-
|
|
|
|
- var volumeKeysInverted = false
|
|
|
|
- private set
|
|
|
|
|
|
+class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfig(preferences) {
|
|
|
|
|
|
var imageCropBorders = false
|
|
var imageCropBorders = false
|
|
private set
|
|
private set
|
|
@@ -33,52 +16,32 @@ class WebtoonConfig(preferences: PreferencesHelper = Injekt.get()) : ViewerConfi
|
|
var doubleTapAnimDuration = 500
|
|
var doubleTapAnimDuration = 500
|
|
private set
|
|
private set
|
|
|
|
|
|
- var alwaysShowChapterTransition = true
|
|
|
|
- private set
|
|
|
|
-
|
|
|
|
var sidePadding = 0
|
|
var sidePadding = 0
|
|
private set
|
|
private set
|
|
|
|
|
|
init {
|
|
init {
|
|
preferences.readWithTapping()
|
|
preferences.readWithTapping()
|
|
- .register({ tappingEnabled = it })
|
|
|
|
|
|
+ .register({ tappingEnabled = it })
|
|
|
|
|
|
preferences.readWithLongTap()
|
|
preferences.readWithLongTap()
|
|
- .register({ longTapEnabled = it })
|
|
|
|
|
|
+ .register({ longTapEnabled = it })
|
|
|
|
|
|
preferences.cropBordersWebtoon()
|
|
preferences.cropBordersWebtoon()
|
|
- .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
|
|
|
|
|
+ .register({ imageCropBorders = it }, { imagePropertyChangedListener?.invoke() })
|
|
|
|
|
|
preferences.doubleTapAnimSpeed()
|
|
preferences.doubleTapAnimSpeed()
|
|
- .register({ doubleTapAnimDuration = it })
|
|
|
|
|
|
+ .register({ doubleTapAnimDuration = it })
|
|
|
|
|
|
preferences.readWithVolumeKeys()
|
|
preferences.readWithVolumeKeys()
|
|
- .register({ volumeKeysEnabled = it })
|
|
|
|
|
|
+ .register({ volumeKeysEnabled = it })
|
|
|
|
|
|
preferences.readWithVolumeKeysInverted()
|
|
preferences.readWithVolumeKeysInverted()
|
|
- .register({ volumeKeysInverted = it })
|
|
|
|
|
|
+ .register({ volumeKeysInverted = it })
|
|
|
|
|
|
preferences.alwaysShowChapterTransition()
|
|
preferences.alwaysShowChapterTransition()
|
|
- .register({ alwaysShowChapterTransition = it })
|
|
|
|
|
|
+ .register({ alwaysShowChapterTransition = it })
|
|
|
|
|
|
preferences.webtoonSidePadding()
|
|
preferences.webtoonSidePadding()
|
|
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
|
.register({ sidePadding = it }, { imagePropertyChangedListener?.invoke() })
|
|
}
|
|
}
|
|
-
|
|
|
|
- fun unsubscribe() {
|
|
|
|
- subscriptions.unsubscribe()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private fun <T> Preference<T>.register(
|
|
|
|
- valueAssignment: (T) -> Unit,
|
|
|
|
- onChanged: (T) -> Unit = {}
|
|
|
|
- ) {
|
|
|
|
- asObservable()
|
|
|
|
- .doOnNext(valueAssignment)
|
|
|
|
- .skip(1)
|
|
|
|
- .distinctUntilChanged()
|
|
|
|
- .doOnNext(onChanged)
|
|
|
|
- .subscribe()
|
|
|
|
- .addTo(subscriptions)
|
|
|
|
- }
|
|
|
|
}
|
|
}
|