diff --git a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt index bb1acbaa..8cd0c160 100644 --- a/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt +++ b/tools/chatgui-android/app/src/main/java/com/utun/chat/ui/components/MessageBubble.kt @@ -454,10 +454,22 @@ private fun ImageBubble(message: Message, textColor: Color, var bmp by remember(message.filePath) { mutableStateOf(null) } + LaunchedEffect(message.id, message.filePath, message.downloadState) { + LogManager.addLog("DEBUG", "Image", "Preview state id=${message.id} state=${message.downloadState} " + + "local=$downloaded downloadControl=${!downloaded}") + } LaunchedEffect(message.filePath) { if (message.filePath.isNotEmpty()) { bmp = withContext(Dispatchers.IO) { - try { PhotoUtil.decodeOriented(message.filePath, 2) } catch (_: Exception) { null } + try { + val image = PhotoUtil.decodeOriented(message.filePath, 2) + if (image == null) LogManager.addLog("WARN", "Image", "Preview decode failed id=${message.id} path=${message.filePath}") + else LogManager.addLog("DEBUG", "Image", "Preview ready id=${message.id} size=${image.width}x${image.height}") + image + } catch (e: Exception) { + LogManager.addLog("WARN", "Image", "Preview decode failed id=${message.id} path=${message.filePath}: ${e.message}") + null + } } } } @@ -480,10 +492,10 @@ private fun ImageBubble(message: Message, textColor: Color, .background(Color(0xFF1E1E23)) ) { bmp?.let { Image(it.asImageBitmap(), contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize()) } - Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { + if (!downloaded) Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) { Box(modifier = Modifier.size(44.dp).background(Color(0xCC000000), CircleShape), contentAlignment = Alignment.Center) { Text( - when { downloading -> "\u23F3"; isError -> "\u267B"; !downloaded -> "\u2B07"; else -> "" }, + when { downloading -> "\u23F3"; isError -> "\u267B"; else -> "\u2B07" }, fontSize = 18.sp, color = Color.White ) }