Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/.kotlin
/captures
.externalNativeBuild
keystore.jks
keystore.jks
7 changes: 4 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ android {
versionName = "0.18.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
ksp {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
}

buildFeatures {
Expand Down Expand Up @@ -56,6 +53,10 @@ android {
}
}

ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}

lint {
quiet = true
disable.addAll(
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/me/vanpetegem/accentor/Accentor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import coil.disk.DiskCache
import com.github.kittinunf.fuel.core.FuelManager
import com.google.android.material.color.DynamicColors
import dagger.hilt.android.HiltAndroidApp
import me.vanpetegem.accentor.BuildConfig
import me.vanpetegem.accentor.data.preferences.PreferencesDataSource
import org.acra.config.dialog
import org.acra.config.mailSender
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@ abstract class AlbumDao {

@Query(
"""
SELECT * FROM albums WHERE release LIKE '%' || :day || '%'
ORDER BY release DESC,
normalized_title ASC,
edition ASC,
edition_description ASC,
id ASC
SELECT * FROM albums WHERE `release` LIKE '%' || :day || '%'
ORDER BY `release` DESC,
`normalized_title` ASC,
`edition` ASC,
`edition_description` ASC,
`id` ASC
""",
)
protected abstract fun findDbAlbumsByDay(day: String): LiveData<List<DbAlbum>>
Expand Down Expand Up @@ -227,7 +227,7 @@ abstract class AlbumDao {
}
}

@Query("SELECT * FROM albums ORDER BY normalized_title ASC, release ASC, edition ASC, edition_description ASC, id ASC")
@Query("SELECT * FROM albums ORDER BY `normalized_title` ASC, `release` ASC, `edition` ASC, `edition_description` ASC, `id` ASC")
protected abstract fun getAllDbAlbums(): LiveData<List<DbAlbum>>

@RewriteQueriesToDropUnusedColumns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class AlbumRepository
val albumsByReleased: LiveData<List<Album>> =
allAlbums.map {
val copy = it.toMutableList()
copy.sortWith({ a1, a2 -> a2.release.compareTo(a1.release) })
copy.sortWith { a1, a2 -> a2.release.compareTo(a1.release) }
copy
}
val albumsByAdded: LiveData<List<Album>> =
allAlbums.map {
val copy = it.toMutableList()
copy.sortWith({ a1, a2 -> a2.createdAt.compareTo(a1.createdAt) })
copy.sortWith { a1, a2 -> a2.createdAt.compareTo(a1.createdAt) }
copy
}
val albumsByPlayed: LiveData<List<Album>> = albumDao.getAllByPlayed()
Expand All @@ -58,7 +58,7 @@ class AlbumRepository
suspend fun refresh(handler: suspend (Result<Unit>) -> Unit) {
val fetchStart = Instant.now()

var toUpsert = ArrayList<Album>()
val toUpsert = ArrayList<Album>()
var count = 0
for (result in index(authenticationRepository.server.value!!, authenticationRepository.authData.value!!)) {
when (result) {
Expand All @@ -83,7 +83,7 @@ class AlbumRepository
handler(Result.Success(Unit))
}

suspend fun clear() {
fun clear() {
albumDao.deleteAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ArtistRepository
val artistsByAdded: LiveData<List<Artist>> =
allArtists.map {
val copy = it.toMutableList()
copy.sortWith({ a1, a2 -> a2.createdAt.compareTo(a1.createdAt) })
copy.sortWith { a1, a2 -> a2.createdAt.compareTo(a1.createdAt) }
copy
}
val artistsByPlayed: LiveData<List<Artist>> = artistDao.getAllByPlayed()
Expand All @@ -41,7 +41,7 @@ class ArtistRepository
suspend fun refresh(handler: suspend (Result<Unit>) -> Unit) {
val fetchStart = Instant.now()

var toUpsert = ArrayList<Artist>()
val toUpsert = ArrayList<Artist>()
var count = 0
for (result in index(authenticationRepository.server.value!!, authenticationRepository.authData.value!!)) {
when (result) {
Expand All @@ -66,7 +66,7 @@ class ArtistRepository
handler(Result.Success(Unit))
}

suspend fun clear() {
fun clear() {
artistDao.deleteAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,52 +29,48 @@ class AuthenticationDataSource

private val serverData = sharedPreferences.stringLiveData(SERVER_KEY)

val authData: LiveData<AuthenticationData?>
val server: LiveData<String?> = serverData

init {
authData =
MediatorLiveData<AuthenticationData?>().apply {
val observer: Observer<Any?> =
Observer {
val id: Int =
idData.value.let {
if (it != null) {
it
} else {
value = null
return@Observer
}
val authData: LiveData<AuthenticationData?> =
MediatorLiveData<AuthenticationData?>().apply {
val observer: Observer<Any?> =
Observer {
val id: Int =
idData.value.let {
if (it != null) {
it
} else {
value = null
return@Observer
}
val userId: Int =
userIdData.value.let {
if (it != null) {
it
} else {
value = null
return@Observer
}
}
val userId: Int =
userIdData.value.let {
if (it != null) {
it
} else {
value = null
return@Observer
}
val token: String =
tokenData.value.let {
if (it != null) {
it
} else {
value = null
return@Observer
}
}
val token: String =
tokenData.value.let {
if (it != null) {
it
} else {
value = null
return@Observer
}
val newVal = AuthenticationData(id, userId, token)
if (newVal != this.value) this.value = newVal
}
}
val newVal = AuthenticationData(id, userId, token)
if (newVal != this.value) this.value = newVal
}

addSource(idData, observer)
addSource(userIdData, observer)
addSource(tokenData, observer)
// If we don't do this, the value will start out as null even if we have data in the prefs.
observer.onChanged(null)
}
}
addSource(idData, observer)
addSource(userIdData, observer)
addSource(tokenData, observer)
// If we don't do this, the value will start out as null even if we have data in the prefs.
observer.onChanged(null)
}
val server: LiveData<String?> = serverData

fun setAuthData(authData: AuthenticationData?) {
if (authData == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AuthenticationRepository
}
}

suspend fun login(
fun login(
server: String,
username: String,
password: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CodecConversionRepository
handler(Result.Success(Unit))
}

suspend fun clear() {
fun clear() {
codecConversionDao.deleteAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ data class Playlist(
albumMap.put(it.albumId, albumRepository.getById(it.albumId)!!)
}
}
tracks.sortWith({ t1, t2 -> t1.compareAlphabetically(t2, albumMap) })
tracks.sortWith { t1, t2 -> t1.compareAlphabetically(t2, albumMap) }
tracks.map { Pair(it, albumMap.get(it.albumId)) }
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class PlaylistRepository
suspend fun refresh(handler: suspend (Result<Unit>) -> Unit) {
val fetchStart = Instant.now()

var toUpsert = ArrayList<Playlist>()
val toUpsert = ArrayList<Playlist>()
var count = 0
for (result in index(authenticationRepository.server.value!!, authenticationRepository.authData.value!!)) {
when (result) {
Expand All @@ -53,7 +53,7 @@ class PlaylistRepository
handler(Result.Success(Unit))
}

suspend fun clear() {
fun clear() {
playlistDao.deleteAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PlayRepository
suspend fun refresh(handler: suspend (Result<Unit>) -> Unit) {
val fetchStart = Instant.now()

var toUpsert = ArrayList<Play>()
val toUpsert = ArrayList<Play>()
var count = 0
for (result in index(authenticationRepository.server.value!!, authenticationRepository.authData.value!!)) {
when (result) {
Expand All @@ -44,7 +44,7 @@ class PlayRepository
handler(Result.Success(Unit))
}

private suspend fun reportUnreportedPlays() {
private fun reportUnreportedPlays() {
for (play in unreportedPlayDao.getAllUnreportedPlays()) {
when (val result = create(authenticationRepository.server.value!!, authenticationRepository.authData.value!!, play.trackId, play.playedAt)) {
is CreateResult.Success -> {
Expand All @@ -63,7 +63,7 @@ class PlayRepository
}
}

suspend fun reportPlay(
fun reportPlay(
trackId: Int,
playedAt: Instant,
) {
Expand All @@ -82,7 +82,7 @@ class PlayRepository
}
}

suspend fun clear() {
fun clear() {
playDao.deleteAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ data class Track(
}

companion object {
const val ALBUMARTIST = "me.vanpetegem.accentor.data.tracks.Track.ALBUMARTIST"
const val ARTIST = "me.vanpetegem.accentor.data.tracks.Track.ARTIST"
const val YEAR = "me.vanpetegem.accentor.data.tracks.Track.YEAR"

fun fromDb(
t: DbTrack,
trackArtists: List<TrackArtist>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ abstract class TrackDao {
dbTrack?.let {
Track.fromDb(
it,
trackArtists.map { TrackArtist(it.artistId, it.name, it.normalizedName, it.role, it.order, it.hidden) },
trackGenres.map { it.genreId },
trackArtists.map { ta -> TrackArtist(ta.artistId, ta.name, ta.normalizedName, ta.role, ta.order, ta.hidden) },
trackGenres.map { tg -> tg.genreId },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TrackRepository
suspend fun refresh(handler: suspend (Result<Unit>) -> Unit) {
val fetchStart = Instant.now()

var toUpsert = ArrayList<Track>()
val toUpsert = ArrayList<Track>()
var count = 0
for (result in index(authenticationRepository.server.value!!, authenticationRepository.authData.value!!)) {
when (result) {
Expand All @@ -61,7 +61,7 @@ class TrackRepository
handler(Result.Success(Unit))
}

suspend fun clear() {
fun clear() {
trackDao.deleteAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class UserRepository
handler(Result.Success(Unit))
}

suspend fun clear() {
fun clear() {
userDao.deleteAll()
}
}
Loading