all: reformat

This commit is contained in:
Alexander Capehart
2025-06-16 07:55:03 -06:00
parent 5465ad3733
commit 3979b8e688
8 changed files with 37 additions and 27 deletions
@@ -160,7 +160,8 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
joinToString(separator = ";") { it.uri.toString().replace(";", "\\;") }
private fun String.toOpenedLocations(): List<Location.Opened> =
splitEscaped { it == ';' }.mapNotNull { Location.Unopened.from(context, it.toUri())?.open(context) }
splitEscaped { it == ';' }
.mapNotNull { Location.Unopened.from(context, it.toUri())?.open(context) }
private fun List<Location>.stringifyLocations(): String =
joinToString(separator = ";") { it.uri.toString().replace(";", "\\;") }
@@ -29,7 +29,8 @@ import org.oxycblt.musikr.fs.Location
* @param listener A [LocationAdapter.Listener] to bind interactions to.
* @author Alexander Capehart (OxygenCobalt)
*/
class ExcludedLocationAdapter(listener: LocationAdapter.Listener<Location.Unopened>) : LocationAdapter<Location.Unopened>(listener) {
class ExcludedLocationAdapter(listener: LocationAdapter.Listener<Location.Unopened>) :
LocationAdapter<Location.Unopened>(listener) {
override fun createViewHolder(parent: ViewGroup): LocationViewHolder<Location.Unopened> =
ExcludedLocationViewHolder.from(parent)
}
@@ -50,6 +51,7 @@ class ExcludedLocationViewHolder private constructor(binding: ItemMusicLocationB
* @return A new instance.
*/
fun from(parent: ViewGroup) =
ExcludedLocationViewHolder(ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
ExcludedLocationViewHolder(
ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
}
}
}
@@ -21,11 +21,11 @@ package org.oxycblt.auxio.music.locations
import android.content.Context
import android.net.Uri
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.R
import org.oxycblt.auxio.music.MusicSettings
import org.oxycblt.musikr.fs.Location
import javax.inject.Inject
/**
* Dialog that manages the excluded locations setting.
@@ -36,8 +36,7 @@ import javax.inject.Inject
class ExcludedLocationsDialog : LocationsDialog<Location.Unopened>() {
override val locationAdapter = ExcludedLocationAdapter(this)
@Inject
override lateinit var musicSettings: MusicSettings
@Inject override lateinit var musicSettings: MusicSettings
override fun getDialogTitle(): Int = R.string.set_excluded_locations
@@ -58,6 +57,7 @@ class ExcludedLocationsDialog : LocationsDialog<Location.Unopened>() {
}
private companion object {
const val KEY_PENDING_EXCLUDED_LOCATIONS = BuildConfig.APPLICATION_ID + ".key.PENDING_EXCLUDED_LOCATIONS"
const val KEY_PENDING_EXCLUDED_LOCATIONS =
BuildConfig.APPLICATION_ID + ".key.PENDING_EXCLUDED_LOCATIONS"
}
}
}
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2024 Auxio Project
* BaseLocationAdapter.kt is part of Auxio.
* LocationAdapter.kt is part of Auxio.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,14 +26,14 @@ import org.oxycblt.auxio.util.context
import org.oxycblt.musikr.fs.Location
import timber.log.Timber as L
abstract class LocationAdapter<T : Location>(private val listener: Listener<T>) : RecyclerView.Adapter<LocationViewHolder<T>>() {
abstract class LocationAdapter<T : Location>(private val listener: Listener<T>) :
RecyclerView.Adapter<LocationViewHolder<T>>() {
private val _locations = mutableListOf<T>()
val locations: List<T> = _locations
override fun getItemCount() = locations.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
createViewHolder(parent)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(parent)
override fun onBindViewHolder(holder: LocationViewHolder<T>, position: Int) =
holder.bind(locations[position], listener)
@@ -73,4 +73,4 @@ abstract class LocationViewHolder<T : Location>(protected val binding: ItemMusic
binding.locationPath.text = location.path.resolve(binding.context)
binding.locationDelete.setOnClickListener { listener.onRemoveLocation(location) }
}
}
}
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2024 Auxio Project
* BaseLocationsDialog.kt is part of Auxio.
* LocationsDialog.kt is part of Auxio.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -81,7 +81,8 @@ abstract class LocationsDialog<T : Location> :
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
outState.putStringArrayList(
getPendingLocationsKey(), ArrayList(locationAdapter.locations.map { it.uri.toString() }))
getPendingLocationsKey(),
ArrayList(locationAdapter.locations.map { it.uri.toString() }))
}
override fun onDestroyBinding(binding: DialogMusicLocationsBinding) {
@@ -122,9 +123,14 @@ abstract class LocationsDialog<T : Location> :
}
protected abstract fun getDialogTitle(): Int
protected abstract fun getCurrentLocations(): List<T>
protected abstract fun saveLocations(locations: List<T>)
protected abstract fun getPendingLocationsKey(): String
protected abstract fun convertUriToLocation(uri: Uri): T?
protected abstract fun createLocationFromUri(context: android.content.Context, uri: Uri): T?
}
}
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021 Auxio Project
* LocationAdapter.kt is part of Auxio.
* MusicLocationAdapter.kt is part of Auxio.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,7 +29,8 @@ import org.oxycblt.musikr.fs.Location
* @param listener A [LocationAdapter.Listener] to bind interactions to.
* @author Alexander Capehart (OxygenCobalt)
*/
class MusicLocationAdapter(listener: LocationAdapter.Listener<Location.Opened>) : LocationAdapter<Location.Opened>(listener) {
class MusicLocationAdapter(listener: LocationAdapter.Listener<Location.Opened>) :
LocationAdapter<Location.Opened>(listener) {
override fun createViewHolder(parent: ViewGroup): LocationViewHolder<Location.Opened> =
MusicLocationViewHolder.from(parent)
}
@@ -50,6 +51,7 @@ class MusicLocationViewHolder private constructor(binding: ItemMusicLocationBind
* @return A new instance.
*/
fun from(parent: ViewGroup) =
MusicLocationViewHolder(ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
MusicLocationViewHolder(
ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
}
}
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2021 Auxio Project
* MusicSourcesDialog.kt is part of Auxio.
* MusicLocationsDialog.kt is part of Auxio.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,11 +21,11 @@ package org.oxycblt.auxio.music.locations
import android.content.Context
import android.net.Uri
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import org.oxycblt.auxio.BuildConfig
import org.oxycblt.auxio.R
import org.oxycblt.auxio.music.MusicSettings
import org.oxycblt.musikr.fs.Location
import javax.inject.Inject
/**
* Dialog that manages the music locations setting.
@@ -36,8 +36,7 @@ import javax.inject.Inject
class MusicLocationsDialog : LocationsDialog<Location.Opened>() {
override val locationAdapter = MusicLocationAdapter(this)
@Inject
override lateinit var musicSettings: MusicSettings
@Inject override lateinit var musicSettings: MusicSettings
override fun getDialogTitle(): Int = R.string.set_locations