Skip to content

Commit

Permalink
fix: Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Myzel394 committed Dec 30, 2023
1 parent 9d4345c commit ef64879
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/app/myzel394/alibi/db/AppSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 8 additions & 11 deletions app/src/main/java/app/myzel394/alibi/helpers/BatchesFolder.kt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down Expand Up @@ -330,7 +327,7 @@ abstract class BatchesFolder(
return File(getInternalFolder(), "$counter.$fileExtension")
}

protected fun getOrCreateMediaFile(
fun getOrCreateMediaFile(
name: String,
mimeType: String,
relativePath: String,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ef64879

Please sign in to comment.