Skip to content

Commit

Permalink
Bump org.jlleitschuh.gradle:ktlint-gradle from 11.6.1 to 12.0.2 (#609)
Browse files Browse the repository at this point in the history
* Bump org.jlleitschuh.gradle:ktlint-gradle from 11.6.1 to 12.0.2

Bumps org.jlleitschuh.gradle:ktlint-gradle from 11.6.1 to 12.0.2.

---
updated-dependencies:
- dependency-name: org.jlleitschuh.gradle:ktlint-gradle
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* Lint

* Fix multiline strings

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Charlotte Van Petegem <[email protected]>
  • Loading branch information
dependabot[bot] and chvp authored Dec 2, 2023
1 parent c8f2cce commit 558f177
Show file tree
Hide file tree
Showing 98 changed files with 2,404 additions and 1,921 deletions.
18 changes: 14 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
[*.{kt,kts}]
indent_size=4
insert_final_newline=true
max_line_length=160
root = true

[*]
end_of_line = lf
charset = utf-8
insert_final_newline = true
indent_size = 4
indent_style = space
trim_trailing_whitespace = true
max_line_length = 160

[*.kt]
ktlint_standard_function-naming = disabled
ktlint_standard_property-naming = disabled
19 changes: 10 additions & 9 deletions app/src/main/java/me/vanpetegem/accentor/Accentor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@ 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.data.preferences.PreferencesDataSource
import java.io.File
import javax.inject.Inject
import me.vanpetegem.accentor.data.preferences.PreferencesDataSource

@HiltAndroidApp
class Accentor : Application(), ImageLoaderFactory {
@Inject lateinit var preferences: PreferencesDataSource

override fun onCreate() {
super.onCreate()
version = if (Build.VERSION.SDK_INT >= 33) {
applicationContext.packageManager.getPackageInfo(
packageName,
PackageManager.PackageInfoFlags.of(0)
).versionName
} else {
applicationContext.packageManager.getPackageInfo(packageName, 0).versionName
}
version =
if (Build.VERSION.SDK_INT >= 33) {
applicationContext.packageManager.getPackageInfo(
packageName,
PackageManager.PackageInfoFlags.of(0),
).versionName
} else {
applicationContext.packageManager.getPackageInfo(packageName, 0).versionName
}
userAgent = "Accentor/$version"
FuelManager.instance.baseHeaders = mapOf("User-Agent" to userAgent)
DynamicColors.applyToActivitiesIfAvailable(this)
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/me/vanpetegem/accentor/api/album/Album.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import me.vanpetegem.accentor.data.authentication.AuthenticationData
import me.vanpetegem.accentor.util.Result
import me.vanpetegem.accentor.util.responseObject

fun index(server: String, authenticationData: AuthenticationData): Sequence<Result<List<ApiAlbum>>> {
fun index(
server: String,
authenticationData: AuthenticationData,
): Sequence<Result<List<ApiAlbum>>> {
var page = 1

fun doFetch(): Result<List<ApiAlbum>>? {
Expand All @@ -26,7 +29,7 @@ fun index(server: String, authenticationData: AuthenticationData): Sequence<Resu
Result.Success(a)
}
},
{ e: Throwable -> Result.Error(Exception("Error getting albums", e)) }
{ e: Throwable -> Result.Error(Exception("Error getting albums", e)) },
)
}
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/me/vanpetegem/accentor/api/artist/Artist.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import me.vanpetegem.accentor.data.authentication.AuthenticationData
import me.vanpetegem.accentor.util.Result
import me.vanpetegem.accentor.util.responseObject

fun index(server: String, authenticationData: AuthenticationData): Sequence<Result<List<ApiArtist>>> {
fun index(
server: String,
authenticationData: AuthenticationData,
): Sequence<Result<List<ApiArtist>>> {
var page = 1

fun doFetch(): Result<List<ApiArtist>>? {
Expand All @@ -26,7 +29,7 @@ fun index(server: String, authenticationData: AuthenticationData): Sequence<Resu
Result.Success(a)
}
},
{ e: Throwable -> Result.Error(Exception("Error getting artists", e)) }
{ e: Throwable -> Result.Error(Exception("Error getting artists", e)) },
)
}
}
Expand Down
21 changes: 15 additions & 6 deletions app/src/main/java/me/vanpetegem/accentor/api/auth/AuthToken.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,42 @@ import me.vanpetegem.accentor.util.responseObject
import me.vanpetegem.accentor.version

