mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05: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)
|
videoCapture = buildVideoCapture(recorder)
|
||||||
|
|
||||||
runOnMain {
|
runOnMain {
|
||||||
|
try {
|
||||||
camera = cameraProvider!!.bindToLifecycle(
|
camera = cameraProvider!!.bindToLifecycle(
|
||||||
this,
|
this,
|
||||||
selectedCamera,
|
selectedCamera,
|
||||||
videoCapture
|
videoCapture
|
||||||
)
|
)
|
||||||
|
|
||||||
cameraControl = CameraControl(camera!!).also {
|
cameraControl = CameraControl(camera!!).also {
|
||||||
it.init()
|
it.init()
|
||||||
}
|
}
|
||||||
onCameraControlAvailable()
|
onCameraControlAvailable()
|
||||||
|
|
||||||
_cameraAvailableListener.complete(Unit)
|
_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.Icons
|
||||||
import androidx.compose.material.icons.filled.Warning
|
import androidx.compose.material.icons.filled.Warning
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Button
|
|
||||||
import androidx.compose.material3.ButtonDefaults
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
@ -15,7 +13,6 @@ import app.myzel394.alibi.R
|
|||||||
@Composable
|
@Composable
|
||||||
fun RecorderErrorDialog(
|
fun RecorderErrorDialog(
|
||||||
onClose: () -> Unit,
|
onClose: () -> Unit,
|
||||||
onSave: () -> Unit,
|
|
||||||
) {
|
) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
onDismissRequest = onClose,
|
onDismissRequest = onClose,
|
||||||
@ -31,14 +28,9 @@ fun RecorderErrorDialog(
|
|||||||
text = {
|
text = {
|
||||||
Text(stringResource(R.string.ui_recorder_error_recording_description))
|
Text(stringResource(R.string.ui_recorder_error_recording_description))
|
||||||
},
|
},
|
||||||
dismissButton = {
|
|
||||||
TextButton(onClick = onClose) {
|
|
||||||
Text(stringResource(R.string.dialog_close_cancel_label))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(onClick = onSave) {
|
TextButton(onClick = onClose) {
|
||||||
Text(stringResource(R.string.ui_recorder_action_save_label))
|
Text(stringResource(R.string.dialog_close_neutral_label))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -93,9 +93,16 @@ fun RecorderEventsHandler(
|
|||||||
recorder: RecorderModel
|
recorder: RecorderModel
|
||||||
) {
|
) {
|
||||||
if (!settings.deleteRecordingsImmediately) {
|
if (!settings.deleteRecordingsImmediately) {
|
||||||
|
val information = recorder.recorderService?.getRecordingInformation()
|
||||||
|
|
||||||
|
if (information == null) {
|
||||||
|
Log.e("RecorderEventsHandler", "Recording information is null")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
dataStore.updateData {
|
dataStore.updateData {
|
||||||
it.setLastRecording(
|
it.setLastRecording(
|
||||||
recorder.recorderService!!.getRecordingInformation()
|
information
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -247,6 +254,13 @@ fun RecorderEventsHandler(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
saveAsLastRecording(audioRecorder as RecorderModel)
|
saveAsLastRecording(audioRecorder as RecorderModel)
|
||||||
|
|
||||||
|
runCatching {
|
||||||
|
audioRecorder.stopRecording(context)
|
||||||
|
}
|
||||||
|
runCatching {
|
||||||
|
audioRecorder.destroyService(context)
|
||||||
|
}
|
||||||
|
|
||||||
showRecorderError = true
|
showRecorderError = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -290,6 +304,13 @@ fun RecorderEventsHandler(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
saveAsLastRecording(videoRecorder as RecorderModel)
|
saveAsLastRecording(videoRecorder as RecorderModel)
|
||||||
|
|
||||||
|
runCatching {
|
||||||
|
videoRecorder.stopRecording(context)
|
||||||
|
}
|
||||||
|
runCatching {
|
||||||
|
videoRecorder.destroyService(context)
|
||||||
|
}
|
||||||
|
|
||||||
showRecorderError = true
|
showRecorderError = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -324,8 +345,6 @@ fun RecorderEventsHandler(
|
|||||||
onClose = {
|
onClose = {
|
||||||
showRecorderError = false
|
showRecorderError = false
|
||||||
},
|
},
|
||||||
onSave = {
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showBatchesInaccessibleError)
|
if (showBatchesInaccessibleError)
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
<string name="ui_recorder_state_paused_title">Recording paused</string>
|
<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_state_paused_description">Alibi is paused</string>
|
||||||
<string name="ui_recorder_error_recording_title">An error occurred</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_title">Language</string>
|
||||||
<string name="ui_settings_language_update_label">Change</string>
|
<string name="ui_settings_language_update_label">Change</string>
|
||||||
<string name="ui_audioRecorder_info_microphone_deviceMicrophone">Device Microphone</string>
|
<string name="ui_audioRecorder_info_microphone_deviceMicrophone">Device Microphone</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user