fix: Improvements

This commit is contained in:
Myzel394 2023-12-31 00:16:37 +01:00
parent 9d4345c2d1
commit ef6487903e
No known key found for this signature in database
GPG Key ID: 79CC92F37B3E1A2B
3 changed files with 18 additions and 13 deletions

View File

@ -26,6 +26,14 @@
<uses-permission android:name="android.permission.USE_BIOMETRIC" />
<!-- Todo: Check android permissions -->
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<application
android:name=".UpdateSettingsApp"
android:allowBackup="true"

View File

@ -429,10 +429,10 @@ data class VideoRecorderSettings(
)
}
fun getMimeType() = "video/mp4"
fun getMimeType() = "video/$fileExtension"
val fileExtension
get() = "mp4"
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) "mp4" else "3gp"
companion object {
fun getDefaultInstance() = VideoRecorderSettings()

View File

@ -1,6 +1,7 @@
package app.myzel394.alibi.helpers
import android.content.ContentUris
import android.content.ContentValues
import app.myzel394.alibi.ui.MEDIA_RECORDINGS_PREFIX
import android.content.Context
@ -31,7 +32,7 @@ abstract class BatchesFolder(
abstract val mediaContentUri: Uri
val mediaPrefix
get() = MEDIA_RECORDINGS_PREFIX + subfolderName + "-"
get() = MEDIA_RECORDINGS_PREFIX + subfolderName.substring(1) + "-"
fun initFolders() {
when (type) {
@ -69,14 +70,10 @@ abstract class BatchesFolder(
)!!.use { cursor ->
while (cursor.moveToNext()) {
val rawName = cursor.getColumnIndex(Media.DISPLAY_NAME).let { id ->
if (id == -1) "" else cursor.getString(id)
if (id == -1) null else cursor.getString(id)
}
if (rawName == "" || rawName == null) {
continue
}
if (!rawName.startsWith(mediaPrefix)) {
if (rawName.isNullOrBlank() || !rawName.startsWith(mediaPrefix)) {
continue
}
@ -85,10 +82,10 @@ abstract class BatchesFolder(
?: continue
val id = cursor.getColumnIndex(Media._ID).let { id ->
if (id == -1) "" else cursor.getString(id)
if (id == -1) null else cursor.getString(id)
}
if (id == "" || id == null) {
if (id.isNullOrBlank()) {
continue
}
@ -330,7 +327,7 @@ abstract class BatchesFolder(
return File(getInternalFolder(), "$counter.$fileExtension")
}
protected fun getOrCreateMediaFile(
fun getOrCreateMediaFile(
name: String,
mimeType: String,
relativePath: String,
@ -364,7 +361,7 @@ abstract class BatchesFolder(
// Create empty output file to be able to write to it
uri = context.contentResolver.insert(
mediaContentUri,
android.content.ContentValues().apply {
ContentValues().apply {
put(
MediaStore.MediaColumns.DISPLAY_NAME,
name