feat: add toggle for focus peaking in settings
This commit is contained in:
1 parent
3216ea63d7
commit
268f8e9f54
10 files changed
+55
-2
No files matched your search
@@ -70,6 +70,7 @@ data class UserPreferences(
|
|||||||
val showHistogram: Boolean = true,
|
val showHistogram: Boolean = true,
|
||||||
val showGrid: Boolean = false, // 网格线显示
|
val showGrid: Boolean = false, // 网格线显示
|
||||||
val showLevelIndicator: Boolean = false, // 水平仪显示
|
val showLevelIndicator: Boolean = false, // 水平仪显示
|
||||||
|
val focusPeakingEnabled: Boolean = true, // 手动对焦峰值显示
|
||||||
val shutterSoundEnabled: Boolean = true, // 快门声音
|
val shutterSoundEnabled: Boolean = true, // 快门声音
|
||||||
val vibrationEnabled: Boolean = true, // 拍摄震动
|
val vibrationEnabled: Boolean = true, // 拍摄震动
|
||||||
val volumeKeyAction: VolumeKeyAction = VolumeKeyAction.CAPTURE, // 音量键操作
|
val volumeKeyAction: VolumeKeyAction = VolumeKeyAction.CAPTURE, // 音量键操作
|
||||||
@@ -165,6 +166,7 @@ class UserPreferencesRepository(private val context: Context) {
|
|||||||
private val SHOW_HISTOGRAM = booleanPreferencesKey("show_histogram")
|
private val SHOW_HISTOGRAM = booleanPreferencesKey("show_histogram")
|
||||||
private val SHOW_GRID = booleanPreferencesKey("show_grid")
|
private val SHOW_GRID = booleanPreferencesKey("show_grid")
|
||||||
private val SHOW_LEVEL_INDICATOR = booleanPreferencesKey("show_level_indicator")
|
private val SHOW_LEVEL_INDICATOR = booleanPreferencesKey("show_level_indicator")
|
||||||
|
private val FOCUS_PEAKING_ENABLED = booleanPreferencesKey("focus_peaking_enabled")
|
||||||
private val SHUTTER_SOUND_ENABLED = booleanPreferencesKey("shutter_sound_enabled")
|
private val SHUTTER_SOUND_ENABLED = booleanPreferencesKey("shutter_sound_enabled")
|
||||||
private val VIBRATION_ENABLED = booleanPreferencesKey("vibration_enabled")
|
private val VIBRATION_ENABLED = booleanPreferencesKey("vibration_enabled")
|
||||||
private val VOLUME_KEY_ACTION = stringPreferencesKey("volume_key_action")
|
private val VOLUME_KEY_ACTION = stringPreferencesKey("volume_key_action")
|
||||||
@@ -268,6 +270,7 @@ class UserPreferencesRepository(private val context: Context) {
|
|||||||
showHistogram = preferences[SHOW_HISTOGRAM] ?: true,
|
showHistogram = preferences[SHOW_HISTOGRAM] ?: true,
|
||||||
showGrid = preferences[SHOW_GRID] ?: false,
|
showGrid = preferences[SHOW_GRID] ?: false,
|
||||||
showLevelIndicator = preferences[SHOW_LEVEL_INDICATOR] ?: false,
|
showLevelIndicator = preferences[SHOW_LEVEL_INDICATOR] ?: false,
|
||||||
|
focusPeakingEnabled = preferences[FOCUS_PEAKING_ENABLED] ?: true,
|
||||||
shutterSoundEnabled = preferences[SHUTTER_SOUND_ENABLED] ?: true,
|
shutterSoundEnabled = preferences[SHUTTER_SOUND_ENABLED] ?: true,
|
||||||
vibrationEnabled = preferences[VIBRATION_ENABLED] ?: true,
|
vibrationEnabled = preferences[VIBRATION_ENABLED] ?: true,
|
||||||
volumeKeyAction = VolumeKeyAction.valueOf(
|
volumeKeyAction = VolumeKeyAction.valueOf(
|
||||||
@@ -614,6 +617,15 @@ class UserPreferencesRepository(private val context: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存是否启用手动对焦峰值显示
|
||||||
|
*/
|
||||||
|
suspend fun saveFocusPeakingEnabled(enabled: Boolean) {
|
||||||
|
context.dataStore.edit { preferences ->
|
||||||
|
preferences[FOCUS_PEAKING_ENABLED] = enabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存是否启用快门声音
|
* 保存是否启用快门声音
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -319,6 +319,9 @@ class LutRenderer : GLSurfaceView.Renderer {
|
|||||||
@Volatile
|
@Volatile
|
||||||
var isAutoFocus: Boolean = true
|
var isAutoFocus: Boolean = true
|
||||||
|
|
||||||
|
@Volatile
|
||||||
|
var focusPeakingEnabled: Boolean = true
|
||||||
|
|
||||||
@Volatile
|
@Volatile
|
||||||
var baselineLutEnabled: Boolean = false
|
var baselineLutEnabled: Boolean = false
|
||||||
|
|
||||||
@@ -914,7 +917,7 @@ class LutRenderer : GLSurfaceView.Renderer {
|
|||||||
val hasCreativeLayer = hasCreativeLayer()
|
val hasCreativeLayer = hasCreativeLayer()
|
||||||
val hasDualLayer = hasBaselineLayer && hasCreativeLayer
|
val hasDualLayer = hasBaselineLayer && hasCreativeLayer
|
||||||
uploadPendingCurveTextures()
|
uploadPendingCurveTextures()
|
||||||
val needsFbo = (liveRecorder != null || activeVideoRecorder != null || hdfEnabled || bokehNeeded || hasDualLayer || !isAutoFocus) &&
|
val needsFbo = (liveRecorder != null || activeVideoRecorder != null || hdfEnabled || bokehNeeded || hasDualLayer || (!isAutoFocus && focusPeakingEnabled)) &&
|
||||||
fboId != 0 && fboTextureId != 0
|
fboId != 0 && fboTextureId != 0
|
||||||
|
|
||||||
if (needsFbo) {
|
if (needsFbo) {
|
||||||
@@ -1046,7 +1049,7 @@ class LutRenderer : GLSurfaceView.Renderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3.5. Focus Peaking (Only for preview, not for recording)
|
// 3.5. Focus Peaking (Only for preview, not for recording)
|
||||||
if (!isAutoFocus) {
|
if (!isAutoFocus && focusPeakingEnabled) {
|
||||||
currentTexId = renderFocusPeaking(currentTexId, currentWidth, currentHeight)
|
currentTexId = renderFocusPeaking(currentTexId, currentWidth, currentHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,11 @@ class CameraGLSurfaceView @JvmOverloads constructor(
|
|||||||
requestRender()
|
requestRender()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setFocusPeakingEnabled(enabled: Boolean) {
|
||||||
|
renderer.focusPeakingEnabled = enabled
|
||||||
|
requestRender()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前 LUT 强度
|
* 获取当前 LUT 强度
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ fun CameraPreviewGL(
|
|||||||
onGLSurfaceViewReady: ((CameraGLSurfaceView) -> Unit)? = null,
|
onGLSurfaceViewReady: ((CameraGLSurfaceView) -> Unit)? = null,
|
||||||
aperture: Float = 0f,
|
aperture: Float = 0f,
|
||||||
isAutoFocus: Boolean = true,
|
isAutoFocus: Boolean = true,
|
||||||
|
focusPeakingEnabled: Boolean = true,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier
|
||||||
) {
|
) {
|
||||||
val rotationDegrees = OrientationObserver.rotationDegrees
|
val rotationDegrees = OrientationObserver.rotationDegrees
|
||||||
@@ -215,6 +216,7 @@ fun CameraPreviewGL(
|
|||||||
glSurfaceView.setVideoLogProfile(videoLogProfile)
|
glSurfaceView.setVideoLogProfile(videoLogProfile)
|
||||||
glSurfaceView.setIsHlgInput(isHlgInput)
|
glSurfaceView.setIsHlgInput(isHlgInput)
|
||||||
glSurfaceView.setAutoFocus(isAutoFocus)
|
glSurfaceView.setAutoFocus(isAutoFocus)
|
||||||
|
glSurfaceView.setFocusPeakingEnabled(focusPeakingEnabled)
|
||||||
},
|
},
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -112,6 +112,7 @@ fun CameraScreen(
|
|||||||
val state by viewModel.state.collectAsState()
|
val state by viewModel.state.collectAsState()
|
||||||
val latestPhoto by galleryViewModel.latestPhoto.collectAsState()
|
val latestPhoto by galleryViewModel.latestPhoto.collectAsState()
|
||||||
val showLevelIndicator by viewModel.showLevelIndicator.collectAsState(initial = false)
|
val showLevelIndicator by viewModel.showLevelIndicator.collectAsState(initial = false)
|
||||||
|
val focusPeakingEnabled by viewModel.focusPeakingEnabled.collectAsState(initial = true)
|
||||||
val currentLutId by viewModel.currentLutId.collectAsState()
|
val currentLutId by viewModel.currentLutId.collectAsState()
|
||||||
val currentRecipeParams by viewModel.currentRecipeParams.collectAsState()
|
val currentRecipeParams by viewModel.currentRecipeParams.collectAsState()
|
||||||
val currentBaselineRecipeParams by viewModel.currentBaselineRecipeParams.collectAsState()
|
val currentBaselineRecipeParams by viewModel.currentBaselineRecipeParams.collectAsState()
|
||||||
@@ -737,6 +738,7 @@ fun CameraScreen(
|
|||||||
isHlgInput = if (hlgHardwareCompatibilityEnabled) state.isHLG else false,
|
isHlgInput = if (hlgHardwareCompatibilityEnabled) state.isHLG else false,
|
||||||
aperture = if (state.isVirtualApertureEnabled) state.virtualAperture else 0f,
|
aperture = if (state.isVirtualApertureEnabled) state.virtualAperture else 0f,
|
||||||
isAutoFocus = state.isAutoFocus,
|
isAutoFocus = state.isAutoFocus,
|
||||||
|
focusPeakingEnabled = focusPeakingEnabled,
|
||||||
modifier = Modifier.fillMaxSize()
|
modifier = Modifier.fillMaxSize()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ fun SettingsScreen(
|
|||||||
) {
|
) {
|
||||||
val state by viewModel.state.collectAsState()
|
val state by viewModel.state.collectAsState()
|
||||||
val showLevelIndicator by viewModel.showLevelIndicator.collectAsState(initial = false)
|
val showLevelIndicator by viewModel.showLevelIndicator.collectAsState(initial = false)
|
||||||
|
val focusPeakingEnabled by viewModel.focusPeakingEnabled.collectAsState(initial = true)
|
||||||
val showGrid = state.showGrid
|
val showGrid = state.showGrid
|
||||||
val shutterSoundEnabled by viewModel.shutterSoundEnabled.collectAsState(initial = true)
|
val shutterSoundEnabled by viewModel.shutterSoundEnabled.collectAsState(initial = true)
|
||||||
val vibrationEnabled by viewModel.vibrationEnabled.collectAsState(initial = true)
|
val vibrationEnabled by viewModel.vibrationEnabled.collectAsState(initial = true)
|
||||||
@@ -701,6 +702,18 @@ fun SettingsScreen(
|
|||||||
modifier = Modifier.padding(vertical = 8.dp)
|
modifier = Modifier.padding(vertical = 8.dp)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
SwitchSettingItem(
|
||||||
|
title = stringResource(R.string.settings_focus_peaking),
|
||||||
|
description = stringResource(R.string.settings_focus_peaking_description),
|
||||||
|
checked = focusPeakingEnabled,
|
||||||
|
onCheckedChange = { viewModel.setFocusPeakingEnabled(it) }
|
||||||
|
)
|
||||||
|
|
||||||
|
HorizontalDivider(
|
||||||
|
color = Color.White.copy(alpha = 0.1f),
|
||||||
|
modifier = Modifier.padding(vertical = 8.dp)
|
||||||
|
)
|
||||||
|
|
||||||
SwitchSettingItem(
|
SwitchSettingItem(
|
||||||
title = stringResource(R.string.settings_grid_lines),
|
title = stringResource(R.string.settings_grid_lines),
|
||||||
description = stringResource(R.string.settings_grid_description),
|
description = stringResource(R.string.settings_grid_description),
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
|
|
||||||
// 新增设置项 StateFlow
|
// 新增设置项 StateFlow
|
||||||
val showLevelIndicator: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.showLevelIndicator }
|
val showLevelIndicator: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.showLevelIndicator }
|
||||||
|
val focusPeakingEnabled: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.focusPeakingEnabled }
|
||||||
val shutterSoundEnabled: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.shutterSoundEnabled }
|
val shutterSoundEnabled: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.shutterSoundEnabled }
|
||||||
val vibrationEnabled: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.vibrationEnabled }
|
val vibrationEnabled: Flow<Boolean> = userPreferencesRepository.userPreferences.map { it.vibrationEnabled }
|
||||||
val volumeKeyAction: StateFlow<VolumeKeyAction> =
|
val volumeKeyAction: StateFlow<VolumeKeyAction> =
|
||||||
@@ -2134,6 +2135,15 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置手动对焦时是否显示峰值对焦
|
||||||
|
*/
|
||||||
|
fun setFocusPeakingEnabled(enabled: Boolean) {
|
||||||
|
viewModelScope.launch {
|
||||||
|
userPreferencesRepository.saveFocusPeakingEnabled(enabled)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置是否启用快门声音
|
* 设置是否启用快门声音
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -163,6 +163,8 @@
|
|||||||
<string name="settings_use_raw_description">使用 RAW 格式 (DNG) 拍摄。关闭后将使用 YCBCR_P010/YUV_420 格式。</string>
|
<string name="settings_use_raw_description">使用 RAW 格式 (DNG) 拍摄。关闭后将使用 YCBCR_P010/YUV_420 格式。</string>
|
||||||
<string name="settings_level_indicator">水平仪</string>
|
<string name="settings_level_indicator">水平仪</string>
|
||||||
<string name="settings_level_description">在拍摄时显示水平仪,帮助保持画面水平</string>
|
<string name="settings_level_description">在拍摄时显示水平仪,帮助保持画面水平</string>
|
||||||
|
<string name="settings_focus_peaking">峰值对焦</string>
|
||||||
|
<string name="settings_focus_peaking_description">手动对焦时显示峰值对焦高亮</string>
|
||||||
<string name="settings_grid_lines">网格线显示</string>
|
<string name="settings_grid_lines">网格线显示</string>
|
||||||
<string name="settings_grid_description">在拍摄时显示网格线,辅助构图</string>
|
<string name="settings_grid_description">在拍摄时显示网格线,辅助构图</string>
|
||||||
<string name="settings_use_multi_frame">多帧降噪</string>
|
<string name="settings_use_multi_frame">多帧降噪</string>
|
||||||
|
|||||||
@@ -114,6 +114,8 @@
|
|||||||
<string name="settings_use_raw_description">使用 RAW 格式 (DNG) 拍攝。關閉後將使用 YCBCR_P010/YUV_420 格式。</string>
|
<string name="settings_use_raw_description">使用 RAW 格式 (DNG) 拍攝。關閉後將使用 YCBCR_P010/YUV_420 格式。</string>
|
||||||
<string name="settings_level_indicator">水平儀</string>
|
<string name="settings_level_indicator">水平儀</string>
|
||||||
<string name="settings_level_description">在拍攝時顯示水平儀,幫助保持畫面水平</string>
|
<string name="settings_level_description">在拍攝時顯示水平儀,幫助保持畫面水平</string>
|
||||||
|
<string name="settings_focus_peaking">峰值對焦</string>
|
||||||
|
<string name="settings_focus_peaking_description">手動對焦時顯示峰值對焦高亮</string>
|
||||||
<string name="settings_grid_lines">網格線顯示</string>
|
<string name="settings_grid_lines">網格線顯示</string>
|
||||||
<string name="settings_grid_description">在拍攝時顯示網格線,輔助構圖</string>
|
<string name="settings_grid_description">在拍攝時顯示網格線,輔助構圖</string>
|
||||||
<string name="settings_use_multi_frame">多幀合成</string>
|
<string name="settings_use_multi_frame">多幀合成</string>
|
||||||
|
|||||||
@@ -165,6 +165,8 @@
|
|||||||
<string name="settings_use_raw_description">Capture photos in RAW format (DNG) for higher quality. Turn off to use YUV format.</string>
|
<string name="settings_use_raw_description">Capture photos in RAW format (DNG) for higher quality. Turn off to use YUV format.</string>
|
||||||
<string name="settings_level_indicator">Horizontal Level</string>
|
<string name="settings_level_indicator">Horizontal Level</string>
|
||||||
<string name="settings_level_description">Show horizontal level indicator while shooting</string>
|
<string name="settings_level_description">Show horizontal level indicator while shooting</string>
|
||||||
|
<string name="settings_focus_peaking">Focus Peaking</string>
|
||||||
|
<string name="settings_focus_peaking_description">Show focus peaking highlights during manual focus</string>
|
||||||
<string name="settings_grid_lines">Grid Lines</string>
|
<string name="settings_grid_lines">Grid Lines</string>
|
||||||
<string name="settings_grid_description">Show grid lines for composition</string>
|
<string name="settings_grid_description">Show grid lines for composition</string>
|
||||||
<string name="settings_use_multi_frame">Multi-Frame Denoise</string>
|
<string name="settings_use_multi_frame">Multi-Frame Denoise</string>
|
||||||
|
|||||||
Reference in new issue
Block a user