fix: Fix custom BatchesFolder

This commit is contained in:
Myzel394 2023-11-18 19:40:02 +01:00
parent 79ba18630c
commit 18195c9893
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
2 changed files with 9 additions and 8 deletions

View File

@ -62,7 +62,7 @@ data class BatchesFolder(
.map {
FFmpegKitConfig.getSafParameterForRead(
context,
customFolder!!.findFile(it.name!!)!!.uri
it.uri,
)!!
}
}
@ -82,7 +82,10 @@ data class BatchesFolder(
BatchType.INTERNAL -> File(getInternalFolder(), "$name.$extension").absolutePath
BatchType.CUSTOM -> FFmpegKitConfig.getSafParameterForWrite(
context,
customFolder!!.createFile("audio/${extension}", "${name}.${extension}")!!.uri
getCustomDefinedFolder().createFile(
"audio/${extension}",
"${name}.${extension}"
)!!.uri
)!!
}
}
@ -97,9 +100,7 @@ data class BatchesFolder(
fun deleteRecordings() {
when (type) {
BatchType.INTERNAL -> getInternalFolder().deleteRecursively()
BatchType.CUSTOM -> getCustomDefinedFolder().listFiles().forEach {
it.delete()
}
BatchType.CUSTOM -> customFolder?.findFile(subfolderName)?.delete()
}
}

View File

@ -67,8 +67,6 @@ class AudioRecorderModel : ViewModel() {
override fun onServiceConnected(className: ComponentName, service: IBinder) {
recorderService =
((service as RecorderService.RecorderBinder).getService() as AudioRecorderService).also { recorder ->
recorder.clearAllRecordings()
// Init variables from us to the service
recorder.onStateChange = { state ->
recorderState = state
@ -95,6 +93,8 @@ class AudioRecorderModel : ViewModel() {
recorder.batchesFolder = batchesFolder ?: recorder.batchesFolder
recorder.settings =
IntervalRecorderService.Settings.from(settings.audioRecorderSettings)
recorder.clearAllRecordings()
}.also {
// Init UI from the service
it.startRecording()
@ -122,8 +122,8 @@ class AudioRecorderModel : ViewModel() {
fun startRecording(context: Context, settings: AppSettings) {
runCatching {
context.unbindService(connection)
recorderService?.clearAllRecordings()
context.unbindService(connection)
}
notificationDetails = settings.notificationSettings.let {