mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
feat: Add doctor; Add check for file saver dialog
This commit is contained in:
parent
d24dd4cf4b
commit
29d4e5a86a
14
app/src/main/java/app/myzel394/alibi/helpers/Doctor.kt
Normal file
14
app/src/main/java/app/myzel394/alibi/helpers/Doctor.kt
Normal file
@ -0,0 +1,14 @@
|
||||
package app.myzel394.alibi.helpers
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
||||
data class Doctor(
|
||||
val context: Context
|
||||
) {
|
||||
fun checkIfFileSaverDialogIsAvailable(): Boolean {
|
||||
val fileSaver = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
|
||||
return fileSaver.resolveActivity(context.packageManager) != null
|
||||
}
|
||||
}
|
@ -231,9 +231,10 @@ class AudioRecorderService :
|
||||
// ==== Microphone related ====
|
||||
private fun resetRecorder() {
|
||||
runCatching {
|
||||
recorder?.let {
|
||||
it.stop()
|
||||
it.release()
|
||||
recorder?.apply {
|
||||
stop()
|
||||
reset()
|
||||
release()
|
||||
}
|
||||
clearAudioDevice()
|
||||
batchesFolder.cleanup()
|
||||
|
@ -40,9 +40,10 @@ abstract class IntervalRecorderService<I, B : BatchesFolder> :
|
||||
|
||||
override fun start() {
|
||||
super.start()
|
||||
|
||||
batchesFolder.initFolders()
|
||||
|
||||
if (!batchesFolder.checkIfFolderIsAccessible()) {
|
||||
// TODO: Add handler
|
||||
onBatchesFolderNotAccessible()
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ class VideoRecorderService :
|
||||
}
|
||||
|
||||
class CameraControl(
|
||||
private val camera: Camera,
|
||||
val camera: Camera
|
||||
) {
|
||||
fun enableTorch() {
|
||||
camera.cameraControl.enableTorch(true)
|
||||
|
@ -1,12 +1,25 @@
|
||||
package app.myzel394.alibi.ui
|
||||
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Error
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import app.myzel394.alibi.R
|
||||
import app.myzel394.alibi.dataStore
|
||||
import app.myzel394.alibi.db.AppSettings
|
||||
import app.myzel394.alibi.helpers.Doctor
|
||||
|
||||
// Handlers that can safely be run when the app is locked (biometric authentication required)
|
||||
@Composable
|
||||
@ -29,4 +42,43 @@ fun LockedAppHandlers() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var showFileSaverUnavailableDialog by remember { mutableStateOf(false) }
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
val doctor = Doctor(context)
|
||||
|
||||
if (!doctor.checkIfFileSaverDialogIsAvailable()) {
|
||||
showFileSaverUnavailableDialog = true
|
||||
}
|
||||
}
|
||||
|
||||
if (showFileSaverUnavailableDialog) {
|
||||
AlertDialog(
|
||||
icon = {
|
||||
Icon(
|
||||
Icons.Default.Error,
|
||||
contentDescription = null
|
||||
)
|
||||
},
|
||||
onDismissRequest = {
|
||||
showFileSaverUnavailableDialog = false
|
||||
},
|
||||
title = {
|
||||
Text(stringResource(R.string.ui_severeError_fileSaverUnavailable_title))
|
||||
},
|
||||
text = {
|
||||
Text(stringResource(R.string.ui_severeError_fileSaverUnavailable_text))
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
showFileSaverUnavailableDialog = false
|
||||
}
|
||||
) {
|
||||
Text(text = stringResource(R.string.dialog_close_neutral_label))
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package app.myzel394.alibi.ui.components.SettingsScreen.Tiles
|
||||
|
||||
import android.media.MediaRecorder
|
||||
import androidx.camera.video.Quality
|
||||
import androidx.camera.video.Recorder
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.HighQuality
|
||||
import androidx.compose.material3.Button
|
||||
|
@ -13,6 +13,7 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import app.myzel394.alibi.db.AppSettings
|
||||
import app.myzel394.alibi.db.RecordingInformation
|
||||
import app.myzel394.alibi.enums.RecorderState
|
||||
import app.myzel394.alibi.helpers.Doctor
|
||||
import app.myzel394.alibi.helpers.VideoBatchesFolder
|
||||
import app.myzel394.alibi.services.VideoRecorderService
|
||||
import app.myzel394.alibi.ui.RECORDER_MEDIA_SELECTED_VALUE
|
||||
|
@ -30,7 +30,6 @@ import app.myzel394.alibi.db.AppSettings
|
||||
import app.myzel394.alibi.db.RecordingInformation
|
||||
import app.myzel394.alibi.ui.components.RecorderScreen.organisms.RecorderEventsHandler
|
||||
import app.myzel394.alibi.ui.components.RecorderScreen.organisms.VideoRecordingStatus
|
||||
import app.myzel394.alibi.ui.effects.rememberSettings
|
||||
import app.myzel394.alibi.ui.models.AudioRecorderModel
|
||||
import app.myzel394.alibi.ui.models.VideoRecorderModel
|
||||
|
||||
|
@ -177,4 +177,6 @@
|
||||
<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_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>
|
||||
<string name="ui_severeError_fileSaverUnavailable_title">File Manager app not found</string>
|
||||
<string name="ui_severeError_fileSaverUnavailable_text">Alibi couldn\'t find a file manager app on your phone. Please install a file manager app and try again. If this message still appears, you can try using a custom batches folder in the advanced settings section. Alibi may not fully work on your device.</string>
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user