music: switch to new storage perms
Switch to the new READ_AUDIO_STORAGE permission for Android 13.
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
|
||||
package org.oxycblt.auxio.home
|
||||
|
||||
import android.Manifest
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.MenuItem
|
||||
@@ -325,8 +324,7 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
|
||||
visibility = View.VISIBLE
|
||||
text = context.getString(R.string.lbl_grant)
|
||||
setOnClickListener {
|
||||
storagePermissionLauncher.launch(
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
storagePermissionLauncher.launch(Indexer.PERMISSION_READ_AUDIO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ class Indexer {
|
||||
val handle = guard.newHandle()
|
||||
|
||||
val notGranted =
|
||||
ContextCompat.checkSelfPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE) ==
|
||||
ContextCompat.checkSelfPermission(context, PERMISSION_READ_AUDIO) ==
|
||||
PackageManager.PERMISSION_DENIED
|
||||
|
||||
if (notGranted) {
|
||||
@@ -462,6 +462,14 @@ class Indexer {
|
||||
companion object {
|
||||
@Volatile private var INSTANCE: Indexer? = null
|
||||
|
||||
val PERMISSION_READ_AUDIO =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
// READ_EXTERNAL_STORAGE was superseded by READ_MEDIA_AUDIO in Android 13
|
||||
Manifest.permission.READ_MEDIA_AUDIO
|
||||
} else {
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
}
|
||||
|
||||
/** Get the process-level instance of [Indexer]. */
|
||||
fun getInstance(): Indexer {
|
||||
val currentInstance = INSTANCE
|
||||
|
||||
Reference in New Issue
Block a user