Hide Hardware Bitmap Threshold setting if unusable

This hides the setting from the UI if the user's device in on Coil's
list of devices with problematic hardware bitmap implementations.

Also moved HARDWARE_BITMAP_UNSUPPORTED into the ImageUtil as a
property for more ergonomic access across the project.
This commit is contained in:
MajorTanya 2024-12-05 16:45:56 +01:00
parent 533b2d0b26
commit 27099b77d3
No known key found for this signature in database
GPG Key ID: 5F5A422B2B40CAA1
2 changed files with 118 additions and 116 deletions

View File

@ -62,6 +62,7 @@ import logcat.LogPriority
import okhttp3.Headers
import tachiyomi.core.common.util.lang.launchNonCancellable
import tachiyomi.core.common.util.lang.withUIContext
import tachiyomi.core.common.util.system.ImageUtil
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.manga.interactor.ResetViewerFlags
import tachiyomi.i18n.MR
@ -341,7 +342,8 @@ object SettingsAdvancedScreen : SearchableSettings {
subtitleProvider = { value, options ->
stringResource(MR.strings.pref_hardware_bitmap_threshold_summary, options[value].orEmpty())
},
enabled = GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT,
enabled = ImageUtil.HARDWARE_BITMAP_UNSUPPORTED ||
GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT,
entries = GLUtil.CUSTOM_TEXTURE_LIMIT_OPTIONS
.mapIndexed { index, option ->
val display = if (index == 0) {

View File

@ -573,12 +573,8 @@ object ImageUtil {
}
private val optimalImageHeight = getDisplayMaxHeightInPx * 2
}
val getDisplayMaxHeightInPx: Int
get() = Resources.getSystem().displayMetrics.let { max(it.heightPixels, it.widthPixels) }
/**
/**
* Taken from Coil
* (https://github.com/coil-kt/coil/blob/1674d3516f061aeacbe749a435b1924f9648fd41/coil-core/src/androidMain/kotlin/coil3/util/hardwareBitmaps.kt)
* ---
@ -588,7 +584,7 @@ val getDisplayMaxHeightInPx: Int
* [Google's official device list](https://support.google.com/googleplay/answer/1727131?hl=en).
*
*/
private val HARDWARE_BITMAP_UNSUPPORTED = when (Build.VERSION.SDK_INT) {
val HARDWARE_BITMAP_UNSUPPORTED = when (Build.VERSION.SDK_INT) {
26 -> run {
val model = Build.MODEL ?: return@run false
@ -691,4 +687,8 @@ private val HARDWARE_BITMAP_UNSUPPORTED = when (Build.VERSION.SDK_INT) {
}
else -> false
}
}
val getDisplayMaxHeightInPx: Int
get() = Resources.getSystem().displayMetrics.let { max(it.heightPixels, it.widthPixels) }