Show captured JPEG file size and enlarge camera metadata text

This commit is contained in:
evgeny committed 2026-10-28 12:08:07 +01:00
1 parent 07c9cf223c
commit a53668ade8
1 file changed
+18 -8
@@ -5,6 +5,7 @@ import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.media.MediaExtractor
import android.media.MediaFormat
import android.text.format.Formatter
import android.util.Size
import androidx.activity.compose.BackHandler
import androidx.activity.compose.rememberLauncherForActivityResult
@@ -467,9 +468,12 @@ fun CameraRecordScreen(initialMode: CaptureMode, onSend: (String, CaptureMode) -
}
Column(Modifier.fillMaxWidth().background(MaterialTheme.colorScheme.surface).padding(horizontal = 16.dp, vertical = 12.dp),
horizontalAlignment = Alignment.CenterHorizontally) {
val info = if (mode == CaptureMode.VIDEO)
"${elapsed / 60_000}:${(elapsed / 1000 % 60).toString().padStart(2, '0')}\n${quality.label}"
else if (photoSize.first > 0) "${photoSize.first}×${photoSize.second}" else ""
val photoBytes = remember(mode, phase, output) {
if (mode == CaptureMode.PHOTO && phase == CapturePhase.CAPTURED) output?.length() ?: 0L else 0L
}
val info = if (mode == CaptureMode.VIDEO) quality.label
else if (phase == CapturePhase.CAPTURED && photoSize.first > 0)
"${photoSize.first}×${photoSize.second}\n${Formatter.formatShortFileSize(context, photoBytes)}" else ""
BoxWithConstraints(Modifier.fillMaxWidth().heightIn(min = 76.dp)) {
val captureEnabled = camera != null && (idle || phase == CapturePhase.RECORDING || phase == CapturePhase.PAUSED)
val showDiscard = output != null && phase != CapturePhase.SENDING
@@ -479,9 +483,9 @@ fun CameraRecordScreen(initialMode: CaptureMode, onSend: (String, CaptureMode) -
val shutterWidth = if (captureEnabled) shutterSize else shutterSize / 2
val controlsWidth = 48.dp * 2 + 24.dp * 2 + shutterWidth
val infoWidth = ((maxWidth - controlsWidth) / 2 - 8.dp).coerceIn(0.dp, 80.dp)
LaunchedEffect(phase, captureEnabled, showDiscard, showSend, infoWidth) {
LaunchedEffect(phase, captureEnabled, showDiscard, showSend, photoBytes, infoWidth) {
LogManager.addLog("DEBUG", "Capture", "Controls phase=$phase panel=$maxWidth shutterVisible=$captureEnabled " +
"discardVisible=$showDiscard sendVisible=$showSend centerSlot=$shutterWidth infoMaxWidth=$infoWidth")
"discardVisible=$showDiscard sendVisible=$showSend centerSlot=$shutterWidth jpegBytes=$photoBytes infoMaxWidth=$infoWidth")
}
Row(Modifier.align(Alignment.Center).heightIn(min = shutterSize), verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(24.dp)) {
@@ -508,9 +512,15 @@ fun CameraRecordScreen(initialMode: CaptureMode, onSend: (String, CaptureMode) -
Icon(Icons.AutoMirrored.Filled.Send, stringResource(R.string.send), tint = MaterialTheme.colorScheme.onSurface)
} else Spacer(Modifier.width(48.dp))
}
if (info.isNotEmpty()) Text(info, color = MaterialTheme.colorScheme.onSurfaceVariant,
fontSize = 11.sp, lineHeight = 13.sp, maxLines = 2, textAlign = TextAlign.End,
modifier = Modifier.align(Alignment.CenterEnd).widthIn(max = infoWidth))
if (info.isNotEmpty()) Column(Modifier.align(Alignment.CenterEnd).widthIn(max = infoWidth),
horizontalAlignment = Alignment.End) {
if (mode == CaptureMode.VIDEO) Text(
"${elapsed / 60_000}:${(elapsed / 1000 % 60).toString().padStart(2, '0')}",
color = MaterialTheme.colorScheme.onSurfaceVariant, fontSize = 11.sp, lineHeight = 13.sp,
maxLines = 1, textAlign = TextAlign.End)
Text(info, color = MaterialTheme.colorScheme.onSurfaceVariant,
fontSize = 13.sp, lineHeight = 15.sp, maxLines = 2, textAlign = TextAlign.End)
}
}
if (phase == CapturePhase.CAPTURING || phase == CapturePhase.FINALIZING) CircularProgressIndicator(Modifier.size(24.dp))
}