mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
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:
@@ -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() })
|
||||
|
||||
|
||||
@@ -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!!)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user