32-bit colors mode implementing
This commit is contained in:
@@ -336,6 +336,9 @@ class AppSettings @Inject constructor(@ApplicationContext context: Context) {
|
||||
return policy.isNetworkAllowed(connectivityManager)
|
||||
}
|
||||
|
||||
val enhancedColors: Boolean
|
||||
get() = prefs.getBoolean(KEY_32BIT_COLOR, false)
|
||||
|
||||
fun isTipEnabled(tip: String): Boolean {
|
||||
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_RELATED_MANGA = "related_manga"
|
||||
const val KEY_NAV_MAIN = "nav_main"
|
||||
const val KEY_32BIT_COLOR = "enhanced_colors"
|
||||
|
||||
// About
|
||||
const val KEY_APP_UPDATE = "app_update"
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package org.koitharu.kotatsu.reader.ui.config
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Bitmap
|
||||
import android.view.View
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.Companion.preferredBitmapConfig
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
@@ -29,6 +32,9 @@ class ReaderSettings(
|
||||
val colorFilter: ReaderColorFilter?
|
||||
get() = colorFilterFlow.value?.takeUnless { it.isEmpty }
|
||||
|
||||
val enhancedColors: Boolean
|
||||
get() = settings.enhancedColors
|
||||
|
||||
val isPagesNumbersEnabled: Boolean
|
||||
get() = settings.isPagesNumbersEnabled
|
||||
|
||||
@@ -40,6 +46,15 @@ class ReaderSettings(
|
||||
view.background = bg.resolve(view.context)
|
||||
}
|
||||
|
||||
fun enhancedColorsMode() {
|
||||
val modeEnabled = settings.enhancedColors
|
||||
preferredBitmapConfig = if (modeEnabled) {
|
||||
Bitmap.Config.ARGB_8888
|
||||
} else {
|
||||
Bitmap.Config.RGB_565
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInactive() {
|
||||
super.onInactive()
|
||||
settings.unsubscribe(internalObserver)
|
||||
@@ -78,7 +93,8 @@ class ReaderSettings(
|
||||
key == AppSettings.KEY_PAGES_NUMBERS ||
|
||||
key == AppSettings.KEY_WEBTOON_ZOOM ||
|
||||
key == AppSettings.KEY_READER_ZOOM_BUTTONS ||
|
||||
key == AppSettings.KEY_READER_BACKGROUND
|
||||
key == AppSettings.KEY_READER_BACKGROUND ||
|
||||
key == AppSettings.KEY_32BIT_COLOR
|
||||
) {
|
||||
notifyChanged()
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import android.annotation.SuppressLint
|
||||
import android.graphics.PointF
|
||||
import android.net.Uri
|
||||
import android.view.View
|
||||
import androidx.core.view.drawToBitmap
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.davemorrissey.labs.subscaleview.ImageSource
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.Companion.preferredBitmapConfig
|
||||
import org.koitharu.kotatsu.R
|
||||
import org.koitharu.kotatsu.core.exceptions.resolve.ExceptionResolver
|
||||
import org.koitharu.kotatsu.core.model.ZoomMode
|
||||
@@ -84,6 +86,7 @@ open class PageHolder(
|
||||
binding.ssiv.height / binding.ssiv.sHeight.toFloat(),
|
||||
)
|
||||
binding.ssiv.colorFilter = settings.colorFilter?.toColorFilter()
|
||||
settings.enhancedColorsMode()
|
||||
when (settings.zoomMode) {
|
||||
ZoomMode.FIT_CENTER -> {
|
||||
binding.ssiv.minimumScaleType = SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE
|
||||
|
||||
@@ -492,4 +492,6 @@
|
||||
<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="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>
|
||||
|
||||
@@ -54,6 +54,12 @@
|
||||
android:title="@string/pages_animation"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
android:key="enhanced_colors"
|
||||
android:summary="@string/enhanced_colors_summary"
|
||||
android:title="@string/enhanced_colors" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="true"
|
||||
android:key="reader_bar"
|
||||
|
||||
Reference in New Issue
Block a user