Merge branch 'feature/32-bit' into devel
This commit is contained in:
@@ -132,7 +132,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'io.coil-kt:coil-base:2.4.0'
|
implementation 'io.coil-kt:coil-base:2.4.0'
|
||||||
implementation 'io.coil-kt:coil-svg:2.4.0'
|
implementation 'io.coil-kt:coil-svg:2.4.0'
|
||||||
implementation 'com.github.KotatsuApp:subsampling-scale-image-view:169806d928'
|
implementation 'com.github.KotatsuApp:subsampling-scale-image-view:cf089a264d'
|
||||||
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
implementation 'com.github.solkin:disk-lru-cache:1.4'
|
||||||
implementation 'io.noties.markwon:core:4.6.2'
|
implementation 'io.noties.markwon:core:4.6.2'
|
||||||
|
|
||||||
|
|||||||
@@ -336,6 +336,9 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
|
|||||||
return policy.isNetworkAllowed(connectivityManager)
|
return policy.isNetworkAllowed(connectivityManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val is32BitColorsEnabled: Boolean
|
||||||
|
get() = prefs.getBoolean(KEY_32BIT_COLOR, false)
|
||||||
|
|
||||||
fun isTipEnabled(tip: String): Boolean {
|
fun isTipEnabled(tip: String): Boolean {
|
||||||
return prefs.getStringSet(KEY_TIPS_CLOSED, emptySet())?.contains(tip) != true
|
return prefs.getStringSet(KEY_TIPS_CLOSED, emptySet())?.contains(tip) != true
|
||||||
}
|
}
|
||||||
@@ -491,6 +494,7 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
|
|||||||
const val KEY_DISABLE_NSFW = "no_nsfw"
|
const val KEY_DISABLE_NSFW = "no_nsfw"
|
||||||
const val KEY_RELATED_MANGA = "related_manga"
|
const val KEY_RELATED_MANGA = "related_manga"
|
||||||
const val KEY_NAV_MAIN = "nav_main"
|
const val KEY_NAV_MAIN = "nav_main"
|
||||||
|
const val KEY_32BIT_COLOR = "enhanced_colors"
|
||||||
|
|
||||||
// About
|
// About
|
||||||
const val KEY_APP_UPDATE = "app_update"
|
const val KEY_APP_UPDATE = "app_update"
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
package org.koitharu.kotatsu.reader.ui.config
|
package org.koitharu.kotatsu.reader.ui.config
|
||||||
|
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
|
import android.graphics.Bitmap
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.annotation.CheckResult
|
||||||
import androidx.lifecycle.MediatorLiveData
|
import androidx.lifecycle.MediatorLiveData
|
||||||
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
|
import com.davemorrissey.labs.subscaleview.decoder.SkiaImageDecoder
|
||||||
|
import com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder
|
||||||
|
import com.davemorrissey.labs.subscaleview.decoder.SkiaPooledImageRegionDecoder
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
@@ -12,6 +18,7 @@ import kotlinx.coroutines.launch
|
|||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.koitharu.kotatsu.core.model.ZoomMode
|
import org.koitharu.kotatsu.core.model.ZoomMode
|
||||||
import org.koitharu.kotatsu.core.prefs.AppSettings
|
import org.koitharu.kotatsu.core.prefs.AppSettings
|
||||||
|
import org.koitharu.kotatsu.core.util.ext.isLowRamDevice
|
||||||
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
|
import org.koitharu.kotatsu.reader.domain.ReaderColorFilter
|
||||||
|
|
||||||
class ReaderSettings(
|
class ReaderSettings(
|
||||||
@@ -29,6 +36,13 @@ class ReaderSettings(
|
|||||||
val colorFilter: ReaderColorFilter?
|
val colorFilter: ReaderColorFilter?
|
||||||
get() = colorFilterFlow.value?.takeUnless { it.isEmpty }
|
get() = colorFilterFlow.value?.takeUnless { it.isEmpty }
|
||||||
|
|
||||||
|
val bitmapConfig: Bitmap.Config
|
||||||
|
get() = if (settings.is32BitColorsEnabled) {
|
||||||
|
Bitmap.Config.ARGB_8888
|
||||||
|
} else {
|
||||||
|
Bitmap.Config.RGB_565
|
||||||
|
}
|
||||||
|
|
||||||
val isPagesNumbersEnabled: Boolean
|
val isPagesNumbersEnabled: Boolean
|
||||||
get() = settings.isPagesNumbersEnabled
|
get() = settings.isPagesNumbersEnabled
|
||||||
|
|
||||||
@@ -40,6 +54,22 @@ class ReaderSettings(
|
|||||||
view.background = bg.resolve(view.context)
|
view.background = bg.resolve(view.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CheckResult
|
||||||
|
fun applyBitmapConfig(ssiv: SubsamplingScaleImageView): Boolean {
|
||||||
|
val config = bitmapConfig
|
||||||
|
return if (ssiv.regionDecoderFactory.bitmapConfig != config) {
|
||||||
|
ssiv.regionDecoderFactory = if (ssiv.context.isLowRamDevice()) {
|
||||||
|
SkiaImageRegionDecoder.Factory(config)
|
||||||
|
} else {
|
||||||
|
SkiaPooledImageRegionDecoder.Factory(config)
|
||||||
|
}
|
||||||
|
ssiv.bitmapDecoderFactory = SkiaImageDecoder.Factory(config)
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onInactive() {
|
override fun onInactive() {
|
||||||
super.onInactive()
|
super.onInactive()
|
||||||
settings.unsubscribe(internalObserver)
|
settings.unsubscribe(internalObserver)
|
||||||
@@ -78,7 +108,8 @@ class ReaderSettings(
|
|||||||
key == AppSettings.KEY_PAGES_NUMBERS ||
|
key == AppSettings.KEY_PAGES_NUMBERS ||
|
||||||
key == AppSettings.KEY_WEBTOON_ZOOM ||
|
key == AppSettings.KEY_WEBTOON_ZOOM ||
|
||||||
key == AppSettings.KEY_READER_ZOOM_BUTTONS ||
|
key == AppSettings.KEY_READER_ZOOM_BUTTONS ||
|
||||||
key == AppSettings.KEY_READER_BACKGROUND
|
key == AppSettings.KEY_READER_BACKGROUND ||
|
||||||
|
key == AppSettings.KEY_32BIT_COLOR
|
||||||
) {
|
) {
|
||||||
notifyChanged()
|
notifyChanged()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,14 @@ class PageHolderDelegate(
|
|||||||
job?.cancel()
|
job?.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun reload() {
|
||||||
|
if (state == State.SHOWN ) {
|
||||||
|
file?.let {
|
||||||
|
callback.onImageReady(it.toUri())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onReady() {
|
override fun onReady() {
|
||||||
state = State.SHOWING
|
state = State.SHOWING
|
||||||
error = null
|
error = null
|
||||||
|
|||||||
@@ -46,6 +46,10 @@ open class PageHolder(
|
|||||||
override fun onConfigChanged() {
|
override fun onConfigChanged() {
|
||||||
super.onConfigChanged()
|
super.onConfigChanged()
|
||||||
binding.zoomControl.isVisible = settings.isZoomControlsEnabled
|
binding.zoomControl.isVisible = settings.isZoomControlsEnabled
|
||||||
|
@Suppress("SENSELESS_COMPARISON")
|
||||||
|
if (settings.applyBitmapConfig(binding.ssiv) && delegate != null) {
|
||||||
|
delegate.reload()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import androidx.core.view.isVisible
|
|||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||||
import com.davemorrissey.labs.subscaleview.decoder.SkiaPooledImageRegionDecoder
|
|
||||||
import org.koitharu.kotatsu.R
|
import org.koitharu.kotatsu.R
|
||||||
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||||
import org.koitharu.kotatsu.core.os.NetworkState
|
import org.koitharu.kotatsu.core.os.NetworkState
|
||||||
@@ -34,12 +33,19 @@ class WebtoonHolder(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
binding.ssiv.bindToLifecycle(owner)
|
binding.ssiv.bindToLifecycle(owner)
|
||||||
binding.ssiv.regionDecoderFactory = SkiaPooledImageRegionDecoder.Factory()
|
|
||||||
binding.ssiv.addOnImageEventListener(delegate)
|
binding.ssiv.addOnImageEventListener(delegate)
|
||||||
bindingInfo.buttonRetry.setOnClickListener(this)
|
bindingInfo.buttonRetry.setOnClickListener(this)
|
||||||
bindingInfo.buttonErrorDetails.setOnClickListener(this)
|
bindingInfo.buttonErrorDetails.setOnClickListener(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onConfigChanged() {
|
||||||
|
super.onConfigChanged()
|
||||||
|
@Suppress("SENSELESS_COMPARISON")
|
||||||
|
if (settings.applyBitmapConfig(binding.ssiv) && delegate != null) {
|
||||||
|
delegate.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBind(data: ReaderPage) {
|
override fun onBind(data: ReaderPage) {
|
||||||
delegate.onBind(data.toMangaPage())
|
delegate.onBind(data.toMangaPage())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -492,4 +492,6 @@
|
|||||||
<string name="keep_screen_on">Keep screen on</string>
|
<string name="keep_screen_on">Keep screen on</string>
|
||||||
<string name="keep_screen_on_summary">Do not turn the screen off while you\'re reading manga</string>
|
<string name="keep_screen_on_summary">Do not turn the screen off while you\'re reading manga</string>
|
||||||
<string name="state_abandoned">Dropped</string>
|
<string name="state_abandoned">Dropped</string>
|
||||||
|
<string name="enhanced_colors_summary">Reduces banding, but may impact performance</string>
|
||||||
|
<string name="enhanced_colors">32-bit color mode</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -54,6 +54,12 @@
|
|||||||
android:title="@string/pages_animation"
|
android:title="@string/pages_animation"
|
||||||
app:useSimpleSummaryProvider="true" />
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="enhanced_colors"
|
||||||
|
android:summary="@string/enhanced_colors_summary"
|
||||||
|
android:title="@string/enhanced_colors" />
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="reader_bar"
|
android:key="reader_bar"
|
||||||
|
|||||||
Reference in New Issue
Block a user