Fix device name, ImportScreen layout, and preserve folder default

- AndroidConnector: use model: field for display name instead of
  product: (which is a cryptic codename like 'o1quew' on Samsung)
- ImportScreen: clean up layout with ToggleRow helper, remove duplicate
  toggles, all 4 options in one Options section
- AppState: preserveFolderStructure defaults to true
This commit is contained in:
Kyle Bolen
2026-07-28 05:20:02 +00:00
parent 409cb3b4d1
commit f6aede99f1
3 changed files with 59 additions and 98 deletions

View File

@@ -49,12 +49,17 @@ class AndroidConnector(
if (parts.size < 2 || parts[1] != "device") return@mapNotNull null if (parts.size < 2 || parts[1] != "device") return@mapNotNull null
val serial = parts[0] val serial = parts[0]
val model = parts.firstOrNull { it.startsWith("model:") } val model = parts.firstOrNull { it.startsWith("model:") }
?.removePrefix("model:") ?: "Android Device" ?.removePrefix("model:")
?.replace("_", " ")
?: "Android Device"
val product = parts.firstOrNull { it.startsWith("product:") } val product = parts.firstOrNull { it.startsWith("product:") }
?.removePrefix("product:") ?.removePrefix("product:")
?.replace("_", " ")
// Prefer model name — it's human-readable (e.g. "SM G991B")
// product is often a cryptic codename (e.g. "o1quew")
val displayName = model.ifBlank { product ?: "Android Device" }
DeviceInfo( DeviceInfo(
displayName = product?.replace("_", " ")?.replaceFirstChar { it.uppercase() } displayName = displayName.trim(),
?: model.replace("_", " "),
type = DeviceType.ANDROID, type = DeviceType.ANDROID,
adbSerial = serial, adbSerial = serial,
) )

View File

@@ -230,7 +230,7 @@ class AppState(private val configStore: ConfigStore) {
convertHeicToJpeg = true, convertHeicToJpeg = true,
stripLivePhotoMotion = true, stripLivePhotoMotion = true,
deleteAfterVerify = false, deleteAfterVerify = false,
preserveFolderStructure = false, preserveFolderStructure = true,
folderName = "", folderName = "",
) )
) )

View File

