musikr.fs: prototype arbitrary saf locations
This commit is contained in:
@@ -247,10 +247,10 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
|
||||
|
||||
private fun String.toOpenedLocations(): List<Location.Opened> =
|
||||
splitEscaped { it == ';' }
|
||||
.mapNotNull { Location.Unopened.from(context, it.toUri())?.open(context) }
|
||||
.mapNotNull { Location.Unopened.from(context, it.toUri()).open(context) }
|
||||
|
||||
private fun String.toUnopenedLocations(): List<Location.Unopened> =
|
||||
splitEscaped { it == ';' }.mapNotNull { Location.Unopened.from(context, it.toUri()) }
|
||||
splitEscaped { it == ';' }.map { Location.Unopened.from(context, it.toUri()) }
|
||||
|
||||
private inline fun String.splitEscaped(selector: (Char) -> Boolean): List<String> {
|
||||
val split = mutableListOf<String>()
|
||||
|
||||
@@ -303,11 +303,10 @@ class LocationsDialog : ViewBindingMaterialDialogFragment<DialogMusicLocationsBi
|
||||
val context = requireContext()
|
||||
val location = Location.Unopened.from(context, uri)
|
||||
|
||||
if (location != null) {
|
||||
pendingLocationCallback?.invoke(location)
|
||||
} else {
|
||||
requireContext().showToast(R.string.err_bad_location)
|
||||
if (location.path.volume == null) {
|
||||
requireContext().showToast(R.string.err_weird_location)
|
||||
}
|
||||
pendingLocationCallback?.invoke(location)
|
||||
pendingLocationCallback = null
|
||||
}
|
||||
|
||||
|
||||
@@ -347,6 +347,7 @@
|
||||
<string name="err_no_app">No app found that can handle this task</string>
|
||||
<!-- No folders in the "Music Folders" setting -->
|
||||
<string name="err_bad_location">This folder is not supported</string>
|
||||
<string name="err_weird_location">Warning: This folder is managed by a 3rd-party</string>
|
||||
<string name="lbl_no_folders">No folders</string>
|
||||
|
||||
<!-- Description Namespace | Accessibility Strings -->
|
||||
|
||||
Reference in New Issue
Block a user