mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 07:15:25 +02:00
feat: Show error dialog when batches folder is inaccessible
This commit is contained in:
parent
47fc65aaf2
commit
cf6c653ad3
@ -11,7 +11,6 @@ val SUPPORTS_DARK_MODE_NATIVELY = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
|||||||
|
|
||||||
val MEDIA_SUBFOLDER_NAME = "alibi"
|
val MEDIA_SUBFOLDER_NAME = "alibi"
|
||||||
|
|
||||||
// TODO: Fix!
|
|
||||||
val SUPPORTS_SCOPED_STORAGE = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
val SUPPORTS_SCOPED_STORAGE = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
|
||||||
val MEDIA_RECORDINGS_PREFIX = "alibi-recording-"
|
val MEDIA_RECORDINGS_PREFIX = "alibi-recording-"
|
||||||
val RECORDER_MEDIA_SELECTED_VALUE = "_'media"
|
val RECORDER_MEDIA_SELECTED_VALUE = "_'media"
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package app.myzel394.alibi.ui.components.RecorderScreen.atoms
|
||||||
|
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.filled.Error
|
||||||
|
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.runtime.Composable
|
||||||
|
import androidx.compose.ui.res.stringResource
|
||||||
|
import app.myzel394.alibi.R
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BatchesInaccessibleDialog(
|
||||||
|
onClose: () -> Unit,
|
||||||
|
) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onClose,
|
||||||
|
icon = {
|
||||||
|
Icon(
|
||||||
|
Icons.Default.Error,
|
||||||
|
contentDescription = null,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
title = {
|
||||||
|
Text(stringResource(R.string.ui_audioRecorder_error_recording_title))
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(stringResource(R.string.ui_audioRecorder_error_batchesInaccessible_description))
|
||||||
|
},
|
||||||
|
confirmButton = {
|
||||||
|
Button(
|
||||||
|
onClick = onClose,
|
||||||
|
colors = ButtonDefaults.textButtonColors(),
|
||||||
|
) {
|
||||||
|
Text(stringResource(R.string.dialog_close_neutral_label))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
@ -23,6 +23,7 @@ import app.myzel394.alibi.helpers.AudioBatchesFolder
|
|||||||
import app.myzel394.alibi.helpers.BatchesFolder
|
import app.myzel394.alibi.helpers.BatchesFolder
|
||||||
import app.myzel394.alibi.helpers.VideoBatchesFolder
|
import app.myzel394.alibi.helpers.VideoBatchesFolder
|
||||||
import app.myzel394.alibi.services.IntervalRecorderService
|
import app.myzel394.alibi.services.IntervalRecorderService
|
||||||
|
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.BatchesInaccessibleDialog
|
||||||
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.RecorderErrorDialog
|
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.RecorderErrorDialog
|
||||||
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.RecorderProcessingDialog
|
import app.myzel394.alibi.ui.components.RecorderScreen.atoms.RecorderProcessingDialog
|
||||||
import app.myzel394.alibi.ui.models.AudioRecorderModel
|
import app.myzel394.alibi.ui.models.AudioRecorderModel
|
||||||
@ -51,6 +52,7 @@ fun RecorderEventsHandler(
|
|||||||
|
|
||||||
var isProcessing by remember { mutableStateOf(false) }
|
var isProcessing by remember { mutableStateOf(false) }
|
||||||
var showRecorderError by remember { mutableStateOf(false) }
|
var showRecorderError by remember { mutableStateOf(false) }
|
||||||
|
var showBatchesInaccessibleError by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
val saveAudioFile = rememberFileSaverDialog(settings.audioRecorderSettings.getMimeType()) {
|
val saveAudioFile = rememberFileSaverDialog(settings.audioRecorderSettings.getMimeType()) {
|
||||||
if (settings.deleteRecordingsImmediately) {
|
if (settings.deleteRecordingsImmediately) {
|
||||||
@ -235,6 +237,18 @@ fun RecorderEventsHandler(
|
|||||||
showRecorderError = true
|
showRecorderError = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
audioRecorder.onBatchesFolderNotAccessible = {
|
||||||
|
scope.launch {
|
||||||
|
showBatchesInaccessibleError = true
|
||||||
|
|
||||||
|
runCatching {
|
||||||
|
audioRecorder.stopRecording(context)
|
||||||
|
}
|
||||||
|
runCatching {
|
||||||
|
audioRecorder.destroyService(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onDispose {
|
onDispose {
|
||||||
audioRecorder.onRecordingSave = {}
|
audioRecorder.onRecordingSave = {}
|
||||||
@ -266,6 +280,18 @@ fun RecorderEventsHandler(
|
|||||||
showRecorderError = true
|
showRecorderError = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
videoRecorder.onBatchesFolderNotAccessible = {
|
||||||
|
scope.launch {
|
||||||
|
showBatchesInaccessibleError = true
|
||||||
|
|
||||||
|
runCatching {
|
||||||
|
videoRecorder.stopRecording(context)
|
||||||
|
}
|
||||||
|
runCatching {
|
||||||
|
videoRecorder.destroyService(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onDispose {
|
onDispose {
|
||||||
videoRecorder.onRecordingSave = {}
|
videoRecorder.onRecordingSave = {}
|
||||||
@ -284,4 +310,11 @@ fun RecorderEventsHandler(
|
|||||||
onSave = {
|
onSave = {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (showBatchesInaccessibleError)
|
||||||
|
BatchesInaccessibleDialog(
|
||||||
|
onClose = {
|
||||||
|
showBatchesInaccessibleError = false
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
@ -47,6 +47,7 @@ abstract class BaseRecorderModel<I, B : BatchesFolder, T : IntervalRecorderServi
|
|||||||
// thus the service is not running and thus doesn't need to be stopped or destroyed
|
// thus the service is not running and thus doesn't need to be stopped or destroyed
|
||||||
var onRecordingSave: (isSavingAsOldRecording: Boolean) -> Unit = {}
|
var onRecordingSave: (isSavingAsOldRecording: Boolean) -> Unit = {}
|
||||||
var onError: () -> Unit = {}
|
var onError: () -> Unit = {}
|
||||||
|
var onBatchesFolderNotAccessible: () -> Unit = {}
|
||||||
abstract var batchesFolder: B?
|
abstract var batchesFolder: B?
|
||||||
|
|
||||||
private var notificationDetails: RecorderNotificationHelper.NotificationDetails? = null
|
private var notificationDetails: RecorderNotificationHelper.NotificationDetails? = null
|
||||||
@ -70,11 +71,14 @@ abstract class BaseRecorderModel<I, B : BatchesFolder, T : IntervalRecorderServi
|
|||||||
recorder.onError = {
|
recorder.onError = {
|
||||||
onError()
|
onError()
|
||||||
}
|
}
|
||||||
|
recorder.onBatchesFolderNotAccessible = {
|
||||||
|
onBatchesFolderNotAccessible()
|
||||||
|
}
|
||||||
|
|
||||||
if (batchesFolder != null) {
|
if (batchesFolder != null) {
|
||||||
recorder.batchesFolder = batchesFolder!!
|
recorder.batchesFolder = batchesFolder!!
|
||||||
} else {
|
} else {
|
||||||
batchesFolder = recorder.batchesFolder as B
|
batchesFolder = recorder.batchesFolder
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings != null) {
|
if (settings != null) {
|
||||||
@ -167,9 +171,9 @@ abstract class BaseRecorderModel<I, B : BatchesFolder, T : IntervalRecorderServi
|
|||||||
|
|
||||||
fun destroyService(context: Context) {
|
fun destroyService(context: Context) {
|
||||||
recorderService!!.destroy()
|
recorderService!!.destroy()
|
||||||
reset()
|
|
||||||
|
|
||||||
stopOldServices(context)
|
stopOldServices(context)
|
||||||
|
reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bind functions used to manually bind to the service if the app
|
// Bind functions used to manually bind to the service if the app
|
||||||
|
@ -176,4 +176,5 @@
|
|||||||
<string name="ui_settings_option_saveFolder_externalPermissionRequired_title">Permission required</string>
|
<string name="ui_settings_option_saveFolder_externalPermissionRequired_title">Permission required</string>
|
||||||
<string name="ui_settings_option_saveFolder_externalPermissionRequired_text">To access the DCIM folder, you need to grant Alibi the permission to access external storage. Alibi will only use this permission to write your recordings to the DCIM folder.</string>
|
<string name="ui_settings_option_saveFolder_externalPermissionRequired_text">To access the DCIM folder, you need to grant Alibi the permission to access external storage. Alibi will only use this permission to write your recordings to the DCIM folder.</string>
|
||||||
<string name="ui_settings_option_saveFolder_externalPermissionRequired_action_confirm">Grant permission</string>
|
<string name="ui_settings_option_saveFolder_externalPermissionRequired_action_confirm">Grant permission</string>
|
||||||
|
<string name="ui_audioRecorder_error_batchesInaccessible_description">Alibi couldn\'t access or write to the batches folder. Try to choose a different folder or use the internal storage instead. The recording has been aborted.</string>
|
||||||
</resources>
|
</resources>
|
Loading…
x
Reference in New Issue
Block a user