diff --git a/app/src/main/java/com/hinnka/mycamera/ui/settings/FilterManagementScreen.kt b/app/src/main/java/com/hinnka/mycamera/ui/settings/FilterManagementScreen.kt index 5fc564d7..326607a6 100644 --- a/app/src/main/java/com/hinnka/mycamera/ui/settings/FilterManagementScreen.kt +++ b/app/src/main/java/com/hinnka/mycamera/ui/settings/FilterManagementScreen.kt @@ -28,6 +28,7 @@ import androidx.compose.ui.unit.sp import com.hinnka.mycamera.R import com.hinnka.mycamera.lut.LutInfo import com.hinnka.mycamera.ui.camera.autoRotate +import com.hinnka.mycamera.ui.camera.LutEditBottomSheet import com.hinnka.mycamera.viewmodel.CameraViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -72,6 +73,10 @@ fun FilterManagementScreen( // 导入状态 var isImporting by remember { mutableStateOf(false) } + // 色彩配方编辑状态 + var showColorRecipeSheet by remember { mutableStateOf(false) } + var editingLutId by remember { mutableStateOf(null) } + // 文件选择器 val lutFilePicker = rememberLauncherForActivityResult( contract = ActivityResultContracts.OpenDocument() @@ -183,6 +188,10 @@ fun FilterManagementScreen( showRenameDialog = true } } else null, + onEditColorRecipe = { + editingLutId = lutInfo.id + showColorRecipeSheet = true + }, onDelete = if (!lutInfo.isBuiltIn) { { deletingLut = lutInfo @@ -283,6 +292,17 @@ fun FilterManagementScreen( viewModel.saveFilterOrder(localLutList.map { it.id }) } } + + // 色彩配方编辑底部弹窗 + if (showColorRecipeSheet && editingLutId != null) { + LutEditBottomSheet( + lutId = editingLutId!!, + onDismiss = { + showColorRecipeSheet = false + editingLutId = null + } + ) + } } /** @@ -295,6 +315,7 @@ private fun FilterManagementItem( isDragging: Boolean, onSetDefault: () -> Unit, onRename: (() -> Unit)?, + onEditColorRecipe: (() -> Unit)?, onDelete: (() -> Unit)?, modifier: Modifier = Modifier ) { @@ -389,6 +410,21 @@ private fun FilterManagementItem( } } + // 色彩配方编辑按钮 + if (onEditColorRecipe != null) { + IconButton( + onClick = onEditColorRecipe, + modifier = Modifier.size(36.dp) + ) { + Icon( + imageVector = Icons.Default.Tune, + contentDescription = stringResource(R.string.color_recipe), + tint = Color.White.copy(alpha = 0.7f), + modifier = Modifier.size(20.dp) + ) + } + } + // 操作按钮(仅自定义滤镜) if (onRename != null) { IconButton( diff --git a/app/src/main/java/com/hinnka/mycamera/ui/settings/FrameManagementScreen.kt b/app/src/main/java/com/hinnka/mycamera/ui/settings/FrameManagementScreen.kt index e3e4c976..825cd1a0 100644 --- a/app/src/main/java/com/hinnka/mycamera/ui/settings/FrameManagementScreen.kt +++ b/app/src/main/java/com/hinnka/mycamera/ui/settings/FrameManagementScreen.kt @@ -3,11 +3,14 @@ package com.hinnka.mycamera.ui.settings import android.net.Uri import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts +import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.foundation.lazy.LazyRow +import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.itemsIndexed import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.shape.RoundedCornerShape @@ -27,7 +30,9 @@ import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp import com.hinnka.mycamera.R import com.hinnka.mycamera.frame.FrameInfo +import com.hinnka.mycamera.frame.TextType import com.hinnka.mycamera.ui.camera.autoRotate +import com.hinnka.mycamera.ui.theme.AccentOrange import com.hinnka.mycamera.viewmodel.CameraViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -78,6 +83,10 @@ fun FrameManagementScreen( // 帮助对话框状态 var showHelpDialog by remember { mutableStateOf(false) } + // 自定义属性编辑状态 + var showFrameEditSheet by remember { mutableStateOf(false) } + var editingFrameId by remember { mutableStateOf(null) } + // JSON 边框配置文件选择器 val frameJsonPicker = rememberLauncherForActivityResult( contract = ActivityResultContracts.OpenDocument() @@ -216,6 +225,7 @@ fun FrameManagementScreen( viewModel.setFrame(null) }, onRename = null, + onEditProperties = null, onDelete = null ) } @@ -238,6 +248,12 @@ fun FrameManagementScreen( showRenameDialog = true } } else null, + onEditProperties = if (frameInfo.isEditable) { + { + editingFrameId = frameInfo.id + showFrameEditSheet = true + } + } else null, onDelete = if (!frameInfo.isBuiltIn) { { deletingFrame = frameInfo @@ -356,6 +372,18 @@ fun FrameManagementScreen( viewModel.saveFrameOrder(localFrameList.map { it.id }) } } + + // 自定义属性编辑底部弹窗 + if (showFrameEditSheet && editingFrameId != null) { + FrameEditBottomSheet( + viewModel = viewModel, + frameId = editingFrameId!!, + onDismiss = { + showFrameEditSheet = false + editingFrameId = null + } + ) + } } /** @@ -370,6 +398,7 @@ private fun FrameManagementItem( canDrag: Boolean, onSetDefault: () -> Unit, onRename: (() -> Unit)?, + onEditProperties: (() -> Unit)?, onDelete: (() -> Unit)?, modifier: Modifier = Modifier ) { @@ -453,6 +482,21 @@ private fun FrameManagementItem( } } + // 自定义属性编辑按钮(仅可编辑边框) + if (onEditProperties != null) { + IconButton( + onClick = onEditProperties, + modifier = Modifier.size(36.dp) + ) { + Icon( + imageVector = Icons.Default.Tune, + contentDescription = stringResource(R.string.watermark_adjustment), + tint = Color.White.copy(alpha = 0.7f), + modifier = Modifier.size(20.dp) + ) + } + } + // 操作按钮(仅自定义边框) if (onRename != null) { IconButton( @@ -483,3 +527,137 @@ private fun FrameManagementItem( } } } + +/** + * 边框自定义属性编辑底部弹窗 + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +private fun FrameEditBottomSheet( + viewModel: CameraViewModel, + frameId: String, + onDismiss: () -> Unit +) { + val scope = rememberCoroutineScope() + val sheetState = rememberModalBottomSheetState() + val customProperties = remember(frameId) { + mutableStateMapOf() + } + + // 加载已保存的自定义属性 + LaunchedEffect(frameId) { + val savedProperties = withContext(Dispatchers.IO) { + viewModel.getFrameCustomProperties(frameId) + } + customProperties.clear() + customProperties.putAll(savedProperties) + } + + ModalBottomSheet( + onDismissRequest = { + // 关闭时保存属性 + scope.launch { + withContext(Dispatchers.IO) { + viewModel.saveFrameCustomProperties(frameId, customProperties.toMap()) + } + } + onDismiss() + }, + sheetState = sheetState, + containerColor = Color(0xFF1A1A1A), + contentColor = Color.White, + scrimColor = Color.Transparent + ) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(16.dp) + .padding(bottom = 32.dp) + ) { + Text( + text = stringResource(R.string.watermark_adjustment), + fontSize = 18.sp, + fontWeight = FontWeight.Bold, + modifier = Modifier.padding(bottom = 16.dp) + ) + + // Logo 选择 + Text( + text = stringResource(R.string.logo), + fontSize = 14.sp, + color = Color.White.copy(alpha = 0.6f), + modifier = Modifier.padding(bottom = 8.dp) + ) + + val logos = listOf( + "none" to stringResource(R.string.none), + "apple" to "Apple", + "leica" to "Leica", + "hasselblad" to "Hasselblad", + "sony" to "Sony", + "canon" to "Canon", + "nikon" to "Nikon", + "fujifilm" to "Fujifilm", + "xiaomi" to "Xiaomi", + "huawei" to "Huawei", + "oppo" to "OPPO", + "vivo" to "Vivo" + ) + + val effectiveLogo = customProperties["LOGO"] ?: "none" + + LazyRow( + horizontalArrangement = Arrangement.spacedBy(8.dp), + modifier = Modifier.padding(bottom = 16.dp) + ) { + items(logos) { (id, name) -> + val isSelected = effectiveLogo == id + Surface( + onClick = { customProperties["LOGO"] = id }, + color = if (isSelected) AccentOrange.copy(alpha = 0.2f) else Color.White.copy(alpha = 0.1f), + shape = RoundedCornerShape(8.dp), + border = if (isSelected) BorderStroke(1.dp, AccentOrange) else null + ) { + Text( + text = name, + modifier = Modifier.padding(horizontal = 12.dp, vertical = 6.dp), + fontSize = 13.sp, + color = if (isSelected) AccentOrange else Color.White + ) + } + } + } + + // 文字默认值编辑 + Text( + text = stringResource(R.string.text_content), + fontSize = 14.sp, + color = Color.White.copy(alpha = 0.6f), + modifier = Modifier.padding(bottom = 8.dp) + ) + + val textTypes = listOf( + TextType.DEVICE_MODEL to stringResource(R.string.device_model), + TextType.BRAND to stringResource(R.string.brand_name) + ) + + textTypes.forEach { (type, label) -> + OutlinedTextField( + value = customProperties[type.name] ?: "", + onValueChange = { customProperties[type.name] = it }, + label = { Text(label) }, + placeholder = { Text(stringResource(R.string.default_from_photo)) }, + modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp), + colors = OutlinedTextFieldDefaults.colors( + focusedBorderColor = AccentOrange, + unfocusedBorderColor = Color.White.copy(alpha = 0.2f), + focusedLabelColor = AccentOrange, + unfocusedLabelColor = Color.White.copy(alpha = 0.5f), + cursorColor = AccentOrange + ), + singleLine = true + ) + } + } + } +} diff --git a/app/src/main/java/com/hinnka/mycamera/viewmodel/CameraViewModel.kt b/app/src/main/java/com/hinnka/mycamera/viewmodel/CameraViewModel.kt index 3b98700a..33542bfa 100644 --- a/app/src/main/java/com/hinnka/mycamera/viewmodel/CameraViewModel.kt +++ b/app/src/main/java/com/hinnka/mycamera/viewmodel/CameraViewModel.kt @@ -675,6 +675,20 @@ class CameraViewModel(application: Application) : AndroidViewModel(application) } } + /** + * 获取边框的自定义属性 + */ + suspend fun getFrameCustomProperties(frameId: String): Map { + return contentRepository.frameManager.loadCustomProperties(frameId) + } + + /** + * 保存边框的自定义属性 + */ + suspend fun saveFrameCustomProperties(frameId: String, properties: Map) { + contentRepository.frameManager.saveCustomProperties(frameId, properties) + } + /** * 设置是否显示直方图 */ diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 90be6c9b..817c7177 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -85,6 +85,7 @@ 日期 (DATE) 时间 (TIME) 日期时间 (DATETIME) + 默认读取照片信息 设置 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 552855b8..46107261 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -86,6 +86,7 @@ Date (DATE) Time (TIME) Date/Time (DATETIME) + Default from photo Settings