android, desktop: fix showing big gifs (opens in viewer) (#5660)

This commit is contained in:
Stanislav Dmitrenko 2025-02-24 16:28:46 +07:00 committed by GitHub
parent 4f00f9efa0
commit b96b6c70d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ import androidx.compose.material.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.*
import androidx.compose.ui.graphics.painter.Painter
import androidx.compose.ui.layout.ContentScale
@ -122,7 +123,7 @@ fun CIImageView(
// IllegalStateException: Recording currently in progress - missing #endRecording() call?
// but can display 5000px image. Using even lower value here just to feel safer.
// It happens to WebP because it's not compressed while sending since it can be animated.
if (painter.intrinsicSize.width <= 4320 && painter.intrinsicSize.height <= 4320) {
if (painter.intrinsicSize != Size.Unspecified && painter.intrinsicSize.width <= 4320 && painter.intrinsicSize.height <= 4320) {
Image(
painter,
contentDescription = stringResource(MR.strings.image_descr),
@ -140,7 +141,7 @@ fun CIImageView(
)
} else {
Box(Modifier
.width(if (painter.intrinsicSize.width * 0.97 <= painter.intrinsicSize.height) imageViewFullWidth() * 0.75f else DEFAULT_MAX_IMAGE_WIDTH)
.width(if (painter.intrinsicSize != Size.Unspecified && painter.intrinsicSize.width * 0.97 <= painter.intrinsicSize.height) imageViewFullWidth() * 0.75f else DEFAULT_MAX_IMAGE_WIDTH)
.combinedClickable(
onLongClick = { showMenu.value = true },
onClick = {}