music: add toggle to load non-music

Add a toggle to control the IS_MUSIC=1 selector.

This is normally used to remove non-music like podcasts and ringtones,
however some people use Auxio was a general-purpose audio player for
these files, so this setting can be used to disable that selector and
load non-music.

Resolves #246.
This commit is contained in:
Alexander Capehart
2022-09-24 16:11:25 -06:00
parent 37f226ad2d
commit 66b9da0d5e
7 changed files with 26 additions and 9 deletions
@@ -138,6 +138,10 @@ abstract class MediaStoreExtractor(private val context: Context, private val cac
val args = mutableListOf<String>()
var selector = BASE_SELECTOR
if (settings.excludeNonMusic) {
selector += " AND ${MediaStore.Audio.AudioColumns.IS_MUSIC}=1"
}
if (dirs.dirs.isNotEmpty()) {
// Need to select for directories. The path query is the same, only difference is
// the presence of a NOT.
@@ -359,8 +363,7 @@ abstract class MediaStoreExtractor(private val context: Context, private val cac
* The base selector that works across all versions of android. Does not exclude
* directories.
*/
private const val BASE_SELECTOR =
"${MediaStore.Audio.Media.IS_MUSIC}=1 " + "AND NOT ${MediaStore.Audio.Media.SIZE}=0"
private const val BASE_SELECTOR = "NOT ${MediaStore.Audio.Media.SIZE}=0"
}
}
@@ -225,6 +225,7 @@ class IndexerService : Service(), Indexer.Controller, Settings.Callback {
override fun onSettingChanged(key: String) {
when (key) {
getString(R.string.set_key_exclude_non_music),
getString(R.string.set_key_music_dirs),
getString(R.string.set_key_music_dirs_include),
getString(R.string.set_key_separators) -> onStartIndexing()
@@ -266,6 +266,10 @@ class Settings(private val context: Context, private val callback: Callback? = n
val shouldBeObserving: Boolean
get() = inner.getBoolean(context.getString(R.string.set_key_observing), false)
/** Whether to load all audio files, even ones not considered music. */
val excludeNonMusic: Boolean
get() = inner.getBoolean(context.getString(R.string.set_key_exclude_non_music), true)
/** Get the list of directories that music should be hidden/loaded from. */
fun getMusicDirs(storageManager: StorageManager): MusicDirs {
val dirs =