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:08:23 -06:00
parent 37f226ad2d
commit 66b9da0d5e
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
7 changed files with 26 additions and 9 deletions

View file

@ -3,14 +3,14 @@
## 3.0.0
#### What's New
- Massively reworked music loading system:
- Added multi-value tags support
- Added support for multiple artists
- Added support for multiple genres
- Artists and album artists are now both given UI entires
- Made music hashing rely on the more reliable MD5
- Artists and album artists are now both given UI entires
- Upgraded music ID management:
- Use MD5 for default UUIDS
- Added support for MusicBrainz IDs (MBIDs)
- **This may impact your library.** Instructions on how to update your library to result in a good
artist experience will be added to the FAQ.
- Added toggle to load non-music (Such as podcasts)
#### What's Improved
- Sorting now takes accented characters into account

View file

@ -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"
}
}

View file

@ -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()

View file

@ -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 =

View file

@ -28,10 +28,11 @@
<string name="set_key_restore_state" translatable="false">auxio_restore_state</string>
<string name="set_key_reindex" translatable="false">auxio_reindex</string>
<string name="set_key_observing" translatable="false">auxio_observing</string>
<string name="set_key_music_dirs" translatable="false">auxio_music_dirs</string>
<string name="set_key_music_dirs_include" translatable="false">auxio_include_dirs</string>
<string name="set_key_exclude_non_music" translatable="false">auxio_exclude_non_music</string>
<string name="set_key_separators" translatable="false">auxio_separators</string>
<string name="set_key_observing" translatable="false">auxio_observing</string>
<string name="set_key_search_filter" translatable="false">KEY_SEARCH_FILTER</string>

View file

@ -222,7 +222,7 @@
<string name="set_reindex">Reload music</string>
<string name="set_reindex_desc">May wipe playback state</string>
<string name="set_observing">Automatic reloading</string>
<string name="set_observing_desc">Reload your music library whenever it changes (Experimental)</string>
<string name="set_observing_desc">Reload your music library whenever it changes (Requires persistent notification)</string>
<string name="set_dirs">Music folders</string>
<string name="set_dirs_desc">Manage where music should be loaded from</string>
<!-- As in the mode to be used with the music folders setting -->
@ -233,6 +233,8 @@
<!-- Restrict music loading to selected folders -->
<string name="set_dirs_mode_include">Include</string>
<string name="set_dirs_mode_include_desc">Music will <b>only</b> be loaded from the folders you add.</string>
<string name="set_exclude_non_music">Exclude non-music</string>
<string name="set_exclude_non_music_desc">Ignore audio files that are not music, such as podcasts</string>
<string name="set_separators">Multi-value separators</string>
<string name="set_separators_desc">Configure characters that denote multiple tag values</string>
<string name="set_separators_warning">Warning: Using this setting may result in some tags being incorrectly interpreted as having multiple values.</string>

View file

@ -153,6 +153,12 @@
app:summary="@string/set_observing_desc"
app:title="@string/set_observing" />
<SwitchPreferenceCompat
app:defaultValue="true"
app:key="@string/set_key_exclude_non_music"
app:summary="@string/set_exclude_non_music_desc"
app:title="@string/set_exclude_non_music" />
<org.oxycblt.auxio.settings.WrappedDialogPreference
app:key="@string/set_key_music_dirs"
app:summary="@string/set_dirs_desc"