mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 14:55:26 +02:00
fix: Improve error handling
Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com>
This commit is contained in:
parent
bc1dbf01db
commit
1b006ba45c
@ -191,17 +191,22 @@ class VideoRecorderService :
|
||||
videoCapture = buildVideoCapture(recorder)
|
||||
|
||||
runOnMain {
|
||||
camera = cameraProvider!!.bindToLifecycle(
|
||||
this,
|
||||
selectedCamera,
|
||||
videoCapture
|
||||
)
|
||||
cameraControl = CameraControl(camera!!).also {
|
||||
it.init()
|
||||
}
|
||||
onCameraControlAvailable()
|
||||
try {
|
||||
camera = cameraProvider!!.bindToLifecycle(
|
||||
this,
|
||||
selectedCamera,
|
||||
videoCapture
|
||||
)
|
||||
|
||||
_cameraAvailableListener.complete(Unit)
|
||||
cameraControl = CameraControl(camera!!).also {
|
||||
it.init()
|
||||
}
|
||||
onCameraControlAvailable()
|
||||
|
||||
_cameraAvailableListener.complete(Unit)
|
||||
} catch (error: IllegalArgumentException) {
|
||||
onError()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,8 +3,6 @@ package app.myzel394.alibi.ui.components.RecorderScreen.atoms
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Warning
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
@ -15,7 +13,6 @@ import app.myzel394.alibi.R
|
||||
@Composable
|
||||
fun RecorderErrorDialog(
|
||||
onClose: () -> Unit,
|
||||
onSave: () -> Unit,
|
||||
) {
|
||||
AlertDialog(
|
||||
onDismissRequest = onClose,
|
||||
@ -31,14 +28,9 @@ fun RecorderErrorDialog(
|
||||
text = {
|
||||
Text(stringResource(R.string.ui_recorder_error_recording_description))
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = onClose) {
|
||||
Text(stringResource(R.string.dialog_close_cancel_label))
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(onClick = onSave) {
|
||||
Text(stringResource(R.string.ui_recorder_action_save_label))
|
||||
TextButton(onClick = onClose) {
|
||||
Text(stringResource(R.string.dialog_close_neutral_label))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
@ -93,9 +93,16 @@ fun RecorderEventsHandler(
|
||||
recorder: RecorderModel
|
||||
) {
|
||||
if (!settings.deleteRecordingsImmediately) {
|
||||
val information = recorder.recorderService?.getRecordingInformation()
|
||||
|
||||
if (information == null) {
|
||||
Log.e("RecorderEventsHandler", "Recording information is null")
|
||||
return
|
||||
}
|
||||
|
||||
dataStore.updateData {
|
||||
it.setLastRecording(
|
||||
recorder.recorderService!!.getRecordingInformation()
|
||||
information
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -247,6 +254,13 @@ fun RecorderEventsHandler(
|
||||
scope.launch {
|
||||
saveAsLastRecording(audioRecorder as RecorderModel)
|
||||
|
||||
runCatching {
|
||||
audioRecorder.stopRecording(context)
|
||||
}
|
||||
runCatching {
|
||||
audioRecorder.destroyService(context)
|
||||
}
|
||||
|
||||
showRecorderError = true
|
||||
}
|
||||
}
|
||||
@ -290,6 +304,13 @@ fun RecorderEventsHandler(
|
||||
scope.launch {
|
||||
saveAsLastRecording(videoRecorder as RecorderModel)
|
||||
|
||||
runCatching {
|
||||
videoRecorder.stopRecording(context)
|
||||
}
|
||||
runCatching {
|
||||
videoRecorder.destroyService(context)
|
||||
}
|
||||
|
||||
showRecorderError = true
|
||||
}
|
||||
}
|
||||
@ -324,8 +345,6 @@ fun RecorderEventsHandler(
|
||||
onClose = {
|
||||
showRecorderError = false
|
||||
},
|
||||
onSave = {
|
||||
},
|
||||
)
|
||||
|
||||
if (showBatchesInaccessibleError)
|
||||
|
@ -80,7 +80,7 @@
|
||||
<string name="ui_recorder_state_paused_title">Recording paused</string>
|
||||
<string name="ui_recorder_state_paused_description">Alibi is paused</string>
|
||||
<string name="ui_recorder_error_recording_title">An error occurred</string>
|
||||
<string name="ui_recorder_error_recording_description">Alibi encountered an error during recording. Would you like to try saving the recording?</string>
|
||||
<string name="ui_recorder_error_recording_description">Alibi encountered an error during recording. Try using different settings or restart the app.</string>
|
||||
<string name="ui_settings_language_title">Language</string>
|
||||
<string name="ui_settings_language_update_label">Change</string>
|
||||
<string name="ui_audioRecorder_info_microphone_deviceMicrophone">Device Microphone</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user