mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
feat: Check if external storage permission is granted on old Android version if media is selected
This commit is contained in:
parent
b581505c97
commit
666f0bee70
@ -1,5 +1,6 @@
|
|||||||
package app.myzel394.alibi.helpers
|
package app.myzel394.alibi.helpers
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
import android.content.ContentUris
|
import android.content.ContentUris
|
||||||
import android.content.ContentValues
|
import android.content.ContentValues
|
||||||
import app.myzel394.alibi.ui.MEDIA_RECORDINGS_PREFIX
|
import app.myzel394.alibi.ui.MEDIA_RECORDINGS_PREFIX
|
||||||
@ -21,6 +22,7 @@ import androidx.core.net.toFile
|
|||||||
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
|
||||||
|
import app.myzel394.alibi.ui.utils.PermissionHelper
|
||||||
import kotlinx.coroutines.CompletableDeferred
|
import kotlinx.coroutines.CompletableDeferred
|
||||||
import kotlin.reflect.KFunction3
|
import kotlin.reflect.KFunction3
|
||||||
|
|
||||||
@ -286,6 +288,7 @@ abstract class BatchesFolder(
|
|||||||
BatchType.MEDIA -> {
|
BatchType.MEDIA -> {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||||
// TODO: Also delete pending recordings
|
// TODO: Also delete pending recordings
|
||||||
|
// --> Doesn't seem to be possible :/
|
||||||
context.contentResolver.delete(
|
context.contentResolver.delete(
|
||||||
scopedMediaContentUri,
|
scopedMediaContentUri,
|
||||||
"${MediaStore.MediaColumns.DISPLAY_NAME} LIKE '$mediaPrefix%'",
|
"${MediaStore.MediaColumns.DISPLAY_NAME} LIKE '$mediaPrefix%'",
|
||||||
@ -382,8 +385,20 @@ abstract class BatchesFolder(
|
|||||||
return when (type) {
|
return when (type) {
|
||||||
BatchType.INTERNAL -> true
|
BatchType.INTERNAL -> true
|
||||||
BatchType.CUSTOM -> getCustomDefinedFolder().canWrite() && getCustomDefinedFolder().canRead()
|
BatchType.CUSTOM -> getCustomDefinedFolder().canWrite() && getCustomDefinedFolder().canRead()
|
||||||
// TODO: Add support for < Android 10
|
BatchType.MEDIA -> {
|
||||||
BatchType.MEDIA -> true
|
if (SUPPORTS_SCOPED_STORAGE) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return PermissionHelper.hasGranted(
|
||||||
|
context,
|
||||||
|
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||||
|
) &&
|
||||||
|
PermissionHelper.hasGranted(
|
||||||
|
context,
|
||||||
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user