diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt index 94bc845d8..89f53bc39 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsAdvancedScreen.kt @@ -332,21 +332,26 @@ object SettingsAdvancedScreen : SearchableSettings { basePreferences.displayProfile().set(uri.toString()) } } - val hardwareBitmapThresholdPref = basePreferences.hardwareBitmapThreshold() - val hardwareBitmapThreshold by hardwareBitmapThresholdPref.collectAsState() return Preference.PreferenceGroup( title = stringResource(MR.strings.pref_category_reader), preferenceItems = persistentListOf( Preference.PreferenceItem.ListPreference( - pref = hardwareBitmapThresholdPref, + pref = basePreferences.hardwareBitmapThreshold(), title = stringResource(MR.strings.pref_hardware_bitmap_threshold), - subtitle = stringResource( - MR.strings.pref_hardware_bitmap_threshold_summary, - hardwareBitmapThreshold, - ), + subtitleProvider = { value, options -> + stringResource(MR.strings.pref_hardware_bitmap_threshold_summary, options[value].orEmpty()) + }, enabled = GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT, entries = GLUtil.CUSTOM_TEXTURE_LIMIT_OPTIONS - .associateWith { it.toString() } + .mapIndexed { index, option -> + val display = if (index == 0) { + stringResource(MR.strings.pref_hardware_bitmap_threshold_default, option) + } else { + option.toString() + } + option to display + } + .toMap() .toImmutableMap(), ), Preference.PreferenceItem.TextPreference( diff --git a/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/GLUtil.kt b/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/GLUtil.kt index 16f3203fb..f78932a68 100644 --- a/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/GLUtil.kt +++ b/core/common/src/main/kotlin/eu/kanade/tachiyomi/util/system/GLUtil.kt @@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.util.system import javax.microedition.khronos.egl.EGL10 import javax.microedition.khronos.egl.EGLConfig import javax.microedition.khronos.egl.EGLContext +import kotlin.math.max object GLUtil { val DEVICE_TEXTURE_LIMIT: Int by lazy { @@ -38,18 +39,21 @@ object GLUtil { egl.eglTerminate(display) // Return largest texture size found (after making it a multiplier of [Multiplier]), or default - if (maximumTextureSize > SAFE_TEXTURE_LIMIT) { - (maximumTextureSize / MULTIPLIER) * MULTIPLIER - } else { - SAFE_TEXTURE_LIMIT - } + max(maximumTextureSize, SAFE_TEXTURE_LIMIT) } const val SAFE_TEXTURE_LIMIT: Int = 2048 val CUSTOM_TEXTURE_LIMIT_OPTIONS: List by lazy { - val steps = ((DEVICE_TEXTURE_LIMIT / MULTIPLIER) - 1) - List(steps) { (it + 2) * MULTIPLIER }.asReversed() + val steps = DEVICE_TEXTURE_LIMIT / MULTIPLIER + buildList(steps) { + add(DEVICE_TEXTURE_LIMIT) + for (step in steps downTo 2) { + val value = step * MULTIPLIER + if (value >= DEVICE_TEXTURE_LIMIT) continue + add(value) + } + } } } diff --git a/i18n/src/commonMain/moko-resources/base/strings.xml b/i18n/src/commonMain/moko-resources/base/strings.xml index 78cc63fdd..a07f533da 100644 --- a/i18n/src/commonMain/moko-resources/base/strings.xml +++ b/i18n/src/commonMain/moko-resources/base/strings.xml @@ -393,6 +393,7 @@ Briefly show current mode when reader is opened Custom display profile Custom hardware bitmap threshold + Default (%d) If reader loads a blank image incrementally reduce the threshold.\nSelected: %s Crop borders Custom brightness diff --git a/presentation-core/src/main/java/mihon/presentation/core/util/PagingDataUtil.kt b/presentation-core/src/main/java/mihon/presentation/core/util/PagingDataUtil.kt index 2ca50f9b7..a48acae50 100644 --- a/presentation-core/src/main/java/mihon/presentation/core/util/PagingDataUtil.kt +++ b/presentation-core/src/main/java/mihon/presentation/core/util/PagingDataUtil.kt @@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.StateFlow @Composable -fun StateFlow>>.collectAsLazyPagingItems(): LazyPagingItems { +fun StateFlow>>.collectAsLazyPagingItems(): LazyPagingItems { val flow by collectAsState() return flow.collectAsLazyPagingItems() }