Skip to content

Commit 193ecd1

Browse files
authored
Merge pull request #121 from Myzel394/fix-name
Fix empty file
2 parents d915f41 + c8de600 commit 193ecd1

File tree

8 files changed

+47
-56
lines changed

8 files changed

+47
-56
lines changed

app/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ android {
3535
applicationId "app.myzel394.alibi"
3636
minSdk 24
3737
targetSdk 34
38-
versionCode 15
39-
versionName "0.5.2"
38+
versionCode 16
39+
versionName "0.5.3"
4040

4141
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4242
vectorDrawables {
@@ -97,7 +97,7 @@ dependencies {
9797
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.8.4'
9898
implementation 'androidx.activity:activity-compose:1.9.1'
9999
implementation 'androidx.activity:activity-ktx:1.9.1'
100-
implementation platform('androidx.compose:compose-bom:2024.06.00')
100+
implementation platform('androidx.compose:compose-bom:2024.09.00')
101101
implementation 'androidx.compose.ui:ui'
102102
implementation 'androidx.compose.ui:ui-graphics'
103103
implementation 'androidx.compose.ui:ui-tooling-preview'
@@ -110,7 +110,7 @@ dependencies {
110110
testImplementation 'junit:junit:4.13.2'
111111
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
112112
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
113-
androidTestImplementation platform('androidx.compose:compose-bom:2024.06.00')
113+
androidTestImplementation platform('androidx.compose:compose-bom:2024.09.00')
114114
androidTestImplementation 'androidx.compose.ui:ui-test-junit4'
115115
debugImplementation 'androidx.compose.ui:ui-tooling'
116116
debugImplementation 'androidx.compose.ui:ui-test-manifest'
@@ -121,7 +121,7 @@ dependencies {
121121
annotationProcessor 'com.google.dagger:hilt-compiler:2.49'
122122
implementation "androidx.hilt:hilt-navigation-compose:1.2.0"
123123

124-
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
124+
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.1'
125125

126126
implementation 'com.arthenica:ffmpeg-kit-full-gpl:5.1'
127127

app/src/main/java/app/myzel394/alibi/helpers/AudioBatchesFolder.kt

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,25 @@ class AudioBatchesFolder(
4040
override fun getOutputFileForFFmpeg(
4141
date: LocalDateTime,
4242
extension: String,
43+
fileName: String,
4344
): String {
4445
return when (type) {
45-
BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath
46+
BatchType.INTERNAL -> asInternalGetOutputFile(fileName).absolutePath
4647

4748
BatchType.CUSTOM -> {
48-
val name = getName(date, extension)
49-
5049
FFmpegKitConfig.getSafParameterForWrite(
5150
context,
52-
(customFolder!!.findFile(name) ?: customFolder.createFile(
51+
(customFolder!!.findFile(fileName) ?: customFolder.createFile(
5352
"audio/${extension}",
54-
getName(date, extension),
53+
fileName,
5554
)!!).uri
5655
)!!
5756
}
5857

5958
BatchType.MEDIA -> {
6059
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
6160
val mediaUri = getOrCreateMediaFile(
62-
name = getName(date, extension),
61+
name = fileName,
6362
mimeType = "audio/$extension",
6463
relativePath = BASE_SCOPED_STORAGE_RELATIVE_PATH + "/" + MEDIA_SUBFOLDER_NAME,
6564
)
@@ -72,7 +71,7 @@ class AudioBatchesFolder(
7271
val path = arrayOf(
7372
Environment.getExternalStoragePublicDirectory(BASE_LEGACY_STORAGE_FOLDER),
7473
MEDIA_SUBFOLDER_NAME,
75-
getName(date, extension)
74+
fileName,
7675
).joinToString("/")
7776
return File(path)
7877
.apply {
@@ -143,7 +142,7 @@ class AudioBatchesFolder(
143142
}
144143

145144
val BASE_LEGACY_STORAGE_FOLDER = Environment.DIRECTORY_PODCASTS
146-
val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/audio_recordings"
145+
val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/.audio_recordings"
147146
val BASE_SCOPED_STORAGE_RELATIVE_PATH =
148147
(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S)
149148
Environment.DIRECTORY_RECORDINGS

app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ abstract class BatchesFolder(
191191
return "$name.$extension"
192192
}
193193

194-
fun asInternalGetOutputFile(date: LocalDateTime, extension: String): File {
195-
return File(getInternalFolder(), getName(date, extension))
194+
fun asInternalGetOutputFile(fileName: String): File {
195+
return File(getInternalFolder(), fileName)
196196
}
197197

198198
fun asMediaGetLegacyFile(name: String): File = File(
@@ -203,16 +203,8 @@ abstract class BatchesFolder(
203203
}
204204

205205
fun checkIfOutputAlreadyExists(
206-
date: LocalDateTime,
207-
extension: String
206+
fileName: String,
208207
): Boolean {
209-
val stem = date
210-
.format(DateTimeFormatter.ISO_DATE_TIME)
211-
.toString()
212-
.replace(":", "-")
213-
.replace(".", "_")
214-
val fileName = "$stem.$extension"
215-
216208
return when (type) {
217209
BatchType.INTERNAL -> File(getInternalFolder(), fileName).exists()
218210

@@ -245,6 +237,7 @@ abstract class BatchesFolder(
245237
abstract fun getOutputFileForFFmpeg(
246238
date: LocalDateTime,
247239
extension: String,
240+
fileName: String,
248241
): String
249242

250243
abstract fun cleanup()
@@ -255,18 +248,17 @@ abstract class BatchesFolder(
255248
disableCache: Boolean? = null,
256249
onNextParameterTry: (String) -> Unit = {},
257250
onProgress: (Float?) -> Unit = {},
251+
fileName: String,
258252
): String {
259253
val disableCache = disableCache ?: (type != BatchType.INTERNAL)
260254
val date = recording.getStartDateForFilename(filenameFormat)
261255

262-
if (!disableCache && checkIfOutputAlreadyExists(
263-
recording.recordingStart,
264-
recording.fileExtension
265-
)
256+
if (!disableCache && checkIfOutputAlreadyExists(fileName)
266257
) {
267258
return getOutputFileForFFmpeg(
268259
date = recording.recordingStart,
269260
extension = recording.fileExtension,
261+
fileName = fileName,
270262
)
271263
}
272264

@@ -282,6 +274,7 @@ abstract class BatchesFolder(
282274
val outputFile = getOutputFileForFFmpeg(
283275
date = date,
284276
extension = recording.fileExtension,
277+
fileName = fileName,
285278
)
286279

287280
concatenationFunction(

app/src/main/java/app/myzel394/alibi/helpers/VideoBatchesFolder.kt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,28 @@ class VideoBatchesFolder(
3939

4040
private var customParcelFileDescriptor: ParcelFileDescriptor? = null
4141

42-
override fun getOutputFileForFFmpeg(date: LocalDateTime, extension: String): String {
42+
override fun getOutputFileForFFmpeg(
43+
date: LocalDateTime,
44+
extension: String,
45+
fileName: String,
46+
): String {
4347
return when (type) {
44-
BatchType.INTERNAL -> asInternalGetOutputFile(date, extension).absolutePath
48+
BatchType.INTERNAL -> asInternalGetOutputFile(fileName).absolutePath
4549

4650
BatchType.CUSTOM -> {
47-
val name = getName(date, extension)
48-
4951
FFmpegKitConfig.getSafParameterForWrite(
5052
context,
51-
(customFolder!!.findFile(name) ?: customFolder.createFile(
53+
(customFolder!!.findFile(fileName) ?: customFolder.createFile(
5254
"video/${extension}",
53-
getName(date, extension),
55+
fileName,
5456
)!!).uri
5557
)!!
5658
}
5759

5860
BatchType.MEDIA -> {
5961
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
6062
val mediaUri = getOrCreateMediaFile(
61-
name = getName(date, extension),
63+
name = fileName,
6264
mimeType = "video/$extension",
6365
relativePath = BASE_SCOPED_STORAGE_RELATIVE_PATH + "/" + MEDIA_SUBFOLDER_NAME,
6466
)
@@ -71,7 +73,7 @@ class VideoBatchesFolder(
7173
val path = arrayOf(
7274
Environment.getExternalStoragePublicDirectory(BASE_LEGACY_STORAGE_FOLDER),
7375
MEDIA_SUBFOLDER_NAME,
74-
getName(date, extension)
76+
fileName,
7577
).joinToString("/")
7678
return File(path)
7779
.apply {
@@ -146,7 +148,7 @@ class VideoBatchesFolder(
146148
}
147149

148150
val BASE_LEGACY_STORAGE_FOLDER = Environment.DIRECTORY_DCIM
149-
val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/video_recordings"
151+
val MEDIA_RECORDINGS_SUBFOLDER = MEDIA_SUBFOLDER_NAME + "/.video_recordings"
150152
val BASE_SCOPED_STORAGE_RELATIVE_PATH = Environment.DIRECTORY_DCIM
151153
val SCOPED_STORAGE_RELATIVE_PATH =
152154
BASE_SCOPED_STORAGE_RELATIVE_PATH + "/" + MEDIA_RECORDINGS_SUBFOLDER

app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/BigButton.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import androidx.compose.foundation.layout.Spacer
1111
import androidx.compose.foundation.layout.height
1212
import androidx.compose.foundation.layout.size
1313
import androidx.compose.foundation.shape.CircleShape
14-
import androidx.compose.material.ripple.rememberRipple
1514
import androidx.compose.material3.ButtonDefaults
1615
import androidx.compose.material3.Icon
1716
import androidx.compose.material3.MaterialTheme
1817
import androidx.compose.material3.Text
18+
import androidx.compose.material3.ripple
1919
import androidx.compose.runtime.Composable
2020
import androidx.compose.runtime.remember
2121
import androidx.compose.ui.Alignment
@@ -40,8 +40,8 @@ fun BigButton(
4040
val orientation = LocalConfiguration.current.orientation
4141

4242
BoxWithConstraints {
43-
val isLarge = if (isBig == null)
44-
maxWidth > 250.dp && maxHeight > 600.dp && orientation == Configuration.ORIENTATION_PORTRAIT else isBig
43+
val isLarge = isBig
44+
?: (maxWidth > 250.dp && maxHeight > 600.dp && orientation == Configuration.ORIENTATION_PORTRAIT)
4545

4646
Column(
4747
modifier = Modifier
@@ -52,7 +52,7 @@ fun BigButton(
5252
}
5353
.combinedClickable(
5454
interactionSource = remember { MutableInteractionSource() },
55-
indication = rememberRipple(color = MaterialTheme.colorScheme.primary),
55+
indication = ripple(color = MaterialTheme.colorScheme.primary),
5656
onClick = onClick,
5757
onLongClick = onLongClick,
5858
),

app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/atoms/SaveButton.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
66
import androidx.compose.foundation.layout.Arrangement
77
import androidx.compose.foundation.layout.Row
88
import androidx.compose.foundation.layout.padding
9-
import androidx.compose.material.ripple.rememberRipple
109
import androidx.compose.material3.ButtonDefaults
1110
import androidx.compose.material3.MaterialTheme
1211
import androidx.compose.material3.Text
12+
import androidx.compose.material3.ripple
1313
import androidx.compose.runtime.Composable
1414
import androidx.compose.runtime.remember
1515
import androidx.compose.ui.Alignment
@@ -39,7 +39,7 @@ fun SaveButton(
3939
}
4040
.combinedClickable(
4141
interactionSource = remember { MutableInteractionSource() },
42-
indication = rememberRipple(color = MaterialTheme.colorScheme.primary),
42+
indication = ripple(color = MaterialTheme.colorScheme.primary),
4343
onClick = onSave,
4444
onLongClick = onLongClick,
4545
)

app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/molecules/RecordingStatus.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ fun RecordingStatus(
7676
LinearProgressIndicator(
7777
progress = { progress },
7878
modifier = progressModifier,
79+
drawStopIndicator = { },
80+
gapSize = 0.dp,
7981
)
8082
}
8183

app/src/main/java/app/myzel394/alibi/ui/components/RecorderScreen/organisms/RecorderEventsHandler.kt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,38 +177,33 @@ fun RecorderEventsHandler(
177177
else -> throw Exception("Unknown recorder type")
178178
}
179179

180+
val fileName = batchesFolder.getName(
181+
recording.recordingStart,
182+
recording.fileExtension,
183+
)
184+
180185
batchesFolder.concatenate(
181186
recording,
182187
filenameFormat = settings.filenameFormat,
188+
fileName = fileName,
183189
onProgress = { percentage ->
184190
processingProgress = percentage
185191
}
186192
)
187193

188194
// Save file
189-
val name = batchesFolder.getName(
190-
recording.recordingStart,
191-
recording.fileExtension,
192-
)
193-
194195
when (batchesFolder.type) {
195196
BatchesFolder.BatchType.INTERNAL -> {
196197
when (batchesFolder) {
197198
is AudioBatchesFolder -> {
198199
saveAudioFile(
199-
batchesFolder.asInternalGetOutputFile(
200-
recording.recordingStart,
201-
recording.fileExtension,
202-
), name
200+
batchesFolder.asInternalGetOutputFile(fileName), fileName
203201
)
204202
}
205203

206204
is VideoBatchesFolder -> {
207205
saveVideoFile(
208-
batchesFolder.asInternalGetOutputFile(
209-
recording.recordingStart,
210-
recording.fileExtension,
211-
), name
206+
batchesFolder.asInternalGetOutputFile(fileName), fileName
212207
)
213208
}
214209
}

0 commit comments

Comments
 (0)