Skip to content

Commit 2c65952

Browse files
committed
all: reformat
1 parent 1ad9df3 commit 2c65952

8 files changed

Lines changed: 37 additions & 27 deletions

File tree

app/src/main/java/org/oxycblt/auxio/music/MusicSettings.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ class MusicSettingsImpl @Inject constructor(@ApplicationContext private val cont
160160
joinToString(separator = ";") { it.uri.toString().replace(";", "\\;") }
161161

162162
private fun String.toOpenedLocations(): List<Location.Opened> =
163-
splitEscaped { it == ';' }.mapNotNull { Location.Unopened.from(context, it.toUri())?.open(context) }
163+
splitEscaped { it == ';' }
164+
.mapNotNull { Location.Unopened.from(context, it.toUri())?.open(context) }
164165

165166
private fun List<Location>.stringifyLocations(): String =
166167
joinToString(separator = ";") { it.uri.toString().replace(";", "\\;") }

app/src/main/java/org/oxycblt/auxio/music/locations/ExcludedLocationAdapter.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import org.oxycblt.musikr.fs.Location
2929
* @param listener A [LocationAdapter.Listener] to bind interactions to.
3030
* @author Alexander Capehart (OxygenCobalt)
3131
*/
32-
class ExcludedLocationAdapter(listener: LocationAdapter.Listener<Location.Unopened>) : LocationAdapter<Location.Unopened>(listener) {
32+
class ExcludedLocationAdapter(listener: LocationAdapter.Listener<Location.Unopened>) :
33+
LocationAdapter<Location.Unopened>(listener) {
3334
override fun createViewHolder(parent: ViewGroup): LocationViewHolder<Location.Unopened> =
3435
ExcludedLocationViewHolder.from(parent)
3536
}
@@ -50,6 +51,7 @@ class ExcludedLocationViewHolder private constructor(binding: ItemMusicLocationB
5051
* @return A new instance.
5152
*/
5253
fun from(parent: ViewGroup) =
53-
ExcludedLocationViewHolder(ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
54+
ExcludedLocationViewHolder(
55+
ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
5456
}
55-
}
57+
}

app/src/main/java/org/oxycblt/auxio/music/locations/ExcludedLocationsDialog.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ package org.oxycblt.auxio.music.locations
2121
import android.content.Context
2222
import android.net.Uri
2323
import dagger.hilt.android.AndroidEntryPoint
24+
import javax.inject.Inject
2425
import org.oxycblt.auxio.BuildConfig
2526
import org.oxycblt.auxio.R
2627
import org.oxycblt.auxio.music.MusicSettings
2728
import org.oxycblt.musikr.fs.Location
28-
import javax.inject.Inject
2929

3030
/**
3131
* Dialog that manages the excluded locations setting.
@@ -36,8 +36,7 @@ import javax.inject.Inject
3636
class ExcludedLocationsDialog : LocationsDialog<Location.Unopened>() {
3737
override val locationAdapter = ExcludedLocationAdapter(this)
3838

39-
@Inject
40-
override lateinit var musicSettings: MusicSettings
39+
@Inject override lateinit var musicSettings: MusicSettings
4140

4241
override fun getDialogTitle(): Int = R.string.set_excluded_locations
4342

@@ -58,6 +57,7 @@ class ExcludedLocationsDialog : LocationsDialog<Location.Unopened>() {
5857
}
5958

6059
private companion object {
61-
const val KEY_PENDING_EXCLUDED_LOCATIONS = BuildConfig.APPLICATION_ID + ".key.PENDING_EXCLUDED_LOCATIONS"
60+
const val KEY_PENDING_EXCLUDED_LOCATIONS =
61+
BuildConfig.APPLICATION_ID + ".key.PENDING_EXCLUDED_LOCATIONS"
6262
}
63-
}
63+
}

app/src/main/java/org/oxycblt/auxio/music/locations/LocationAdapter.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2024 Auxio Project
3-
* BaseLocationAdapter.kt is part of Auxio.
3+
* LocationAdapter.kt is part of Auxio.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -26,14 +26,14 @@ import org.oxycblt.auxio.util.context
2626
import org.oxycblt.musikr.fs.Location
2727
import timber.log.Timber as L
2828

29-
abstract class LocationAdapter<T : Location>(private val listener: Listener<T>) : RecyclerView.Adapter<LocationViewHolder<T>>() {
29+
abstract class LocationAdapter<T : Location>(private val listener: Listener<T>) :
30+
RecyclerView.Adapter<LocationViewHolder<T>>() {
3031
private val _locations = mutableListOf<T>()
3132
val locations: List<T> = _locations
3233

3334
override fun getItemCount() = locations.size
3435

35-
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
36-
createViewHolder(parent)
36+
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(parent)
3737

3838
override fun onBindViewHolder(holder: LocationViewHolder<T>, position: Int) =
3939
holder.bind(locations[position], listener)
@@ -73,4 +73,4 @@ abstract class LocationViewHolder<T : Location>(protected val binding: ItemMusic
7373
binding.locationPath.text = location.path.resolve(binding.context)
7474
binding.locationDelete.setOnClickListener { listener.onRemoveLocation(location) }
7575
}
76-
}
76+
}

app/src/main/java/org/oxycblt/auxio/music/locations/LocationsDialog.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2024 Auxio Project
3-
* BaseLocationsDialog.kt is part of Auxio.
3+
* LocationsDialog.kt is part of Auxio.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -81,7 +81,8 @@ abstract class LocationsDialog<T : Location> :
8181
override fun onSaveInstanceState(outState: Bundle) {
8282
super.onSaveInstanceState(outState)
8383
outState.putStringArrayList(
84-
getPendingLocationsKey(), ArrayList(locationAdapter.locations.map { it.uri.toString() }))
84+
getPendingLocationsKey(),
85+
ArrayList(locationAdapter.locations.map { it.uri.toString() }))
8586
}
8687

8788
override fun onDestroyBinding(binding: DialogMusicLocationsBinding) {
@@ -122,9 +123,14 @@ abstract class LocationsDialog<T : Location> :
122123
}
123124

124125
protected abstract fun getDialogTitle(): Int
126+
125127
protected abstract fun getCurrentLocations(): List<T>
128+
126129
protected abstract fun saveLocations(locations: List<T>)
130+
127131
protected abstract fun getPendingLocationsKey(): String
132+
128133
protected abstract fun convertUriToLocation(uri: Uri): T?
134+
129135
protected abstract fun createLocationFromUri(context: android.content.Context, uri: Uri): T?
130-
}
136+
}

app/src/main/java/org/oxycblt/auxio/music/locations/MusicLocationAdapter.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2021 Auxio Project
3-
* LocationAdapter.kt is part of Auxio.
3+
* MusicLocationAdapter.kt is part of Auxio.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -29,7 +29,8 @@ import org.oxycblt.musikr.fs.Location
2929
* @param listener A [LocationAdapter.Listener] to bind interactions to.
3030
* @author Alexander Capehart (OxygenCobalt)
3131
*/
32-
class MusicLocationAdapter(listener: LocationAdapter.Listener<Location.Opened>) : LocationAdapter<Location.Opened>(listener) {
32+
class MusicLocationAdapter(listener: LocationAdapter.Listener<Location.Opened>) :
33+
LocationAdapter<Location.Opened>(listener) {
3334
override fun createViewHolder(parent: ViewGroup): LocationViewHolder<Location.Opened> =
3435
MusicLocationViewHolder.from(parent)
3536
}
@@ -50,6 +51,7 @@ class MusicLocationViewHolder private constructor(binding: ItemMusicLocationBind
5051
* @return A new instance.
5152
*/
5253
fun from(parent: ViewGroup) =
53-
MusicLocationViewHolder(ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
54+
MusicLocationViewHolder(
55+
ItemMusicLocationBinding.inflate(parent.context.inflater, parent, false))
5456
}
5557
}

app/src/main/java/org/oxycblt/auxio/music/locations/MusicLocationsDialog.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2021 Auxio Project
3-
* MusicSourcesDialog.kt is part of Auxio.
3+
* MusicLocationsDialog.kt is part of Auxio.
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -21,11 +21,11 @@ package org.oxycblt.auxio.music.locations
2121
import android.content.Context
2222
import android.net.Uri
2323
import dagger.hilt.android.AndroidEntryPoint
24+
import javax.inject.Inject
2425
import org.oxycblt.auxio.BuildConfig
2526
import org.oxycblt.auxio.R
2627
import org.oxycblt.auxio.music.MusicSettings
2728
import org.oxycblt.musikr.fs.Location
28-
import javax.inject.Inject
2929

3030
/**
3131
* Dialog that manages the music locations setting.
@@ -36,8 +36,7 @@ import javax.inject.Inject
3636
class MusicLocationsDialog : LocationsDialog<Location.Opened>() {
3737
override val locationAdapter = MusicLocationAdapter(this)
3838

39-
@Inject
40-
override lateinit var musicSettings: MusicSettings
39+
@Inject override lateinit var musicSettings: MusicSettings
4140

4241
override fun getDialogTitle(): Int = R.string.set_locations
4342

musikr/src/main/java/org/oxycblt/musikr/fs/Location.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ sealed class Location(val uri: Uri, val path: Path) {
3838
try {
3939
context.contentResolverSafe.takePersistableUriPermission(
4040
uri,
41-
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
41+
Intent.FLAG_GRANT_READ_URI_PERMISSION or
42+
Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
4243
} catch (e: Exception) {
4344
// Not fully sure what happens if I'm disallowed to take the permission,
4445
// check for both circumstances (error or no-op)
@@ -68,8 +69,7 @@ sealed class Location(val uri: Uri, val path: Path) {
6869
}
6970

7071
class Opened internal constructor(uri: Uri, path: Path) : Location(uri, path) {
71-
override fun equals(other: Any?) =
72-
other is Opened && uri == other.uri && path == other.path
72+
override fun equals(other: Any?) = other is Opened && uri == other.uri && path == other.path
7373

7474
override fun hashCode() = 31 * uri.hashCode() + path.hashCode()
7575
}

0 commit comments

Comments
 (0)