Automatic background color for PagerViewer (#4996)

* Add J2K implementation of automatic background

Co-authored-by: Jays2Kings <8617760+Jays2Kings@users.noreply.github.com>

* Tweak the monstrosity called automatic background

* Add ability to choose Automatic as a background

* More tweaks

Co-authored-by: Jays2Kings <8617760+Jays2Kings@users.noreply.github.com>
This commit is contained in:
Andreas
2021-05-05 04:46:42 +02:00
committed by GitHub
parent 157d8db68c
commit 122cdae5bc
5 changed files with 243 additions and 1 deletions

View File

@@ -23,6 +23,9 @@ class PagerConfig(
preferences: PreferencesHelper = Injekt.get()
) : ViewerConfig(preferences, scope) {
var automaticBackground = false
private set
var dualPageSplitChangedListener: ((Boolean) -> Unit)? = null
var imageScaleType = 1
@@ -35,6 +38,9 @@ class PagerConfig(
private set
init {
preferences.readerTheme()
.register({ automaticBackground = it == 3 }, { imagePropertyChangedListener?.invoke() })
preferences.imageScaleType()
.register({ imageScaleType = it }, { imagePropertyChangedListener?.invoke() })

View File

@@ -238,7 +238,12 @@ class PagerPageHolder(
.observeOn(AndroidSchedulers.mainThread())
.doOnNext { isAnimated ->
if (!isAnimated) {
initSubsamplingImageView().setImage(ImageSource.inputStream(openStream!!))
initSubsamplingImageView().apply {
if (viewer.config.automaticBackground) {
background = ImageUtil.chooseBackground(context, openStream!!)
}
setImage(ImageSource.inputStream(openStream!!))
}
} else {
initImageView().setImage(openStream!!)
}