From 3cfbbdef1c9ba1ccccc1bb2a91d5505ef91faa17 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 7 Sep 2024 21:39:45 +0200 Subject: [PATCH 1/5] fix: Use one source of truth for the filename (instead of recalculating it, this doesn't work, as the date _time_ will differ) Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../alibi/helpers/AudioBatchesFolder.kt | 13 +++++------ .../myzel394/alibi/helpers/BatchesFolder.kt | 23 +++++++------------ .../alibi/helpers/VideoBatchesFolder.kt | 18 ++++++++------- .../organisms/RecorderEventsHandler.kt | 21 +++++++---------- 4 files changed, 32 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt b/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt index 46c50f0a..4f1b6075 100644 --- a/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt +++ b/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt @@ -40,18 +40,17 @@ class AudioBatchesFolder( override fun getOutputFileForFFmpeg( date: LocalDateTime, extension: String, + fileName: String, ): String { return when (type) { - BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath + BatchType.INTERNAL -> asInternalGetOutputFile(fileName).absolutePath BatchType.CUSTOM -> { - val name = getName(date, extension) - FFmpegKitConfig.getSafParameterForWrite( context, - (customFolder!!.findFile(name) ?: customFolder.createFile( + (customFolder!!.findFile(fileName) ?: customFolder.createFile( "audio/${extension}", - getName(date, extension), + fileName, )!!).uri )!! } @@ -59,7 +58,7 @@ class AudioBatchesFolder( BatchType.MEDIA -> { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { val mediaUri = getOrCreateMediaFile( - name = getName(date, extension), + name = fileName, mimeType = "audio/$extension", relativePath = BASE_SCOPED_STORAGE_RELATIVE_PATH + "/" + MEDIA_SUBFOLDER_NAME, ) @@ -72,7 +71,7 @@ class AudioBatchesFolder( val path = arrayOf( Environment.getExternalStoragePublicDirectory(BASE_LEGACY_STORAGE_FOLDER), MEDIA_SUBFOLDER_NAME, - getName(date, extension) + fileName, ).joinToString("/") return File(path) .apply { diff --git a/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt b/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt index e60be726..e55d301a 100644 --- a/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt +++ b/app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt @@ -191,8 +191,8 @@ abstract class BatchesFolder( return "$name.$extension" } - fun asInternalGetOutputFile(date: LocalDateTime, extension: String): File { - return File(getInternalFolder(), getName(date, extension)) + fun asInternalGetOutputFile(fileName: String): File { + return File(getInternalFolder(), fileName) } fun asMediaGetLegacyFile(name: String): File = File( @@ -203,16 +203,8 @@ abstract class BatchesFolder( } fun checkIfOutputAlreadyExists( - date: LocalDateTime, - extension: String + fileName: String, ): Boolean { - val stem = date - .format(DateTimeFormatter.ISO_DATE_TIME) - .toString() - .replace(":", "-") - .replace(".", "_") - val fileName = "$stem.$extension" - return when (type) { BatchType.INTERNAL -> File(getInternalFolder(), fileName).exists() @@ -245,6 +237,7 @@ abstract class BatchesFolder( abstract fun getOutputFileForFFmpeg( date: LocalDateTime, extension: String, + fileName: String, ): String abstract fun cleanup() @@ -255,18 +248,17 @@ abstract class BatchesFolder( disableCache: Boolean? = null, onNextParameterTry: (String) -> Unit = {}, onProgress: (Float?) -> Unit = {}, + fileName: String, ): String { val disableCache = disableCache ?: (type != BatchType.INTERNAL) val date = recording.getStartDateForFilename(filenameFormat) - if (!disableCache && checkIfOutputAlreadyExists( - recording.recordingStart, - recording.fileExtension - ) + if (!disableCache && checkIfOutputAlreadyExists(fileName) ) { return getOutputFileForFFmpeg( date = recording.recordingStart, extension = recording.fileExtension, + fileName = fileName, ) } @@ -282,6 +274,7 @@ abstract class BatchesFolder( val outputFile = getOutputFileForFFmpeg( date = date, extension = recording.fileExtension, + fileName = fileName, ) concatenationFunction( diff --git a/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt b/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt index e1436816..7daf27e6 100644 --- a/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt +++ b/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt @@ -39,18 +39,20 @@ class VideoBatchesFolder( private var customParcelFileDescriptor: ParcelFileDescriptor? = null - override fun getOutputFileForFFmpeg(date: LocalDateTime, extension: String): String { + override fun getOutputFileForFFmpeg( + date: LocalDateTime, + extension: String, + fileName: String, + ): String { return when (type) { - BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath + BatchType.INTERNAL -> asInternalGetOutputFile(fileName).absolutePath BatchType.CUSTOM -> { - val name = getName(date, extension) - FFmpegKitConfig.getSafParameterForWrite( context, - (customFolder!!.findFile(name) ?: customFolder.createFile( + (customFolder!!.findFile(fileName) ?: customFolder.createFile( "video/${extension}", - getName(date, extension), + fileName, )!!).uri )!! } @@ -58,7 +60,7 @@ class VideoBatchesFolder( BatchType.MEDIA -> { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { val mediaUri = getOrCreateMediaFile( - name = getName(date, extension), + name = fileName, mimeType = "video/$extension", relativePath = BASE_SCOPED_STORAGE_RELATIVE_PATH + "/" + MEDIA_SUBFOLDER_NAME, ) @@ -71,7 +73,7 @@ class VideoBatchesFolder( val path = arrayOf( Environment.getExternalStoragePublicDirectory(BASE_LEGACY_STORAGE_FOLDER), MEDIA_SUBFOLDER_NAME, - getName(date, extension) + fileName, ).joinToString("/") return File(path) .apply { diff --git a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/organisms/RecorderEventsHandler.kt b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/organisms/RecorderEventsHandler.kt index 5040e450..91b7e0de 100644 --- a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/organisms/RecorderEventsHandler.kt +++ b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/organisms/RecorderEventsHandler.kt @@ -177,38 +177,33 @@ fun RecorderEventsHandler( else -> throw Exception("Unknown recorder type") } + val fileName = batchesFolder.getName( + recording.recordingStart, + recording.fileExtension, + ) + batchesFolder.concatenate( recording, filenameFormat = settings.filenameFormat, + fileName = fileName, onProgress = { percentage -> processingProgress = percentage } ) // Save file - val name = batchesFolder.getName( - recording.recordingStart, - recording.fileExtension, - ) - when (batchesFolder.type) { BatchesFolder.BatchType.INTERNAL -> { when (batchesFolder) { is AudioBatchesFolder -> { saveAudioFile( - batchesFolder.asInternalGetOutputFile( - recording.recordingStart, - recording.fileExtension, - ), name + batchesFolder.asInternalGetOutputFile(fileName), fileName ) } is VideoBatchesFolder -> { saveVideoFile( - batchesFolder.asInternalGetOutputFile( - recording.recordingStart, - recording.fileExtension, - ), name + batchesFolder.asInternalGetOutputFile(fileName), fileName ) } } From b4dfe9112585106ed9e827240d843e975c8cdb49 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 7 Sep 2024 21:44:14 +0200 Subject: [PATCH 2/5] chore: Update dependencies Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- app/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 963fcad8..beabf8dd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -97,7 +97,7 @@ dependencies { implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4' implementation 'androidx.activity:activity-compose:1.9.1' implementation 'androidx.activity:activity-ktx:1.9.1' - implementation platform('androidx.compose:compose-bom:2024.06.00') + implementation platform('androidx.compose:compose-bom:2024.09.00') implementation 'androidx.compose.ui:ui' implementation 'androidx.compose.ui:ui-graphics' implementation 'androidx.compose.ui:ui-tooling-preview' @@ -110,7 +110,7 @@ dependencies { testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' - androidTestImplementation platform('androidx.compose:compose-bom:2024.06.00') + androidTestImplementation platform('androidx.compose:compose-bom:2024.09.00') androidTestImplementation 'androidx.compose.ui:ui-test-junit4' debugImplementation 'androidx.compose.ui:ui-tooling' debugImplementation 'androidx.compose.ui:ui-test-manifest' @@ -121,7 +121,7 @@ dependencies { annotationProcessor 'com.google.dagger:hilt-compiler:2.49' implementation "androidx.hilt:hilt-navigation-compose:1.2.0" - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4' + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.1' implementation 'com.arthenica:ffmpeg-kit-full-gpl:5.1' From a085a3564b54bba8f4b0cf9007c44ac961ee9227 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 7 Sep 2024 21:44:32 +0200 Subject: [PATCH 3/5] chore: Update version Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index beabf8dd..cc2a117e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -35,8 +35,8 @@ android { applicationId "app.myzel394.alibi" minSdk 24 targetSdk 34 - versionCode 15 - versionName "0.5.2" + versionCode 16 + versionName "0.5.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { From deff57a54fed1e6d69ceb84ddb9d642943b4516b Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 7 Sep 2024 21:55:53 +0200 Subject: [PATCH 4/5] chore: Update to new APIs Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../alibi/ui/components/RecorderScreen/atoms/BigButton.kt | 8 ++++---- .../ui/components/RecorderScreen/atoms/SaveButton.kt | 4 ++-- .../RecorderScreen/molecules/RecordingStatus.kt | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/BigButton.kt b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/BigButton.kt index a7dc7f33..9649d562 100644 --- a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/BigButton.kt +++ b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/BigButton.kt @@ -11,11 +11,11 @@ import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape -import androidx.compose.material.ripple.rememberRipple import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.Icon import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.ripple import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -40,8 +40,8 @@ fun BigButton( val orientation = LocalConfiguration.current.orientation BoxWithConstraints { - val isLarge = if (isBig == null) - maxWidth > 250.dp && maxHeight > 600.dp && orientation == Configuration.ORIENTATION_PORTRAIT else isBig + val isLarge = isBig + ?: (maxWidth > 250.dp && maxHeight > 600.dp && orientation == Configuration.ORIENTATION_PORTRAIT) Column( modifier = Modifier @@ -52,7 +52,7 @@ fun BigButton( } .combinedClickable( interactionSource = remember { MutableInteractionSource() }, - indication = rememberRipple(color = MaterialTheme.colorScheme.primary), + indication = ripple(color = MaterialTheme.colorScheme.primary), onClick = onClick, onLongClick = onLongClick, ), diff --git a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/SaveButton.kt b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/SaveButton.kt index fc259cb5..7649a35e 100644 --- a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/SaveButton.kt +++ b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/SaveButton.kt @@ -6,10 +6,10 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding -import androidx.compose.material.ripple.rememberRipple import androidx.compose.material3.ButtonDefaults import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Text +import androidx.compose.material3.ripple import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment @@ -39,7 +39,7 @@ fun SaveButton( } .combinedClickable( interactionSource = remember { MutableInteractionSource() }, - indication = rememberRipple(color = MaterialTheme.colorScheme.primary), + indication = ripple(color = MaterialTheme.colorScheme.primary), onClick = onSave, onLongClick = onLongClick, ) diff --git a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/molecules/RecordingStatus.kt b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/molecules/RecordingStatus.kt index b5ad34de..0eab5e20 100644 --- a/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/molecules/RecordingStatus.kt +++ b/app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/molecules/RecordingStatus.kt @@ -76,6 +76,8 @@ fun RecordingStatus( LinearProgressIndicator( progress = { progress }, modifier = progressModifier, + drawStopIndicator = { }, + gapSize = 0.dp, ) } From c8de60085afb26e7f4691fa69f7fb8ee930e9b3b Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 7 Sep 2024 22:11:25 +0200 Subject: [PATCH 5/5] fix: Fix folder names Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt | 2 +- .../main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt b/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt index 4f1b6075..c3dc81ae 100644 --- a/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt +++ b/app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt @@ -142,7 +142,7 @@ class AudioBatchesFolder( } val BASE_LEGACY_STORAGE_FOLDER = Environment.DIRECTORY_PODCASTS - val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/audio_recordings" + val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/.audio_recordings" val BASE_SCOPED_STORAGE_RELATIVE_PATH = (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) Environment.DIRECTORY_RECORDINGS diff --git a/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt b/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt index 7daf27e6..612d6485 100644 --- a/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt +++ b/app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt @@ -148,7 +148,7 @@ class VideoBatchesFolder( } val BASE_LEGACY_STORAGE_FOLDER = Environment.DIRECTORY_DCIM - val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/video_recordings" + val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/.video_recordings" val BASE_SCOPED_STORAGE_RELATIVE_PATH = Environment.DIRECTORY_DCIM val SCOPED_STORAGE_RELATIVE_PATH = BASE_SCOPED_STORAGE_RELATIVE_PATH + "/" + MEDIA_RECORDINGS_SUBFOLDER