Код: Выделить всё
val activity = LocalActivity.current!!
AndroidView(modifier = Modifier
.background(colorResource(R.color.white), RoundedCornerShape(10))
.padding(16.dp),
factory = {
WebView(it)
// The code that seems to have no effect is from here...
.apply {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
settings.setAlgorithmicDarkeningAllowed(true)
} else if (WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK)) {
when (activity.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) {
Configuration.UI_MODE_NIGHT_YES -> {
WebSettingsCompat.setForceDark(settings, FORCE_DARK_ON)
}
Configuration.UI_MODE_NIGHT_NO, Configuration.UI_MODE_NIGHT_UNDEFINED -> {
WebSettingsCompat.setForceDark(settings, FORCE_DARK_OFF)
}
else -> {
//
}
}
}
}
// ...until here.
}, update = {
val reader = activity.resources.openRawResource(R.raw.about).reader()
val unencodedHtml = reader.readText()
reader.close()
val encodedHtml: String =
Base64.encodeToString(unencodedHtml.toByteArray(), Base64.NO_PADDING)
it.loadData(encodedHtml, "text/html", "base64")
})
Подробнее здесь: https://stackoverflow.com/questions/794 ... xel-colors