feat: remove quick shot
This commit is contained in:
1 parent
6405f45109
commit
3c31218e68
20 files changed
+31
-1037
No files matched your search
@@ -43,8 +43,6 @@ import com.hinnka.mycamera.model.ColorRecipeParams
|
||||
import com.hinnka.mycamera.utils.DeviceUtil
|
||||
import com.hinnka.mycamera.utils.OrientationObserver
|
||||
import com.hinnka.mycamera.video.CaptureMode
|
||||
import com.hinnka.mycamera.video.QuickShotCapabilitiesResolver
|
||||
import com.hinnka.mycamera.video.QuickShotResolutionPreset
|
||||
import com.hinnka.mycamera.video.VideoAspectRatio
|
||||
import com.hinnka.mycamera.video.VIDEO_AUDIO_INPUT_AUTO
|
||||
import com.hinnka.mycamera.video.VideoBitratePreset
|
||||
@@ -1929,37 +1927,6 @@ class Camera2Controller(private val context: Context) {
|
||||
return snapshot.previewSize
|
||||
}
|
||||
|
||||
private fun refreshQuickShotCapabilities(characteristics: CameraCharacteristics? = null): Size {
|
||||
val openCameraId = getCurrentOpenCameraId()
|
||||
if (openCameraId.isEmpty()) {
|
||||
return _state.value.currentPreviewSize
|
||||
}
|
||||
|
||||
val resolvedCharacteristics = characteristics
|
||||
?: getCameraCharacteristicsOrNull(openCameraId, "quick-shot capabilities")
|
||||
if (resolvedCharacteristics == null) {
|
||||
PLog.e(TAG, "Failed to load quick-shot capabilities")
|
||||
return _state.value.currentPreviewSize
|
||||
}
|
||||
|
||||
val snapshot = QuickShotCapabilitiesResolver.resolve(
|
||||
characteristics = resolvedCharacteristics,
|
||||
requestedConfig = _state.value.quickShotConfig,
|
||||
aspectRatio = _state.value.aspectRatio
|
||||
)
|
||||
|
||||
_state.value = _state.value.copy(
|
||||
quickShotConfig = snapshot.config,
|
||||
quickShotCapabilities = snapshot.capabilities,
|
||||
currentPreviewSize = if (_state.value.captureMode == CaptureMode.QUICK_SHOT) {
|
||||
snapshot.previewSize
|
||||
} else {
|
||||
_state.value.currentPreviewSize
|
||||
}
|
||||
)
|
||||
return snapshot.previewSize
|
||||
}
|
||||
|
||||
private fun startVideoRecordingTicker() {
|
||||
stopVideoRecordingTicker()
|
||||
videoRecordingStartElapsedMs = SystemClock.elapsedRealtime()
|
||||
@@ -2202,10 +2169,8 @@ class Camera2Controller(private val context: Context) {
|
||||
}
|
||||
|
||||
val resolvedVideoPreviewSize = refreshVideoCapabilities(openCharacteristics)
|
||||
val resolvedQuickShotPreviewSize = refreshQuickShotCapabilities(openCharacteristics)
|
||||
previewSize = when (captureMode) {
|
||||
CaptureMode.VIDEO -> resolvedVideoPreviewSize
|
||||
CaptureMode.QUICK_SHOT -> resolvedQuickShotPreviewSize
|
||||
CaptureMode.PHOTO -> CameraUtils.getFixedPreviewSize(openCharacteristics, _state.value.aspectRatio)
|
||||
}
|
||||
surfaceTexture.setDefaultBufferSize(previewSize.width, previewSize.height)
|
||||
@@ -2259,9 +2224,7 @@ class Camera2Controller(private val context: Context) {
|
||||
awbTemperatureMin = resolveAwbTemperatureRange().lower,
|
||||
awbTemperatureMax = resolveAwbTemperatureRange().upper,
|
||||
currentPreviewSize = previewSize,
|
||||
currentCaptureSize = if (
|
||||
captureMode == CaptureMode.VIDEO || captureMode == CaptureMode.QUICK_SHOT
|
||||
) {
|
||||
currentCaptureSize = if (captureMode == CaptureMode.VIDEO) {
|
||||
previewSize
|
||||
} else {
|
||||
currentState.currentCaptureSize
|
||||
@@ -3722,7 +3685,7 @@ class Camera2Controller(private val context: Context) {
|
||||
return CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE
|
||||
}
|
||||
|
||||
val preferredModes = if (captureMode == CaptureMode.VIDEO || captureMode == CaptureMode.QUICK_SHOT) {
|
||||
val preferredModes = if (captureMode == CaptureMode.VIDEO) {
|
||||
intArrayOf(
|
||||
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_VIDEO,
|
||||
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE,
|
||||
@@ -6136,9 +6099,6 @@ class Camera2Controller(private val context: Context) {
|
||||
*/
|
||||
fun setAspectRatio(ratio: AspectRatio) {
|
||||
_state.value = _state.value.copy(aspectRatio = ratio)
|
||||
if (_state.value.captureMode == CaptureMode.QUICK_SHOT) {
|
||||
refreshQuickShotCapabilities()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6184,11 +6144,6 @@ class Camera2Controller(private val context: Context) {
|
||||
if (mode == CaptureMode.VIDEO) {
|
||||
livePhotoRecorder.stopRecording()
|
||||
refreshVideoCapabilities()
|
||||
} else if (mode == CaptureMode.QUICK_SHOT) {
|
||||
livePhotoRecorder.stopRecording()
|
||||
stopVideoRecordingTicker()
|
||||
_state.value = _state.value.copy(videoRecordingState = VideoRecordingState())
|
||||
refreshQuickShotCapabilities()
|
||||
} else {
|
||||
stopVideoRecordingTicker()
|
||||
_state.value = _state.value.copy(videoRecordingState = VideoRecordingState())
|
||||
@@ -6203,20 +6158,6 @@ class Camera2Controller(private val context: Context) {
|
||||
refreshVideoCapabilities()
|
||||
}
|
||||
|
||||
fun setQuickShotResolution(resolution: QuickShotResolutionPreset) {
|
||||
_state.value = _state.value.copy(
|
||||
quickShotConfig = _state.value.quickShotConfig.copy(resolution = resolution)
|
||||
)
|
||||
refreshQuickShotCapabilities()
|
||||
}
|
||||
|
||||
fun setQuickShotCaptureState(isCapturing: Boolean, burstCapturing: Boolean = false) {
|
||||
_state.value = _state.value.copy(
|
||||
isCapturing = isCapturing,
|
||||
burstCapturing = burstCapturing
|
||||
)
|
||||
}
|
||||
|
||||
fun setVideoFps(fps: VideoFpsPreset) {
|
||||
_state.value = _state.value.copy(videoConfig = _state.value.videoConfig.copy(fps = fps))
|
||||
refreshVideoCapabilities()
|
||||
|
||||
@@ -4,8 +4,6 @@ import android.graphics.Rect
|
||||
import android.util.Range
|
||||
import android.util.Size
|
||||
import com.hinnka.mycamera.video.CaptureMode
|
||||
import com.hinnka.mycamera.video.QuickShotCapabilities
|
||||
import com.hinnka.mycamera.video.QuickShotConfig
|
||||
import com.hinnka.mycamera.video.VideoCapabilities
|
||||
import com.hinnka.mycamera.video.VideoConfig
|
||||
import com.hinnka.mycamera.video.VideoRecordingState
|
||||
@@ -378,8 +376,6 @@ data class CameraState(
|
||||
val isP3Supported: Boolean = false,
|
||||
val currentDynamicRangeProfile: String = "STANDARD",
|
||||
val captureMode: CaptureMode = CaptureMode.PHOTO,
|
||||
val quickShotConfig: QuickShotConfig = QuickShotConfig(),
|
||||
val quickShotCapabilities: QuickShotCapabilities = QuickShotCapabilities(),
|
||||
val videoConfig: VideoConfig = VideoConfig(),
|
||||
val videoCapabilities: VideoCapabilities = VideoCapabilities(),
|
||||
val videoRecordingState: VideoRecordingState = VideoRecordingState(),
|
||||
@@ -449,8 +445,7 @@ data class CameraState(
|
||||
val sensorRange = getShutterSpeedRange()
|
||||
val upper = when (captureMode) {
|
||||
CaptureMode.VIDEO -> sensorRange.upper.coerceAtMost(MAX_VIDEO_MANUAL_SHUTTER_SPEED_NS)
|
||||
CaptureMode.PHOTO,
|
||||
CaptureMode.QUICK_SHOT -> sensorRange.upper
|
||||
CaptureMode.PHOTO -> sensorRange.upper
|
||||
}.coerceAtLeast(sensorRange.lower)
|
||||
return Range(sensorRange.lower, upper)
|
||||
}
|
||||
@@ -458,8 +453,7 @@ data class CameraState(
|
||||
fun getPreviewExposureTimeLimitNs(): Long {
|
||||
return when (captureMode) {
|
||||
CaptureMode.VIDEO -> MAX_VIDEO_MANUAL_SHUTTER_SPEED_NS
|
||||
CaptureMode.PHOTO,
|
||||
CaptureMode.QUICK_SHOT -> MAX_PHOTO_PREVIEW_SHUTTER_SPEED_NS
|
||||
CaptureMode.PHOTO -> MAX_PHOTO_PREVIEW_SHUTTER_SPEED_NS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,7 +497,7 @@ data class CameraState(
|
||||
|
||||
fun getPreviewAspectRatio(): Float {
|
||||
return when (captureMode) {
|
||||
CaptureMode.PHOTO, CaptureMode.QUICK_SHOT -> aspectRatio.getValue(isLandscape = false)
|
||||
CaptureMode.PHOTO -> aspectRatio.getValue(isLandscape = false)
|
||||
CaptureMode.VIDEO -> videoConfig.aspectRatio.getPortraitAspectRatio(
|
||||
videoCapabilities.openGatePortraitAspectRatio
|
||||
)
|
||||
|
||||
@@ -41,7 +41,6 @@ import com.hinnka.mycamera.screencapture.PhantomPipCrop
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import com.hinnka.mycamera.video.CaptureMode
|
||||
import com.hinnka.mycamera.video.QuickShotResolutionPreset
|
||||
import com.hinnka.mycamera.video.VideoAspectRatio
|
||||
import com.hinnka.mycamera.video.VIDEO_AUDIO_INPUT_AUTO
|
||||
import com.hinnka.mycamera.video.VideoBitratePreset
|
||||
@@ -231,7 +230,6 @@ data class UserPreferences(
|
||||
val useHlg10: Boolean = false,
|
||||
val hlgHardwareCompatibilityEnabled: Boolean = false,
|
||||
val useP3ColorSpace: Boolean = false,
|
||||
val quickShotResolution: QuickShotResolutionPreset = QuickShotResolutionPreset.FHD_1080P,
|
||||
val videoResolution: VideoResolutionPreset = VideoResolutionPreset.FHD_1080P,
|
||||
val videoFps: VideoFpsPreset = VideoFpsPreset.FPS_30,
|
||||
val videoAspectRatio: VideoAspectRatio = VideoAspectRatio.RATIO_16_9,
|
||||
@@ -492,7 +490,6 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
private val USE_HLG10 = booleanPreferencesKey("use_hlg10")
|
||||
private val HLG_HARDWARE_COMPATIBILITY_ENABLED = booleanPreferencesKey("hlg_hardware_compatibility_enabled")
|
||||
private val USE_P3_COLOR_SPACE = booleanPreferencesKey("use_p3_color_space")
|
||||
private val QUICK_SHOT_RESOLUTION = stringPreferencesKey("quick_shot_resolution")
|
||||
private val VIDEO_RESOLUTION = stringPreferencesKey("video_resolution")
|
||||
private val VIDEO_FPS = stringPreferencesKey("video_fps")
|
||||
private val VIDEO_ASPECT_RATIO = stringPreferencesKey("video_aspect_ratio")
|
||||
@@ -589,7 +586,9 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
}
|
||||
val useRawMaxHdrComposition = rawMaxSpatialMode == MgcRawMaxMode.SPATIAL
|
||||
UserPreferences(
|
||||
captureMode = CaptureMode.valueOf(preferences[CAPTURE_MODE] ?: CaptureMode.PHOTO.name),
|
||||
captureMode = CaptureMode.entries.firstOrNull {
|
||||
it.name == preferences[CAPTURE_MODE]
|
||||
} ?: CaptureMode.PHOTO,
|
||||
aspectRatio = preferences[ASPECT_RATIO_KEY] ?: "RATIO_4_3",
|
||||
topSheetAspectRatios = parseTopSheetAspectRatios(
|
||||
preferences[TOP_SHEET_ASPECT_RATIOS],
|
||||
@@ -778,11 +777,6 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
useHlg10 = preferences[USE_HLG10] ?: false,
|
||||
hlgHardwareCompatibilityEnabled = preferences[HLG_HARDWARE_COMPATIBILITY_ENABLED] ?: false,
|
||||
useP3ColorSpace = preferences[USE_P3_COLOR_SPACE] ?: false,
|
||||
quickShotResolution = runCatching {
|
||||
QuickShotResolutionPreset.valueOf(
|
||||
preferences[QUICK_SHOT_RESOLUTION] ?: QuickShotResolutionPreset.FHD_1080P.name
|
||||
)
|
||||
}.getOrDefault(QuickShotResolutionPreset.FHD_1080P),
|
||||
videoResolution = VideoResolutionPreset.valueOf(
|
||||
preferences[VIDEO_RESOLUTION] ?: VideoResolutionPreset.FHD_1080P.name
|
||||
),
|
||||
@@ -2190,12 +2184,6 @@ class UserPreferencesRepository(private val context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun saveQuickShotResolution(resolution: QuickShotResolutionPreset) {
|
||||
context.dataStore.edit { preferences ->
|
||||
preferences[QUICK_SHOT_RESOLUTION] = resolution.name
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun saveVideoResolution(resolution: VideoResolutionPreset) {
|
||||
context.dataStore.edit { preferences ->
|
||||
preferences[VIDEO_RESOLUTION] = resolution.name
|
||||
|
||||
@@ -1282,7 +1282,6 @@ object GalleryManager {
|
||||
): Boolean {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val tempExportFile = File(context.cacheDir, "temp_export_${System.nanoTime()}.jpg")
|
||||
var quickShotSourceBitmap: Bitmap? = null
|
||||
try {
|
||||
val hasEncodingOverride =
|
||||
preferHeicExport != null || preferJpeg444Export != null
|
||||
@@ -1305,23 +1304,7 @@ object GalleryManager {
|
||||
(exportPreferences?.useJpeg444Export ?: false) && !shouldPreferHeic
|
||||
}
|
||||
val exportDestination = resolvePhotoExportDestination(context)
|
||||
quickShotSourceBitmap = if (
|
||||
bitmap == null &&
|
||||
metadata.captureMode == "quick_shot" &&
|
||||
getOriginalImageFile(context, id) == null
|
||||
) {
|
||||
metadata.sourceUri
|
||||
?.let(Uri::parse)
|
||||
?.let { sourceUri -> loadBitmap(context, sourceUri) }
|
||||
.also { sourceBitmap ->
|
||||
if (sourceBitmap == null && !metadata.sourceUri.isNullOrBlank()) {
|
||||
PLog.w(TAG, "Unable to load quick-shot source for export: ${metadata.sourceUri}")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val exportInputBitmap = bitmap ?: quickShotSourceBitmap
|
||||
val exportInputBitmap = bitmap
|
||||
|
||||
if (
|
||||
!shouldPreferHeic &&
|
||||
@@ -1631,7 +1614,6 @@ object GalleryManager {
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to export photo", e)
|
||||
} finally {
|
||||
quickShotSourceBitmap?.takeUnless { it.isRecycled }?.recycle()
|
||||
tempExportFile.delete()
|
||||
}
|
||||
|
||||
@@ -1689,120 +1671,6 @@ object GalleryManager {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun saveQuickShotBitmapToSystemGallery(
|
||||
context: Context,
|
||||
metadata: MediaMetadata,
|
||||
bitmap: Bitmap,
|
||||
photoQuality: Int,
|
||||
photoId: String = UUID.randomUUID().toString()
|
||||
): String? = withContext(Dispatchers.IO) {
|
||||
val date = metadata.dateTaken ?: System.currentTimeMillis()
|
||||
val baseFilename = "PhotonCamera_${SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US).format(Date(date))}"
|
||||
val photoDir = getPhotoDir(context, photoId, true)
|
||||
var exportedUri: Uri? = null
|
||||
var tempFile: File? = null
|
||||
try {
|
||||
val exportPreferences = ContentRepository.getInstance(context)
|
||||
.userPreferencesRepository
|
||||
.userPreferences
|
||||
.firstOrNull()
|
||||
val shouldPreferHeic = exportPreferences?.useHeicExport ?: false
|
||||
val shouldPreferJpeg444 =
|
||||
(exportPreferences?.useJpeg444Export ?: false) && !shouldPreferHeic
|
||||
val captureInfo = metadata.toCaptureInfo().copy(
|
||||
imageWidth = bitmap.width,
|
||||
imageHeight = bitmap.height
|
||||
)
|
||||
|
||||
var extension = "jpg"
|
||||
var mimeType = "image/jpeg"
|
||||
var encodedFile: File? = null
|
||||
if (shouldPreferHeic) {
|
||||
val heicFile = File(context.cacheDir, "temp_quick_shot_${System.nanoTime()}.${HeicExportEncoder.EXTENSION}")
|
||||
val exifData = ExifWriter.buildExifBlock(context.cacheDir, captureInfo)
|
||||
val heicSaved = exifData != null && HeicExportEncoder.write(
|
||||
bitmap = bitmap,
|
||||
outputFile = heicFile,
|
||||
quality = photoQuality,
|
||||
exifData = exifData
|
||||
)
|
||||
if (heicSaved) {
|
||||
extension = HeicExportEncoder.EXTENSION
|
||||
mimeType = HeicExportEncoder.MIME_TYPE
|
||||
encodedFile = heicFile
|
||||
} else {
|
||||
heicFile.delete()
|
||||
PLog.w(TAG, "Quick-shot HEIC save failed or unsupported, falling back to JPEG")
|
||||
}
|
||||
}
|
||||
|
||||
if (encodedFile == null) {
|
||||
val jpegFile = File(context.cacheDir, "temp_quick_shot_${System.nanoTime()}.jpg")
|
||||
val jpegSaved = writeExportJpeg(
|
||||
bitmap = bitmap,
|
||||
outputFile = jpegFile,
|
||||
quality = photoQuality,
|
||||
captureInfo = captureInfo,
|
||||
preferJpeg444 = shouldPreferJpeg444,
|
||||
)
|
||||
if (!jpegSaved) {
|
||||
jpegFile.delete()
|
||||
photoDir.deleteRecursively()
|
||||
return@withContext null
|
||||
}
|
||||
encodedFile = jpegFile
|
||||
}
|
||||
tempFile = encodedFile
|
||||
val filename = "$baseFilename.$extension"
|
||||
|
||||
val destination = resolvePhotoExportDestination(context)
|
||||
exportedUri = exportFileToConfiguredPhotoStorage(
|
||||
context = context,
|
||||
destination = destination,
|
||||
collectionUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
|
||||
displayName = filename,
|
||||
mimeType = mimeType,
|
||||
sourceFile = encodedFile,
|
||||
dateTaken = date,
|
||||
)
|
||||
val uri = exportedUri ?: run {
|
||||
photoDir.deleteRecursively()
|
||||
return@withContext null
|
||||
}
|
||||
|
||||
generateThumbnail(bitmap, getThumbnailFile(context, photoId))
|
||||
val savedMetadata = metadata.copy(
|
||||
mediaType = MediaType.IMAGE,
|
||||
sourceUri = uri.toString(),
|
||||
exportedUris = emptyList(),
|
||||
mimeType = mimeType,
|
||||
width = bitmap.width,
|
||||
height = bitmap.height,
|
||||
captureMode = metadata.captureMode ?: "quick_shot"
|
||||
)
|
||||
val metadataSaved = saveMetadata(context, photoId, savedMetadata)
|
||||
if (!metadataSaved) {
|
||||
discardPhotoExportUri(context, uri)
|
||||
photoDir.deleteRecursively()
|
||||
return@withContext null
|
||||
}
|
||||
photoDir.setLastModified(date)
|
||||
notifyPhotoLibraryChanged()
|
||||
PLog.d(
|
||||
TAG,
|
||||
"Quick-shot bitmap saved directly to system gallery: $uri, photoId=$photoId, mimeType=$mimeType"
|
||||
)
|
||||
photoId
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to save quick-shot bitmap to system gallery", e)
|
||||
exportedUri?.let { discardPhotoExportUri(context, it) }
|
||||
photoDir.deleteRecursively()
|
||||
null
|
||||
} finally {
|
||||
tempFile?.delete()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun exportEncodedPhotoToMediaStore(
|
||||
context: Context,
|
||||
id: String,
|
||||
@@ -4941,7 +4809,7 @@ object GalleryManager {
|
||||
val shouldDeleteSourceUri = metadata != null &&
|
||||
!metadata.isImported &&
|
||||
!sourceUri.isNullOrBlank() &&
|
||||
(metadata.mediaType == MediaType.VIDEO || metadata.captureMode == "quick_shot")
|
||||
metadata.mediaType == MediaType.VIDEO
|
||||
if (shouldDeleteSourceUri) {
|
||||
add(sourceUri)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ import com.hinnka.mycamera.utils.OrientationObserver
|
||||
import com.hinnka.mycamera.viewmodel.CameraViewModel
|
||||
import com.hinnka.mycamera.viewmodel.GalleryViewModel
|
||||
import com.hinnka.mycamera.video.CaptureMode
|
||||
import com.hinnka.mycamera.video.QuickShotResolutionPreset
|
||||
import com.hinnka.mycamera.video.VideoAspectRatio
|
||||
import com.hinnka.mycamera.video.VideoFpsPreset
|
||||
import com.hinnka.mycamera.video.VideoLogProfile
|
||||
@@ -554,10 +553,6 @@ fun CameraScreen(
|
||||
}
|
||||
|
||||
fun animateZoomStopWithPreviewTransition(targetZoom: Float) {
|
||||
if (state.captureMode != CaptureMode.PHOTO && state.captureMode != CaptureMode.VIDEO) {
|
||||
setZoomWithPreviewTransition(targetZoom)
|
||||
return
|
||||
}
|
||||
if (viewModel.isVideoLensLocked() ||
|
||||
viewModel.isCurrentLensCustomZoomRatioStop(targetZoom)
|
||||
) {
|
||||
@@ -667,8 +662,7 @@ fun CameraScreen(
|
||||
) {
|
||||
val canRevealInitialPreview =
|
||||
canStartShutterAnimation ||
|
||||
state.captureMode == CaptureMode.VIDEO ||
|
||||
state.captureMode == CaptureMode.QUICK_SHOT
|
||||
state.captureMode == CaptureMode.VIDEO
|
||||
if (hasPlayedInitialPreviewTransition || !state.isPreviewActive || !canRevealInitialPreview) return@LaunchedEffect
|
||||
previewTransitionActive = true
|
||||
delay(InitialPreviewTransitionDelayMillis)
|
||||
@@ -850,11 +844,6 @@ fun CameraScreen(
|
||||
},
|
||||
useLivePhoto = useLivePhoto,
|
||||
onLivePhotoToggle = { viewModel.setUseLivePhoto(!state.useLivePhoto) },
|
||||
quickShotConfig = state.quickShotConfig,
|
||||
quickShotCapabilities = state.quickShotCapabilities,
|
||||
onQuickShotResolutionClick = {
|
||||
cycleQuickShotResolution(state)?.let(viewModel::setQuickShotResolution)
|
||||
},
|
||||
videoConfig = state.videoConfig,
|
||||
videoCapabilities = state.videoCapabilities,
|
||||
onVideoTorchToggle = { viewModel.setVideoTorchEnabled(!state.videoConfig.torchEnabled) },
|
||||
@@ -1606,9 +1595,6 @@ fun CameraScreen(
|
||||
videoAudioInputId = state.videoConfig.audioInputId,
|
||||
videoAudioInputOptions = videoAudioInputOptions,
|
||||
onVideoAudioInputChange = { viewModel.setVideoAudioInputId(it) },
|
||||
quickShotResolution = state.quickShotConfig.resolution,
|
||||
quickShotCapabilities = state.quickShotCapabilities,
|
||||
onQuickShotResolutionChange = { runPreviewTransition { viewModel.setQuickShotResolution(it) } },
|
||||
useRaw = useRaw && state.isRawSupported,
|
||||
onRawToggle = { viewModel.setUseRaw(it) },
|
||||
isRawSupported = state.isRawSupported,
|
||||
@@ -2014,10 +2000,9 @@ fun Controls(
|
||||
isVideoRecording = state.videoRecordingState.isRecording,
|
||||
isVideoProcessing = state.videoRecordingState.isProcessing,
|
||||
isPaused = state.videoRecordingState.isPaused,
|
||||
allowLongPress = state.captureMode == CaptureMode.QUICK_SHOT ||
|
||||
(!naturalLightEnabled &&
|
||||
state.captureMode == CaptureMode.PHOTO &&
|
||||
!useMultipleExposure),
|
||||
allowLongPress = !naturalLightEnabled &&
|
||||
state.captureMode == CaptureMode.PHOTO &&
|
||||
!useMultipleExposure,
|
||||
multipleExposureEnabled = useMultipleExposure && state.captureMode == CaptureMode.PHOTO,
|
||||
multipleExposureProgress = multipleExposureState.capturedCount.toFloat() /
|
||||
multipleExposureState.targetCount.coerceAtLeast(1).toFloat(),
|
||||
@@ -2328,7 +2313,7 @@ private fun CaptureModeSwitcher(
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.width(148.dp)
|
||||
.width(100.dp)
|
||||
.height(30.dp)
|
||||
.clip(RoundedCornerShape(16.dp))
|
||||
.background(Color.White.copy(alpha = 0.12f))
|
||||
@@ -2337,9 +2322,8 @@ private fun CaptureModeSwitcher(
|
||||
val knobWidth = 48.dp
|
||||
val knobOffset by animateDpAsState(
|
||||
targetValue = when (captureMode) {
|
||||
CaptureMode.QUICK_SHOT -> 0.dp
|
||||
CaptureMode.PHOTO -> 48.dp
|
||||
CaptureMode.VIDEO -> 96.dp
|
||||
CaptureMode.PHOTO -> 0.dp
|
||||
CaptureMode.VIDEO -> 48.dp
|
||||
},
|
||||
animationSpec = tween(durationMillis = 220),
|
||||
label = "modeSwitcher"
|
||||
@@ -2356,14 +2340,6 @@ private fun CaptureModeSwitcher(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
ModeSwitcherItem(
|
||||
icon = AppIcons.Bolt,
|
||||
selected = captureMode == CaptureMode.QUICK_SHOT,
|
||||
enabled = enabled,
|
||||
contentDescription = stringResource(R.string.capture_mode_quick_shot),
|
||||
onClick = { onModeSelected(CaptureMode.QUICK_SHOT) },
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
ModeSwitcherItem(
|
||||
icon = AppIcons.CameraAlt,
|
||||
selected = captureMode == CaptureMode.PHOTO,
|
||||
@@ -2413,10 +2389,6 @@ private fun cycleVideoResolution(state: CameraState): VideoResolutionPreset? {
|
||||
return nextOption(state.videoConfig.resolution, state.videoCapabilities.availableResolutions)
|
||||
}
|
||||
|
||||
private fun cycleQuickShotResolution(state: CameraState): QuickShotResolutionPreset? {
|
||||
return nextOption(state.quickShotConfig.resolution, state.quickShotCapabilities.availableResolutions)
|
||||
}
|
||||
|
||||
private fun cycleVideoFps(state: CameraState): VideoFpsPreset? {
|
||||
return nextOption(state.videoConfig.fps, state.videoCapabilities.availableFps)
|
||||
}
|
||||
|
||||
@@ -26,9 +26,6 @@ import androidx.compose.ui.unit.sp
|
||||
import com.hinnka.mycamera.R
|
||||
import com.hinnka.mycamera.ui.components.PhysicalButton
|
||||
import com.hinnka.mycamera.video.CaptureMode
|
||||
import com.hinnka.mycamera.video.QuickShotCapabilities
|
||||
import com.hinnka.mycamera.video.QuickShotConfig
|
||||
import com.hinnka.mycamera.video.QuickShotResolutionPreset
|
||||
import com.hinnka.mycamera.video.VideoAspectRatio
|
||||
import com.hinnka.mycamera.video.VideoCapabilities
|
||||
import com.hinnka.mycamera.video.VideoConfig
|
||||
@@ -49,9 +46,6 @@ fun CameraTopBar(
|
||||
onHistogramToggle: () -> Unit,
|
||||
useLivePhoto: Boolean,
|
||||
onLivePhotoToggle: () -> Unit,
|
||||
quickShotConfig: QuickShotConfig,
|
||||
quickShotCapabilities: QuickShotCapabilities,
|
||||
onQuickShotResolutionClick: () -> Unit,
|
||||
videoConfig: VideoConfig,
|
||||
videoCapabilities: VideoCapabilities,
|
||||
onVideoTorchToggle: () -> Unit,
|
||||
@@ -77,23 +71,6 @@ fun CameraTopBar(
|
||||
return
|
||||
}
|
||||
|
||||
if (captureMode == CaptureMode.QUICK_SHOT) {
|
||||
QuickShotTopBar(
|
||||
flashMode = flashMode,
|
||||
onFlashToggle = onFlashToggle,
|
||||
timerSeconds = timerSeconds,
|
||||
onTimerToggle = onTimerToggle,
|
||||
showHistogram = showHistogram,
|
||||
onHistogramToggle = onHistogramToggle,
|
||||
quickShotConfig = quickShotConfig,
|
||||
quickShotCapabilities = quickShotCapabilities,
|
||||
onQuickShotResolutionClick = onQuickShotResolutionClick,
|
||||
onSettingsClick = onSettingsClick,
|
||||
modifier = modifier
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
@@ -178,76 +155,6 @@ fun CameraTopBar(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun QuickShotTopBar(
|
||||
flashMode: Int,
|
||||
onFlashToggle: () -> Unit,
|
||||
timerSeconds: Int,
|
||||
onTimerToggle: () -> Unit,
|
||||
showHistogram: Boolean,
|
||||
onHistogramToggle: () -> Unit,
|
||||
quickShotConfig: QuickShotConfig,
|
||||
quickShotCapabilities: QuickShotCapabilities,
|
||||
onQuickShotResolutionClick: () -> Unit,
|
||||
onSettingsClick: () -> Unit,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
Row(
|
||||
modifier = modifier
|
||||
.fillMaxWidth()
|
||||
.padding(top = 32.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
IconButton(onClick = onFlashToggle) {
|
||||
Icon(
|
||||
imageVector = when (flashMode) {
|
||||
0 -> AppIcons.FlashOff
|
||||
1 -> AppIcons.FlashOn
|
||||
2 -> AppIcons.FlashlightOn
|
||||
else -> AppIcons.FlashOff
|
||||
},
|
||||
modifier = Modifier.size(20.dp).autoRotate(),
|
||||
contentDescription = stringResource(R.string.flash),
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
|
||||
IconButton(
|
||||
onClick = onQuickShotResolutionClick,
|
||||
modifier = Modifier.size(64.dp, 48.dp),
|
||||
enabled = quickShotCapabilities.availableResolutions.size > 1
|
||||
) {
|
||||
Text(
|
||||
text = quickShotResolutionLabel(quickShotConfig.resolution),
|
||||
color = if (quickShotCapabilities.availableResolutions.size > 1) Color.White else Color.White.copy(alpha = 0.5f),
|
||||
fontSize = 12.sp,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontFamily = FontFamily.Monospace,
|
||||
modifier = Modifier.autoRotate()
|
||||
)
|
||||
}
|
||||
|
||||
IconButton(onClick = onHistogramToggle) {
|
||||
Icon(
|
||||
imageVector = AppIcons.BarChart,
|
||||
contentDescription = stringResource(R.string.histogram),
|
||||
modifier = Modifier.size(20.dp).autoRotate(),
|
||||
tint = if (showHistogram) Color.Yellow else Color.White
|
||||
)
|
||||
}
|
||||
|
||||
IconButton(onClick = onSettingsClick) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.Settings,
|
||||
contentDescription = stringResource(R.string.settings),
|
||||
modifier = Modifier.size(20.dp).autoRotate(),
|
||||
tint = Color.White
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun VideoTopBar(
|
||||
isRecording: Boolean,
|
||||
@@ -352,14 +259,6 @@ private fun VideoParameterCluster(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun quickShotResolutionLabel(resolution: QuickShotResolutionPreset): String {
|
||||
return when (resolution) {
|
||||
QuickShotResolutionPreset.FULL -> stringResource(R.string.quick_shot_resolution_full)
|
||||
else -> resolution.displayName
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ParameterText(
|
||||
text: String,
|
||||
|
||||
@@ -115,9 +115,6 @@ fun CameraTopSheet(
|
||||
videoAudioInputId: String,
|
||||
videoAudioInputOptions: List<VideoAudioInputOption>,
|
||||
onVideoAudioInputChange: (String) -> Unit,
|
||||
quickShotResolution: QuickShotResolutionPreset,
|
||||
quickShotCapabilities: QuickShotCapabilities,
|
||||
onQuickShotResolutionChange: (QuickShotResolutionPreset) -> Unit,
|
||||
useRaw: Boolean,
|
||||
onRawToggle: (Boolean) -> Unit,
|
||||
isRawSupported: Boolean,
|
||||
@@ -379,7 +376,7 @@ fun CameraTopSheet(
|
||||
handleContentManagementAction(onPresetManageClick)
|
||||
}
|
||||
)
|
||||
} else if (captureMode == CaptureMode.VIDEO) {
|
||||
} else {
|
||||
SectionLabel(title = stringResource(R.string.video_aspect_chip))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
@@ -543,56 +540,9 @@ fun CameraTopSheet(
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SectionLabel(title = stringResource(R.string.aspect_ratio))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
AspectRatio.sanitizeTopSheetRatios(topSheetAspectRatios).forEach { ratio ->
|
||||
val isSelected = aspectRatio == ratio
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.height(40.dp)
|
||||
.clip(RoundedCornerShape(8.dp))
|
||||
.background(
|
||||
if (isSelected) Color(0xFFFF6B35) else Color.White.copy(
|
||||
alpha = 0.12f
|
||||
)
|
||||
)
|
||||
.clickable { onAspectRatioChange(ratio) },
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = ratio.getDisplayName(),
|
||||
color = if (isSelected) Color.Black else Color.White,
|
||||
fontSize = 11.sp,
|
||||
fontWeight = if (isSelected) FontWeight.Bold else FontWeight.Medium
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
horizontalArrangement = Arrangement.spacedBy(10.dp)
|
||||
) {
|
||||
MeteringModeQuickSetting(
|
||||
meteringMode = meteringMode,
|
||||
onMeteringModeChange = onMeteringModeChange,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
ToolboxQuickSetting(
|
||||
onToolboxClick = onToolboxClick,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (captureMode != CaptureMode.PHOTO) {
|
||||
if (captureMode == CaptureMode.VIDEO) {
|
||||
Spacer(modifier = Modifier.height(16.dp))
|
||||
|
||||
ContentManagementQuickSetting(
|
||||
@@ -914,14 +864,6 @@ private fun videoAspectRatioLabel(aspectRatio: VideoAspectRatio): String {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun quickShotResolutionLabel(resolution: QuickShotResolutionPreset): String {
|
||||
return when (resolution) {
|
||||
QuickShotResolutionPreset.FULL -> stringResource(R.string.quick_shot_resolution_full)
|
||||
else -> resolution.displayName
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun videoLogProfileLabel(profile: VideoLogProfile): String {
|
||||
return when (profile) {
|
||||
|
||||
@@ -180,31 +180,6 @@ object AppIcons {
|
||||
}
|
||||
}
|
||||
|
||||
val Bolt: ImageVector
|
||||
get() {
|
||||
_bolt?.let { return it }
|
||||
return ImageVector.Builder(
|
||||
name = "AppIcons.Bolt",
|
||||
defaultWidth = 24f.dp,
|
||||
defaultHeight = 24f.dp,
|
||||
viewportWidth = 960f,
|
||||
viewportHeight = 960f,
|
||||
autoMirror = false,
|
||||
).apply {
|
||||
group(
|
||||
translationY = 960f,
|
||||
) {
|
||||
addPath(
|
||||
pathData = addPathNodes("m320-80 40-280H160l360-520h80l-40 320h240L400-80h-80Z"),
|
||||
fill = SolidColor(Color.Black),
|
||||
pathFillType = PathFillType.NonZero,
|
||||
)
|
||||
}
|
||||
}.build().also {
|
||||
_bolt = it
|
||||
}
|
||||
}
|
||||
|
||||
val Bookmark: ImageVector
|
||||
get() {
|
||||
_bookmark?.let { return it }
|
||||
@@ -1553,7 +1528,6 @@ private var _addPhotoAlternate: ImageVector? = null
|
||||
private var _article: ImageVector? = null
|
||||
private var _autoAwesome: ImageVector? = null
|
||||
private var _barChart: ImageVector? = null
|
||||
private var _bolt: ImageVector? = null
|
||||
private var _bookmark: ImageVector? = null
|
||||
private var _borderBottom: ImageVector? = null
|
||||
private var _burstMode: ImageVector? = null
|
||||
|
||||
@@ -1,162 +0,0 @@
|
||||
package com.hinnka.mycamera.video
|
||||
|
||||
import android.graphics.SurfaceTexture
|
||||
import android.hardware.camera2.CameraCharacteristics
|
||||
import android.util.Size
|
||||
import com.hinnka.mycamera.camera.AspectRatio
|
||||
import com.hinnka.mycamera.utils.PLog
|
||||
import kotlin.math.abs
|
||||
|
||||
enum class QuickShotResolutionPreset(
|
||||
val displayName: String,
|
||||
val targetLongEdge: Int?
|
||||
) {
|
||||
FHD_1080P("1080p", 1920),
|
||||
QHD_2K("2K", 2560),
|
||||
UHD_4K("4K", 3840),
|
||||
FULL("Full", null);
|
||||
}
|
||||
|
||||
data class QuickShotConfig(
|
||||
val resolution: QuickShotResolutionPreset = QuickShotResolutionPreset.FHD_1080P
|
||||
)
|
||||
|
||||
data class QuickShotCapabilities(
|
||||
val availableResolutions: List<QuickShotResolutionPreset> = emptyList(),
|
||||
val previewSizesByResolution: Map<QuickShotResolutionPreset, Size> = emptyMap()
|
||||
)
|
||||
|
||||
data class QuickShotCapabilitySnapshot(
|
||||
val config: QuickShotConfig,
|
||||
val capabilities: QuickShotCapabilities,
|
||||
val previewSize: Size
|
||||
)
|
||||
|
||||
data class QuickShotOutputSize(
|
||||
val width: Int,
|
||||
val height: Int
|
||||
) {
|
||||
val longEdge: Int
|
||||
get() = maxOf(width, height)
|
||||
|
||||
val area: Long
|
||||
get() = width.toLong() * height.toLong()
|
||||
|
||||
fun portraitAspectRatio(): Float {
|
||||
val shortEdge = minOf(width, height).coerceAtLeast(1)
|
||||
return shortEdge.toFloat() / longEdge.coerceAtLeast(1).toFloat()
|
||||
}
|
||||
|
||||
fun toAndroidSize(): Size = Size(width, height)
|
||||
}
|
||||
|
||||
data class QuickShotSizeSnapshot(
|
||||
val config: QuickShotConfig,
|
||||
val availableResolutions: List<QuickShotResolutionPreset>,
|
||||
val previewSizesByResolution: Map<QuickShotResolutionPreset, QuickShotOutputSize>,
|
||||
val previewSize: QuickShotOutputSize
|
||||
)
|
||||
|
||||
object QuickShotCapabilitiesResolver {
|
||||
private const val TAG = "QuickShotCapabilitiesResolver"
|
||||
private val FALLBACK_SIZE = QuickShotOutputSize(1440, 1920)
|
||||
|
||||
fun resolve(
|
||||
characteristics: CameraCharacteristics,
|
||||
requestedConfig: QuickShotConfig,
|
||||
aspectRatio: AspectRatio
|
||||
): QuickShotCapabilitySnapshot {
|
||||
val streamConfigMap = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
|
||||
val previewOutputSizes = try {
|
||||
streamConfigMap?.getOutputSizes(SurfaceTexture::class.java)
|
||||
?.map { QuickShotOutputSize(it.width, it.height) }
|
||||
.orEmpty()
|
||||
} catch (e: Exception) {
|
||||
PLog.w(TAG, "Failed to query quick-shot preview sizes: ${e.message}")
|
||||
emptyList()
|
||||
}
|
||||
val sizeSnapshot = resolveFromOutputSizes(
|
||||
outputSizes = previewOutputSizes,
|
||||
requestedConfig = requestedConfig,
|
||||
portraitAspectRatio = aspectRatio.getValue(isLandscape = false)
|
||||
)
|
||||
return QuickShotCapabilitySnapshot(
|
||||
config = sizeSnapshot.config,
|
||||
capabilities = QuickShotCapabilities(
|
||||
availableResolutions = sizeSnapshot.availableResolutions,
|
||||
previewSizesByResolution = sizeSnapshot.previewSizesByResolution.mapValues { it.value.toAndroidSize() }
|
||||
),
|
||||
previewSize = sizeSnapshot.previewSize.toAndroidSize()
|
||||
)
|
||||
}
|
||||
|
||||
fun resolveFromOutputSizes(
|
||||
outputSizes: List<QuickShotOutputSize>,
|
||||
requestedConfig: QuickShotConfig,
|
||||
portraitAspectRatio: Float
|
||||
): QuickShotSizeSnapshot {
|
||||
val sanitizedSizes = outputSizes
|
||||
.filter { it.width > 0 && it.height > 0 }
|
||||
.distinct()
|
||||
|
||||
if (sanitizedSizes.isEmpty()) {
|
||||
return QuickShotSizeSnapshot(
|
||||
config = requestedConfig.copy(resolution = QuickShotResolutionPreset.FHD_1080P),
|
||||
availableResolutions = listOf(QuickShotResolutionPreset.FHD_1080P),
|
||||
previewSizesByResolution = mapOf(QuickShotResolutionPreset.FHD_1080P to FALLBACK_SIZE),
|
||||
previewSize = FALLBACK_SIZE
|
||||
)
|
||||
}
|
||||
|
||||
val availableSizes = QuickShotResolutionPreset.entries.mapNotNull { preset ->
|
||||
val size = findBestOutputSize(sanitizedSizes, preset, portraitAspectRatio)
|
||||
size?.let { preset to it }
|
||||
}
|
||||
val availableResolutions = availableSizes.map { it.first }
|
||||
val resolvedResolution = requestedConfig.resolution.takeIf { it in availableResolutions }
|
||||
?: availableResolutions.firstOrNull()
|
||||
?: QuickShotResolutionPreset.FHD_1080P
|
||||
val previewSizesByResolution = availableSizes.toMap()
|
||||
val previewSize = previewSizesByResolution[resolvedResolution]
|
||||
?: findFullSize(sanitizedSizes, portraitAspectRatio)
|
||||
?: FALLBACK_SIZE
|
||||
|
||||
return QuickShotSizeSnapshot(
|
||||
config = requestedConfig.copy(resolution = resolvedResolution),
|
||||
availableResolutions = availableResolutions.ifEmpty { listOf(resolvedResolution) },
|
||||
previewSizesByResolution = previewSizesByResolution.ifEmpty { mapOf(resolvedResolution to previewSize) },
|
||||
previewSize = previewSize
|
||||
)
|
||||
}
|
||||
|
||||
private fun findBestOutputSize(
|
||||
outputSizes: List<QuickShotOutputSize>,
|
||||
preset: QuickShotResolutionPreset,
|
||||
portraitAspectRatio: Float
|
||||
): QuickShotOutputSize? {
|
||||
if (preset == QuickShotResolutionPreset.FULL) {
|
||||
return findFullSize(outputSizes, portraitAspectRatio)
|
||||
}
|
||||
val targetLongEdge = preset.targetLongEdge ?: return null
|
||||
return outputSizes
|
||||
.filter { it.longEdge >= targetLongEdge }
|
||||
.sortedWith(
|
||||
compareBy<QuickShotOutputSize> { abs(it.portraitAspectRatio() - portraitAspectRatio) }
|
||||
.thenBy { abs(it.longEdge - targetLongEdge) }
|
||||
.thenBy { it.area }
|
||||
)
|
||||
.firstOrNull()
|
||||
}
|
||||
|
||||
private fun findFullSize(
|
||||
outputSizes: List<QuickShotOutputSize>,
|
||||
portraitAspectRatio: Float
|
||||
): QuickShotOutputSize? {
|
||||
return outputSizes
|
||||
.sortedWith(
|
||||
compareByDescending<QuickShotOutputSize> { it.area }
|
||||
.thenBy { abs(it.portraitAspectRatio() - portraitAspectRatio) }
|
||||
)
|
||||
.firstOrNull()
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ enum class VideoStabilizationMode(val displayName: String) {
|
||||
|
||||
enum class CaptureMode {
|
||||
PHOTO,
|
||||
QUICK_SHOT,
|
||||
VIDEO
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,6 @@ import com.hinnka.mycamera.ui.camera.CameraGLSurfaceView
|
||||
import com.hinnka.mycamera.ui.camera.ZoomDisplayMode
|
||||
import com.hinnka.mycamera.utils.*
|
||||
import com.hinnka.mycamera.video.CaptureMode
|
||||
import com.hinnka.mycamera.video.QuickShotResolutionPreset
|
||||
import com.hinnka.mycamera.video.VideoAudioInputManager
|
||||
import com.hinnka.mycamera.video.VideoAudioInputOption
|
||||
import com.hinnka.mycamera.video.VideoAspectRatio
|
||||
@@ -106,7 +105,6 @@ import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import java.io.File
|
||||
import java.util.UUID
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.hypot
|
||||
|
||||
@@ -522,7 +520,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
private const val HDR_BRACKET_FRAME_COUNT = 3
|
||||
private const val HDR_BRACKET_ZERO_INDEX = 0
|
||||
private const val HDR_BRACKET_LOW_INDEX = 2
|
||||
private const val QUICK_SHOT_BURST_MAX_PENDING_SAVES = 2
|
||||
private const val FIRST_PREVIEW_PREWARM_GRACE_MS = 1_000L
|
||||
private const val MIN_PREWARM_MEMORY_CLASS_MB = 384
|
||||
private const val EYE_FOCUS_MOVE_THRESHOLD = 0.035f
|
||||
@@ -1904,9 +1901,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
private var burstPhotoId: String? = null
|
||||
var burstImageCount by mutableStateOf(0)
|
||||
private set
|
||||
private var quickShotBurstActive = false
|
||||
private var quickShotBurstCaptureInFlight = false
|
||||
private val quickShotBurstPendingSaves = AtomicInteger(0)
|
||||
|
||||
var showGhostPermissions by mutableStateOf(false)
|
||||
|
||||
@@ -2165,9 +2159,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
if (currentCameraState.customVendorKeySettings != it.customVendorKeySettings) {
|
||||
cameraController.setCustomVendorKeySettings(it.customVendorKeySettings)
|
||||
}
|
||||
if (currentCameraState.quickShotConfig.resolution != it.quickShotResolution) {
|
||||
cameraController.setQuickShotResolution(it.quickShotResolution)
|
||||
}
|
||||
// 同步 RAW 设置到相机控制器
|
||||
val multipleExposureEnabled = it.useMultipleExposure
|
||||
val effectiveUseRaw = it.useRaw && !multipleExposureEnabled
|
||||
@@ -2379,7 +2370,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
// 如果保存的值无效,使用默认值
|
||||
}
|
||||
cameraController.setCaptureMode(prefs.captureMode)
|
||||
cameraController.setQuickShotResolution(prefs.quickShotResolution)
|
||||
cameraController.setVideoResolution(prefs.videoResolution)
|
||||
cameraController.setVideoFps(prefs.videoFps)
|
||||
cameraController.setVideoAspectRatio(prefs.videoAspectRatio)
|
||||
@@ -3349,11 +3339,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
|
||||
fun capture() {
|
||||
if (state.value.captureMode == CaptureMode.QUICK_SHOT) {
|
||||
captureQuickShot()
|
||||
return
|
||||
}
|
||||
|
||||
if (state.value.captureMode == CaptureMode.VIDEO) {
|
||||
if (state.value.videoRecordingState.isProcessing) {
|
||||
return
|
||||
@@ -3462,72 +3447,10 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
} ?: PLog.w(TAG, "captureVideoFrame skipped: glSurfaceView unavailable")
|
||||
}
|
||||
|
||||
private fun captureQuickShot() {
|
||||
val currentState = state.value
|
||||
if (currentState.captureMode != CaptureMode.QUICK_SHOT || currentState.isCapturing) {
|
||||
return
|
||||
}
|
||||
|
||||
updateCaptureLocation()
|
||||
|
||||
if (isShutterSoundEnabled) {
|
||||
shutterSoundPlayer.play()
|
||||
}
|
||||
if (isVibrationEnabled) {
|
||||
vibrationHelper.vibrate()
|
||||
}
|
||||
|
||||
val glView = glSurfaceView
|
||||
if (glView == null) {
|
||||
PLog.w(TAG, "captureQuickShot skipped: glSurfaceView unavailable")
|
||||
return
|
||||
}
|
||||
|
||||
cameraController.setQuickShotCaptureState(isCapturing = true)
|
||||
val quickShotRotation = capturePreviewThumbnailRotation()
|
||||
glView.capturePreviewFrame(quickShotCaptureLongEdge()) { bitmap ->
|
||||
cameraController.setQuickShotCaptureState(isCapturing = false)
|
||||
viewModelScope.launch {
|
||||
var bitmapToSave = bitmap
|
||||
try {
|
||||
bitmapToSave = rotatePreviewBitmapForCapture(bitmap, quickShotRotation)
|
||||
savePreviewBitmapCapture(
|
||||
bitmap = bitmapToSave,
|
||||
metadataCaptureMode = "quick_shot",
|
||||
ratio = state.value.aspectRatio,
|
||||
storeRenderedLookMetadata = false
|
||||
)
|
||||
} finally {
|
||||
if (!bitmapToSave.isRecycled) {
|
||||
bitmapToSave.recycle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateCaptureLocation() {
|
||||
if (userPreferences.value.saveLocation) {
|
||||
val location = locationManager.getCurrentLocation()
|
||||
cameraController.setLocation(location?.latitude, location?.longitude)
|
||||
} else {
|
||||
cameraController.setLocation(null, null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun quickShotCaptureLongEdge(): Int {
|
||||
val previewSize = state.value.currentPreviewSize
|
||||
return maxOf(previewSize.width, previewSize.height).coerceAtLeast(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始连拍
|
||||
*/
|
||||
fun startContinuousCapture() {
|
||||
if (state.value.captureMode == CaptureMode.QUICK_SHOT) {
|
||||
startQuickShotBurst()
|
||||
return
|
||||
}
|
||||
if (naturalLightEnabled.value) {
|
||||
PLog.d(TAG, "Continuous photo burst disabled while Natural Light tone map is active")
|
||||
return
|
||||
@@ -3550,10 +3473,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
* 停止连拍
|
||||
*/
|
||||
fun stopContinuousCapture() {
|
||||
if (state.value.captureMode == CaptureMode.QUICK_SHOT) {
|
||||
stopQuickShotBurst()
|
||||
return
|
||||
}
|
||||
if (state.value.useRaw && state.value.isRawSupported) return
|
||||
cameraController.stopBurstCapture()
|
||||
shutterSoundPlayer.stopBurst()
|
||||
@@ -3562,80 +3481,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startQuickShotBurst() {
|
||||
if (quickShotBurstActive) return
|
||||
updateCaptureLocation()
|
||||
generateThumbnail()
|
||||
burstImages.clear()
|
||||
burstImageCount = 0
|
||||
burstPhotoId = UUID.randomUUID().toString()
|
||||
quickShotBurstPendingSaves.set(0)
|
||||
quickShotBurstCaptureInFlight = false
|
||||
quickShotBurstActive = true
|
||||
cameraController.setQuickShotCaptureState(isCapturing = true, burstCapturing = true)
|
||||
if (isShutterSoundEnabled) {
|
||||
shutterSoundPlayer.playBurst()
|
||||
}
|
||||
requestNextQuickShotBurstFrame()
|
||||
}
|
||||
|
||||
private fun stopQuickShotBurst() {
|
||||
if (!quickShotBurstActive && !state.value.burstCapturing) return
|
||||
quickShotBurstActive = false
|
||||
quickShotBurstCaptureInFlight = false
|
||||
cameraController.setQuickShotCaptureState(isCapturing = false, burstCapturing = false)
|
||||
shutterSoundPlayer.stopBurst()
|
||||
burstImageCount = 0
|
||||
viewModelScope.launch {
|
||||
_imageSavedEvent.emit(Unit)
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestNextQuickShotBurstFrame() {
|
||||
if (!quickShotBurstActive || quickShotBurstCaptureInFlight) return
|
||||
val glView = glSurfaceView ?: run {
|
||||
PLog.w(TAG, "Quick-shot burst stopped: glSurfaceView unavailable")
|
||||
stopQuickShotBurst()
|
||||
return
|
||||
}
|
||||
quickShotBurstCaptureInFlight = true
|
||||
val quickShotRotation = capturePreviewThumbnailRotation()
|
||||
glView.captureNextPreviewFrame(quickShotCaptureLongEdge()) { bitmap ->
|
||||
quickShotBurstCaptureInFlight = false
|
||||
if (!quickShotBurstActive) {
|
||||
if (!bitmap.isRecycled) {
|
||||
bitmap.recycle()
|
||||
}
|
||||
return@captureNextPreviewFrame
|
||||
}
|
||||
|
||||
val pendingSaveCount = quickShotBurstPendingSaves.incrementAndGet()
|
||||
if (pendingSaveCount > QUICK_SHOT_BURST_MAX_PENDING_SAVES) {
|
||||
quickShotBurstPendingSaves.decrementAndGet()
|
||||
if (!bitmap.isRecycled) {
|
||||
bitmap.recycle()
|
||||
}
|
||||
PLog.w(TAG, "Quick-shot burst frame dropped: pendingSaves=$pendingSaveCount")
|
||||
requestNextQuickShotBurstFrame()
|
||||
return@captureNextPreviewFrame
|
||||
}
|
||||
|
||||
burstImageCount++
|
||||
viewModelScope.launch {
|
||||
try {
|
||||
saveQuickShotBurstFrame(bitmap, quickShotRotation)
|
||||
} finally {
|
||||
if (!bitmap.isRecycled) {
|
||||
bitmap.recycle()
|
||||
}
|
||||
quickShotBurstPendingSaves.decrementAndGet()
|
||||
}
|
||||
}
|
||||
requestNextQuickShotBurstFrame()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 切换摄像头(前后置切换)
|
||||
*/
|
||||
@@ -3850,14 +3695,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
fun setQuickShotResolution(resolution: QuickShotResolutionPreset) {
|
||||
cameraController.setQuickShotResolution(resolution)
|
||||
reopenCamera()
|
||||
viewModelScope.launch {
|
||||
userPreferencesRepository.saveQuickShotResolution(resolution)
|
||||
}
|
||||
}
|
||||
|
||||
fun setVideoFps(fps: VideoFpsPreset) {
|
||||
cameraController.setVideoFps(fps)
|
||||
reopenCamera()
|
||||
@@ -5845,16 +5682,14 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
savePreviewBitmapCapture(
|
||||
bitmap = bitmap,
|
||||
metadataCaptureMode = "video_snapshot",
|
||||
ratio = mapVideoAspectRatioToPhotoAspectRatio(state.value.videoConfig.aspectRatio),
|
||||
storeRenderedLookMetadata = true
|
||||
ratio = mapVideoAspectRatioToPhotoAspectRatio(state.value.videoConfig.aspectRatio)
|
||||
)
|
||||
}
|
||||
|
||||
private suspend fun savePreviewBitmapCapture(
|
||||
bitmap: Bitmap,
|
||||
metadataCaptureMode: String,
|
||||
ratio: AspectRatio?,
|
||||
storeRenderedLookMetadata: Boolean
|
||||
ratio: AspectRatio?
|
||||
) {
|
||||
try {
|
||||
val context = getApplication<Application>()
|
||||
@@ -5867,11 +5702,7 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
val userPrefs = userPreferencesRepository.userPreferences.firstOrNull()
|
||||
val shouldMirror = cameraController.getLensFacing() == CameraCharacteristics.LENS_FACING_FRONT &&
|
||||
(userPrefs?.mirrorFrontCamera ?: true)
|
||||
val baselineMetadata = if (storeRenderedLookMetadata) {
|
||||
resolveBaselineMetadata(BaselineColorCorrectionTarget.JPG, userPrefs)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val baselineMetadata = resolveBaselineMetadata(BaselineColorCorrectionTarget.JPG, userPrefs)
|
||||
val currentCameraId = cameraController.getCurrentCameraId()
|
||||
val effectiveRawAutoExposure = resolveEffectiveRawAutoExposure(
|
||||
userPrefs = userPrefs,
|
||||
@@ -5891,9 +5722,9 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
|
||||
val metadata = MediaMetadata(
|
||||
lutId = if (storeRenderedLookMetadata) currentLutId.value else null,
|
||||
frameId = if (storeRenderedLookMetadata) currentFrameId else null,
|
||||
colorRecipeParams = if (storeRenderedLookMetadata) getMergedRecipeParams() else null,
|
||||
lutId = currentLutId.value,
|
||||
frameId = currentFrameId,
|
||||
colorRecipeParams = getMergedRecipeParams(),
|
||||
baselineTarget = baselineMetadata?.first,
|
||||
baselineLutId = baselineMetadata?.second,
|
||||
baselineColorRecipeParams = baselineMetadata?.third,
|
||||
@@ -5929,11 +5760,11 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
rawBlackBorderCrop = currentRawBlackBorderCrop(),
|
||||
rawRenderingEngine = resolveCaptureRawRenderingEngine(userPrefs),
|
||||
rawToneMappingParameters = resolveCaptureRawToneMappingParameters(userPrefs),
|
||||
spectralFilmStock = if (storeRenderedLookMetadata) spectralFilmSettings.stock else null,
|
||||
spectralFilmPrint = if (storeRenderedLookMetadata) spectralFilmSettings.print else null,
|
||||
spectralFilmCDensityGain = if (storeRenderedLookMetadata) spectralFilmSettings.tuning.cDensityGain else 1f,
|
||||
spectralFilmMDensityGain = if (storeRenderedLookMetadata) spectralFilmSettings.tuning.mDensityGain else 1f,
|
||||
spectralFilmYDensityGain = if (storeRenderedLookMetadata) spectralFilmSettings.tuning.yDensityGain else 1f,
|
||||
spectralFilmStock = spectralFilmSettings.stock,
|
||||
spectralFilmPrint = spectralFilmSettings.print,
|
||||
spectralFilmCDensityGain = spectralFilmSettings.tuning.cDensityGain,
|
||||
spectralFilmMDensityGain = spectralFilmSettings.tuning.mDensityGain,
|
||||
spectralFilmYDensityGain = spectralFilmSettings.tuning.yDensityGain,
|
||||
width = bitmap.width,
|
||||
height = bitmap.height,
|
||||
ratio = ratio,
|
||||
@@ -5960,22 +5791,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
captureMode = metadataCaptureMode
|
||||
)
|
||||
|
||||
if (metadataCaptureMode == "quick_shot") {
|
||||
val photoId = GalleryManager.saveQuickShotBitmapToSystemGallery(
|
||||
context = context,
|
||||
metadata = metadata,
|
||||
bitmap = bitmap,
|
||||
photoQuality = photoQualityValue
|
||||
)
|
||||
if (photoId == null) {
|
||||
PLog.e(TAG, "Failed to save quick-shot bitmap capture to system gallery")
|
||||
return
|
||||
}
|
||||
PLog.d(TAG, "Quick-shot bitmap capture saved to system gallery: $photoId")
|
||||
_imageSavedEvent.emit(Unit)
|
||||
return
|
||||
}
|
||||
|
||||
val photoId = GalleryManager.preparePhoto(
|
||||
context,
|
||||
metadata,
|
||||
@@ -6010,148 +5825,6 @@ class CameraViewModel(application: Application) : AndroidViewModel(application)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun saveQuickShotBurstFrame(bitmap: Bitmap, rotationDegrees: Float) {
|
||||
var bitmapToSave: Bitmap? = null
|
||||
try {
|
||||
val context = getApplication<Application>()
|
||||
val photoId = burstPhotoId ?: return
|
||||
val captureBitmap = rotatePreviewBitmapForCapture(bitmap, rotationDegrees)
|
||||
bitmapToSave = captureBitmap
|
||||
val currentState = state.value
|
||||
val shouldAutoSave = autoSaveAfterCapture.firstOrNull() ?: false
|
||||
val sharpeningValue = 0f
|
||||
val noiseReductionValue = 0f
|
||||
val chromaNoiseReductionValue = 0f
|
||||
val photoQualityValue = photoQuality.firstOrNull() ?: 95
|
||||
val userPrefs = userPreferencesRepository.userPreferences.firstOrNull()
|
||||
val shouldMirror = cameraController.getLensFacing() == CameraCharacteristics.LENS_FACING_FRONT &&
|
||||
(userPrefs?.mirrorFrontCamera ?: true)
|
||||
val currentCameraId = cameraController.getCurrentCameraId()
|
||||
val effectiveRawAutoExposure = resolveEffectiveRawAutoExposure(
|
||||
userPrefs = userPrefs,
|
||||
)
|
||||
val captureInfo = cameraController.rebuildCaptureInfo(
|
||||
result = null,
|
||||
imageWidth = captureBitmap.width,
|
||||
imageHeight = captureBitmap.height,
|
||||
latitude = currentState.latitude,
|
||||
longitude = currentState.longitude
|
||||
)
|
||||
val computationalAperture = if (currentState.isVirtualApertureEnabled) {
|
||||
currentState.virtualAperture
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
if (GalleryManager.loadMetadata(context, photoId) == null) {
|
||||
val metadata = MediaMetadata(
|
||||
lutId = null,
|
||||
frameId = null,
|
||||
colorRecipeParams = null,
|
||||
baselineTarget = null,
|
||||
baselineLutId = null,
|
||||
baselineColorRecipeParams = null,
|
||||
sharpening = sharpeningValue,
|
||||
noiseReduction = noiseReductionValue,
|
||||
chromaNoiseReduction = chromaNoiseReductionValue,
|
||||
captureNoiseReductionLevel = currentState.nrLevel,
|
||||
rawDcpId = userPrefs?.rawDcpIdForLens(currentCameraId),
|
||||
rawHncsProfileId = userPrefs?.rawHncsProfileId,
|
||||
rawHncsRenderIntent = userPrefs?.rawHncsRenderIntent
|
||||
?: HncsRenderIntent.Standard,
|
||||
rawHncsFilmCurveMode = userPrefs?.rawHncsFilmCurveMode
|
||||
?: HncsFilmCurveMode.Standard,
|
||||
rawExposureCompensation = userPrefs?.rawExposureCompensation ?: 0f,
|
||||
rawAutoExposure = effectiveRawAutoExposure,
|
||||
customProperties = rawProcessingMetadataProperties(
|
||||
userPrefs,
|
||||
cameraController.getCurrentSensorPhysicalAreaMm2(),
|
||||
),
|
||||
rawHighlightsAdjustment = userPrefs?.rawHighlightsAdjustment ?: 0f,
|
||||
rawShadowsAdjustment = userPrefs?.rawShadowsAdjustment ?: 0f,
|
||||
rawBlackPointCorrection = userPrefs?.rawBlackPointCorrection ?: 0f,
|
||||
rawWhitePointCorrection = userPrefs?.rawWhitePointCorrection ?: 0f,
|
||||
rawAutoWhiteBalanceEstimate = userPrefs?.rawAutoWhiteBalanceEstimate ?: false,
|
||||
rawLensShadingCorrectionEnabled = userPrefs?.rawLensShadingCorrectionEnabled,
|
||||
rawBlackLevelMode = userPrefs?.rawBlackLevelModes?.get(currentCameraId) ?: "Default",
|
||||
rawCustomBlackLevel = userPrefs?.rawCustomBlackLevels?.get(currentCameraId) ?: 0f,
|
||||
rawWhiteLevelMode = userPrefs?.rawWhiteLevelModes?.get(currentCameraId)
|
||||
?: RawWhiteLevelCorrection.MODE_DEFAULT,
|
||||
rawCustomWhiteLevel = userPrefs?.rawCustomWhiteLevels?.get(currentCameraId) ?: 0f,
|
||||
rawCfaCorrectionMode = userPrefs?.rawCfaCorrectionModes?.get(currentCameraId) ?: RawCfaCorrection.MODE_DEFAULT,
|
||||
cameraId = currentCameraId,
|
||||
rawBlackBorderCrop = currentRawBlackBorderCrop(),
|
||||
rawRenderingEngine = resolveCaptureRawRenderingEngine(userPrefs),
|
||||
rawToneMappingParameters = resolveCaptureRawToneMappingParameters(userPrefs),
|
||||
spectralFilmStock = null,
|
||||
spectralFilmPrint = null,
|
||||
spectralFilmCDensityGain = 1f,
|
||||
spectralFilmMDensityGain = 1f,
|
||||
spectralFilmYDensityGain = 1f,
|
||||
width = captureBitmap.width,
|
||||
height = captureBitmap.height,
|
||||
ratio = currentState.aspectRatio,
|
||||
rotation = 0,
|
||||
deviceModel = DeviceUtil.model,
|
||||
brand = captureInfo.make,
|
||||
dateTaken = captureInfo.captureTime,
|
||||
latitude = captureInfo.latitude,
|
||||
longitude = captureInfo.longitude,
|
||||
altitude = captureInfo.altitude,
|
||||
iso = captureInfo.iso,
|
||||
shutterSpeed = captureInfo.formatExposureTime(),
|
||||
focalLength = captureInfo.formatFocalLength(),
|
||||
focalLength35mm = captureInfo.formatFocalLength35mm(),
|
||||
aperture = captureInfo.formatAperture(),
|
||||
exposureBias = currentState.exposureBias,
|
||||
droMode = droMode.value,
|
||||
isMirrored = shouldMirror,
|
||||
colorSpace = captureInfo.colorSpace,
|
||||
dynamicRangeProfile = currentState.currentDynamicRangeProfile,
|
||||
computationalAperture = computationalAperture,
|
||||
focusPointX = currentState.focusPoint?.first,
|
||||
focusPointY = currentState.focusPoint?.second,
|
||||
captureMode = "quick_shot"
|
||||
)
|
||||
|
||||
val preparedPhotoId = GalleryManager.preparePhoto(
|
||||
context,
|
||||
metadata,
|
||||
null,
|
||||
captureBitmap,
|
||||
false,
|
||||
1.0f,
|
||||
includeCropRegionInOutputSize = false,
|
||||
photoId = photoId
|
||||
)
|
||||
if (preparedPhotoId == null) {
|
||||
PLog.e(TAG, "Failed to prepare quick-shot burst photo")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
GalleryManager.saveBitmapBurstPhoto(
|
||||
context,
|
||||
photoId,
|
||||
captureBitmap,
|
||||
shouldAutoSave,
|
||||
contentRepository.photoProcessor,
|
||||
sharpeningValue,
|
||||
noiseReductionValue,
|
||||
chromaNoiseReductionValue,
|
||||
photoQualityValue
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
PLog.e(TAG, "Failed to save quick-shot burst frame", e)
|
||||
} finally {
|
||||
bitmapToSave?.let { rotated ->
|
||||
if (rotated !== bitmap && !rotated.isRecycled) {
|
||||
rotated.recycle()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun mapVideoAspectRatioToPhotoAspectRatio(aspectRatio: VideoAspectRatio): AspectRatio? {
|
||||
return when (aspectRatio) {
|
||||
VideoAspectRatio.RATIO_16_9 -> AspectRatio.RATIO_16_9
|
||||
|
||||
@@ -1792,7 +1792,7 @@ class GalleryViewModel(application: Application) : AndroidViewModel(application)
|
||||
val shouldDeleteSourceUri = metadata != null &&
|
||||
!metadata.isImported &&
|
||||
!sourceUri.isNullOrBlank() &&
|
||||
(metadata.mediaType == MediaType.VIDEO || metadata.captureMode == "quick_shot")
|
||||
metadata.mediaType == MediaType.VIDEO
|
||||
if (shouldDeleteSourceUri) {
|
||||
try {
|
||||
allExportedUris.add(sourceUri.toUri())
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<string name="unknown">未知</string>
|
||||
<string name="take_photo">拍照</string>
|
||||
<string name="capture_mode_photo">拍照</string>
|
||||
<string name="capture_mode_quick_shot">快拍</string>
|
||||
<string name="capture_mode_video">影片</string>
|
||||
|
||||
<!-- Exposure Controls -->
|
||||
@@ -43,8 +42,6 @@
|
||||
<string name="settings_custom_aspect_ratio_width">寬</string>
|
||||
<string name="settings_custom_aspect_ratio_height">高</string>
|
||||
<string name="video_torch_chip">補光</string>
|
||||
<string name="quick_shot_resolution_title">快拍解析度</string>
|
||||
<string name="quick_shot_resolution_full">全尺寸</string>
|
||||
<string name="video_aspect_chip">畫幅</string>
|
||||
<string name="video_log_chip">Log</string>
|
||||
<string name="video_option_off">關</string>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<string name="unknown">未知</string>
|
||||
<string name="take_photo">拍照</string>
|
||||
<string name="capture_mode_photo">拍照</string>
|
||||
<string name="capture_mode_quick_shot">快拍</string>
|
||||
<string name="capture_mode_video">视频</string>
|
||||
|
||||
<!-- Exposure Controls -->
|
||||
@@ -43,8 +42,6 @@
|
||||
<string name="settings_custom_aspect_ratio_width">宽</string>
|
||||
<string name="settings_custom_aspect_ratio_height">高</string>
|
||||
<string name="video_torch_chip">补光</string>
|
||||
<string name="quick_shot_resolution_title">快拍分辨率</string>
|
||||
<string name="quick_shot_resolution_full">全尺寸</string>
|
||||
<string name="video_aspect_chip">画幅</string>
|
||||
<string name="video_log_chip">Log</string>
|
||||
<string name="video_option_off">关</string>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<string name="unknown">未知</string>
|
||||
<string name="take_photo">拍照</string>
|
||||
<string name="capture_mode_photo">拍照</string>
|
||||
<string name="capture_mode_quick_shot">快拍</string>
|
||||
<string name="capture_mode_video">影片</string>
|
||||
|
||||
<!-- Exposure Controls -->
|
||||
@@ -43,8 +42,6 @@
|
||||
<string name="settings_custom_aspect_ratio_width">寬</string>
|
||||
<string name="settings_custom_aspect_ratio_height">高</string>
|
||||
<string name="video_torch_chip">補光</string>
|
||||
<string name="quick_shot_resolution_title">快拍解析度</string>
|
||||
<string name="quick_shot_resolution_full">全尺寸</string>
|
||||
<string name="video_aspect_chip">畫幅</string>
|
||||
<string name="video_log_chip">Log</string>
|
||||
<string name="video_option_off">關</string>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<string name="unknown">未知</string>
|
||||
<string name="take_photo">拍照</string>
|
||||
<string name="capture_mode_photo">拍照</string>
|
||||
<string name="capture_mode_quick_shot">快拍</string>
|
||||
<string name="capture_mode_video">影片</string>
|
||||
|
||||
<!-- Exposure Controls -->
|
||||
@@ -43,8 +42,6 @@
|
||||
<string name="settings_custom_aspect_ratio_width">寬</string>
|
||||
<string name="settings_custom_aspect_ratio_height">高</string>
|
||||
<string name="video_torch_chip">補光</string>
|
||||
<string name="quick_shot_resolution_title">快拍解析度</string>
|
||||
<string name="quick_shot_resolution_full">全尺寸</string>
|
||||
<string name="video_aspect_chip">畫幅</string>
|
||||
<string name="video_log_chip">Log</string>
|
||||
<string name="video_option_off">關</string>
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
<string name="unknown">Unknown</string>
|
||||
<string name="take_photo">Take Photo</string>
|
||||
<string name="capture_mode_photo">Photo</string>
|
||||
<string name="capture_mode_quick_shot">Quick Shot</string>
|
||||
<string name="capture_mode_video">Video</string>
|
||||
|
||||
<!-- Exposure Controls -->
|
||||
@@ -43,8 +42,6 @@
|
||||
<string name="settings_custom_aspect_ratio_width">Width</string>
|
||||
<string name="settings_custom_aspect_ratio_height">Height</string>
|
||||
<string name="video_torch_chip">Torch</string>
|
||||
<string name="quick_shot_resolution_title">Quick Shot Resolution</string>
|
||||
<string name="quick_shot_resolution_full">Full</string>
|
||||
<string name="video_aspect_chip">Aspect</string>
|
||||
<string name="video_log_chip">Log</string>
|
||||
<string name="video_option_off">Off</string>
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.hinnka.mycamera.video
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class QuickShotCapabilitiesResolverTest {
|
||||
@Test
|
||||
fun resolveFromOutputSizes_prefersExactAspectAndTargetLongEdge() {
|
||||
val snapshot = QuickShotCapabilitiesResolver.resolveFromOutputSizes(
|
||||
outputSizes = listOf(
|
||||
QuickShotOutputSize(1920, 1080),
|
||||
QuickShotOutputSize(1920, 1440),
|
||||
QuickShotOutputSize(2560, 1440),
|
||||
QuickShotOutputSize(2560, 1920)
|
||||
),
|
||||
requestedConfig = QuickShotConfig(QuickShotResolutionPreset.QHD_2K),
|
||||
portraitAspectRatio = 3f / 4f
|
||||
)
|
||||
|
||||
assertEquals(QuickShotResolutionPreset.QHD_2K, snapshot.config.resolution)
|
||||
assertEquals(QuickShotOutputSize(2560, 1920), snapshot.previewSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveFromOutputSizes_usesClosestLargerSizeWhenExactLongEdgeMissing() {
|
||||
val snapshot = QuickShotCapabilitiesResolver.resolveFromOutputSizes(
|
||||
outputSizes = listOf(
|
||||
QuickShotOutputSize(1920, 1440),
|
||||
QuickShotOutputSize(2688, 2016),
|
||||
QuickShotOutputSize(3840, 2160)
|
||||
),
|
||||
requestedConfig = QuickShotConfig(QuickShotResolutionPreset.QHD_2K),
|
||||
portraitAspectRatio = 3f / 4f
|
||||
)
|
||||
|
||||
assertEquals(QuickShotResolutionPreset.QHD_2K, snapshot.config.resolution)
|
||||
assertEquals(QuickShotOutputSize(2688, 2016), snapshot.previewSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveFromOutputSizes_fullUsesLargestSurfaceTextureSize() {
|
||||
val snapshot = QuickShotCapabilitiesResolver.resolveFromOutputSizes(
|
||||
outputSizes = listOf(
|
||||
QuickShotOutputSize(1920, 1440),
|
||||
QuickShotOutputSize(3840, 2160),
|
||||
QuickShotOutputSize(4000, 3000)
|
||||
),
|
||||
requestedConfig = QuickShotConfig(QuickShotResolutionPreset.FULL),
|
||||
portraitAspectRatio = 3f / 4f
|
||||
)
|
||||
|
||||
assertEquals(QuickShotResolutionPreset.FULL, snapshot.config.resolution)
|
||||
assertEquals(QuickShotOutputSize(4000, 3000), snapshot.previewSize)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun resolveFromOutputSizes_fallsBackWhenRequestedPresetUnavailable() {
|
||||
val snapshot = QuickShotCapabilitiesResolver.resolveFromOutputSizes(
|
||||
outputSizes = listOf(QuickShotOutputSize(1280, 720)),
|
||||
requestedConfig = QuickShotConfig(QuickShotResolutionPreset.UHD_4K),
|
||||
portraitAspectRatio = 9f / 16f
|
||||
)
|
||||
|
||||
assertEquals(QuickShotResolutionPreset.FULL, snapshot.config.resolution)
|
||||
assertEquals(QuickShotOutputSize(1280, 720), snapshot.previewSize)
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ class VideoRecordingLockPolicyTest {
|
||||
|
||||
assertFalse(config.shouldLockLens(CaptureMode.VIDEO, isRecording = false))
|
||||
assertFalse(config.shouldLockLens(CaptureMode.PHOTO, isRecording = true))
|
||||
assertFalse(config.shouldLockLens(CaptureMode.QUICK_SHOT, isRecording = true))
|
||||
assertTrue(config.shouldLockLens(CaptureMode.VIDEO, isRecording = true))
|
||||
}
|
||||
|
||||
@@ -21,7 +20,6 @@ class VideoRecordingLockPolicyTest {
|
||||
|
||||
assertFalse(config.shouldLockWhiteBalance(CaptureMode.VIDEO, isRecording = false))
|
||||
assertFalse(config.shouldLockWhiteBalance(CaptureMode.PHOTO, isRecording = true))
|
||||
assertFalse(config.shouldLockWhiteBalance(CaptureMode.QUICK_SHOT, isRecording = true))
|
||||
assertTrue(config.shouldLockWhiteBalance(CaptureMode.VIDEO, isRecording = true))
|
||||
}
|
||||
|
||||
|
||||
@@ -43,16 +43,6 @@ class LutCaptureModeSelectionTest {
|
||||
defaultLutId = "default",
|
||||
),
|
||||
)
|
||||
assertEquals(
|
||||
"photo",
|
||||
resolveLutIdForCaptureMode(
|
||||
photoLutId = "photo",
|
||||
videoLutId = "video",
|
||||
separateVideoLutEnabled = true,
|
||||
captureMode = CaptureMode.QUICK_SHOT,
|
||||
defaultLutId = "default",
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user