@@ -3,7 +3,6 @@ package com.bolenpad.photophetch.ui
import androidx.compose.foundation.layout.* import androidx.compose.foundation.layout.*
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.FolderOpen
import androidx.compose.material3.* import androidx.compose.material3.*
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
@@ -13,10 +12,6 @@ import androidx.compose.ui.unit.dp
import com.bolenpad.photophetch.util.StagingPath import com.bolenpad.photophetch.util.StagingPath
import java.nio.file.Paths import java.nio.file.Paths
/**
* Import configuration screen — shown after photo selection, before starting the copy.
* User confirms destination folder name, conversion settings, and delete-after-verify preference.
*/
@Composable @Composable
fun ImportScreen(state: AppState) { fun ImportScreen(state: AppState) {
val importConfig by state.importConfig.collectAsState() val importConfig by state.importConfig.collectAsState()
@@ -24,7 +19,6 @@ fun ImportScreen(state: AppState) {
val selected by state.selectedPhotos.collectAsState() val selected by state.selectedPhotos.collectAsState()
val device by state.selectedDevice.collectAsState() val device by state.selectedDevice.collectAsState()
// Validate staging root
val stagingError = if (config.stagingRoot.isNotBlank()) { val stagingError = if (config.stagingRoot.isNotBlank()) {
StagingPath.validateStagingRoot(Paths.get(config.stagingRoot)) StagingPath.validateStagingRoot(Paths.get(config.stagingRoot))
} else "Staging directory not configured" } else "Staging directory not configured"
@@ -41,19 +35,17 @@ fun ImportScreen(state: AppState) {
Text("Import Configuration", style = MaterialTheme.typography.headlineSmall) Text("Import Configuration", style = MaterialTheme.typography.headlineSmall)
} }
// Summary card // Summary
Card { Card {
Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) { Column(modifier = Modifier.padding(16.dp), verticalArrangement = Arrangement.spacedBy(4.dp)) {
Text("${selected.size} files selected", fontWeight = FontWeight.SemiBold) Text("${selected.size} files selected", fontWeight = FontWeight.SemiBold)
device?.let { device?.let { Text("From: ${it.displayName}", style = MaterialTheme.typography.bodySmall) }
Text("From: ${it.displayName}", style = MaterialTheme.typography.bodySmall)
}
} }
} }
HorizontalDivider() HorizontalDivider()
// Destination folder name // Destination
Text("Destination Folder", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold) Text("Destination Folder", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold)
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Text( Text(
@@ -75,93 +67,36 @@ fun ImportScreen(state: AppState) {
HorizontalDivider() HorizontalDivider()
// Conversion options // Options
Text("Conversion", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold) Text("Options", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold)
Row( ToggleRow(
modifier = Modifier.fillMaxWidth(), label = "Convert HEIC → JPEG",
verticalAlignment = Alignment.CenterVertically, description = "Recommended for PhotoPhile on Linux. Uses macOS sips.",
horizontalArrangement = Arrangement.SpaceBetween, checked = importConfig.convertHeicToJpeg,
) { onCheckedChange = { state.updateImportConfig { copy(convertHeicToJpeg = it) } },
Column(modifier = Modifier.weight(1f)) { )
Text("Convert HEIC → JPEG") ToggleRow(
Text( label = "Strip Live Photo motion clips",
"Recommended for PhotoPhile on Linux. Uses macOS sips (built-in).", description = "Excludes .MOV companions from Live Photos.",
style = MaterialTheme.typography.bodySmall, checked = importConfig.stripLivePhotoMotion,
color = MaterialTheme.colorScheme.onSurfaceVariant, onCheckedChange = { state.updateImportConfig { copy(stripLivePhotoMotion = it) } },
) )
} ToggleRow(
Switch( label = "Preserve folder structure",
checked = importConfig.convertHeicToJpeg, description = "Files go into subfolders matching their source (e.g. Camera/, Screenshots/).",
onCheckedChange = { state.updateImportConfig { copy(convertHeicToJpeg = it) } }, checked = importConfig.preserveFolderStructure,
) onCheckedChange = { state.updateImportConfig { copy(preserveFolderStructure = it) } },
} )
ToggleRow(
Row( label = "Delete from phone after verification",
modifier = Modifier.fillMaxWidth(), description = "Only deletes files that passed SHA-256 check. You'll confirm on the next screen.",
verticalAlignment = Alignment.CenterVertically, checked = importConfig.deleteAfterVerify,
horizontalArrangement = Arrangement.SpaceBetween, onCheckedChange = { state.updateImportConfig { copy(deleteAfterVerify = it) } },
) { )
Column(modifier = Modifier.weight(1f)) {
Text("Strip Live Photo motion clips")
Text(
"Excludes .MOV companions from Live Photos. You want JPEGs, not motion clips.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Switch(
checked = importConfig.stripLivePhotoMotion,
onCheckedChange = { state.updateImportConfig { copy(stripLivePhotoMotion = it) } },
)
}
HorizontalDivider()
// Delete after verify
Text("After Import", style = MaterialTheme.typography.titleSmall, fontWeight = FontWeight.SemiBold)
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Column(modifier = Modifier.weight(1f)) {
Text("Preserve folder structure")
Text(
"Copy files into subfolders matching their device path (e.g. Camera/, Screenshots/). Enabled automatically in Show All mode.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Switch(
checked = importConfig.preserveFolderStructure,
onCheckedChange = { state.updateImportConfig { copy(preserveFolderStructure = it) } },
)
}
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Column(modifier = Modifier.weight(1f)) {
Text("Delete from phone after verification")
Text(
"Only deletes files that passed SHA-256 verification. You'll confirm on the next screen.",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
Switch(
checked = importConfig.deleteAfterVerify,
onCheckedChange = { state.updateImportConfig { copy(deleteAfterVerify = it) } },
)
}
Spacer(Modifier.weight(1f)) Spacer(Modifier.weight(1f))
// Start import button
Button( Button(
onClick = { state.startImport() }, onClick = { state.startImport() },
enabled = stagingError == null && importConfig.folderName.isNotBlank() && selected.isNotEmpty(), enabled = stagingError == null && importConfig.folderName.isNotBlank() && selected.isNotEmpty(),
@@ -171,3 +106,24 @@ fun ImportScreen(state: AppState) {
} }
} }
} }
@Composable
private fun ToggleRow(
label: String,
description: String,
checked: Boolean,
onCheckedChange: (Boolean) -> Unit,
) {
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween,
) {
Column(modifier = Modifier.weight(1f).padding(end = 8.dp)) {
Text(label)
Text(description, style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant)
}
Switch(checked = checked, onCheckedChange = onCheckedChange)
}
}