feat: frame for phantom

This commit is contained in:
zhoubinjia committed 2026-07-30 17:07:54 +08:00
1 parent b330e6e9c7
commit d9dbc1c0b4
11 files changed
+71 -9

No files matched your search

@@ -134,6 +134,7 @@ data class UserPreferences(
val rawCfaCorrectionModes: Map<String, String> = emptyMap(),
val exportDngWithRawExport: Boolean = false,
val frameId: String? = null,
val phantomFrameId: String? = null,
val showHistogram: Boolean = true,
val showGrid: Boolean = false, // 网格线显示
val showLevelIndicator: Boolean = false, // 水平仪显示
@@ -341,6 +342,7 @@ class UserPreferencesRepository(private val context: Context) {
private val EXPORT_DNG_WITH_RAW_EXPORT_KEY = booleanPreferencesKey("export_dng_with_raw_export")
private val PHANTOM_BASELINE_LUT_ID_KEY = stringPreferencesKey("phantom_baseline_lut_id")
private val FRAME_ID_KEY = stringPreferencesKey("frame_id")
private val PHANTOM_FRAME_ID_KEY = stringPreferencesKey("phantom_frame_id")
private val SHOW_HISTOGRAM = booleanPreferencesKey("show_histogram")
private val SHOW_GRID = booleanPreferencesKey("show_grid")
private val SHOW_LEVEL_INDICATOR = booleanPreferencesKey("show_level_indicator")
@@ -555,6 +557,7 @@ class UserPreferencesRepository(private val context: Context) {
exportDngWithRawExport = preferences[EXPORT_DNG_WITH_RAW_EXPORT_KEY] ?: false,
phantomBaselineLutId = preferences[PHANTOM_BASELINE_LUT_ID_KEY],
frameId = preferences[FRAME_ID_KEY],
phantomFrameId = preferences[PHANTOM_FRAME_ID_KEY],
showHistogram = preferences[SHOW_HISTOGRAM] ?: true,
showGrid = preferences[SHOW_GRID] ?: false,
showLevelIndicator = preferences[SHOW_LEVEL_INDICATOR] ?: false,
@@ -1283,6 +1286,19 @@ class UserPreferencesRepository(private val context: Context) {
}
}
/**
* 保存幻影模式独立使用的边框。
*/
suspend fun savePhantomFrameConfig(frameId: String?) {
context.dataStore.edit { preferences ->
if (frameId != null) {
preferences[PHANTOM_FRAME_ID_KEY] = frameId
} else {
preferences.remove(PHANTOM_FRAME_ID_KEY)
}
}
}
/**
* 保存是否显示直方图
*/
@@ -588,6 +588,7 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
val lutId = preferences?.lutId
?: availableLutList.firstOrNull { it.isDefault }?.id
val saveAsNew = preferences?.phantomSaveAsNew ?: false
val phantomFrameId = preferences?.phantomFrameId
val computationalAperture = preferences?.defaultVirtualAperture?.let { if (it > 0f) it else null }
val existingPhotoId = if (processingInfo?.uri == uri) processingInfo?.photoId else null
val isRawSource = isRawMedia(name, mimeType)
@@ -621,6 +622,7 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
if (baselineTarget != null) {
current.copy(
lutId = lutId,
frameId = phantomFrameId,
colorRecipeParams = metadataCreativeColorRecipeParams,
baselineTarget = baselineTarget,
baselineLutId = baselineLutId,
@@ -629,6 +631,7 @@ class PhantomService(val context: Context) : LifecycleOwner, SavedStateRegistryO
} else {
current.copy(
lutId = lutId,
frameId = phantomFrameId,
colorRecipeParams = metadataCreativeColorRecipeParams,
baselineTarget = null,
baselineLutId = null,
@@ -55,6 +55,7 @@ fun FrameManagementScreen(
modifier: Modifier = Modifier
) {
val currentFrameId = viewModel.currentFrameId
val phantomFrameId by viewModel.phantomFrameId.collectAsState()
val availableFrames = viewModel.availableFrameList
val customImportManager = viewModel.getCustomImportManager()
val scope = rememberCoroutineScope()
@@ -421,6 +422,9 @@ fun FrameManagementScreen(
if (currentFrameId == deletingFrame!!.id) {
viewModel.setFrame(null)
}
if (phantomFrameId == deletingFrame!!.id) {
viewModel.setPhantomFrame(null)
}
viewModel.refreshCustomContent()
showDeleteDialog = false
deletingFrame = null
@@ -330,6 +330,7 @@ fun SettingsScreen(
val availableOpenAIModels by viewModel.availableOpenAIModels.collectAsState()
val isFetchingAIModels by viewModel.isFetchingAIModels.collectAsState()
val phantomSaveAsNew by viewModel.phantomSaveAsNew.collectAsState()
val phantomFrameId by viewModel.phantomFrameId.collectAsState()
val defaultVirtualAperture by viewModel.defaultVirtualAperture.collectAsState(initial = 0f)
val jpgBaselineLutId by viewModel.jpgBaselineLutId.collectAsState()
val rawBaselineLutId by viewModel.rawBaselineLutId.collectAsState()
@@ -361,6 +362,7 @@ fun SettingsScreen(
val rawMaxOutputScale by viewModel.rawMaxOutputScale.collectAsState()
val availableDcps = viewModel.availableDcps
val availableLuts = viewModel.availableLutList
val availableFrames = viewModel.availableFrameList
val previewThumbnail = viewModel.previewThumbnail
var selectedPage by remember { mutableStateOf<SettingsPage?>(null) }
@@ -2029,6 +2031,19 @@ fun SettingsScreen(
modifier = Modifier.padding(vertical = 12.dp)
)
FrameWatermarkSetting(
title = stringResource(R.string.settings_phantom_frame_title),
description = stringResource(R.string.settings_phantom_frame_description),
availableFrames = availableFrames,
currentFrameId = phantomFrameId,
onFrameSelected = viewModel::setPhantomFrame
)
HorizontalDivider(
color = Color.White.copy(alpha = 0.1f),
modifier = Modifier.padding(vertical = 12.dp)
)
BaselineColorCorrectionSettingItem(
title = stringResource(R.string.settings_baseline_phantom_title),
description = stringResource(R.string.settings_baseline_phantom_description),
@@ -2724,6 +2739,7 @@ private fun SettingsCategoryOverview(
description = listOf(
stringResource(R.string.settings_phantom_pip_preview),
stringResource(R.string.settings_phantom_save_as_new),
stringResource(R.string.settings_phantom_frame_title),
stringResource(R.string.settings_baseline_phantom_title)
).joinToString(" · "),
onClick = { onPageSelected(SettingsPage.PHANTOM) }
@@ -3572,6 +3588,8 @@ fun NavigationSettingItem(
*/
@Composable
fun FrameWatermarkSetting(
title: String,
description: String,
availableFrames: List<FrameInfo>,
currentFrameId: String?,
onFrameSelected: (String?) -> Unit,
@@ -3580,18 +3598,18 @@ fun FrameWatermarkSetting(
val frameScrollState = rememberLazyListState()
LaunchedEffect(currentFrameId) {
currentFrameId?.let { lutId ->
val selectedIndex = availableFrames.indexOfFirst { it.id == lutId }
if (selectedIndex >= 1) {
frameScrollState.animateScrollToItem(selectedIndex - 1)
}
}
LaunchedEffect(currentFrameId, availableFrames) {
val selectedIndex = currentFrameId
?.let { frameId -> availableFrames.indexOfFirst { it.id == frameId } }
?.takeIf { it >= 0 }
?.plus(1)
?: 0
frameScrollState.animateScrollToItem(selectedIndex)
}
Column(modifier = modifier.fillMaxWidth()) {
Text(
text = stringResource(R.string.settings_frame_style),
text = title,
color = Color.White,
fontSize = 16.sp,
fontWeight = FontWeight.Normal,
@@ -3629,7 +3647,7 @@ fun FrameWatermarkSetting(
Spacer(modifier = Modifier.height(12.dp))
Text(
text = stringResource(R.string.settings_frame_description),
text = description,
color = Color.White.copy(alpha = 0.6f),
fontSize = 13.sp
)
@@ -1177,6 +1177,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
val phantomBaselineLutId: StateFlow<String?> = userPreferencesRepository.userPreferences
.map { it.phantomBaselineLutId }
.stateIn(viewModelScope, SharingStarted.Eagerly, null)
val phantomFrameId: StateFlow<String?> = userPreferencesRepository.userPreferences
.map { it.phantomFrameId }
.stateIn(viewModelScope, SharingStarted.Eagerly, null)
val rawDcpId: StateFlow<String?> = userPreferencesRepository.userPreferences
.map { it.rawDcpId }
.stateIn(viewModelScope, SharingStarted.Eagerly, null)
@@ -6195,6 +6198,12 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
}
}
fun setPhantomFrame(frameId: String?) {
viewModelScope.launch {
userPreferencesRepository.savePhantomFrameConfig(frameId)
}
}
fun setDefaultVirtualAperture(aperture: Float) {
viewModelScope.launch {
userPreferencesRepository.saveDefaultVirtualAperture(aperture)
@@ -912,6 +912,8 @@
<string name="settings_phantom_pip_crop_reset">重置裁剪</string>
<string name="settings_phantom_pip_crop_choose_background">選擇背景圖</string>
<string name="settings_phantom_pip_crop_default_background">預設背景</string>
<string name="settings_phantom_frame_title">幻影模式邊框</string>
<string name="settings_phantom_frame_description">選擇僅用於幻影模式匯出的邊框,不使用 App 內的預設邊框設定。</string>
<string name="settings_phantom_save_as_new">另存新圖</string>
<string name="settings_phantom_save_as_new_description">開啟時,會在儲存編輯后的相片時創建一個新檔案,而不是覆蓋原圖。</string>
<string name="color_space">色彩空間</string>
+2
View File
@@ -728,6 +728,8 @@
<string name="settings_phantom_pip_crop_reset">รีเซ็ตการครอบตัด</string>
<string name="settings_phantom_pip_crop_choose_background">เลือกภาพพื้นหลัง</string>
<string name="settings_phantom_pip_crop_default_background">พื้นหลังเริ่มต้น</string>
<string name="settings_phantom_frame_title">กรอบโหมด Phantom</string>
<string name="settings_phantom_frame_description">เลือกกรอบที่ใช้เฉพาะกับการส่งออกในโหมด Phantom โดยจะไม่ใช้กรอบเริ่มต้นของแอป</string>
<string name="settings_phantom_save_as_new">บันทึกภาพใหม่เป็น</string>
<string name="settings_phantom_save_as_new_description">เมื่อเปิด ไฟล์ใหม่จะถูกสร้างขึ้นเมื่อมีการบันทึกรูปภาพที่แก้ไขแล้ว แทนที่จะเขียนทับรูปภาพต้นฉบับ</string>
<string name="color_space">พื้นที่สี</string>
@@ -912,6 +912,8 @@
<string name="settings_phantom_pip_crop_reset">重置裁剪</string>
<string name="settings_phantom_pip_crop_choose_background">选择背景图</string>
<string name="settings_phantom_pip_crop_default_background">默认背景</string>
<string name="settings_phantom_frame_title">幻影模式边框</string>
<string name="settings_phantom_frame_description">选择仅用于幻影模式导出的边框,不使用 App 内的默认边框设置。</string>
<string name="settings_phantom_save_as_new">另存新图</string>
<string name="settings_phantom_save_as_new_description">开启时,会在保存编辑后的照片时创建一个新文件,而不是覆盖原图。</string>
<string name="color_space">色彩空间</string>
@@ -912,6 +912,8 @@
<string name="settings_phantom_pip_crop_reset">重置裁剪</string>
<string name="settings_phantom_pip_crop_choose_background">選擇背景圖</string>
<string name="settings_phantom_pip_crop_default_background">預設背景</string>
<string name="settings_phantom_frame_title">幻影模式邊框</string>
<string name="settings_phantom_frame_description">選擇僅用於幻影模式匯出的邊框,不使用 App 內的預設邊框設定。</string>
<string name="settings_phantom_save_as_new">另存新圖</string>
<string name="settings_phantom_save_as_new_description">開啟時,會在儲存編輯后的相片時創建一個新檔案,而不是覆蓋原圖。</string>
<string name="color_space">色彩空間</string>
@@ -912,6 +912,8 @@
<string name="settings_phantom_pip_crop_reset">重置裁剪</string>
<string name="settings_phantom_pip_crop_choose_background">選擇背景圖</string>
<string name="settings_phantom_pip_crop_default_background">預設背景</string>
<string name="settings_phantom_frame_title">幻影模式邊框</string>
<string name="settings_phantom_frame_description">選擇僅用於幻影模式匯出的邊框,不使用 App 內的預設邊框設定。</string>
<string name="settings_phantom_save_as_new">另存新圖</string>
<string name="settings_phantom_save_as_new_description">開啟時,會在儲存編輯后的相片時創建一個新檔案,而不是覆蓋原圖。</string>
<string name="color_space">色彩空間</string>
+2
View File
@@ -912,6 +912,8 @@
<string name="settings_phantom_pip_crop_reset">Reset Crop</string>
<string name="settings_phantom_pip_crop_choose_background">Choose Background</string>
<string name="settings_phantom_pip_crop_default_background">Default Background</string>
<string name="settings_phantom_frame_title">Phantom Mode Frame</string>
<string name="settings_phantom_frame_description">Choose a frame used only for Phantom Mode exports. The app\'s default frame is not used.</string>
<string name="settings_phantom_save_as_new">Save as New Image</string>
<string name="settings_phantom_save_as_new_description">When enabled, the app will save the edited photo as a new image instead of overwriting the original one.</string>
<string name="color_space">Color Space</string>