|
|
|
@ -454,10 +454,22 @@ private fun ImageBubble(message: Message, textColor: Color, |
|
|
|
|
|
|
|
|
|
|
|
var bmp by remember(message.filePath) { mutableStateOf<Bitmap?>(null) } |
|
|
|
var bmp by remember(message.filePath) { mutableStateOf<Bitmap?>(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) { |
|
|
|
LaunchedEffect(message.filePath) { |
|
|
|
if (message.filePath.isNotEmpty()) { |
|
|
|
if (message.filePath.isNotEmpty()) { |
|
|
|
bmp = withContext(Dispatchers.IO) { |
|
|
|
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)) |
|
|
|
.background(Color(0xFF1E1E23)) |
|
|
|
) { |
|
|
|
) { |
|
|
|
bmp?.let { Image(it.asImageBitmap(), contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize()) } |
|
|
|
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) { |
|
|
|
Box(modifier = Modifier.size(44.dp).background(Color(0xCC000000), CircleShape), contentAlignment = Alignment.Center) { |
|
|
|
Text( |
|
|
|
Text( |
|
|
|
when { downloading -> "\u23F3"; isError -> "\u267B"; !downloaded -> "\u2B07"; else -> "" }, |
|
|
|
when { downloading -> "\u23F3"; isError -> "\u267B"; else -> "\u2B07" }, |
|
|
|
fontSize = 18.sp, color = Color.White |
|
|
|
fontSize = 18.sp, color = Color.White |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|