music: fixup mediastore query setup

This commit is contained in:
Alexander Capehart
2025-07-04 13:51:16 -06:00
parent 34a8d162cb
commit 29efd6a100
4 changed files with 47 additions and 110 deletions
@@ -65,19 +65,22 @@ private constructor(
}
// Handle include/exclude directories
if (query.include.isNotEmpty()) {
val pathSelector = pathInterpreterFactory.createSelector(query.include.map { it.path })
if (pathSelector != null) {
selector += " AND (${pathSelector.template})"
args.addAll(pathSelector.args)
when (query.mode) {
FilterMode.INCLUDE -> {
val pathSelector =
pathInterpreterFactory.createSelector(query.filtered.map { it.path })
if (pathSelector != null) {
selector += " AND (${pathSelector.template})"
args.addAll(pathSelector.args)
}
}
}
if (query.exclude.isNotEmpty()) {
val pathSelector = pathInterpreterFactory.createSelector(query.exclude.map { it.path })
if (pathSelector != null) {
selector += " AND NOT (${pathSelector.template})"
args.addAll(pathSelector.args)
FilterMode.EXCLUDE -> {
val pathSelector =
pathInterpreterFactory.createSelector(query.filtered.map { it.path })
if (pathSelector != null) {
selector += " AND NOT (${pathSelector.template})"
args.addAll(pathSelector.args)
}
}
}
@@ -215,11 +218,16 @@ private constructor(
}
data class Query(
val include: List<Location.Unopened>,
val exclude: List<Location.Unopened>,
val mode: FilterMode,
val filtered: List<Location>,
val excludeNonMusic: Boolean
)
enum class FilterMode {
INCLUDE,
EXCLUDE
}
companion object {
fun from(context: Context, query: Query) =
MediaStoreFS(