musikr: fix hidden files setting
This commit is contained in:
parent
20a06ba2fb
commit
387a36a3f8
4 changed files with 9 additions and 8 deletions
|
@ -57,5 +57,5 @@ data class Interpretation(
|
||||||
val separators: Separators,
|
val separators: Separators,
|
||||||
|
|
||||||
/** Whether to ignore hidden files and directories (those starting with a dot). */
|
/** Whether to ignore hidden files and directories (those starting with a dot). */
|
||||||
val ignoreHidden: Boolean = true
|
val ignoreHidden: Boolean
|
||||||
)
|
)
|
||||||
|
|
|
@ -71,7 +71,7 @@ interface Musikr {
|
||||||
fun new(context: Context, storage: Storage, interpretation: Interpretation): Musikr =
|
fun new(context: Context, storage: Storage, interpretation: Interpretation): Musikr =
|
||||||
MusikrImpl(
|
MusikrImpl(
|
||||||
storage,
|
storage,
|
||||||
ExploreStep.from(context, storage),
|
ExploreStep.from(context, storage, interpretation),
|
||||||
ExtractStep.from(context, storage),
|
ExtractStep.from(context, storage),
|
||||||
EvaluateStep.new(storage, interpretation))
|
EvaluateStep.new(storage, interpretation))
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,16 +31,16 @@ import org.oxycblt.musikr.fs.MusicLocation
|
||||||
import org.oxycblt.musikr.fs.Path
|
import org.oxycblt.musikr.fs.Path
|
||||||
|
|
||||||
internal interface DeviceFiles {
|
internal interface DeviceFiles {
|
||||||
fun explore(locations: Flow<MusicLocation>, ignoreHidden: Boolean = true): Flow<DeviceNode>
|
fun explore(locations: Flow<MusicLocation>): Flow<DeviceNode>
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun from(context: Context): DeviceFiles = DeviceFilesImpl(context.contentResolverSafe)
|
fun from(context: Context, ignoreHidden: Boolean): DeviceFiles = DeviceFilesImpl(context.contentResolverSafe, ignoreHidden)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
private class DeviceFilesImpl(private val contentResolver: ContentResolver) : DeviceFiles {
|
private class DeviceFilesImpl(private val contentResolver: ContentResolver, private val ignoreHidden: Boolean) : DeviceFiles {
|
||||||
override fun explore(locations: Flow<MusicLocation>, ignoreHidden: Boolean): Flow<DeviceNode> =
|
override fun explore(locations: Flow<MusicLocation>): Flow<DeviceNode> =
|
||||||
locations.flatMapMerge { location ->
|
locations.flatMapMerge { location ->
|
||||||
// Create a root directory for each location
|
// Create a root directory for each location
|
||||||
val rootDirectory =
|
val rootDirectory =
|
||||||
|
|
|
@ -30,6 +30,7 @@ import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.flow.flowOn
|
import kotlinx.coroutines.flow.flowOn
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.merge
|
import kotlinx.coroutines.flow.merge
|
||||||
|
import org.oxycblt.musikr.Interpretation
|
||||||
import org.oxycblt.musikr.Storage
|
import org.oxycblt.musikr.Storage
|
||||||
import org.oxycblt.musikr.fs.MusicLocation
|
import org.oxycblt.musikr.fs.MusicLocation
|
||||||
import org.oxycblt.musikr.fs.device.DeviceDirectory
|
import org.oxycblt.musikr.fs.device.DeviceDirectory
|
||||||
|
@ -44,8 +45,8 @@ internal interface ExploreStep {
|
||||||
fun explore(locations: List<MusicLocation>): Flow<ExploreNode>
|
fun explore(locations: List<MusicLocation>): Flow<ExploreNode>
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun from(context: Context, storage: Storage): ExploreStep =
|
fun from(context: Context, storage: Storage, interpretation: Interpretation): ExploreStep =
|
||||||
ExploreStepImpl(DeviceFiles.from(context), storage.storedPlaylists)
|
ExploreStepImpl(DeviceFiles.from(context, interpretation.ignoreHidden), storage.storedPlaylists)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue