feat: lsc settings
This commit is contained in:
1 parent
007e655689
commit
249e54d937
4 files changed
+61
-11
No files matched your search
@@ -178,13 +178,15 @@ object GalleryManager {
|
||||
context: Context,
|
||||
metadata: MediaMetadata?
|
||||
): Boolean {
|
||||
// Imported DNG files carry their own residual/complete LSC gain map. Always let the
|
||||
// RAW processor consume that embedded map; the user preference only controls RAW
|
||||
// captured by this app.
|
||||
if (metadata?.isImported == true) return true
|
||||
return metadata?.rawLensShadingCorrectionEnabled
|
||||
?: (ContentRepository.getInstance(context).userPreferencesRepository.userPreferences.firstOrNull()
|
||||
?.rawLensShadingCorrectionEnabled ?: true)
|
||||
?: if (metadata?.isImported == true) {
|
||||
// Imported DNG files default to consuming their embedded residual/complete map,
|
||||
// while an explicit photo-level edit is still honored above.
|
||||
true
|
||||
} else {
|
||||
ContentRepository.getInstance(context).userPreferencesRepository.userPreferences.firstOrNull()
|
||||
?.rawLensShadingCorrectionEnabled ?: true
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun resolveRawAutoExposure(
|
||||
|
||||
@@ -74,12 +74,14 @@ class PhotoProcessor(
|
||||
}
|
||||
|
||||
private suspend fun resolveRawLensShadingCorrectionEnabled(metadata: MediaMetadata): Boolean {
|
||||
// Imported DNG files carry their own residual/complete LSC gain map. Always let the
|
||||
// RAW processor consume that embedded map; the user preference only controls RAW
|
||||
// captured by this app.
|
||||
if (metadata.isImported) return true
|
||||
return metadata.rawLensShadingCorrectionEnabled
|
||||
?: (userPreferencesRepository.userPreferences.firstOrNull()?.rawLensShadingCorrectionEnabled ?: true)
|
||||
?: if (metadata.isImported) {
|
||||
// Imported DNG files default to consuming their embedded residual/complete map,
|
||||
// while an explicit photo-level edit is still honored above.
|
||||
true
|
||||
} else {
|
||||
userPreferencesRepository.userPreferences.firstOrNull()?.rawLensShadingCorrectionEnabled ?: true
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun resolveRawAutoExposure(metadata: MediaMetadata): Boolean {
|
||||
|
||||
@@ -111,6 +111,7 @@ private data class PreviewRenderSignature(
|
||||
val editRawShadowsAdjustment: Float,
|
||||
val editRawBlackPointCorrection: Float,
|
||||
val editRawWhitePointCorrection: Float,
|
||||
val editRawLensShadingCorrectionEnabled: Boolean,
|
||||
val editRawDROMode: String,
|
||||
val editRawBlackLevelMode: String,
|
||||
val editRawCustomBlackLevel: Float,
|
||||
@@ -195,6 +196,7 @@ fun GalleryEditScreen(
|
||||
val editRawShadowsAdjustment by viewModel.editRawShadowsAdjustment.collectAsState()
|
||||
val editRawBlackPointCorrection by viewModel.editRawBlackPointCorrection.collectAsState()
|
||||
val editRawWhitePointCorrection by viewModel.editRawWhitePointCorrection.collectAsState()
|
||||
val editRawLensShadingCorrectionEnabled by viewModel.editRawLensShadingCorrectionEnabled.collectAsState()
|
||||
val editRawDROMode by viewModel.editRawDROMode.collectAsState()
|
||||
val editRawBlackLevelMode by viewModel.editRawBlackLevelMode.collectAsState()
|
||||
val editRawCustomBlackLevel by viewModel.editRawCustomBlackLevel.collectAsState()
|
||||
@@ -265,6 +267,7 @@ fun GalleryEditScreen(
|
||||
editRawShadowsAdjustment = if (fast) 0f else editRawShadowsAdjustment,
|
||||
editRawBlackPointCorrection = if (fast) 0f else editRawBlackPointCorrection,
|
||||
editRawWhitePointCorrection = if (fast) 0f else editRawWhitePointCorrection,
|
||||
editRawLensShadingCorrectionEnabled = if (fast) false else editRawLensShadingCorrectionEnabled,
|
||||
editRawDROMode = if (fast) "" else editRawDROMode,
|
||||
editRawBlackLevelMode = if (fast) "" else editRawBlackLevelMode,
|
||||
editRawCustomBlackLevel = if (fast) 0f else editRawCustomBlackLevel,
|
||||
@@ -1247,6 +1250,19 @@ fun GalleryEditScreen(
|
||||
contentMode = RawEditPanelContentMode.FULL,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
SwitchSettingItem(
|
||||
title = stringResource(R.string.settings_raw_lens_shading_correction),
|
||||
description = stringResource(R.string.settings_raw_lens_shading_correction_description),
|
||||
checked = editRawLensShadingCorrectionEnabled,
|
||||
onCheckedChange = { enabled ->
|
||||
viewModel.saveRawLensShadingCorrectionEnabled(
|
||||
currentEditSourcePhoto,
|
||||
enabled
|
||||
) { success ->
|
||||
if (success) requestRawPreviewRefresh()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
3 -> {
|
||||
if (!currentPhoto.isVideo) {
|
||||
|
||||
@@ -96,6 +96,10 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
.map { it.chromaNoiseReduction }
|
||||
.stateIn(viewModelScope, SharingStarted.Eagerly, 0f)
|
||||
|
||||
val rawLensShadingCorrectionEnabled: StateFlow<Boolean> = userPreferencesRepository.userPreferences
|
||||
.map { it.rawLensShadingCorrectionEnabled }
|
||||
.stateIn(viewModelScope, SharingStarted.Eagerly, true)
|
||||
|
||||
val categoryOrder: StateFlow<List<String>> = userPreferencesRepository.userPreferences
|
||||
.map { it.categoryOrder }
|
||||
.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList())
|
||||
@@ -336,6 +340,8 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
private set
|
||||
var editRawWhitePointCorrection = MutableStateFlow(0f)
|
||||
private set
|
||||
var editRawLensShadingCorrectionEnabled = MutableStateFlow(true)
|
||||
private set
|
||||
var editRawDROMode = MutableStateFlow("OFF")
|
||||
private set
|
||||
var editRawBlackLevelMode = MutableStateFlow(RawCfaCorrection.MODE_DEFAULT)
|
||||
@@ -1009,9 +1015,15 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
editRawAutoExposure.value == (metadata.rawAutoExposure ?: true) &&
|
||||
editRawHighlightsAdjustment.value == (metadata.rawHighlightsAdjustment ?: 0f) &&
|
||||
editRawShadowsAdjustment.value == (metadata.rawShadowsAdjustment ?: 0f) &&
|
||||
editRawLensShadingCorrectionEnabled.value == resolveRawLensShadingCorrectionForEdit(metadata) &&
|
||||
editRawToneMappingParameters.value == metadata.rawToneMappingParameters
|
||||
}
|
||||
|
||||
private fun resolveRawLensShadingCorrectionForEdit(metadata: MediaMetadata?): Boolean {
|
||||
return metadata?.rawLensShadingCorrectionEnabled
|
||||
?: if (metadata?.isImported == true) true else rawLensShadingCorrectionEnabled.value
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入从系统相册分享的照片
|
||||
*/
|
||||
@@ -1283,6 +1295,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
editRawShadowsAdjustment.value = m.rawShadowsAdjustment ?: 0f
|
||||
editRawBlackPointCorrection.value = m.rawBlackPointCorrection ?: 0f
|
||||
editRawWhitePointCorrection.value = m.rawWhitePointCorrection ?: 0f
|
||||
editRawLensShadingCorrectionEnabled.value = resolveRawLensShadingCorrectionForEdit(m)
|
||||
editRawBlackLevelMode.value = m.rawBlackLevelMode ?: RawCfaCorrection.MODE_DEFAULT
|
||||
editRawCustomBlackLevel.value = m.rawCustomBlackLevel ?: 0f
|
||||
editRawWhiteLevelMode.value = m.rawWhiteLevelMode ?: RawWhiteLevelCorrection.MODE_DEFAULT
|
||||
@@ -1852,6 +1865,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
editRawAutoExposure.value = metadata.rawAutoExposure ?: true
|
||||
editRawHighlightsAdjustment.value = metadata.rawHighlightsAdjustment ?: 0f
|
||||
editRawShadowsAdjustment.value = metadata.rawShadowsAdjustment ?: 0f
|
||||
editRawLensShadingCorrectionEnabled.value = resolveRawLensShadingCorrectionForEdit(metadata)
|
||||
editRawToneMappingParameters.value = metadata.rawToneMappingParameters
|
||||
}
|
||||
|
||||
@@ -1908,6 +1922,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
editRawShadowsAdjustment.value = metadata.rawShadowsAdjustment ?: 0f
|
||||
editRawBlackPointCorrection.value = metadata.rawBlackPointCorrection ?: 0f
|
||||
editRawWhitePointCorrection.value = metadata.rawWhitePointCorrection ?: 0f
|
||||
editRawLensShadingCorrectionEnabled.value = resolveRawLensShadingCorrectionForEdit(metadata)
|
||||
editRawBlackLevelMode.value = metadata.rawBlackLevelMode ?: RawCfaCorrection.MODE_DEFAULT
|
||||
editRawCustomBlackLevel.value = metadata.rawCustomBlackLevel ?: 0f
|
||||
editRawWhiteLevelMode.value = metadata.rawWhiteLevelMode ?: RawWhiteLevelCorrection.MODE_DEFAULT
|
||||
@@ -1934,6 +1949,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
editRawShadowsAdjustment.value = 0f
|
||||
editRawBlackPointCorrection.value = 0f
|
||||
editRawWhitePointCorrection.value = 0f
|
||||
editRawLensShadingCorrectionEnabled.value = rawLensShadingCorrectionEnabled.value
|
||||
editRawBlackLevelMode.value = RawCfaCorrection.MODE_DEFAULT
|
||||
editRawCustomBlackLevel.value = 0f
|
||||
editRawWhiteLevelMode.value = RawWhiteLevelCorrection.MODE_DEFAULT
|
||||
@@ -2041,6 +2057,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
editRawShadowsAdjustment.value = 0f
|
||||
editRawBlackPointCorrection.value = 0f
|
||||
editRawWhitePointCorrection.value = 0f
|
||||
editRawLensShadingCorrectionEnabled.value = true
|
||||
editRawBlackLevelMode.value = RawCfaCorrection.MODE_DEFAULT
|
||||
editRawCustomBlackLevel.value = 0f
|
||||
editRawWhiteLevelMode.value = RawWhiteLevelCorrection.MODE_DEFAULT
|
||||
@@ -2179,6 +2196,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
val shadows = editRawShadowsAdjustment.value
|
||||
val blackPoint = editRawBlackPointCorrection.value
|
||||
val whitePoint = editRawWhitePointCorrection.value
|
||||
val lensShadingCorrectionEnabled = editRawLensShadingCorrectionEnabled.value
|
||||
val droMode = editRawDROMode.value
|
||||
val blackLevelMode = editRawBlackLevelMode.value
|
||||
val customBlackLevel = editRawCustomBlackLevel.value
|
||||
@@ -2214,6 +2232,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
rawShadowsAdjustment = shadows,
|
||||
rawBlackPointCorrection = blackPoint,
|
||||
rawWhitePointCorrection = whitePoint,
|
||||
rawLensShadingCorrectionEnabled = lensShadingCorrectionEnabled,
|
||||
rawBlackLevelMode = blackLevelMode,
|
||||
rawCustomBlackLevel = customBlackLevel,
|
||||
rawWhiteLevelMode = whiteLevelMode,
|
||||
@@ -2332,6 +2351,15 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
persistRawEditMetadata(mediaData, onComplete)
|
||||
}
|
||||
|
||||
fun saveRawLensShadingCorrectionEnabled(
|
||||
mediaData: MediaData,
|
||||
enabled: Boolean,
|
||||
onComplete: ((Boolean) -> Unit)? = null
|
||||
) {
|
||||
editRawLensShadingCorrectionEnabled.value = enabled
|
||||
persistRawEditMetadata(mediaData, onComplete)
|
||||
}
|
||||
|
||||
fun saveRawBlackLevelMode(mediaData: MediaData, mode: String, onComplete: ((Boolean) -> Unit)? = null) {
|
||||
editRawBlackLevelMode.value = mode
|
||||
persistRawEditMetadata(mediaData, onComplete)
|
||||
@@ -2632,6 +2660,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
rawShadowsAdjustment = editRawShadowsAdjustment.value,
|
||||
rawBlackPointCorrection = editRawBlackPointCorrection.value,
|
||||
rawWhitePointCorrection = editRawWhitePointCorrection.value,
|
||||
rawLensShadingCorrectionEnabled = editRawLensShadingCorrectionEnabled.value,
|
||||
rawBlackLevelMode = editRawBlackLevelMode.value,
|
||||
rawCustomBlackLevel = editRawCustomBlackLevel.value,
|
||||
rawWhiteLevelMode = editRawWhiteLevelMode.value,
|
||||
@@ -2971,6 +3000,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
rawShadowsAdjustment = editRawShadowsAdjustment.value,
|
||||
rawBlackPointCorrection = editRawBlackPointCorrection.value,
|
||||
rawWhitePointCorrection = editRawWhitePointCorrection.value,
|
||||
rawLensShadingCorrectionEnabled = editRawLensShadingCorrectionEnabled.value,
|
||||
rawBlackLevelMode = editRawBlackLevelMode.value,
|
||||
rawCustomBlackLevel = editRawCustomBlackLevel.value,
|
||||
rawWhiteLevelMode = editRawWhiteLevelMode.value,
|
||||
|
||||
Reference in new issue
Block a user