class AuthToken(val user_agent: String)

class Credentials(val name: String, val password: String, val auth_token: AuthToken)

fun create(server: String, username: String, password: String): Result<AuthenticationData> {
fun create(
server: String,
username: String,
password: String,
): Result<AuthenticationData> {
return "$server/api/auth_tokens".httpPost()
.set("Accept", "application/json")
.jsonBody(
Credentials(
username,
password,
AuthToken("Accentor $version on Android ${Build.VERSION.RELEASE} (${Build.DEVICE})")
)
AuthToken("Accentor $version on Android ${Build.VERSION.RELEASE} (${Build.DEVICE})"),
),
)
.responseObject<AuthenticationData>().third
.fold(
{ user: AuthenticationData -> Result.Success(user) },
{ e: Throwable -> Result.Error(Exception("Error logging in", e)) }
{ e: Throwable -> Result.Error(Exception("Error logging in", e)) },
)
}

fun destroy(server: String, authenticationData: AuthenticationData, id: Int): Result<Unit> {
fun destroy(
server: String,
authenticationData: AuthenticationData,
id: Int,
): Result<Unit> {
return "$server/api/auth_tokens/$id".httpDelete()
.set("Accept", "application/json")
.set("X-Secret", authenticationData.secret)
.set("X-Device-Id", authenticationData.deviceId)
.response().third
.fold(
{ Result.Success(Unit) },
{ e: Throwable -> Result.Error(Exception("Error logging out", e)) }
{ e: Throwable -> Result.Error(Exception("Error logging out", e)) },
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import me.vanpetegem.accentor.data.codecconversions.ApiCodecConversion
import me.vanpetegem.accentor.util.Result
import me.vanpetegem.accentor.util.responseObject

fun index(server: String, authenticationData: AuthenticationData): Sequence<Result<List<ApiCodecConversion>>> {
fun index(
server: String,
authenticationData: AuthenticationData,
): Sequence<Result<List<ApiCodecConversion>>> {
var page = 1

fun doFetch(): Result<List<ApiCodecConversion>>? {
Expand All @@ -26,7 +29,7 @@ fun index(server: String, authenticationData: AuthenticationData): Sequence<Resu
Result.Success(c)
}
},
{ e: Throwable -> Result.Error(Exception("Error getting codec conversions", e)) }
{ e: Throwable -> Result.Error(Exception("Error getting codec conversions", e)) },
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import me.vanpetegem.accentor.data.playlists.ApiPlaylist
import me.vanpetegem.accentor.util.Result
import me.vanpetegem.accentor.util.responseObject

fun index(server: String, authenticationData: AuthenticationData): Sequence<Result<List<ApiPlaylist>>> {
fun index(
server: String,
authenticationData: AuthenticationData,
): Sequence<Result<List<ApiPlaylist>>> {
var page = 1

fun doFetch(): Result<List<ApiPlaylist>>? {
Expand All @@ -26,7 +29,7 @@ fun index(server: String, authenticationData: AuthenticationData): Sequence<Resu
Result.Success(a)
}
},
{ e: Throwable -> Result.Error(Exception("Error getting playlists", e)) }
{ e: Throwable -> Result.Error(Exception("Error getting playlists", e)) },
)
}
}
Expand Down
19 changes: 14 additions & 5 deletions app/src/main/java/me/vanpetegem/accentor/api/plays/Play.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ package me.vanpetegem.accentor.api.plays

import com.github.kittinunf.fuel.httpGet
import com.github.kittinunf.fuel.httpPost
import java.time.Instant
import me.vanpetegem.accentor.api.util.retry
import me.vanpetegem.accentor.data.authentication.AuthenticationData
import me.vanpetegem.accentor.data.plays.ApiPlay
import me.vanpetegem.accentor.util.Result
import me.vanpetegem.accentor.util.jsonBody
import me.vanpetegem.accentor.util.responseObject
import java.time.Instant

data class Arguments(val play: PlayArguments)

data class PlayArguments(val trackId: Int, val playedAt: Instant)

fun create(server: String, authenticationData: AuthenticationData, trackId: Int, playedAt: Instant): Result<ApiPlay> {
fun create(
server: String,
authenticationData: AuthenticationData,
trackId: Int,
playedAt: Instant,
): Result<ApiPlay> {
return "$server/api/plays".httpPost()
.set("Accept", "application/json")
.set("X-Secret", authenticationData.secret)
Expand All @@ -22,11 +28,14 @@ fun create(server: String, authenticationData: AuthenticationData, trackId: Int,
.responseObject<ApiPlay>().third
.fold(
{ play: ApiPlay -> Result.Success(play) },
{ e: Throwable -> Result.Error(Exception("Error creating play", e)) }
{ e: Throwable -> Result.Error(Exception("Error creating play", e)) },
)
}

fun index(server: String, authenticationData: AuthenticationData): Sequence<Result<List<ApiPlay>>> {
fun index(
server: String,
authenticationData: AuthenticationData,
): Sequence<Result<List<ApiPlay>>> {
var page = 1

fun doFetch(): Result<List<ApiPlay>>? {
Expand All @@ -45,7 +54,7 @@ fun index(server: String, authenticationData: AuthenticationData): Sequence<Resu
Result.Success(p)
}
},
{ e: Throwable -> Result.Error(Exception("Error getting plays", e)) }
{ e: Throwable -> Result.Error(Exception("Error getting plays", e)) },
)
}
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/me/vanpetegem/accentor/api/track/Track.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import me.vanpetegem.accentor.data.tracks.ApiTrack
import me.vanpetegem.accentor.util.Result
import me.vanpetegem.accentor.util.responseObject

fun index(server: String, authenticationData: AuthenticationData): Sequence<Result<List<ApiTrack>>> {
fun index(
server: String,
authenticationData: AuthenticationData,
): Sequence<Result<List<ApiTrack>>> {
var page = 1

fun doFetch(): Result<List<ApiTrack>>? {
Expand All @@ -26,7 +29,7 @@ fun index(server: String, authenticationData: AuthenticationData): Sequence<Resu
Result.Success(a)
}
},
{ e: Throwable -> Result.Error(Exception("Error getting tracks", e)) }
{ e: Throwable -> Result.Error(Exception("Error getting tracks", e)) },
)
}
}
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/java/me/vanpetegem/accentor/api/user/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import me.vanpetegem.accentor.data.users.ApiUser
import me.vanpetegem.accentor.util.Result
import me.vanpetegem.accentor.util.responseObject

fun index(server: String, authenticationData: AuthenticationData): Sequence<Result<List<ApiUser>>> {
fun index(
server: String,
authenticationData: AuthenticationData,
): Sequence<Result<List<ApiUser>>> {
var page = 1

fun doFetch(): Result<List<ApiUser>>? {
Expand All @@ -26,7 +29,7 @@ fun index(server: String, authenticationData: AuthenticationData): Sequence<Resu
Result.Success(u)
}
},
{ e: Throwable -> Result.Error(Exception("Error getting users", e)) }
{ e: Throwable -> Result.Error(Exception("Error getting users", e)) },
)
}
}
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/java/me/vanpetegem/accentor/api/util/Util.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package me.vanpetegem.accentor.api.util

import me.vanpetegem.accentor.util.Result

fun <T> retry(n: Int, block: () -> Result<T>?): Result<T>? {
fun <T> retry(
n: Int,
block: () -> Result<T>?,
): Result<T>? {
var tries = 0
var result: Result<T>?
do {
Expand Down
Loading

0 comments on commit 558f177

Please sign in to comment.