mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-19 15:15:26 +02:00
fix: Sort batches
This commit is contained in:
parent
da34df6b87
commit
3a542f3a4d
@ -18,7 +18,7 @@ import java.time.format.DateTimeFormatter
|
|||||||
import com.arthenica.ffmpegkit.FFmpegKitConfig
|
import com.arthenica.ffmpegkit.FFmpegKitConfig
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.net.toFile
|
import androidx.core.net.toUri
|
||||||
import app.myzel394.alibi.ui.RECORDER_INTERNAL_SELECTED_VALUE
|
import app.myzel394.alibi.ui.RECORDER_INTERNAL_SELECTED_VALUE
|
||||||
import app.myzel394.alibi.ui.RECORDER_MEDIA_SELECTED_VALUE
|
import app.myzel394.alibi.ui.RECORDER_MEDIA_SELECTED_VALUE
|
||||||
import app.myzel394.alibi.ui.SUPPORTS_SCOPED_STORAGE
|
import app.myzel394.alibi.ui.SUPPORTS_SCOPED_STORAGE
|
||||||
@ -112,15 +112,19 @@ abstract class BatchesFolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getBatchesForFFmpeg(): List<String> {
|
fun getBatchesForFFmpeg(): List<String> {
|
||||||
|
// TODO: There is probably a better way to do this iteratively, look at it if you have time
|
||||||
return when (type) {
|
return when (type) {
|
||||||
BatchType.INTERNAL ->
|
BatchType.INTERNAL ->
|
||||||
(getInternalFolder()
|
((getInternalFolder()
|
||||||
.listFiles()
|
.listFiles()
|
||||||
?.filter {
|
?.filter {
|
||||||
it.nameWithoutExtension.toIntOrNull() != null
|
it.nameWithoutExtension.toIntOrNull() != null
|
||||||
}
|
}
|
||||||
?.toList()
|
?.toList()
|
||||||
?: emptyList())
|
?: emptyList()) as List<File>)
|
||||||
|
.sortedBy {
|
||||||
|
it.nameWithoutExtension.toInt()
|
||||||
|
}
|
||||||
.map { it.absolutePath }
|
.map { it.absolutePath }
|
||||||
|
|
||||||
BatchType.CUSTOM -> getCustomDefinedFolder()
|
BatchType.CUSTOM -> getCustomDefinedFolder()
|
||||||
@ -128,6 +132,9 @@ abstract class BatchesFolder(
|
|||||||
.filter {
|
.filter {
|
||||||
it.name?.substringBeforeLast(".")?.toIntOrNull() != null
|
it.name?.substringBeforeLast(".")?.toIntOrNull() != null
|
||||||
}
|
}
|
||||||
|
.sortedBy {
|
||||||
|
it.name!!.substringBeforeLast(".").toInt()
|
||||||
|
}
|
||||||
.map {
|
.map {
|
||||||
FFmpegKitConfig.getSafParameterForRead(
|
FFmpegKitConfig.getSafParameterForRead(
|
||||||
context,
|
context,
|
||||||
@ -136,24 +143,32 @@ abstract class BatchesFolder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
BatchType.MEDIA -> {
|
BatchType.MEDIA -> {
|
||||||
val filePaths = mutableListOf<String>()
|
val fileUris = mutableListOf<Uri>()
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
queryMediaContent { _, _, uri, _ ->
|
queryMediaContent { _, _, uri, _ ->
|
||||||
filePaths.add(
|
fileUris.add(uri)
|
||||||
FFmpegKitConfig.getSafParameterForRead(
|
|
||||||
context,
|
|
||||||
uri,
|
|
||||||
)!!
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
legacyMediaFolder.listFiles()?.forEach {
|
legacyMediaFolder.listFiles()?.forEach {
|
||||||
filePaths.add(it.absolutePath)
|
fileUris.add(it.toUri())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filePaths
|
fileUris
|
||||||
|
.sortedBy {
|
||||||
|
return@sortedBy it
|
||||||
|
.lastPathSegment!!
|
||||||
|
.substring(mediaPrefix.length)
|
||||||
|
.substringBeforeLast(".")
|
||||||
|
.toInt()
|
||||||
|
}
|
||||||
|
.map { uri ->
|
||||||
|
FFmpegKitConfig.getSafParameterForRead(
|
||||||
|
context,
|
||||||
|
uri,
|
||||||
|
)!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,6 +382,7 @@ abstract class BatchesFolder(
|
|||||||
null,
|
null,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: Fix "would you like to try saving" -> Save button
|
||||||
legacyMediaFolder.listFiles()?.forEach {
|
legacyMediaFolder.listFiles()?.forEach {
|
||||||
val fileCounter =
|
val fileCounter =
|
||||||
it.nameWithoutExtension.substring(mediaPrefix.length).toIntOrNull()
|
it.nameWithoutExtension.substring(mediaPrefix.length).toIntOrNull()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user