mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Prompt for microphone permission when recording video in new camera.
Previously, the new camera would silently record video without audio when microphone permission was missing. Now it shows the same rationale dialog and permanent denial flow as the old camera.
This commit is contained in:
@@ -104,6 +104,7 @@ fun BoxScope.StandardCameraHud(
|
||||
modifier: Modifier = Modifier,
|
||||
maxRecordingDurationMs: Long = DEFAULT_MAX_RECORDING_DURATION_MS,
|
||||
mediaSelectionCount: Int = 0,
|
||||
hasAudioPermission: () -> Boolean = { true },
|
||||
stringResources: StringResources = StringResources(0, 0)
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
@@ -131,6 +132,7 @@ fun BoxScope.StandardCameraHud(
|
||||
modifier = modifier,
|
||||
maxRecordingDurationMs = maxRecordingDurationMs,
|
||||
mediaSelectionCount = mediaSelectionCount,
|
||||
hasAudioPermission = hasAudioPermission,
|
||||
stringResources = stringResources
|
||||
)
|
||||
}
|
||||
@@ -142,6 +144,7 @@ private fun BoxScope.StandardCameraHudContent(
|
||||
modifier: Modifier = Modifier,
|
||||
maxRecordingDurationMs: Long = DEFAULT_MAX_RECORDING_DURATION_MS,
|
||||
mediaSelectionCount: Int = 0,
|
||||
hasAudioPermission: () -> Boolean = { true },
|
||||
stringResources: StringResources = StringResources()
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
@@ -177,6 +180,7 @@ private fun BoxScope.StandardCameraHudContent(
|
||||
},
|
||||
mediaSelectionCount = mediaSelectionCount,
|
||||
emitter = emitter,
|
||||
hasAudioPermission = hasAudioPermission,
|
||||
stringResources = stringResources,
|
||||
modifier = modifier.align(if (isLandscape) Alignment.CenterEnd else Alignment.BottomCenter)
|
||||
)
|
||||
@@ -209,6 +213,7 @@ private fun CameraControls(
|
||||
recordingProgress: Float,
|
||||
mediaSelectionCount: Int,
|
||||
emitter: (StandardCameraHudEvents) -> Unit,
|
||||
hasAudioPermission: () -> Boolean,
|
||||
stringResources: StringResources,
|
||||
modifier: Modifier = Modifier
|
||||
) {
|
||||
@@ -229,7 +234,13 @@ private fun CameraControls(
|
||||
isRecording = isRecording,
|
||||
recordingProgress = recordingProgress,
|
||||
onTap = { emitter(StandardCameraHudEvents.PhotoCaptureTriggered) },
|
||||
onLongPressStart = { emitter(StandardCameraHudEvents.VideoCaptureStarted) },
|
||||
onLongPressStart = {
|
||||
if (hasAudioPermission()) {
|
||||
emitter(StandardCameraHudEvents.VideoCaptureStarted)
|
||||
} else {
|
||||
emitter(StandardCameraHudEvents.AudioPermissionRequired)
|
||||
}
|
||||
},
|
||||
onLongPressEnd = { emitter(StandardCameraHudEvents.VideoCaptureStopped) },
|
||||
onZoomChange = { emitter(StandardCameraHudEvents.SetZoomLevel(it)) }
|
||||
)
|
||||
|
||||
@@ -37,4 +37,9 @@ sealed interface StandardCameraHudEvents {
|
||||
* Emitted when a capture error should be cleared (after displaying to user).
|
||||
*/
|
||||
data object ClearCaptureError : StandardCameraHudEvents
|
||||
|
||||
/**
|
||||
* Emitted when the user attempts to start video recording but audio permission has not been granted.
|
||||
*/
|
||||
data object AudioPermissionRequired : StandardCameraHudEvents
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user