From 09a2ebcc613e8284db535655cd9ad3ae1ce23ceb Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Sat, 11 Oct 2025 10:10:19 +0800 Subject: [PATCH] Workaround crash when 0-sized TextField is focused It only affects API < 28 https://developer.android.com/about/versions/pie/android-9.0-changes-28#focus --- .../com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt index 977a1191a..54971af36 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/GalleryCommentsScreen.kt @@ -11,6 +11,7 @@ import android.text.style.URLSpan import androidx.annotation.ColorInt import androidx.compose.animation.AnimatedVisibilityScope import androidx.compose.animation.Crossfade +import androidx.compose.foundation.focusable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -25,6 +26,7 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.navigationBarsPadding import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState @@ -89,6 +91,7 @@ import com.ehviewer.core.model.GalleryComment import com.ehviewer.core.ui.util.animateFloatMergePredictiveBackAsState import com.ehviewer.core.ui.util.snackBarPadding import com.ehviewer.core.ui.util.thenIf +import com.ehviewer.core.util.isAtLeastP import com.ehviewer.core.util.launch import com.ehviewer.core.util.launchIO import com.ehviewer.core.util.logcat @@ -455,6 +458,11 @@ fun AnimatedVisibilityScope.GalleryCommentsScreen(gid: Long, navigator: Destinat } } } + if (!isAtLeastP) { + // Workaround for crash when 0-sized TextField is focused + // https://issuetracker.google.com/440964236 + Box(Modifier.size(1.dp).focusable()) + } Surface( modifier = Modifier.align(Alignment.BottomCenter).layout { measurable, constraints -> val origin = measurable.measure(constraints)