feat: copy paste lut edit
This commit is contained in:
1 parent
61683b9def
commit
17feb53562
9 files changed
+935
-102
No files matched your search
@@ -111,10 +111,13 @@ fun GalleryDetailScreen(
|
||||
var showExportDialog by remember { mutableStateOf(false) }
|
||||
var isSaving by remember { mutableStateOf(false) }
|
||||
var isExportingDng by remember { mutableStateOf(false) }
|
||||
var isCopyingSettings by remember { mutableStateOf(false) }
|
||||
var isPastingSettings by remember { mutableStateOf(false) }
|
||||
val isVideoExporting = viewModel.isVideoExporting
|
||||
val videoExportProgress = viewModel.videoExportProgress
|
||||
var showVideoExportConfirmDialog by remember { mutableStateOf(false) }
|
||||
val isSharing by viewModel.isSharing.collectAsState()
|
||||
val hasCopiedEditSettings by viewModel.hasCopiedEditSettings.collectAsState()
|
||||
val isPurchased by viewModel.isPurchased.collectAsState()
|
||||
var showAiScoreSheet by remember { mutableStateOf(false) }
|
||||
var showMoreSheet by remember { mutableStateOf(false) }
|
||||
@@ -883,12 +886,72 @@ fun GalleryDetailScreen(
|
||||
modifier = Modifier.fillMaxWidth().horizontalScroll(rememberScrollState()),
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
GalleryActionItem(
|
||||
icon = AppIcons.ContentCopy,
|
||||
text = stringResource(R.string.copy_settings),
|
||||
isLoading = isCopyingSettings,
|
||||
enabled = !isCopyingSettings &&
|
||||
!isPastingSettings &&
|
||||
!isSharing &&
|
||||
!isSaving,
|
||||
onClick = {
|
||||
isCopyingSettings = true
|
||||
viewModel.copyPhotoSettings(currentPhoto) { success ->
|
||||
isCopyingSettings = false
|
||||
if (success) {
|
||||
showMoreSheet = false
|
||||
}
|
||||
Toast.makeText(
|
||||
context,
|
||||
if (success) {
|
||||
R.string.copy_settings_success
|
||||
} else {
|
||||
R.string.copy_settings_failed
|
||||
},
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
GalleryActionItem(
|
||||
icon = AppIcons.ContentCopy,
|
||||
text = stringResource(R.string.paste_settings),
|
||||
isLoading = isPastingSettings,
|
||||
enabled = hasCopiedEditSettings &&
|
||||
!isCopyingSettings &&
|
||||
!isPastingSettings &&
|
||||
!isSharing &&
|
||||
!isSaving,
|
||||
onClick = {
|
||||
isPastingSettings = true
|
||||
viewModel.pasteCopiedSettingsToPhoto(currentPhoto) { success ->
|
||||
isPastingSettings = false
|
||||
if (success) {
|
||||
showMoreSheet = false
|
||||
}
|
||||
Toast.makeText(
|
||||
context,
|
||||
if (success) {
|
||||
R.string.paste_settings_success
|
||||
} else {
|
||||
R.string.paste_settings_failed
|
||||
},
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
// 分享
|
||||
GalleryActionItem(
|
||||
icon = Icons.Default.Share,
|
||||
text = stringResource(R.string.share),
|
||||
isLoading = isSharing,
|
||||
enabled = !isSharing && !isSaving,
|
||||
enabled = !isSharing &&
|
||||
!isSaving &&
|
||||
!isCopyingSettings &&
|
||||
!isPastingSettings,
|
||||
onClick = {
|
||||
showMoreSheet = false
|
||||
viewModel.sharePhoto(currentPhoto)
|
||||
@@ -901,6 +964,7 @@ fun GalleryDetailScreen(
|
||||
icon = AppIcons.Output,
|
||||
text = stringResource(R.string.export),
|
||||
isLoading = isSaving,
|
||||
enabled = !isCopyingSettings && !isPastingSettings,
|
||||
onClick = {
|
||||
showExportDialog = true
|
||||
}
|
||||
@@ -913,6 +977,7 @@ fun GalleryDetailScreen(
|
||||
icon = AppIcons.Output,
|
||||
text = if (isVideoExporting && videoExportProgress > 0) "$videoExportProgress%" else stringResource(R.string.export),
|
||||
isLoading = isVideoExporting,
|
||||
enabled = !isCopyingSettings && !isPastingSettings,
|
||||
onClick = {
|
||||
if (isVideoTransformerExportSupported()) {
|
||||
showVideoExportConfirmDialog = true
|
||||
@@ -929,7 +994,10 @@ fun GalleryDetailScreen(
|
||||
iconText = "DNG",
|
||||
text = "DNG",
|
||||
isLoading = isExportingDng,
|
||||
enabled = !isSaving && !isExportingDng,
|
||||
enabled = !isSaving &&
|
||||
!isExportingDng &&
|
||||
!isCopyingSettings &&
|
||||
!isPastingSettings,
|
||||
onClick = {
|
||||
showMoreSheet = false
|
||||
isExportingDng = true
|
||||
|
||||
@@ -29,6 +29,7 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Check
|
||||
import androidx.compose.material.icons.filled.MoreVert
|
||||
import androidx.compose.material.icons.filled.Refresh
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
@@ -175,9 +176,11 @@ fun GalleryEditScreen(
|
||||
val showPaymentDialog = viewModel.showPaymentDialog
|
||||
val isPurchased by viewModel.isPurchased.collectAsState()
|
||||
val categoryOrder by viewModel.categoryOrder.collectAsState()
|
||||
val hasCopiedEditSettings by viewModel.hasCopiedEditSettings.collectAsState()
|
||||
|
||||
var isSaving by remember { mutableStateOf(false) }
|
||||
var isLoadingPreview by remember { mutableStateOf(false) }
|
||||
var showMoreMenu by remember { mutableStateOf(false) }
|
||||
val frameScrollState = rememberLazyListState()
|
||||
var showBaselineLutEditSheet by remember { mutableStateOf(false) }
|
||||
var baselineLutEditId by remember { mutableStateOf<String?>(null) }
|
||||
@@ -870,6 +873,65 @@ fun GalleryEditScreen(
|
||||
)
|
||||
}
|
||||
}
|
||||
// 更多始终放在 actions 的最右侧。
|
||||
Box {
|
||||
IconButton(onClick = { showMoreMenu = true }) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.MoreVert,
|
||||
contentDescription = stringResource(R.string.more_options),
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
DropdownMenu(
|
||||
expanded = showMoreMenu,
|
||||
onDismissRequest = { showMoreMenu = false }
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.copy_settings)) },
|
||||
onClick = {
|
||||
showMoreMenu = false
|
||||
viewModel.copyCurrentEditSettings(
|
||||
editFrameCustomProperties
|
||||
)
|
||||
Toast.makeText(
|
||||
context,
|
||||
R.string.copy_settings_success,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = AppIcons.ContentCopy,
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.paste_settings)) },
|
||||
onClick = {
|
||||
showMoreMenu = false
|
||||
viewModel
|
||||
.pasteCopiedEditSettingsToCurrentEdit()
|
||||
?.let { pastedCustomProperties ->
|
||||
editFrameCustomProperties =
|
||||
pastedCustomProperties
|
||||
Toast.makeText(
|
||||
context,
|
||||
R.string.paste_settings_success,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
},
|
||||
enabled = hasCopiedEditSettings,
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = AppIcons.ContentCopy,
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = Color.Transparent
|
||||
|
||||
@@ -66,6 +66,7 @@ import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.gallery.MediaData
|
||||
import com.hinnka.mycamera.ui.theme.AccentOrange
|
||||
import com.hinnka.mycamera.utils.OrientationObserver
|
||||
import com.hinnka.mycamera.viewmodel.GalleryBatchOperation
|
||||
import com.hinnka.mycamera.viewmodel.GalleryTab
|
||||
import com.hinnka.mycamera.viewmodel.GalleryViewModel
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
@@ -135,15 +136,23 @@ fun GalleryScreen(
|
||||
val isSystemLoadingMore by viewModel.isSystemLoadingMore.collectAsState()
|
||||
val isPhotonLoadingMore by viewModel.isPhotonLoadingMore.collectAsState()
|
||||
val isSharing by viewModel.isSharing.collectAsState()
|
||||
val isExporting by viewModel.isExporting.collectAsState()
|
||||
val isPastingSettings by viewModel.isPastingSettings.collectAsState()
|
||||
val hasCopiedEditSettings by viewModel.hasCopiedEditSettings.collectAsState()
|
||||
val batchOperationProgress by viewModel.batchOperationProgress.collectAsState()
|
||||
val isSelectionMode = viewModel.isSelectionMode
|
||||
val selectedPhotos = viewModel.selectedPhotos
|
||||
val selectedImageCount = selectedPhotos.count { it.isImage }
|
||||
val selectedTab = viewModel.selectedTab
|
||||
val hasPermission = viewModel.hasGalleryPermission
|
||||
val isBatchOperationRunning = isExporting || isPastingSettings
|
||||
val scope = rememberCoroutineScope()
|
||||
var shouldRenderGrid by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
BackHandler(enabled = isSelectionMode) {
|
||||
viewModel.exitSelectionMode()
|
||||
if (!isBatchOperationRunning) {
|
||||
viewModel.exitSelectionMode()
|
||||
}
|
||||
}
|
||||
|
||||
fun importSelectedMedia(uris: List<Uri>, videoUris: List<Uri?>? = null) {
|
||||
@@ -299,27 +308,41 @@ fun GalleryScreen(
|
||||
}
|
||||
},
|
||||
navigationIcon = {
|
||||
IconButton(onClick = {
|
||||
if (isSelectionMode) {
|
||||
viewModel.exitSelectionMode()
|
||||
} else {
|
||||
onBack()
|
||||
}
|
||||
}) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
if (isSelectionMode) {
|
||||
viewModel.exitSelectionMode()
|
||||
} else {
|
||||
onBack()
|
||||
}
|
||||
},
|
||||
enabled = !isBatchOperationRunning
|
||||
) {
|
||||
Icon(
|
||||
imageVector = if (isSelectionMode) Icons.Default.Close else Icons.AutoMirrored.Filled.ArrowBack,
|
||||
contentDescription = stringResource(R.string.back),
|
||||
tint = Color.White
|
||||
tint = if (isBatchOperationRunning) {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
} else {
|
||||
Color.White
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
actions = {
|
||||
if (isSelectionMode) {
|
||||
IconButton(onClick = { viewModel.toggleSelectAll() }) {
|
||||
IconButton(
|
||||
onClick = { viewModel.toggleSelectAll() },
|
||||
enabled = !isBatchOperationRunning
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.SelectAll,
|
||||
contentDescription = stringResource(R.string.select_all),
|
||||
tint = Color.White
|
||||
tint = if (isBatchOperationRunning) {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
} else {
|
||||
Color.White
|
||||
}
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@@ -363,97 +386,193 @@ fun GalleryScreen(
|
||||
.fillMaxWidth()
|
||||
.navigationBarsPadding()
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
// 删除按钮
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.clickable { showDeleteDialog = true }
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Delete,
|
||||
contentDescription = stringResource(R.string.delete),
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.delete),
|
||||
color = Color.White,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
|
||||
// 分享按钮
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.clickable(enabled = !isSharing) { viewModel.shareSelectedPhotos() }
|
||||
) {
|
||||
if (isSharing) {
|
||||
CircularProgressIndicator(
|
||||
color = Color.White,
|
||||
modifier = Modifier.size(28.dp),
|
||||
strokeWidth = 2.dp
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
batchOperationProgress?.let { progress ->
|
||||
val progressLabel = when (progress.operation) {
|
||||
GalleryBatchOperation.PASTE_SETTINGS ->
|
||||
R.string.pasting_settings_progress
|
||||
GalleryBatchOperation.EXPORT ->
|
||||
R.string.exporting_progress
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 16.dp, end = 16.dp, top = 12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(6.dp)
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(
|
||||
progressLabel,
|
||||
progress.completed,
|
||||
progress.total
|
||||
),
|
||||
color = Color.White.copy(alpha = 0.8f),
|
||||
fontSize = 12.sp
|
||||
)
|
||||
} else {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Share,
|
||||
contentDescription = stringResource(R.string.share),
|
||||
tint = Color.White,
|
||||
modifier = Modifier.size(28.dp)
|
||||
LinearProgressIndicator(
|
||||
progress = {
|
||||
progress.completed.toFloat() /
|
||||
progress.total.coerceAtLeast(1).toFloat()
|
||||
},
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(4.dp),
|
||||
color = AccentOrange,
|
||||
trackColor = Color.White.copy(alpha = 0.15f)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.share),
|
||||
color = Color.White,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
|
||||
// 导出按钮
|
||||
if (viewModel.selectedTab == GalleryTab.PHOTON) {
|
||||
val isExporting by viewModel.isExporting.collectAsState()
|
||||
val context = LocalContext.current
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly
|
||||
) {
|
||||
// 删除按钮
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.clickable(enabled = !isExporting) {
|
||||
viewModel.exportSelectedPhotos { count ->
|
||||
if (count > 0) {
|
||||
Toast.makeText(context, R.string.export_complete, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
modifier = Modifier.clickable(
|
||||
enabled = !isBatchOperationRunning
|
||||
) {
|
||||
showDeleteDialog = true
|
||||
}
|
||||
) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Delete,
|
||||
contentDescription = stringResource(R.string.delete),
|
||||
tint = if (isBatchOperationRunning) {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
} else {
|
||||
Color.White
|
||||
},
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.delete),
|
||||
color = Color.White,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
|
||||
// 分享按钮
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.clickable(
|
||||
enabled = !isSharing && !isBatchOperationRunning
|
||||
) {
|
||||
viewModel.shareSelectedPhotos()
|
||||
}
|
||||
) {
|
||||
if (isSharing) {
|
||||
CircularProgressIndicator(
|
||||
color = Color.White,
|
||||
modifier = Modifier.size(28.dp),
|
||||
strokeWidth = 2.dp
|
||||
)
|
||||
} else {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Share,
|
||||
contentDescription = stringResource(R.string.share),
|
||||
tint = if (isBatchOperationRunning) {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
} else {
|
||||
Color.White
|
||||
},
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
}
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.share),
|
||||
color = Color.White,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
|
||||
// 批量粘贴设置
|
||||
val canPasteSettings = hasCopiedEditSettings &&
|
||||
selectedImageCount > 0 &&
|
||||
!isBatchOperationRunning
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.clickable(enabled = canPasteSettings) {
|
||||
viewModel.pasteCopiedSettingsToSelectedPhotos {
|
||||
successCount,
|
||||
total ->
|
||||
Toast.makeText(
|
||||
context,
|
||||
context.getString(
|
||||
R.string.paste_settings_complete,
|
||||
successCount,
|
||||
total
|
||||
),
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
) {
|
||||
if (isExporting) {
|
||||
val progress = viewModel.exportProgress
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
CircularProgressIndicator(
|
||||
color = Color.White,
|
||||
modifier = Modifier.size(28.dp),
|
||||
strokeWidth = 2.dp
|
||||
)
|
||||
Text(
|
||||
text = "${progress.first}/${progress.second}",
|
||||
color = Color.White,
|
||||
fontSize = 10.sp
|
||||
)
|
||||
Icon(
|
||||
imageVector = AppIcons.ContentCopy,
|
||||
contentDescription =
|
||||
stringResource(R.string.paste_settings),
|
||||
tint = if (canPasteSettings) {
|
||||
AccentOrange
|
||||
} else {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
},
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.paste_settings),
|
||||
color = if (canPasteSettings) {
|
||||
Color.White
|
||||
} else {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
},
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
|
||||
// 批量导出
|
||||
if (viewModel.selectedTab == GalleryTab.PHOTON) {
|
||||
val canExport = selectedImageCount > 0 &&
|
||||
!isBatchOperationRunning
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.clickable(enabled = canExport) {
|
||||
viewModel.exportSelectedPhotos { count ->
|
||||
if (count > 0) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
R.string.export_complete,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
) {
|
||||
Icon(
|
||||
imageVector = AppIcons.Output,
|
||||
contentDescription = stringResource(R.string.export),
|
||||
tint = AccentOrange,
|
||||
contentDescription =
|
||||
stringResource(R.string.export),
|
||||
tint = if (canExport) {
|
||||
AccentOrange
|
||||
} else {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
},
|
||||
modifier = Modifier.size(28.dp)
|
||||
)
|
||||
Spacer(modifier = Modifier.height(4.dp))
|
||||
Text(
|
||||
text = stringResource(R.string.export),
|
||||
color = Color.White,
|
||||
color = if (canExport) {
|
||||
Color.White
|
||||
} else {
|
||||
Color.White.copy(alpha = 0.38f)
|
||||
},
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,22 @@ enum class GalleryTab {
|
||||
PHOTON, SYSTEM
|
||||
}
|
||||
|
||||
enum class GalleryBatchOperation {
|
||||
PASTE_SETTINGS,
|
||||
EXPORT
|
||||
}
|
||||
|
||||
data class GalleryBatchOperationProgress(
|
||||
val operation: GalleryBatchOperation,
|
||||
val completed: Int,
|
||||
val total: Int
|
||||
)
|
||||
|
||||
private data class CopiedEditSettings(
|
||||
val metadata: MediaMetadata,
|
||||
val normalizedCropRect: RectF?
|
||||
)
|
||||
|
||||
/**
|
||||
* 相册 ViewModel
|
||||
* 管理照片列表、选择状态和各种操作
|
||||
@@ -203,6 +219,20 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
var exportProgress by mutableStateOf(0 to 0)
|
||||
private set
|
||||
|
||||
private val _isPastingSettings = MutableStateFlow(false)
|
||||
val isPastingSettings: StateFlow<Boolean> = _isPastingSettings.asStateFlow()
|
||||
var pasteSettingsProgress by mutableStateOf(0 to 0)
|
||||
private set
|
||||
|
||||
private val _batchOperationProgress =
|
||||
MutableStateFlow<GalleryBatchOperationProgress?>(null)
|
||||
val batchOperationProgress: StateFlow<GalleryBatchOperationProgress?> =
|
||||
_batchOperationProgress.asStateFlow()
|
||||
|
||||
private var copiedEditSettings: CopiedEditSettings? = null
|
||||
private val _hasCopiedEditSettings = MutableStateFlow(false)
|
||||
val hasCopiedEditSettings: StateFlow<Boolean> = _hasCopiedEditSettings.asStateFlow()
|
||||
|
||||
// 视频导出状态
|
||||
var isVideoExporting by mutableStateOf(false)
|
||||
private set
|
||||
@@ -2225,6 +2255,177 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 复制当前编辑页中实际生效的后期设置。RAW 开发参数刻意不进入剪贴板,
|
||||
* 避免粘贴后改变目标照片的 RAW 开发结果并触发重新刷新。
|
||||
*
|
||||
* 色彩配方保存为当前有效值,而不是继续引用 LUT 的默认值,确保复制后即使 LUT
|
||||
* 的全局配方发生变化,粘贴结果仍与复制时看到的画面一致。
|
||||
*/
|
||||
fun copyCurrentEditSettings(customProperties: Map<String, String>) {
|
||||
val normalizedCrop = editCropRect.value?.let(::RectF)
|
||||
val sourceIsRaw = getCurrentPhoto()?.let(::isRawMedia) == true
|
||||
copiedEditSettings = CopiedEditSettings(
|
||||
metadata = MediaMetadata(
|
||||
lutId = editLutId.value,
|
||||
colorRecipeParams = (editPhotoRecipeParams.value ?: editLutRecipeParams.value)
|
||||
.deepCopy(),
|
||||
sharpening = editSharpening.value.takeUnless { sourceIsRaw },
|
||||
noiseReduction = editNoiseReduction.value.takeUnless { sourceIsRaw },
|
||||
chromaNoiseReduction =
|
||||
editChromaNoiseReduction.value.takeUnless { sourceIsRaw },
|
||||
frameId = editFrameId.value,
|
||||
customProperties = customProperties.toMap(),
|
||||
computationalAperture = editComputationalAperture.value,
|
||||
focusPointX = editFocusPointX.value,
|
||||
focusPointY = editFocusPointY.value,
|
||||
postRotationDegrees = editRotationDegrees.value,
|
||||
postMirrorHorizontal = editMirrorHorizontal.value,
|
||||
applyEffectsToVideo = editApplyEffectsToVideo.value
|
||||
),
|
||||
normalizedCropRect = normalizedCrop
|
||||
)
|
||||
_hasCopiedEditSettings.value = true
|
||||
}
|
||||
|
||||
/**
|
||||
* 从详情页复制照片已经保存的后期设置。
|
||||
*/
|
||||
fun copyPhotoSettings(
|
||||
photo: MediaData,
|
||||
onComplete: (Boolean) -> Unit = {}
|
||||
) {
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val context = getApplication<Application>()
|
||||
val sourcePhoto = photo.relatedPhoto ?: photo
|
||||
val sourceIsRaw = isRawMedia(photo)
|
||||
val metadata = withContext(Dispatchers.IO) {
|
||||
GalleryManager.loadMetadata(context, sourcePhoto.id)
|
||||
?: sourcePhoto.metadata
|
||||
?: photo.metadata
|
||||
?: if (selectedTab == GalleryTab.SYSTEM) {
|
||||
MediaMetadata.fromUri(context, photo.uri)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} ?: run {
|
||||
onComplete(false)
|
||||
return@launch
|
||||
}
|
||||
val effectiveRecipe = metadata.colorRecipeParams
|
||||
?: metadata.lutId?.let { lutId ->
|
||||
withContext(Dispatchers.IO) {
|
||||
contentRepository.lutManager.loadColorRecipeParams(lutId)
|
||||
}
|
||||
}
|
||||
val baseWidth = metadata.width.takeIf { it > 0 } ?: sourcePhoto.width
|
||||
val baseHeight = metadata.height.takeIf { it > 0 } ?: sourcePhoto.height
|
||||
val (cropWidth, cropHeight) = PostEditGeometry.rotatedDimensions(
|
||||
baseWidth,
|
||||
baseHeight,
|
||||
metadata.postRotationDegrees
|
||||
)
|
||||
val normalizedCrop = metadata.postCropRegion
|
||||
?.takeIf { cropWidth > 0 && cropHeight > 0 }
|
||||
?.let { crop ->
|
||||
RectF(
|
||||
crop.left.toFloat() / cropWidth,
|
||||
crop.top.toFloat() / cropHeight,
|
||||
crop.right.toFloat() / cropWidth,
|
||||
crop.bottom.toFloat() / cropHeight
|
||||
)
|
||||
}
|
||||
|
||||
copiedEditSettings = CopiedEditSettings(
|
||||
metadata = MediaMetadata(
|
||||
lutId = metadata.lutId,
|
||||
colorRecipeParams = effectiveRecipe?.deepCopy(),
|
||||
sharpening = metadata.sharpening.takeUnless { sourceIsRaw },
|
||||
noiseReduction = metadata.noiseReduction.takeUnless { sourceIsRaw },
|
||||
chromaNoiseReduction =
|
||||
metadata.chromaNoiseReduction.takeUnless { sourceIsRaw },
|
||||
frameId = metadata.frameId,
|
||||
customProperties = metadata.customProperties.toMap(),
|
||||
computationalAperture = metadata.computationalAperture,
|
||||
focusPointX = metadata.focusPointX,
|
||||
focusPointY = metadata.focusPointY,
|
||||
postRotationDegrees = metadata.postRotationDegrees,
|
||||
postMirrorHorizontal = metadata.postMirrorHorizontal,
|
||||
applyEffectsToVideo = metadata.applyEffectsToVideo
|
||||
),
|
||||
normalizedCropRect = normalizedCrop
|
||||
)
|
||||
_hasCopiedEditSettings.value = true
|
||||
onComplete(true)
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to copy settings from photo ${photo.id}", e)
|
||||
onComplete(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将已复制设置放入当前编辑态;返回边框自定义属性供编辑页同步本地预览状态。
|
||||
*/
|
||||
fun pasteCopiedEditSettingsToCurrentEdit(): Map<String, String>? {
|
||||
val copied = copiedEditSettings ?: return null
|
||||
val settings = copied.metadata
|
||||
|
||||
pendingEditLutRecipeSync = null
|
||||
editLutRecipeSyncJob?.cancel()
|
||||
editLutRecipeSyncJob = null
|
||||
|
||||
editLutId.value = settings.lutId
|
||||
editPhotoRecipeParams.value = settings.colorRecipeParams?.deepCopy()
|
||||
editFrameId.value = settings.frameId
|
||||
val targetIsRaw = getCurrentPhoto()?.let(::isRawMedia) == true
|
||||
if (!targetIsRaw) {
|
||||
settings.sharpening?.let { editSharpening.value = it }
|
||||
settings.noiseReduction?.let { editNoiseReduction.value = it }
|
||||
settings.chromaNoiseReduction?.let {
|
||||
editChromaNoiseReduction.value = it
|
||||
}
|
||||
}
|
||||
editComputationalAperture.value = settings.computationalAperture
|
||||
editFocusPointX.value = settings.focusPointX
|
||||
editFocusPointY.value = settings.focusPointY
|
||||
editRotationDegrees.value =
|
||||
PostEditGeometry.normalizeRotation(settings.postRotationDegrees)
|
||||
editMirrorHorizontal.value = settings.postMirrorHorizontal
|
||||
editCropRect.value = copied.normalizedCropRect?.let(::RectF)
|
||||
editCropAspectOption.value = copied.normalizedCropRect?.let {
|
||||
CropAspectOption.Custom(it.width(), it.height())
|
||||
} ?: CropAspectOption.Free
|
||||
editApplyEffectsToVideo.value = settings.applyEffectsToVideo
|
||||
currentMediaMetadata = (currentMediaMetadata ?: MediaMetadata()).copy(
|
||||
customProperties = settings.customProperties.toMap()
|
||||
)
|
||||
|
||||
settings.lutId?.let { lutId ->
|
||||
viewModelScope.launch {
|
||||
editLutConfig = withContext(Dispatchers.IO) {
|
||||
contentRepository.lutManager.loadLut(lutId)
|
||||
}
|
||||
}
|
||||
} ?: run {
|
||||
editLutConfig = null
|
||||
}
|
||||
updateBokehPhoto()
|
||||
return settings.customProperties.toMap()
|
||||
}
|
||||
|
||||
private fun ColorRecipeParams.deepCopy(): ColorRecipeParams {
|
||||
return copy(
|
||||
masterCurvePoints = masterCurvePoints?.copyOf(),
|
||||
redCurvePoints = redCurvePoints?.copyOf(),
|
||||
greenCurvePoints = greenCurvePoints?.copyOf(),
|
||||
blueCurvePoints = blueCurvePoints?.copyOf()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置锐化强度
|
||||
*/
|
||||
@@ -3151,6 +3352,8 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
current.copy(
|
||||
lutId = editLutId.value,
|
||||
frameId = editFrameId.value,
|
||||
customProperties = currentMediaMetadata?.customProperties
|
||||
?: targetMetadata?.customProperties.orEmpty(),
|
||||
colorRecipeParams = editPhotoRecipeParams.value,
|
||||
sharpening = editSharpening.value,
|
||||
noiseReduction = editNoiseReduction.value,
|
||||
@@ -3430,18 +3633,320 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
private fun applyCopiedEditSettings(
|
||||
current: MediaMetadata,
|
||||
copied: CopiedEditSettings,
|
||||
copyDetailProcessing: Boolean
|
||||
): MediaMetadata {
|
||||
val settings = copied.metadata
|
||||
val (cropWidth, cropHeight) = PostEditGeometry.rotatedDimensions(
|
||||
current.width,
|
||||
current.height,
|
||||
settings.postRotationDegrees
|
||||
)
|
||||
val cropRegion = copied.normalizedCropRect
|
||||
?.takeIf { cropWidth > 0 && cropHeight > 0 }
|
||||
?.let { rect ->
|
||||
android.graphics.Rect(
|
||||
(rect.left * cropWidth).roundToInt(),
|
||||
(rect.top * cropHeight).roundToInt(),
|
||||
(rect.right * cropWidth).roundToInt(),
|
||||
(rect.bottom * cropHeight).roundToInt()
|
||||
)
|
||||
}
|
||||
|
||||
return current.copy(
|
||||
lutId = settings.lutId,
|
||||
frameId = settings.frameId,
|
||||
customProperties = settings.customProperties.toMap(),
|
||||
colorRecipeParams = settings.colorRecipeParams?.deepCopy(),
|
||||
sharpening = if (copyDetailProcessing && settings.sharpening != null) {
|
||||
settings.sharpening
|
||||
} else {
|
||||
current.sharpening
|
||||
},
|
||||
noiseReduction =
|
||||
if (copyDetailProcessing && settings.noiseReduction != null) {
|
||||
settings.noiseReduction
|
||||
} else {
|
||||
current.noiseReduction
|
||||
},
|
||||
chromaNoiseReduction =
|
||||
if (copyDetailProcessing && settings.chromaNoiseReduction != null) {
|
||||
settings.chromaNoiseReduction
|
||||
} else {
|
||||
current.chromaNoiseReduction
|
||||
},
|
||||
computationalAperture = settings.computationalAperture,
|
||||
focusPointX = settings.focusPointX,
|
||||
focusPointY = settings.focusPointY,
|
||||
postCropRegion = cropRegion,
|
||||
postRotationDegrees =
|
||||
PostEditGeometry.normalizeRotation(settings.postRotationDegrees),
|
||||
postMirrorHorizontal = settings.postMirrorHorizontal,
|
||||
applyEffectsToVideo = settings.applyEffectsToVideo
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 从详情页将剪贴板设置直接保存到当前照片,不进入编辑模式。
|
||||
*/
|
||||
fun pasteCopiedSettingsToPhoto(
|
||||
photo: MediaData,
|
||||
onComplete: (Boolean) -> Unit = {}
|
||||
) {
|
||||
val copied = copiedEditSettings ?: run {
|
||||
onComplete(false)
|
||||
return
|
||||
}
|
||||
val selectedTabSnapshot = selectedTab
|
||||
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
val context = getApplication<Application>()
|
||||
val result = withContext(Dispatchers.IO) {
|
||||
val targetPhotoId = if (selectedTabSnapshot == GalleryTab.SYSTEM) {
|
||||
photo.relatedPhoto?.id
|
||||
?: findPhotonPhotoBySourceUri(photo.uri)?.id
|
||||
?: GalleryManager.importPhoto(context, photo.uri, null)
|
||||
} else {
|
||||
photo.id
|
||||
} ?: return@withContext null
|
||||
|
||||
val targetIsRaw =
|
||||
GalleryManager.getDngFile(context, targetPhotoId).exists()
|
||||
val fallbackMetadata = photo.relatedPhoto?.metadata
|
||||
?: photo.metadata
|
||||
?: MediaMetadata(
|
||||
mediaType = photo.mediaType,
|
||||
width = photo.width,
|
||||
height = photo.height
|
||||
)
|
||||
val updated = GalleryManager.updateMetadata(
|
||||
context,
|
||||
targetPhotoId
|
||||
) { latest ->
|
||||
val metadataWithResolvedSize =
|
||||
if (latest.width > 0 && latest.height > 0) {
|
||||
latest
|
||||
} else {
|
||||
latest.copy(
|
||||
width = fallbackMetadata.width,
|
||||
height = fallbackMetadata.height
|
||||
)
|
||||
}
|
||||
applyCopiedEditSettings(
|
||||
current = metadataWithResolvedSize,
|
||||
copied = copied,
|
||||
copyDetailProcessing = !targetIsRaw
|
||||
)
|
||||
} ?: return@withContext null
|
||||
|
||||
invalidatePreviewCache(targetPhotoId)
|
||||
GalleryManager.deleteDetailHdrFile(context, targetPhotoId)
|
||||
GalleryManager.queueDetailHdrCacheBuild(
|
||||
context = context,
|
||||
photoId = targetPhotoId,
|
||||
metadata = updated,
|
||||
sharpening = updated.sharpening ?: 0f,
|
||||
noiseReduction = updated.noiseReduction ?: 0f,
|
||||
chromaNoiseReduction = updated.chromaNoiseReduction ?: 0f
|
||||
)
|
||||
GalleryManager.updateThumbnail(
|
||||
context = context,
|
||||
photoId = targetPhotoId,
|
||||
photoProcessor = contentRepository.photoProcessor,
|
||||
metadata = updated
|
||||
)
|
||||
targetPhotoId to updated
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
onComplete(false)
|
||||
return@launch
|
||||
}
|
||||
val (targetPhotoId, updated) = result
|
||||
currentMediaMetadata = updated
|
||||
currentPhotoMetadataId = photo.id
|
||||
photo.relatedPhoto?.metadata = updated
|
||||
if (selectedTabSnapshot == GalleryTab.PHOTON) {
|
||||
photo.metadata = updated
|
||||
}
|
||||
applyPhotoMetadataUpdateToMemory(targetPhotoId, updated)
|
||||
if (selectedTabSnapshot == GalleryTab.SYSTEM) {
|
||||
loadPhotos(reset = true)
|
||||
_photos.value.firstOrNull { it.id == targetPhotoId }?.let {
|
||||
linkSystemPhotoToPhoton(photo.id, it)
|
||||
}
|
||||
}
|
||||
photoRefreshKeys[targetPhotoId] = System.currentTimeMillis()
|
||||
onComplete(true)
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to paste settings to photo ${photo.id}", e)
|
||||
onComplete(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将剪贴板中的设置批量应用到选中的照片。系统相册照片会先建立 Photon 副本,
|
||||
* 使粘贴保持非破坏性,并与单张编辑保存使用同一份元数据链路。
|
||||
*/
|
||||
fun pasteCopiedSettingsToSelectedPhotos(
|
||||
onComplete: (successCount: Int, total: Int) -> Unit = { _, _ -> }
|
||||
) {
|
||||
if (_isExporting.value || _isPastingSettings.value) return
|
||||
val copied = copiedEditSettings ?: run {
|
||||
onComplete(0, 0)
|
||||
return
|
||||
}
|
||||
val selectedSnapshot = selectedPhotos.filter { it.isImage }
|
||||
if (selectedSnapshot.isEmpty()) {
|
||||
onComplete(0, 0)
|
||||
return
|
||||
}
|
||||
val selectedTabSnapshot = selectedTab
|
||||
|
||||
viewModelScope.launch {
|
||||
_isPastingSettings.value = true
|
||||
val total = selectedSnapshot.size
|
||||
pasteSettingsProgress = 0 to total
|
||||
_batchOperationProgress.value = GalleryBatchOperationProgress(
|
||||
operation = GalleryBatchOperation.PASTE_SETTINGS,
|
||||
completed = 0,
|
||||
total = total
|
||||
)
|
||||
var successCount = 0
|
||||
|
||||
try {
|
||||
val context = getApplication<Application>()
|
||||
withContext(Dispatchers.IO) {
|
||||
selectedSnapshot.forEachIndexed { index, photo ->
|
||||
var refreshedPhotoId: String? = null
|
||||
try {
|
||||
val targetPhotoId = if (selectedTabSnapshot == GalleryTab.SYSTEM) {
|
||||
photo.relatedPhoto?.id
|
||||
?: findPhotonPhotoBySourceUri(photo.uri)?.id
|
||||
?: GalleryManager.importPhoto(context, photo.uri, null)
|
||||
} else {
|
||||
photo.id
|
||||
}
|
||||
if (targetPhotoId != null) {
|
||||
val targetIsRaw =
|
||||
GalleryManager.getDngFile(context, targetPhotoId).exists()
|
||||
val current = GalleryManager.loadMetadata(context, targetPhotoId)
|
||||
?: photo.relatedPhoto?.metadata
|
||||
?: photo.metadata
|
||||
?: MediaMetadata(
|
||||
width = photo.width,
|
||||
height = photo.height,
|
||||
mediaType = photo.mediaType
|
||||
)
|
||||
val updated = GalleryManager.updateMetadata(
|
||||
context,
|
||||
targetPhotoId
|
||||
) { latest ->
|
||||
val metadataWithResolvedSize =
|
||||
if (latest.width > 0 && latest.height > 0) {
|
||||
latest
|
||||
} else {
|
||||
latest.copy(
|
||||
width = current.width,
|
||||
height = current.height
|
||||
)
|
||||
}
|
||||
applyCopiedEditSettings(
|
||||
metadataWithResolvedSize,
|
||||
copied,
|
||||
copyDetailProcessing = !targetIsRaw
|
||||
)
|
||||
}
|
||||
if (updated != null) {
|
||||
invalidatePreviewCache(targetPhotoId)
|
||||
GalleryManager.deleteDetailHdrFile(context, targetPhotoId)
|
||||
GalleryManager.queueDetailHdrCacheBuild(
|
||||
context = context,
|
||||
photoId = targetPhotoId,
|
||||
metadata = updated,
|
||||
sharpening = updated.sharpening ?: 0f,
|
||||
noiseReduction = updated.noiseReduction ?: 0f,
|
||||
chromaNoiseReduction =
|
||||
updated.chromaNoiseReduction ?: 0f
|
||||
)
|
||||
GalleryManager.updateThumbnail(
|
||||
context = context,
|
||||
photoId = targetPhotoId,
|
||||
photoProcessor = contentRepository.photoProcessor,
|
||||
metadata = updated
|
||||
)
|
||||
refreshedPhotoId = targetPhotoId
|
||||
successCount += 1
|
||||
}
|
||||
}
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
PLog.e(
|
||||
TAG,
|
||||
"Failed to paste settings to selected photo ${photo.id}",
|
||||
e
|
||||
)
|
||||
} finally {
|
||||
withContext(Dispatchers.Main) {
|
||||
val completed = index + 1
|
||||
pasteSettingsProgress = completed to total
|
||||
_batchOperationProgress.value =
|
||||
GalleryBatchOperationProgress(
|
||||
operation =
|
||||
GalleryBatchOperation.PASTE_SETTINGS,
|
||||
completed = completed,
|
||||
total = total
|
||||
)
|
||||
refreshedPhotoId?.let { photoId ->
|
||||
photoRefreshKeys[photoId] = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exitSelectionMode()
|
||||
loadPhotos(reset = true)
|
||||
onComplete(successCount, total)
|
||||
} finally {
|
||||
_isPastingSettings.value = false
|
||||
pasteSettingsProgress = 0 to 0
|
||||
_batchOperationProgress.value = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量导出选中的照片
|
||||
*/
|
||||
fun exportSelectedPhotos(onComplete: (Int) -> Unit = {}) {
|
||||
if (_isExporting.value || _isPastingSettings.value) return
|
||||
val selectedSnapshot = selectedPhotos.toList()
|
||||
if (selectedSnapshot.isEmpty()) return
|
||||
val toExport = selectedSnapshot.filter { it.isImage }
|
||||
if (toExport.isEmpty()) {
|
||||
onComplete(0)
|
||||
return
|
||||
}
|
||||
val selectedTabSnapshot = selectedTab
|
||||
|
||||
viewModelScope.launch {
|
||||
_isExporting.value = true
|
||||
val toExport = selectedSnapshot.filter { it.isImage }
|
||||
val total = toExport.size
|
||||
exportProgress = 0 to total
|
||||
_batchOperationProgress.value = GalleryBatchOperationProgress(
|
||||
operation = GalleryBatchOperation.EXPORT,
|
||||
completed = 0,
|
||||
total = total
|
||||
)
|
||||
var successCount = 0
|
||||
|
||||
try {
|
||||
val context = getApplication<Application>()
|
||||
@@ -3449,33 +3954,67 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
toExport.forEachIndexed { index, photo ->
|
||||
var photoId = photo.id
|
||||
// 如果在系统相册 Tab,导出其关联的照片
|
||||
if (selectedTab == GalleryTab.SYSTEM) {
|
||||
photoId = photo.relatedPhoto?.id ?: return@forEachIndexed
|
||||
}
|
||||
val metadata = GalleryManager.loadMetadata(context, photoId) ?: photo.metadata ?: MediaMetadata()
|
||||
GalleryManager.exportPhoto(
|
||||
context, photoId, null, contentRepository.photoProcessor, metadata,
|
||||
sharpening.value, noiseReduction.value,
|
||||
chromaNoiseReduction.value, quality
|
||||
)
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
exportProgress = (index + 1) to total
|
||||
try {
|
||||
val photoId = if (selectedTabSnapshot == GalleryTab.SYSTEM) {
|
||||
photo.relatedPhoto?.id
|
||||
} else {
|
||||
photo.id
|
||||
}
|
||||
if (photoId != null) {
|
||||
val metadata = GalleryManager.loadMetadata(context, photoId)
|
||||
?: photo.relatedPhoto?.metadata
|
||||
?: photo.metadata
|
||||
?: MediaMetadata()
|
||||
val exported = GalleryManager.exportPhoto(
|
||||
context,
|
||||
photoId,
|
||||
null,
|
||||
contentRepository.photoProcessor,
|
||||
metadata,
|
||||
sharpening.value,
|
||||
noiseReduction.value,
|
||||
chromaNoiseReduction.value,
|
||||
quality
|
||||
)
|
||||
if (exported) {
|
||||
successCount += 1
|
||||
}
|
||||
}
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
PLog.e(
|
||||
TAG,
|
||||
"Failed to export selected photo ${photo.id}",
|
||||
e
|
||||
)
|
||||
} finally {
|
||||
withContext(Dispatchers.Main) {
|
||||
val completed = index + 1
|
||||
exportProgress = completed to total
|
||||
_batchOperationProgress.value =
|
||||
GalleryBatchOperationProgress(
|
||||
operation = GalleryBatchOperation.EXPORT,
|
||||
completed = completed,
|
||||
total = total
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exitSelectionMode()
|
||||
loadPhotos()
|
||||
onComplete(total)
|
||||
onComplete(successCount)
|
||||
} catch (e: CancellationException) {
|
||||
throw e
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to batch export photos", e)
|
||||
onComplete(0)
|
||||
} finally {
|
||||
_isExporting.value = false
|
||||
exportProgress = 0 to 0
|
||||
_batchOperationProgress.value = null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,6 +579,15 @@
|
||||
|
||||
<!-- 邊框匯入幫助 -->
|
||||
<string name="more_options">更多操作</string>
|
||||
<string name="copy_settings">複製設定</string>
|
||||
<string name="paste_settings">貼上設定</string>
|
||||
<string name="copy_settings_success">已複製設定</string>
|
||||
<string name="paste_settings_success">已貼上設定</string>
|
||||
<string name="copy_settings_failed">複製設定失敗</string>
|
||||
<string name="paste_settings_failed">貼上設定失敗</string>
|
||||
<string name="paste_settings_complete">已向 %2$d 張相片中的 %1$d 張貼上設定</string>
|
||||
<string name="pasting_settings_progress">正在貼上設定 · %1$d/%2$d</string>
|
||||
<string name="exporting_progress">正在匯出 · %1$d/%2$d</string>
|
||||
<string name="discard">放棄</string>
|
||||
<string name="frame_editor_create_menu">創建或匯入邊框</string>
|
||||
<string name="frame_editor_new_title">新建邊框樣式</string>
|
||||
|
||||
@@ -579,6 +579,15 @@
|
||||
|
||||
<!-- 边框导入帮助 -->
|
||||
<string name="more_options">更多操作</string>
|
||||
<string name="copy_settings">复制设置</string>
|
||||
<string name="paste_settings">粘贴设置</string>
|
||||
<string name="copy_settings_success">已复制设置</string>
|
||||
<string name="paste_settings_success">已粘贴设置</string>
|
||||
<string name="copy_settings_failed">复制设置失败</string>
|
||||
<string name="paste_settings_failed">粘贴设置失败</string>
|
||||
<string name="paste_settings_complete">已向 %2$d 张照片中的 %1$d 张粘贴设置</string>
|
||||
<string name="pasting_settings_progress">正在粘贴设置 · %1$d/%2$d</string>
|
||||
<string name="exporting_progress">正在导出 · %1$d/%2$d</string>
|
||||
<string name="discard">放弃</string>
|
||||
<string name="frame_editor_create_menu">创建或导入边框</string>
|
||||
<string name="frame_editor_new_title">新建边框样式</string>
|
||||
|
||||
@@ -579,6 +579,15 @@
|
||||
|
||||
<!-- 邊框匯入幫助 -->
|
||||
<string name="more_options">更多操作</string>
|
||||
<string name="copy_settings">複製設定</string>
|
||||
<string name="paste_settings">貼上設定</string>
|
||||
<string name="copy_settings_success">已複製設定</string>
|
||||
<string name="paste_settings_success">已貼上設定</string>
|
||||
<string name="copy_settings_failed">複製設定失敗</string>
|
||||
<string name="paste_settings_failed">貼上設定失敗</string>
|
||||
<string name="paste_settings_complete">已向 %2$d 張相片中的 %1$d 張貼上設定</string>
|
||||
<string name="pasting_settings_progress">正在貼上設定 · %1$d/%2$d</string>
|
||||
<string name="exporting_progress">正在匯出 · %1$d/%2$d</string>
|
||||
<string name="discard">放棄</string>
|
||||
<string name="frame_editor_create_menu">創建或匯入邊框</string>
|
||||
<string name="frame_editor_new_title">新建邊框樣式</string>
|
||||
|
||||
@@ -579,6 +579,15 @@
|
||||
|
||||
<!-- 邊框匯入幫助 -->
|
||||
<string name="more_options">更多操作</string>
|
||||
<string name="copy_settings">複製設定</string>
|
||||
<string name="paste_settings">貼上設定</string>
|
||||
<string name="copy_settings_success">已複製設定</string>
|
||||
<string name="paste_settings_success">已貼上設定</string>
|
||||
<string name="copy_settings_failed">複製設定失敗</string>
|
||||
<string name="paste_settings_failed">貼上設定失敗</string>
|
||||
<string name="paste_settings_complete">已向 %2$d 張相片中的 %1$d 張貼上設定</string>
|
||||
<string name="pasting_settings_progress">正在貼上設定 · %1$d/%2$d</string>
|
||||
<string name="exporting_progress">正在匯出 · %1$d/%2$d</string>
|
||||
<string name="discard">放棄</string>
|
||||
<string name="frame_editor_create_menu">創建或匯入邊框</string>
|
||||
<string name="frame_editor_new_title">新建邊框樣式</string>
|
||||
|
||||
@@ -589,6 +589,15 @@
|
||||
|
||||
<!-- Frame Import Help -->
|
||||
<string name="more_options">More options</string>
|
||||
<string name="copy_settings">Copy settings</string>
|
||||
<string name="paste_settings">Paste settings</string>
|
||||
<string name="copy_settings_success">Settings copied</string>
|
||||
<string name="paste_settings_success">Settings pasted</string>
|
||||
<string name="copy_settings_failed">Couldn’t copy settings</string>
|
||||
<string name="paste_settings_failed">Couldn’t paste settings</string>
|
||||
<string name="paste_settings_complete">Settings pasted to %1$d of %2$d photos</string>
|
||||
<string name="pasting_settings_progress">Pasting settings · %1$d/%2$d</string>
|
||||
<string name="exporting_progress">Exporting · %1$d/%2$d</string>
|
||||
<string name="discard">Discard</string>
|
||||
<string name="frame_editor_create_menu">Create or import frame</string>
|
||||
<string name="frame_editor_new_title">New Frame</string>
|
||||
|
||||
Reference in new issue
Block a user