Verify screen: per-file checkboxes for delete + preview dialog
VerifyScreen redesigned as review-before-delete: - All imported files shown with status icons (green/yellow/red) - Checkboxes appear when deleteAfterVerify is on - Pre-checked: EXIF-verified files (safe to delete) - Pre-unchecked: EXIF-unverified files (kept on phone by default) - Failed copies: no checkbox (excluded from deletion entirely) - Uncheck any file to protect it from deletion - 'Delete N files' button → confirmation card - Confirmation shows count of excluded unverified files - Click any row → PreviewDialog with full image + EXIF status AppState: add deleteSpecificFromDevice(devicePaths) to delete exactly the set of paths the user confirmed on the verify screen.
This commit is contained in:
@@ -426,16 +426,24 @@ class AppState(private val configStore: ConfigStore) {
|
|||||||
// Post-import deletion
|
// Post-import deletion
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
fun deleteVerifiedFromDevice() {
|
fun deleteVerifiedFromDevice() {
|
||||||
|
deleteSpecificFromDevice(
|
||||||
|
_importResult.value?.results
|
||||||
|
?.filter { it.verified && it.exifVerified != false }
|
||||||
|
?.map { it.photo.devicePath }
|
||||||
|
?.toSet() ?: emptySet()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteSpecificFromDevice(devicePaths: Set<String>) {
|
||||||
val device = _selectedDevice.value ?: return
|
val device = _selectedDevice.value ?: return
|
||||||
val result = _importResult.value ?: return
|
val result = _importResult.value ?: return
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
val connector = connectorFor(device)
|
val connector = connectorFor(device)
|
||||||
result.results
|
result.results
|
||||||
.filter { it.verified && it.exifVerified != false } // skip exifVerified=false
|
.filter { it.photo.devicePath in devicePaths }
|
||||||
.forEach { r ->
|
.forEach { r ->
|
||||||
try {
|
try {
|
||||||
connector.deletePhoto(device, r.photo)
|
connector.deletePhoto(device, r.photo)
|
||||||
// Also delete companion MOV if this was a Live Photo still
|
|
||||||
if (r.photo.isLivePhotoStill && r.photo.companionDevicePath != null) {
|
if (r.photo.isLivePhotoStill && r.photo.companionDevicePath != null) {
|
||||||
val companion = r.photo.copy(
|
val companion = r.photo.copy(
|
||||||
devicePath = r.photo.companionDevicePath,
|
devicePath = r.photo.companionDevicePath,
|
||||||
@@ -443,7 +451,7 @@ class AppState(private val configStore: ConfigStore) {
|
|||||||
)
|
)
|
||||||
try { connector.deletePhoto(device, companion) }
|
try { connector.deletePhoto(device, companion) }
|
||||||
catch (e: DeviceException) {
|
catch (e: DeviceException) {
|
||||||
log.warn("Could not delete companion for ${r.photo.filename}: ${e.message}")
|
log.warn("Companion delete failed for ${r.photo.filename}: ${e.message}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: DeviceException) {
|
} catch (e: DeviceException) {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package com.bolenpad.photophetch.ui
|
package com.bolenpad.photophetch.ui
|
||||||
|
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.clickable
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.CheckCircle
|
import androidx.compose.material.icons.filled.CheckCircle
|
||||||
import androidx.compose.material.icons.filled.Error
|
import androidx.compose.material.icons.filled.Error
|
||||||
@@ -30,7 +31,7 @@ import org.jetbrains.skia.Image as SkiaImage
|
|||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shown during active import (IMPORTING screen).
|
* Progress screen shown during active import.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun ImportingScreen(state: AppState) {
|
fun ImportingScreen(state: AppState) {
|
||||||
@@ -51,11 +52,8 @@ fun ImportingScreen(state: AppState) {
|
|||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
Text("${p.completed} / ${p.total} files")
|
Text("${p.completed} / ${p.total} files")
|
||||||
if (p.currentFile.isNotBlank()) {
|
if (p.currentFile.isNotBlank()) {
|
||||||
Text(
|
Text(p.currentFile, style = MaterialTheme.typography.bodySmall,
|
||||||
p.currentFile,
|
color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CircularProgressIndicator()
|
CircularProgressIndicator()
|
||||||
@@ -64,24 +62,38 @@ fun ImportingScreen(state: AppState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shown after import completes (VERIFY screen).
|
* Review screen shown after import completes.
|
||||||
|
*
|
||||||
|
* Shows all imported files with their copy/EXIF status.
|
||||||
|
* Files are pre-checked for deletion based on verification:
|
||||||
|
* - EXIF-verified camera originals → pre-checked
|
||||||
|
* - EXIF-unverified files → pre-unchecked (never auto-deleted)
|
||||||
|
* - Failed copies → excluded from deletion entirely
|
||||||
|
*
|
||||||
|
* User can uncheck any file to protect it from deletion, then confirm.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun VerifyScreen(state: AppState) {
|
fun VerifyScreen(state: AppState) {
|
||||||
val result by state.importResult.collectAsState()
|
val result by state.importResult.collectAsState()
|
||||||
val importConfig by state.importConfig.collectAsState()
|
val importConfig by state.importConfig.collectAsState()
|
||||||
var deleteConfirmShown by remember { mutableStateOf(false) }
|
|
||||||
var deleteDone by remember { mutableStateOf(false) }
|
|
||||||
var previewResult by remember { mutableStateOf<CopyResult?>(null) }
|
var previewResult by remember { mutableStateOf<CopyResult?>(null) }
|
||||||
|
|
||||||
val r = result ?: return
|
val r = result ?: return
|
||||||
|
|
||||||
|
// Pre-populate delete set: only verified copies with confirmed EXIF
|
||||||
|
val deletableResults = r.results.filter { it.verified && it.error == null }
|
||||||
|
val initiallyChecked = deletableResults
|
||||||
|
.filter { it.exifVerified != false } // pre-check verified, pre-uncheck unverified EXIF
|
||||||
|
.map { it.photo.devicePath }
|
||||||
|
.toSet()
|
||||||
|
|
||||||
|
var toDelete by remember(r) { mutableStateOf(initiallyChecked) }
|
||||||
|
var deleteConfirmShown by remember { mutableStateOf(false) }
|
||||||
|
var deleteDone by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
// Preview dialog
|
// Preview dialog
|
||||||
previewResult?.let { pr ->
|
previewResult?.let { pr ->
|
||||||
PreviewDialog(
|
PreviewDialog(result = pr, onDismiss = { previewResult = null })
|
||||||
result = pr,
|
|
||||||
onDismiss = { previewResult = null },
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = Modifier.fillMaxSize().padding(24.dp)) {
|
Column(modifier = Modifier.fillMaxSize().padding(24.dp)) {
|
||||||
@@ -90,17 +102,30 @@ fun VerifyScreen(state: AppState) {
|
|||||||
ResultSummaryHeader(
|
ResultSummaryHeader(
|
||||||
success = r.successCount,
|
success = r.successCount,
|
||||||
failure = r.failureCount,
|
failure = r.failureCount,
|
||||||
|
exifUnverified = r.results.count { it.exifVerified == false },
|
||||||
destination = "${r.job.stagingRoot}/${r.job.folderName}",
|
destination = "${r.job.stagingRoot}/${r.job.folderName}",
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(Modifier.height(16.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
Text("Results", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
Text("Results", style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold)
|
||||||
|
if (importConfig.deleteAfterVerify && !deleteDone) {
|
||||||
|
Text(
|
||||||
|
"${toDelete.size} selected for deletion",
|
||||||
|
style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
Spacer(Modifier.height(4.dp))
|
Spacer(Modifier.height(4.dp))
|
||||||
HorizontalDivider()
|
|
||||||
|
|
||||||
// Scrollable results list — shadows are pinned to the divider edges
|
// Scrollable results with top/bottom shadows
|
||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
|
|
||||||
val topShadowAlpha by remember {
|
val topShadowAlpha by remember {
|
||||||
derivedStateOf {
|
derivedStateOf {
|
||||||
val scrolled = listState.firstVisibleItemScrollOffset +
|
val scrolled = listState.firstVisibleItemScrollOffset +
|
||||||
@@ -117,95 +142,81 @@ fun VerifyScreen(state: AppState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top edge: shadow drawn below the divider line above the list
|
|
||||||
if (topShadowAlpha > 0f) {
|
if (topShadowAlpha > 0f) {
|
||||||
Box(
|
Box(modifier = Modifier.fillMaxWidth().height(16.dp).drawWithContent {
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(16.dp)
|
|
||||||
.drawWithContent {
|
|
||||||
drawContent()
|
drawContent()
|
||||||
drawRect(
|
drawRect(brush = Brush.verticalGradient(
|
||||||
brush = Brush.verticalGradient(
|
colors = listOf(Color.Black.copy(alpha = 0.08f * topShadowAlpha), Color.Transparent)))
|
||||||
colors = listOf(
|
})
|
||||||
Color.Black.copy(alpha = 0.10f * topShadowAlpha),
|
|
||||||
Color.Transparent,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
state = listState,
|
state = listState,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||||
contentPadding = PaddingValues(vertical = 4.dp),
|
|
||||||
) {
|
) {
|
||||||
items(r.results, key = { it.photo.devicePath }) { copyResult ->
|
items(r.results, key = { it.photo.devicePath }) { copyResult ->
|
||||||
CopyResultRow(copyResult, onPreview = { previewResult = it })
|
val isChecked = copyResult.photo.devicePath in toDelete
|
||||||
|
val canCheck = copyResult.verified && copyResult.error == null
|
||||||
|
|
||||||
|
CopyResultRow(
|
||||||
|
result = copyResult,
|
||||||
|
showCheckbox = importConfig.deleteAfterVerify && !deleteDone,
|
||||||
|
isChecked = isChecked,
|
||||||
|
canCheck = canCheck,
|
||||||
|
onToggleCheck = {
|
||||||
|
toDelete = if (isChecked) toDelete - copyResult.photo.devicePath
|
||||||
|
else toDelete + copyResult.photo.devicePath
|
||||||
|
},
|
||||||
|
onPreview = { previewResult = it },
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottom edge: shadow drawn above the divider line below the list
|
|
||||||
if (bottomShadowAlpha > 0f) {
|
if (bottomShadowAlpha > 0f) {
|
||||||
Box(
|
Box(modifier = Modifier.fillMaxWidth().height(16.dp).drawWithContent {
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.height(16.dp)
|
|
||||||
.drawWithContent {
|
|
||||||
drawContent()
|
drawContent()
|
||||||
drawRect(
|
drawRect(brush = Brush.verticalGradient(
|
||||||
brush = Brush.verticalGradient(
|
colors = listOf(Color.Transparent, Color.Black.copy(alpha = 0.08f * bottomShadowAlpha))))
|
||||||
colors = listOf(
|
})
|
||||||
Color.Transparent,
|
|
||||||
Color.Black.copy(alpha = 0.10f * bottomShadowAlpha),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
if (importConfig.deleteAfterVerify && r.successCount > 0 && !deleteDone) {
|
if (importConfig.deleteAfterVerify && !deleteDone) {
|
||||||
if (deleteConfirmShown) {
|
if (deleteConfirmShown) {
|
||||||
DeleteConfirmCard(
|
DeleteConfirmCard(
|
||||||
count = r.successCount,
|
count = toDelete.size,
|
||||||
|
exifUnverifiedCount = r.results.count {
|
||||||
|
it.photo.devicePath !in toDelete && it.exifVerified == false
|
||||||
|
},
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
state.deleteVerifiedFromDevice()
|
state.deleteSpecificFromDevice(toDelete)
|
||||||
deleteDone = true
|
deleteDone = true
|
||||||
deleteConfirmShown = false
|
deleteConfirmShown = false
|
||||||
},
|
},
|
||||||
onCancel = { deleteConfirmShown = false },
|
onCancel = { deleteConfirmShown = false },
|
||||||
)
|
)
|
||||||
} else {
|
} else if (toDelete.isNotEmpty()) {
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
onClick = { deleteConfirmShown = true },
|
onClick = { deleteConfirmShown = true },
|
||||||
colors = ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.error),
|
colors = ButtonDefaults.outlinedButtonColors(contentColor = MaterialTheme.colorScheme.error),
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) {
|
) {
|
||||||
Text("Delete ${r.successCount} verified files from phone")
|
Text("Delete ${toDelete.size} files from phone")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (deleteDone) {
|
} else if (deleteDone) {
|
||||||
Text(
|
Text("✓ Files deleted from phone",
|
||||||
"✓ ${r.successCount} files deleted from phone",
|
|
||||||
color = MaterialTheme.colorScheme.primary,
|
color = MaterialTheme.colorScheme.primary,
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(8.dp))
|
Spacer(Modifier.height(8.dp))
|
||||||
Button(
|
Button(
|
||||||
onClick = {
|
onClick = { state.navigateTo(Screen.CONNECT); state.selectNone() },
|
||||||
state.navigateTo(Screen.CONNECT)
|
|
||||||
state.selectNone()
|
|
||||||
},
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) {
|
) {
|
||||||
Icon(Icons.Default.Home, contentDescription = null, modifier = Modifier.size(18.dp))
|
Icon(Icons.Default.Home, contentDescription = null, modifier = Modifier.size(18.dp))
|
||||||
@@ -216,42 +227,40 @@ fun VerifyScreen(state: AppState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ResultSummaryHeader(success: Int, failure: Int, destination: String) {
|
private fun ResultSummaryHeader(success: Int, failure: Int, exifUnverified: Int, destination: String) {
|
||||||
Card(
|
Card(colors = CardDefaults.cardColors(
|
||||||
colors = CardDefaults.cardColors(
|
containerColor = if (failure == 0) MaterialTheme.colorScheme.primaryContainer
|
||||||
containerColor = if (failure == 0)
|
else MaterialTheme.colorScheme.errorContainer,
|
||||||
MaterialTheme.colorScheme.primaryContainer
|
)) {
|
||||||
else
|
|
||||||
MaterialTheme.colorScheme.errorContainer,
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
|
||||||
Text(
|
Text(
|
||||||
if (failure == 0) "Import complete ✓" else "Import complete with errors",
|
if (failure == 0) "Import complete ✓" else "Import complete with errors",
|
||||||
style = MaterialTheme.typography.titleMedium,
|
style = MaterialTheme.typography.titleMedium, fontWeight = FontWeight.SemiBold,
|
||||||
fontWeight = FontWeight.SemiBold,
|
|
||||||
)
|
|
||||||
Text("$success verified, $failure failed")
|
|
||||||
Text(
|
|
||||||
"→ $destination",
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
|
||||||
)
|
)
|
||||||
|
Text("$success copied, $failure failed" +
|
||||||
|
if (exifUnverified > 0) ", $exifUnverified EXIF unverified (⚠ not auto-deleted)" else "")
|
||||||
|
Text("→ $destination", style = MaterialTheme.typography.bodySmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun CopyResultRow(result: CopyResult, onPreview: (CopyResult) -> Unit) {
|
private fun CopyResultRow(
|
||||||
val hasRemoteHash = result.sourceSha256 != "(not available)"
|
result: CopyResult,
|
||||||
|
showCheckbox: Boolean,
|
||||||
|
isChecked: Boolean,
|
||||||
|
canCheck: Boolean,
|
||||||
|
onToggleCheck: () -> Unit,
|
||||||
|
onPreview: (CopyResult) -> Unit,
|
||||||
|
) {
|
||||||
val isFailed = result.error != null || !result.verified
|
val isFailed = result.error != null || !result.verified
|
||||||
val exifUnverified = result.exifVerified == false
|
val exifUnverified = result.exifVerified == false
|
||||||
val exifUnavailable = result.exifVerified == null
|
val exifUnavailable = result.exifVerified == null
|
||||||
|
|
||||||
// Color: red=failed, yellow=unverified EXIF, green=fully verified
|
|
||||||
val iconTint = when {
|
val iconTint = when {
|
||||||
isFailed -> MaterialTheme.colorScheme.error
|
isFailed -> MaterialTheme.colorScheme.error
|
||||||
exifUnverified -> MaterialTheme.colorScheme.tertiary // yellow-ish
|
exifUnverified -> MaterialTheme.colorScheme.tertiary
|
||||||
else -> MaterialTheme.colorScheme.primary
|
else -> MaterialTheme.colorScheme.primary
|
||||||
}
|
}
|
||||||
val icon = when {
|
val icon = when {
|
||||||
@@ -261,12 +270,24 @@ private fun CopyResultRow(result: CopyResult, onPreview: (CopyResult) -> Unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().padding(vertical = 4.dp)
|
modifier = Modifier.fillMaxWidth().padding(vertical = 3.dp)
|
||||||
.clickable { onPreview(result) }, // click to preview
|
.clickable { onPreview(result) },
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
|
// Delete checkbox (only shown when deleteAfterVerify is on and import isn't done)
|
||||||
|
if (showCheckbox && canCheck) {
|
||||||
|
Checkbox(
|
||||||
|
checked = isChecked,
|
||||||
|
onCheckedChange = { onToggleCheck() },
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
)
|
||||||
|
} else if (showCheckbox) {
|
||||||
|
Spacer(Modifier.width(20.dp))
|
||||||
|
}
|
||||||
|
|
||||||
Icon(icon, contentDescription = null, tint = iconTint, modifier = Modifier.size(18.dp))
|
Icon(icon, contentDescription = null, tint = iconTint, modifier = Modifier.size(18.dp))
|
||||||
|
|
||||||
Column(modifier = Modifier.weight(1f)) {
|
Column(modifier = Modifier.weight(1f)) {
|
||||||
val displayName = if (result.convertedFromHeic)
|
val displayName = if (result.convertedFromHeic)
|
||||||
"${result.photo.filename} → ${result.destinationPath.fileName}"
|
"${result.photo.filename} → ${result.destinationPath.fileName}"
|
||||||
@@ -275,10 +296,9 @@ private fun CopyResultRow(result: CopyResult, onPreview: (CopyResult) -> Unit) {
|
|||||||
Text(
|
Text(
|
||||||
when {
|
when {
|
||||||
isFailed -> result.error ?: "Failed"
|
isFailed -> result.error ?: "Failed"
|
||||||
exifUnverified -> "⚠ EXIF Make: '${result.exifMake?.ifEmpty { "(absent)" } ?: "(absent)"}' — not deleted from phone"
|
exifUnverified -> "⚠ Make: '${result.exifMake?.ifEmpty { "(absent)" } ?: "(absent)"}' — kept on phone"
|
||||||
exifUnavailable -> "Copied · ${result.photo.sizeBytes / 1024} KB · local SHA-256: ${result.destSha256.take(12)}…"
|
exifUnavailable -> "Copied · ${result.photo.sizeBytes / 1024} KB"
|
||||||
hasRemoteHash -> "SHA-256 verified · ${result.photo.sizeBytes / 1024} KB"
|
else -> "✓ Make: ${result.exifMake} · ${result.photo.sizeBytes / 1024} KB"
|
||||||
else -> "Copied · ${result.photo.sizeBytes / 1024} KB · local SHA-256: ${result.destSha256.take(12)}…"
|
|
||||||
},
|
},
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = when {
|
color = when {
|
||||||
@@ -288,34 +308,40 @@ private fun CopyResultRow(result: CopyResult, onPreview: (CopyResult) -> Unit) {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// Tap hint
|
|
||||||
Text("👁", style = MaterialTheme.typography.labelSmall,
|
Text("👁", style = MaterialTheme.typography.labelSmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant)
|
color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun DeleteConfirmCard(count: Int, onConfirm: () -> Unit, onCancel: () -> Unit) {
|
private fun DeleteConfirmCard(
|
||||||
|
count: Int,
|
||||||
|
exifUnverifiedCount: Int,
|
||||||
|
onConfirm: () -> Unit,
|
||||||
|
onCancel: () -> Unit,
|
||||||
|
) {
|
||||||
Card(
|
Card(
|
||||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer),
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.errorContainer),
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
|
Text("Delete $count files from phone?", fontWeight = FontWeight.SemiBold,
|
||||||
|
color = MaterialTheme.colorScheme.onErrorContainer)
|
||||||
Text(
|
Text(
|
||||||
"Delete $count files from phone?",
|
buildString {
|
||||||
fontWeight = FontWeight.SemiBold,
|
append("This is permanent and cannot be undone.")
|
||||||
color = MaterialTheme.colorScheme.onErrorContainer,
|
if (exifUnverifiedCount > 0) {
|
||||||
)
|
append(" $exifUnverifiedCount unverified file(s) are excluded and will stay on your phone.")
|
||||||
Text(
|
}
|
||||||
"This is permanent. Only files that passed SHA-256 verification will be deleted.",
|
},
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onErrorContainer,
|
color = MaterialTheme.colorScheme.onErrorContainer,
|
||||||
)
|
)
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
Button(
|
Button(onClick = onConfirm,
|
||||||
onClick = onConfirm,
|
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.error)) {
|
||||||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.error),
|
Text("Delete from Phone")
|
||||||
) { Text("Delete from Phone") }
|
}
|
||||||
OutlinedButton(onClick = onCancel) { Text("Cancel") }
|
OutlinedButton(onClick = onCancel) { Text("Cancel") }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,31 +352,24 @@ private fun DeleteConfirmCard(count: Int, onConfirm: () -> Unit, onCancel: () ->
|
|||||||
private fun PreviewDialog(result: CopyResult, onDismiss: () -> Unit) {
|
private fun PreviewDialog(result: CopyResult, onDismiss: () -> Unit) {
|
||||||
var bitmap by remember(result.destinationPath) { mutableStateOf<ImageBitmap?>(null) }
|
var bitmap by remember(result.destinationPath) { mutableStateOf<ImageBitmap?>(null) }
|
||||||
|
|
||||||
// Load from destination file (already on disk after import)
|
|
||||||
LaunchedEffect(result.destinationPath) {
|
LaunchedEffect(result.destinationPath) {
|
||||||
val bytes = withContext(Dispatchers.IO) {
|
val bytes = withContext(Dispatchers.IO) {
|
||||||
try { Files.readAllBytes(result.destinationPath) } catch (_: Exception) { null }
|
try { Files.readAllBytes(result.destinationPath) } catch (_: Exception) { null }
|
||||||
}
|
}
|
||||||
if (bytes != null) {
|
if (bytes != null) {
|
||||||
runCatching {
|
runCatching { bitmap = SkiaImage.makeFromEncoded(bytes).toComposeImageBitmap() }
|
||||||
// Use sips to get a reasonable preview size if file is large
|
|
||||||
bitmap = SkiaImage.makeFromEncoded(bytes).toComposeImageBitmap()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dialog(onDismissRequest = onDismiss) {
|
Dialog(onDismissRequest = onDismiss) {
|
||||||
Card(modifier = Modifier.fillMaxWidth(0.9f)) {
|
Card(modifier = Modifier.fillMaxWidth(0.9f)) {
|
||||||
Column(modifier = Modifier.padding(16.dp),
|
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||||
verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
|
||||||
|
|
||||||
// Filename + EXIF status
|
|
||||||
Text(result.photo.filename, fontWeight = FontWeight.SemiBold)
|
Text(result.photo.filename, fontWeight = FontWeight.SemiBold)
|
||||||
Text(
|
Text(
|
||||||
when (result.exifVerified) {
|
when (result.exifVerified) {
|
||||||
true -> "✓ EXIF Make: ${result.exifMake}"
|
true -> "✓ EXIF Make: ${result.exifMake}"
|
||||||
false -> "⚠ EXIF Make: '${result.exifMake?.ifEmpty { "(absent)" } ?: "(absent)"}' — not a confirmed camera original"
|
false -> "⚠ Make: '${result.exifMake?.ifEmpty { "(absent)" } ?: "(absent)"}' — not a confirmed camera original"
|
||||||
null -> "EXIF not checked (exiftool not installed)"
|
null -> "EXIF not checked (install exiftool)"
|
||||||
},
|
},
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = when (result.exifVerified) {
|
color = when (result.exifVerified) {
|
||||||
@@ -359,36 +378,20 @@ private fun PreviewDialog(result: CopyResult, onDismiss: () -> Unit) {
|
|||||||
null -> MaterialTheme.colorScheme.onSurfaceVariant
|
null -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
|
Box(modifier = Modifier.fillMaxWidth().aspectRatio(4f / 3f),
|
||||||
// Preview image
|
contentAlignment = Alignment.Center) {
|
||||||
Box(
|
|
||||||
modifier = Modifier.fillMaxWidth().aspectRatio(4f / 3f),
|
|
||||||
contentAlignment = Alignment.Center,
|
|
||||||
) {
|
|
||||||
if (bitmap != null) {
|
if (bitmap != null) {
|
||||||
androidx.compose.foundation.Image(
|
Image(bitmap = bitmap!!, contentDescription = result.photo.filename,
|
||||||
bitmap = bitmap!!,
|
contentScale = ContentScale.Fit, modifier = Modifier.fillMaxSize())
|
||||||
contentDescription = result.photo.filename,
|
|
||||||
contentScale = ContentScale.Fit,
|
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
CircularProgressIndicator()
|
CircularProgressIndicator()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Text("${result.photo.sizeBytes / 1024} KB · ${result.destinationPath}",
|
||||||
// File info
|
|
||||||
Text(
|
|
||||||
"${result.photo.sizeBytes / 1024} KB · ${result.destinationPath}",
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
style = MaterialTheme.typography.labelSmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||||
)
|
Button(onClick = onDismiss, modifier = Modifier.fillMaxWidth()) { Text("Close") }
|
||||||
|
|
||||||
Button(onClick = onDismiss, modifier = Modifier.fillMaxWidth()) {
|
|
||||||
Text("Close")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user