From ee9e55fb3568ba9149c7203a98c3d15e5069e5e5 Mon Sep 17 00:00:00 2001 From: zhoubinjia Date: Mon, 7 Sep 2026 10:40:54 +0800 Subject: [PATCH] feat: camera screen ui --- .../mycamera/ui/camera/CameraParameterBar.kt | 173 ++++++++++++------ .../hinnka/mycamera/ui/camera/CameraScreen.kt | 12 +- .../mycamera/ui/settings/SettingsScreen.kt | 2 +- app/src/main/res/values-b+zh+Hant/strings.xml | 6 +- app/src/main/res/values-zh-rCN/strings.xml | 6 +- app/src/main/res/values-zh-rHK/strings.xml | 6 +- app/src/main/res/values-zh-rTW/strings.xml | 6 +- 7 files changed, 144 insertions(+), 67 deletions(-) diff --git a/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraParameterBar.kt b/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraParameterBar.kt index 9cdd63f1..2141a142 100644 --- a/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraParameterBar.kt +++ b/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraParameterBar.kt @@ -3,9 +3,11 @@ package com.hinnka.mycamera.ui.camera import android.hardware.camera2.CameraMetadata import androidx.compose.animation.animateColorAsState import androidx.compose.foundation.background +import androidx.compose.foundation.border import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -26,6 +28,7 @@ import androidx.compose.ui.unit.sp import com.hinnka.mycamera.R import com.hinnka.mycamera.camera.CameraState import com.hinnka.mycamera.camera.CameraUtils +import com.hinnka.mycamera.video.CaptureMode import kotlin.math.roundToLong internal val CameraParameterAccent = Color(0xFFFFD700) @@ -55,43 +58,50 @@ fun CameraParameterBar( internal data class CameraParameterItem( val parameter: CameraParameter, val label: String, - val value: String, + val value: String?, val isEnabled: Boolean = true, val isWarning: Boolean = false ) @Composable -internal fun cameraParameterItems(state: CameraState): List = listOf( - CameraParameterItem( - CameraParameter.EXPOSURE_COMPENSATION, - stringResource(R.string.camera_parameter_exposure), - CameraUtils.formatExposureCompensation(state.exposureCompensation, state.getExposureCompensationStep()), - isEnabled = state.isAutoExposure - ), - CameraParameterItem( - CameraParameter.SHUTTER_SPEED, - stringResource(R.string.camera_parameter_shutter), - formatShutterSpeedValue(state.shutterSpeed), - isWarning = state.isPreviewExposureLimited() - ), - CameraParameterItem( - CameraParameter.ISO, - stringResource(R.string.camera_parameter_iso), - state.iso.toString() - ), - CameraParameterItem( - CameraParameter.FOCUS, - stringResource(R.string.camera_parameter_focus), - formatFocusDistance(state.focusDistance), - isEnabled = state.minimumFocusDistance > 0f - ), - CameraParameterItem( - CameraParameter.WHITE_BALANCE, - stringResource(R.string.camera_parameter_white_balance), - formatWhiteBalanceValue(state), - isEnabled = state.canAdjustWhiteBalance || state.actualAwbTemperature != null +internal fun cameraParameterItems(state: CameraState): List { + // Match the mode switcher: PHOTO capture also backs the RAW professional mode. + val showValues = state.captureMode == CaptureMode.VIDEO || + (state.useRaw && state.isRawSupported) + return listOf( + CameraParameterItem( + CameraParameter.EXPOSURE_COMPENSATION, + stringResource(R.string.camera_parameter_exposure), + if (showValues) CameraUtils.formatExposureCompensation( + state.exposureCompensation, state.getExposureCompensationStep() + ) else null, + isEnabled = state.isAutoExposure + ), + CameraParameterItem( + CameraParameter.SHUTTER_SPEED, + stringResource(R.string.camera_parameter_shutter), + if (showValues) formatShutterSpeedValue(state.shutterSpeed) else null, + isWarning = showValues && state.isPreviewExposureLimited() + ), + CameraParameterItem( + CameraParameter.ISO, + stringResource(R.string.camera_parameter_iso), + if (showValues) state.iso.toString() else null + ), + CameraParameterItem( + CameraParameter.FOCUS, + stringResource(R.string.camera_parameter_focus), + if (showValues) formatFocusDistance(state.focusDistance) else null, + isEnabled = state.minimumFocusDistance > 0f + ), + CameraParameterItem( + CameraParameter.WHITE_BALANCE, + stringResource(R.string.camera_parameter_white_balance), + if (showValues) formatWhiteBalanceValue(state) else null, + isEnabled = state.canAdjustWhiteBalance || state.actualAwbTemperature != null + ) ) -) +} @Composable internal fun ParameterItem( @@ -101,6 +111,7 @@ internal fun ParameterItem( vertical: Boolean = false, modifier: Modifier = Modifier ) { + val titleOnly = item.value == null val valueColor by animateColorAsState( targetValue = when { item.isWarning -> Color(0xFFFF6666) @@ -113,7 +124,8 @@ internal fun ParameterItem( val labelColor by animateColorAsState( targetValue = when { !item.isEnabled -> Color.White.copy(alpha = 0.3f) - isSelected -> CameraParameterAccent.copy(alpha = 0.8f) + isSelected -> CameraParameterAccent.copy(alpha = if (titleOnly) 1f else 0.8f) + titleOnly -> Color.White.copy(alpha = 0.9f) else -> Color.White.copy(alpha = 0.6f) }, label = "parameterLabelColor" @@ -124,6 +136,7 @@ internal fun ParameterItem( if (vertical) Modifier.size(48.dp, 76.dp) else Modifier.height(CameraControlsLayoutDefaults.ParameterBarHeight) ) + .then(if (titleOnly) Modifier.clip(RoundedCornerShape(8.dp)) else Modifier) .semantics { selected = isSelected } .clickable(enabled = item.isEnabled, role = Role.Button, onClick = onClick), contentAlignment = Alignment.Center @@ -136,30 +149,39 @@ internal fun ParameterItem( }, contentAlignment = Alignment.Center ) { - Column( - horizontalAlignment = Alignment.CenterHorizontally, - verticalArrangement = Arrangement.spacedBy(1.dp) - ) { - Text( - text = item.value, - color = valueColor, - fontSize = 14.sp, - fontWeight = FontWeight.Medium, - style = TextStyle(shadow = ViewfinderTextShadow), - textAlign = TextAlign.Center, - maxLines = 1, - softWrap = false - ) - Text( - text = item.label, + if (item.value == null) { + PhotoParameterTitle( + label = item.label, color = labelColor, - fontSize = 9.sp, - fontWeight = FontWeight.Medium, - style = TextStyle(shadow = ViewfinderTextShadow), - maxLines = 1 + isSelected = isSelected, + isEnabled = item.isEnabled ) + } else { + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(1.dp) + ) { + Text( + text = item.value, + color = valueColor, + fontSize = 14.sp, + fontWeight = FontWeight.Medium, + style = TextStyle(shadow = ViewfinderTextShadow), + textAlign = TextAlign.Center, + maxLines = 1, + softWrap = false + ) + Text( + text = item.label, + color = labelColor, + fontSize = 9.sp, + fontWeight = FontWeight.Medium, + style = TextStyle(shadow = ViewfinderTextShadow), + maxLines = 1 + ) + } } - if (isSelected) { + if (isSelected && !titleOnly) { Box( Modifier.align(Alignment.BottomCenter) .padding(bottom = 3.dp) @@ -172,6 +194,51 @@ internal fun ParameterItem( } } +@Composable +private fun PhotoParameterTitle( + label: String, + color: Color, + isSelected: Boolean, + isEnabled: Boolean +) { + val backgroundColor by animateColorAsState( + targetValue = when { + !isEnabled -> Color.Black.copy(alpha = 0.12f) + isSelected -> CameraParameterAccent.copy(alpha = 0.16f) + else -> Color.Black.copy(alpha = 0.28f) + }, + label = "photoParameterBackground" + ) + val borderColor by animateColorAsState( + targetValue = when { + !isEnabled -> Color.White.copy(alpha = 0.05f) + isSelected -> CameraParameterAccent.copy(alpha = 0.6f) + else -> Color.White.copy(alpha = 0.12f) + }, + label = "photoParameterBorder" + ) + val shape = RoundedCornerShape(8.dp) + Box( + modifier = Modifier + .padding(horizontal = 4.dp) + .fillMaxWidth() + .height(34.dp) + .background(backgroundColor, shape), + contentAlignment = Alignment.Center + ) { + Text( + text = label, + color = color, + fontSize = 13.sp, + fontWeight = FontWeight.SemiBold, + style = TextStyle(shadow = ViewfinderTextShadow), + textAlign = TextAlign.Center, + maxLines = 1, + softWrap = false + ) + } +} + internal fun formatShutterSpeedValue(value: Long): String { return when { value <= 0L -> "0" diff --git a/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraScreen.kt b/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraScreen.kt index bab8eacd..e02e9a35 100644 --- a/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraScreen.kt +++ b/app/src/main/java/com/hinnka/mycamera/ui/camera/CameraScreen.kt @@ -1400,10 +1400,20 @@ fun CameraScreen( } if (isXpan) { + // Center both side bars in the space above the capture controls, which + // overlap the lower part of the XPAN viewfinder. + val sideControlsBottom = minOf( + viewfinderTop + cardHeight, + contentHeight - CameraControlsLayoutDefaults.CaptureAreaHeight - + CameraControlsLayoutDefaults.CaptureClearance + ) + val sideControlsHeight = (sideControlsBottom - viewfinderTop) + .coerceIn(0.dp, cardHeight) Box( modifier = Modifier .fillMaxWidth() - .height(cardHeight), + .height(cardHeight) + .padding(bottom = cardHeight - sideControlsHeight), contentAlignment = Alignment.Center ) { Box( diff --git a/app/src/main/java/com/hinnka/mycamera/ui/settings/SettingsScreen.kt b/app/src/main/java/com/hinnka/mycamera/ui/settings/SettingsScreen.kt index cf916e76..95513732 100644 --- a/app/src/main/java/com/hinnka/mycamera/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/com/hinnka/mycamera/ui/settings/SettingsScreen.kt @@ -1809,7 +1809,7 @@ fun SettingsScreen( } SettingsPage.PHOTO_MODE -> { - // 拍照模式设置 + // 照片模式设置 SettingsSection( title = stringResource(R.string.settings_section_photo_mode), showTitle = false diff --git a/app/src/main/res/values-b+zh+Hant/strings.xml b/app/src/main/res/values-b+zh+Hant/strings.xml index a93e6e90..46af10f4 100644 --- a/app/src/main/res/values-b+zh+Hant/strings.xml +++ b/app/src/main/res/values-b+zh+Hant/strings.xml @@ -23,7 +23,7 @@ 未知 拍照 專業 - 拍照 + 照片 影片 @@ -223,7 +223,7 @@ 鎖定白平衡 影片錄製過程中鎖定白平衡。 畫質與性能 - 拍照模式設定 + 照片模式設定 專業模式設定 專業模式參數 僅在專業模式下可用 @@ -260,7 +260,7 @@ 調整 HDR+ 相片的輸出尺寸。倍率越高,相片尺寸和檔案大小越大,處理時間也可能更長。 %1$.2f× 多幀降噪幀數 - 拍照模式下多幀降噪使用的幀數。幀數越多降噪越明顯,但處理時間也越長。 + 照片模式下多幀降噪使用的幀數。幀數越多降噪越明顯,但處理時間也越長。 HDR+ 幀數 HDR+ 拍攝使用的幀數。開啟包圍曝光後,最低為 2 幀,使用一般曝光與可用的長曝光;3 幀及以上使用完整包圍曝光方案。 HDR+ 包圍曝光 diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 1ab343f3..a0f90c9d 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -23,7 +23,7 @@ 未知 拍照 专业 - 拍照 + 照片 视频 @@ -223,7 +223,7 @@ 锁定白平衡 视频录制过程中锁定白平衡。 画质与性能 - 拍照模式设置 + 照片模式设置 专业模式设置 专业模式参数 仅在专业模式下可用 @@ -260,7 +260,7 @@ 调整 HDR+ 照片的输出尺寸。倍率越高,照片尺寸和文件体积越大,处理时间也可能更长。 %1$.2f× 多帧降噪帧数 - 拍照模式下多帧降噪使用的帧数。帧数越多降噪越明显,但处理时间也越长。 + 照片模式下多帧降噪使用的帧数。帧数越多降噪越明显,但处理时间也越长。 HDR+ 帧数 HDR+ 拍摄使用的帧数。开启包围曝光后,最低为 2 帧,使用普通曝光和可用的长曝光;3 帧及以上使用完整包围曝光方案。 HDR+ 包围曝光 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index f7d7eeef..33c385a5 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -23,7 +23,7 @@ 未知 拍照 專業 - 拍照 + 照片 影片 @@ -223,7 +223,7 @@ 鎖定白平衡 影片錄製過程中鎖定白平衡。 畫質與性能 - 拍照模式設定 + 照片模式設定 專業模式設定 專業模式參數 僅在專業模式下可用 @@ -260,7 +260,7 @@ 調整 HDR+ 相片的輸出尺寸。倍率越高,相片尺寸和檔案大小越大,處理時間也可能更長。 %1$.2f× 多幀降噪幀數 - 拍照模式下多幀降噪使用的幀數。幀數越多降噪越明顯,但處理時間也越長。 + 照片模式下多幀降噪使用的幀數。幀數越多降噪越明顯,但處理時間也越長。 HDR+ 幀數 HDR+ 拍攝使用的幀數。開啟包圍曝光後,最低為 2 幀,使用一般曝光與可用的長曝光;3 幀及以上使用完整包圍曝光方案。 HDR+ 包圍曝光 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 6290c59a..00906c4d 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -23,7 +23,7 @@ 未知 拍照 專業 - 拍照 + 照片 影片 @@ -223,7 +223,7 @@ 鎖定白平衡 影片錄製過程中鎖定白平衡。 畫質與性能 - 拍照模式設定 + 照片模式設定 專業模式設定 專業模式參數 僅在專業模式下可用 @@ -260,7 +260,7 @@ 調整 HDR+ 相片的輸出尺寸。倍率越高,相片尺寸和檔案大小越大,處理時間也可能更長。 %1$.2f× 多幀降噪幀數 - 拍照模式下多幀降噪使用的幀數。幀數越多降噪越明顯,但處理時間也越長。 + 照片模式下多幀降噪使用的幀數。幀數越多降噪越明顯,但處理時間也越長。 HDR+ 幀數 HDR+ 拍攝使用的幀數。開啟包圍曝光後,最低為 2 幀,使用一般曝光與可用的長曝光;3 幀及以上使用完整包圍曝光方案。 HDR+ 包圍曝光