fix(android): clear the two lint errors that failed the Android build

The banner height came from Configuration.screenHeightDp, which lint now
rejects in favour of LocalWindowInfo's container size; the four phone
library screenshots move by a pixel with it. The mood colour scaled its
picture with Bitmap.createScaledBitmap where lint asks for the KTX
Bitmap.scale.
This commit is contained in:
nvrl committed 2026-10-31 03:42:32 +01:00
1 parent 3fe4900337
commit fe69d2fae4
6 files changed
+5 -3

No files matched your search

@@ -17,7 +17,7 @@ import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.graphics.lerp import androidx.compose.ui.graphics.lerp
import androidx.compose.ui.graphics.luminance import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.layout.layout import androidx.compose.ui.layout.layout
import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.platform.LocalWindowInfo
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.semantics.selected import androidx.compose.ui.semantics.selected
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
@@ -861,7 +861,8 @@ private fun FeaturedBanner(
} }
// Most of a phone's first screen, but never so much of a tablet's that // Most of a phone's first screen, but never so much of a tablet's that
// nothing under it shows. // nothing under it shows.
val height = (LocalConfiguration.current.screenHeightDp * 0.62f).dp.coerceIn(360.dp, 620.dp) val screenHeight = with(LocalDensity.current) { LocalWindowInfo.current.containerSize.height.toDp() }
val height = (screenHeight * 0.62f).coerceIn(360.dp, 620.dp)
Box(modifier.fillMaxWidth().height(height)) { Box(modifier.fillMaxWidth().height(height)) {
HorizontalPager(pager, Modifier.fillMaxSize(), key = { titles[it].key }) { page -> HorizontalPager(pager, Modifier.fillMaxSize(), key = { titles[it].key }) { page ->
val title = titles[page] val title = titles[page]
@@ -43,6 +43,7 @@ import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.core.graphics.scale
import io.narl.protonstream.native.NativeRuntime import io.narl.protonstream.native.NativeRuntime
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
@@ -181,7 +182,7 @@ private suspend fun moodOf(key: String, bitmap: Bitmap): Color? {
moods.get(key)?.let { return Color(it) } moods.get(key)?.let { return Color(it) }
val argb = withContext(Dispatchers.Default) { val argb = withContext(Dispatchers.Default) {
runCatching { runCatching {
val small = Bitmap.createScaledBitmap(bitmap, MOOD_EDGE, MOOD_EDGE, true) val small = bitmap.scale(MOOD_EDGE, MOOD_EDGE)
val pixels = IntArray(MOOD_EDGE * MOOD_EDGE) val pixels = IntArray(MOOD_EDGE * MOOD_EDGE)
small.getPixels(pixels, 0, MOOD_EDGE, 0, 0, MOOD_EDGE, MOOD_EDGE) small.getPixels(pixels, 0, MOOD_EDGE, 0, 0, MOOD_EDGE, MOOD_EDGE)
sharedPictureMood(pixels.map(Int::toUInt))?.toInt() sharedPictureMood(pixels.map(Int::toUInt))?.toInt()
Binary file not shown.

Before

Width:  |  Height:  |  Size: 868 KiB

After

Width:  |  Height:  |  Size: 867 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 827 KiB

After

Width:  |  Height:  |  Size: 828 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 783 KiB

After

Width:  |  Height:  |  Size: 782 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 888 KiB

After

Width:  |  Height:  |  Size: 888 KiB