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

View File

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