all: reformat
This commit is contained in:
@@ -129,8 +129,8 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
|
||||
get() {
|
||||
val locations =
|
||||
unlikelyToBeNull(
|
||||
sharedPreferences
|
||||
.getString(getString(R.string.set_key_music_locations), ""))
|
||||
sharedPreferences.getString(
|
||||
getString(R.string.set_key_music_locations), ""))
|
||||
.toOpenedLocations()
|
||||
val excludedLocations =
|
||||
unlikelyToBeNull(
|
||||
|
||||
@@ -20,7 +20,6 @@ package org.oxycblt.musikr.cache.db
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import org.oxycblt.musikr.cache.Cache
|
||||
|
||||
@@ -20,8 +20,6 @@ package org.oxycblt.musikr.fs.mediastore
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import android.provider.MediaStore as AOSPMediaStore
|
||||
import androidx.core.database.getStringOrNull
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
@@ -30,10 +28,10 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.callbackFlow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.yield
|
||||
import org.oxycblt.musikr.fs.AddedMs
|
||||
import org.oxycblt.musikr.fs.FS
|
||||
import org.oxycblt.musikr.fs.FSUpdate
|
||||
import org.oxycblt.musikr.fs.File
|
||||
import org.oxycblt.musikr.fs.AddedMs
|
||||
import org.oxycblt.musikr.fs.Location
|
||||
import org.oxycblt.musikr.fs.path.MediaStorePathInterpreter
|
||||
import org.oxycblt.musikr.fs.path.VolumeManager
|
||||
@@ -111,8 +109,7 @@ private constructor(
|
||||
AOSPMediaStore.Audio.Media.EXTERNAL_CONTENT_URI, id.toString())
|
||||
val mimeType = cursor.getStringOrNull(mimeTypeIndex) ?: "audio/*"
|
||||
val size = cursor.getLong(sizeIndex)
|
||||
val dateAdded =
|
||||
cursor.getLong(dateAddedIndex) * 1000 // Convert to milliseconds
|
||||
val dateAdded = cursor.getLong(dateAddedIndex) * 1000 // Convert to milliseconds
|
||||
val dateModified =
|
||||
cursor.getLong(dateModifiedIndex) * 1000 // Convert to milliseconds
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.provider.DocumentsContract
|
||||
import android.util.Log
|
||||
import android.provider.MediaStore as AOSPMediaStore
|
||||
import androidx.annotation.RequiresApi
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.Deferred
|
||||
@@ -43,9 +43,7 @@ import org.oxycblt.musikr.fs.FSUpdate
|
||||
import org.oxycblt.musikr.fs.File
|
||||
import org.oxycblt.musikr.fs.Location
|
||||
import org.oxycblt.musikr.fs.Path
|
||||
import org.oxycblt.musikr.fs.mediastore.MediaStore
|
||||
import org.oxycblt.musikr.fs.track.LocationObserver
|
||||
import android.provider.MediaStore as AOSPMediaStore
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
class SAF
|
||||
@@ -134,11 +132,12 @@ private constructor(
|
||||
size = size,
|
||||
modifiedMs = lastModified,
|
||||
parent = directoryDeferred,
|
||||
addedMs = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
JoinAddedMs(context, childUri)
|
||||
} else {
|
||||
NullAddedMs
|
||||
})
|
||||
addedMs =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
JoinAddedMs(context, childUri)
|
||||
} else {
|
||||
NullAddedMs
|
||||
})
|
||||
children.add(file)
|
||||
emit(file)
|
||||
}
|
||||
@@ -158,14 +157,16 @@ private constructor(
|
||||
private class JoinAddedMs(private val context: Context, private val uri: Uri) : AddedMs {
|
||||
override suspend fun resolve(): Long? {
|
||||
val mediaUri = AOSPMediaStore.getMediaUri(context, uri) ?: return null
|
||||
return context.contentResolverSafe.useQuery(mediaUri, arrayOf(AOSPMediaStore.Files.FileColumns.DATE_ADDED)) {
|
||||
if (it.moveToFirst()) {
|
||||
val dateAddedIndex = it.getColumnIndexOrThrow(AOSPMediaStore.Files.FileColumns.DATE_ADDED)
|
||||
it.getLong(dateAddedIndex) * 1000
|
||||
} else {
|
||||
null
|
||||
return context.contentResolverSafe.useQuery(
|
||||
mediaUri, arrayOf(AOSPMediaStore.Files.FileColumns.DATE_ADDED)) {
|
||||
if (it.moveToFirst()) {
|
||||
val dateAddedIndex =
|
||||
it.getColumnIndexOrThrow(AOSPMediaStore.Files.FileColumns.DATE_ADDED)
|
||||
it.getLong(dateAddedIndex) * 1000
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,8 +56,7 @@ private class ExploreStepImpl(private val fs: FS, private val storage: Storage)
|
||||
.distributedMap(n = 8, on = Dispatchers.IO, buffer = Channel.UNLIMITED) { file ->
|
||||
when (val cacheResult = storage.cache.read(file)) {
|
||||
is CacheResult.Hit -> NeedsCover(cacheResult.song)
|
||||
is CacheResult.Stale ->
|
||||
Finalized(NewSong(cacheResult.file))
|
||||
is CacheResult.Stale -> Finalized(NewSong(cacheResult.file))
|
||||
is CacheResult.Miss -> Finalized(NewSong(cacheResult.file))
|
||||
}
|
||||
}
|
||||
@@ -72,8 +71,7 @@ private class ExploreStepImpl(private val fs: FS, private val storage: Storage)
|
||||
is CoverResult.Hit ->
|
||||
Finalized(it.cachedSong.toRawSong(coverResult.cover))
|
||||
null -> Finalized(it.cachedSong.toRawSong(null))
|
||||
else ->
|
||||
Finalized(NewSong(it.cachedSong.file))
|
||||
else -> Finalized(NewSong(it.cachedSong.file))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
package org.oxycblt.musikr.pipeline
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -91,7 +90,8 @@ private class ExtractStepImpl(
|
||||
tags,
|
||||
cover,
|
||||
// The thing about date added is that it's resolution can actually
|
||||
// be expensive in some modes (ex. saf backend), so we resolve this by
|
||||
// be expensive in some modes (ex. saf backend), so we resolve this
|
||||
// by
|
||||
// moving date added extraction as an extraction operation rather
|
||||
// than doing the redundant work during exploration (well, kind of,
|
||||
// MediaStore's date added query is basically free, it's only saf
|
||||
|
||||
Reference in New Issue
Block a user