all: reformat
This commit is contained in:
@@ -292,8 +292,7 @@ class LocationsDialog : ViewBindingMaterialDialogFragment<DialogMusicLocationsBi
|
|||||||
|
|
||||||
private fun onNewLocation(launcher: ActivityResultLauncher<Uri?>?) {
|
private fun onNewLocation(launcher: ActivityResultLauncher<Uri?>?) {
|
||||||
L.d("Opening launcher")
|
L.d("Opening launcher")
|
||||||
val launcher =
|
val launcher = requireNotNull(launcher) { "Document tree launcher was not available" }
|
||||||
requireNotNull(launcher) { "Document tree launcher was not available" }
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
launcher.launch(null)
|
launcher.launch(null)
|
||||||
|
|||||||
@@ -61,7 +61,10 @@ sealed class Location(val uri: Uri, val path: Path) {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun from(context: Context, uri: Uri) =
|
fun from(context: Context, uri: Uri) =
|
||||||
Unopened(uri, getTreePath(context, uri) ?: Path(Volume.ThirdParty(uri), Components.root()))
|
Unopened(
|
||||||
|
uri,
|
||||||
|
getTreePath(context, uri) ?: Path(Volume.ThirdParty(uri), Components.root()),
|
||||||
|
)
|
||||||
|
|
||||||
private fun getTreePath(context: Context, uri: Uri): Path? {
|
private fun getTreePath(context: Context, uri: Uri): Path? {
|
||||||
if (!DocumentsContract.isTreeUri(uri)) return null
|
if (!DocumentsContract.isTreeUri(uri)) return null
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ sealed interface Volume {
|
|||||||
data class ThirdParty(val uri: Uri) : Volume {
|
data class ThirdParty(val uri: Uri) : Volume {
|
||||||
override val mediaStoreName: String? = null
|
override val mediaStoreName: String? = null
|
||||||
override val components: Components? = null
|
override val components: Components? = null
|
||||||
|
|
||||||
override fun resolveName(context: Context) = uri.toString()
|
override fun resolveName(context: Context) = uri.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,9 @@ private class ExternalPlaylistManagerImpl(
|
|||||||
private val m3u: M3U,
|
private val m3u: M3U,
|
||||||
) : ExternalPlaylistManager {
|
) : ExternalPlaylistManager {
|
||||||
override suspend fun import(uri: Uri): ImportedPlaylist? {
|
override suspend fun import(uri: Uri): ImportedPlaylist? {
|
||||||
val filePath = documentPathFactory.unpackDocumentUri(uri) ?: Path(Volume.ThirdParty(uri), Components.root())
|
val filePath =
|
||||||
|
documentPathFactory.unpackDocumentUri(uri)
|
||||||
|
?: Path(Volume.ThirdParty(uri), Components.root())
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
context.contentResolverSafe.openInputStream(uri)?.use {
|
context.contentResolverSafe.openInputStream(uri)?.use {
|
||||||
@@ -119,7 +121,9 @@ private class ExternalPlaylistManagerImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun export(playlist: Playlist, uri: Uri, config: ExportConfig): Boolean {
|
override suspend fun export(playlist: Playlist, uri: Uri, config: ExportConfig): Boolean {
|
||||||
val filePath = documentPathFactory.unpackDocumentUri(uri) ?: Path(Volume.ThirdParty(uri), Components.root())
|
val filePath =
|
||||||
|
documentPathFactory.unpackDocumentUri(uri)
|
||||||
|
?: Path(Volume.ThirdParty(uri), Components.root())
|
||||||
val workingDirectory =
|
val workingDirectory =
|
||||||
if (config.absolute) {
|
if (config.absolute) {
|
||||||
Path(filePath.volume, Components.parseUnix("/"))
|
Path(filePath.volume, Components.parseUnix("/"))
|
||||||
|
|||||||
Reference in New Issue
Block a user