Skip to content

Commit

Permalink
Kotlin 2.0.21
Browse files Browse the repository at this point in the history
  • Loading branch information
GrakovNe authored Nov 22, 2024
1 parent f8e0d73 commit 0ff5dc5
Show file tree
Hide file tree
Showing 146 changed files with 756 additions and 749 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.compose.compiler)

id("kotlin-kapt")
id("com.google.dagger.hilt.android")
id("org.jmailen.kotlinter") version "3.10.0"
id("org.jmailen.kotlinter") version "3.15.0"
id("com.google.devtools.ksp")
}

kotlinter {
reporters = arrayOf("checkstyle", "plain")
experimentalRules = true
}

tasks.lintKotlinMain {
Expand All @@ -25,8 +25,8 @@ android {
applicationId = "org.grakovne.lissen"
minSdk = 28
targetSdk = 35
versionCode = 41
versionName = "1.1.10"
versionCode = 42
versionName = "1.1.11"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class LibraryNavigationTest {
timeoutMillis = 2000,
condition = {
composeTestRule.onAllNodesWithTag("libraryScreen").fetchSemanticsNodes().isNotEmpty()
}
},
)

composeTestRule.onNodeWithTag("libraryScreen").assertExists()
Expand All @@ -72,7 +72,7 @@ class LibraryNavigationTest {
timeoutMillis = 2000,
condition = {
composeTestRule.onAllNodesWithTag("playerScreen").fetchSemanticsNodes().isNotEmpty()
}
},
)

composeTestRule.onNodeWithTag("playerScreen").assertExists()
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/grakovne/lissen/LissenApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class LissenApplication : Application() {
ReportField.ANDROID_VERSION,
ReportField.PHONE_MODEL,
ReportField.STACK_TRACE,
ReportField.LOGCAT
ReportField.LOGCAT,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AudiobookshelfChannelProvider @Inject constructor(
private val libraryAudiobookshelfChannel: LibraryAudiobookshelfChannel,
private val unknownAudiobookshelfChannel: UnknownAudiobookshelfChannel,
private val audiobookshelfAuthService: AudiobookshelfAuthService,
private val sharedPreferences: LissenSharedPreferences
private val sharedPreferences: LissenSharedPreferences,
) : ChannelProvider {

override fun provideMediaChannel(): MediaChannel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ abstract class AudiobookshelfChannel(
private val libraryResponseConverter: LibraryResponseConverter,
private val mediaRepository: AudioBookshelfMediaRepository,
private val recentBookResponseConverter: RecentListeningResponseConverter,
private val connectionInfoResponseConverter: ConnectionInfoResponseConverter
private val connectionInfoResponseConverter: ConnectionInfoResponseConverter,
) : MediaChannel {

override fun provideFileUri(
libraryItemId: String,
fileId: String
fileId: String,
): Uri = Uri.parse(preferences.getHost())
.buildUpon()
.appendPath("api")
Expand All @@ -44,11 +44,11 @@ abstract class AudiobookshelfChannel(

override suspend fun syncProgress(
sessionId: String,
progress: PlaybackProgress
progress: PlaybackProgress,
): ApiResult<Unit> = syncService.syncProgress(sessionId, progress)

override suspend fun fetchBookCover(
bookId: String
bookId: String,
): ApiResult<InputStream> = mediaRepository.fetchBookCover(bookId)

override suspend fun fetchLibraries(): ApiResult<List<Library>> = dataRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class UnknownAudiobookshelfChannel @Inject constructor(
syncService: AudioBookshelfSyncService,
sessionResponseConverter: PlaybackSessionResponseConverter,
libraryResponseConverter: LibraryResponseConverter,
connectionInfoResponseConverter: ConnectionInfoResponseConverter
connectionInfoResponseConverter: ConnectionInfoResponseConverter,
) : AudiobookshelfChannel(
dataRepository = dataRepository,
mediaRepository = mediaRepository,
Expand All @@ -36,31 +36,31 @@ class UnknownAudiobookshelfChannel @Inject constructor(
preferences = preferences,
syncService = syncService,
libraryResponseConverter = libraryResponseConverter,
connectionInfoResponseConverter = connectionInfoResponseConverter
connectionInfoResponseConverter = connectionInfoResponseConverter,
) {

override fun getLibraryType(): LibraryType = LibraryType.UNKNOWN

override suspend fun fetchBooks(
libraryId: String,
pageSize: Int,
pageNumber: Int
pageNumber: Int,
): ApiResult<PagedItems<Book>> = ApiResult.Error(ApiError.UnsupportedError)

override suspend fun searchBooks(
libraryId: String,
query: String,
limit: Int
limit: Int,
): ApiResult<List<Book>> = ApiResult.Error(ApiError.UnsupportedError)

override suspend fun startPlayback(
bookId: String,
episodeId: String,
supportedMimeTypes: List<String>,
deviceId: String
deviceId: String,
): ApiResult<PlaybackSession> = ApiResult.Error(ApiError.UnsupportedError)

override suspend fun fetchBook(
bookId: String
bookId: String,
): ApiResult<DetailedItem> = ApiResult.Error(ApiError.UnsupportedError)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import org.grakovne.lissen.domain.connection.ServerRequestHeader
data class ApiClientConfig(
val host: String?,
val token: String?,
val customHeaders: List<ServerRequestHeader>?
val customHeaders: List<ServerRequestHeader>?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import javax.inject.Singleton
@Singleton
class AudioBookshelfDataRepository @Inject constructor(
private val preferences: LissenSharedPreferences,
private val requestHeadersProvider: RequestHeadersProvider
private val requestHeadersProvider: RequestHeadersProvider,
) {

private var configCache: ApiClientConfig? = null
Expand All @@ -35,65 +35,65 @@ class AudioBookshelfDataRepository @Inject constructor(
safeApiCall { getClientInstance().fetchLibraries() }

suspend fun fetchAuthorItems(
authorId: String
authorId: String,
): ApiResult<AuthorItemsResponse> = safeApiCall {
getClientInstance()
.fetchAuthorLibraryItems(
authorId = authorId
authorId = authorId,
)
}

suspend fun searchPodcasts(
libraryId: String,
query: String,
limit: Int
limit: Int,
): ApiResult<PodcastSearchResponse> = safeApiCall {
getClientInstance()
.searchPodcasts(
libraryId = libraryId,
request = query,
limit = limit
limit = limit,
)
}

suspend fun searchBooks(
libraryId: String,
query: String,
limit: Int
limit: Int,
): ApiResult<LibrarySearchResponse> = safeApiCall {
getClientInstance()
.searchLibraryItems(
libraryId = libraryId,
request = query,
limit = limit
limit = limit,
)
}

suspend fun fetchLibraryItems(
libraryId: String,
pageSize: Int,
pageNumber: Int
pageNumber: Int,
): ApiResult<LibraryItemsResponse> =
safeApiCall {
getClientInstance()
.fetchLibraryItems(
libraryId = libraryId,
pageSize = pageSize,
pageNumber = pageNumber
pageNumber = pageNumber,
)
}

suspend fun fetchPodcastItems(
libraryId: String,
pageSize: Int,
pageNumber: Int
pageNumber: Int,
): ApiResult<PodcastItemsResponse> =
safeApiCall {
getClientInstance()
.fetchPodcastItems(
libraryId = libraryId,
pageSize = pageSize,
pageNumber = pageNumber
pageNumber = pageNumber,
)
}

Expand All @@ -117,14 +117,14 @@ class AudioBookshelfDataRepository @Inject constructor(

suspend fun startPlayback(
itemId: String,
request: PlaybackStartRequest
request: PlaybackStartRequest,
): ApiResult<PlaybackSessionResponse> =
safeApiCall { getClientInstance().startLibraryPlayback(itemId, request) }

suspend fun startPodcastPlayback(
itemId: String,
episodeId: String,
request: PlaybackStartRequest
request: PlaybackStartRequest,
): ApiResult<PlaybackSessionResponse> =
safeApiCall { getClientInstance().startPodcastPlayback(itemId, episodeId, request) }

Expand All @@ -133,7 +133,7 @@ class AudioBookshelfDataRepository @Inject constructor(

suspend fun publishLibraryItemProgress(
itemId: String,
progress: ProgressSyncRequest
progress: ProgressSyncRequest,
): ApiResult<Unit> =
safeApiCall { getClientInstance().publishLibraryItemProgress(itemId, progress) }

Expand All @@ -144,7 +144,7 @@ class AudioBookshelfDataRepository @Inject constructor(
val cache = ApiClientConfig(
host = host,
token = token,
customHeaders = requestHeadersProvider.fetchRequestHeaders()
customHeaders = requestHeadersProvider.fetchRequestHeaders(),
)

val currentClientCache = clientCache
Expand Down Expand Up @@ -176,10 +176,10 @@ class AudioBookshelfDataRepository @Inject constructor(

private fun apiClient(
host: String,
token: String?
token: String?,
): ApiClient = ApiClient(
host = host,
token = token,
requestHeaders = requestHeadersProvider.fetchRequestHeaders()
requestHeaders = requestHeadersProvider.fetchRequestHeaders(),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import javax.inject.Singleton
@Singleton
class AudioBookshelfMediaRepository @Inject constructor(
private val preferences: LissenSharedPreferences,
private val requestHeadersProvider: RequestHeadersProvider
private val requestHeadersProvider: RequestHeadersProvider,
) {

private var configCache: ApiClientConfig? = null
Expand All @@ -26,7 +26,7 @@ class AudioBookshelfMediaRepository @Inject constructor(
safeCall { getClientInstance().getItemCover(itemId) }

private suspend fun safeCall(
apiCall: suspend () -> Response<ResponseBody>
apiCall: suspend () -> Response<ResponseBody>,
): ApiResult<InputStream> {
return try {
val response = apiCall.invoke()
Expand Down Expand Up @@ -60,7 +60,7 @@ class AudioBookshelfMediaRepository @Inject constructor(
val cache = ApiClientConfig(
host = host,
token = token,
customHeaders = requestHeadersProvider.fetchRequestHeaders()
customHeaders = requestHeadersProvider.fetchRequestHeaders(),
)

val currentClientCache = clientCache
Expand Down Expand Up @@ -92,11 +92,11 @@ class AudioBookshelfMediaRepository @Inject constructor(

private fun apiClient(
host: String,
token: String
token: String,
): BinaryApiClient = BinaryApiClient(
host = host,
token = token,
requestHeaders = requestHeadersProvider.fetchRequestHeaders()
requestHeaders = requestHeadersProvider.fetchRequestHeaders(),
)

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import javax.inject.Singleton

@Singleton
class AudioBookshelfSyncService @Inject constructor(
private val dataRepository: AudioBookshelfDataRepository
private val dataRepository: AudioBookshelfDataRepository,
) {

private var previousItemId: String? = null
private var previousTrackedTime: Double = 0.0

suspend fun syncProgress(
itemId: String,
progress: PlaybackProgress
progress: PlaybackProgress,
): ApiResult<Unit> {
val trackedTime = previousTrackedTime
.takeIf { itemId == previousItemId }
Expand All @@ -27,7 +27,7 @@ class AudioBookshelfSyncService @Inject constructor(
val request = ProgressSyncRequest(
currentTime = progress.currentTime,
duration = progress.totalTime,
timeListened = trackedTime
timeListened = trackedTime,
)

return dataRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import javax.inject.Singleton
@Singleton
class AudiobookshelfAuthService @Inject constructor(
private val loginResponseConverter: LoginResponseConverter,
private val requestHeadersProvider: RequestHeadersProvider
private val requestHeadersProvider: RequestHeadersProvider,
) : ChannelAuthService {

override suspend fun authorize(
host: String,
username: String,
password: String
password: String,
): ApiResult<UserAccount> {
if (host.isBlank() || !urlPattern.matches(host)) {
return ApiResult.Error(ApiError.InvalidCredentialsHost)
Expand All @@ -33,7 +33,7 @@ class AudiobookshelfAuthService @Inject constructor(
try {
val apiClient = ApiClient(
host = host,
requestHeaders = requestHeadersProvider.fetchRequestHeaders()
requestHeaders = requestHeadersProvider.fetchRequestHeaders(),
)

apiService = apiClient.retrofit.create(AudiobookshelfApiClient::class.java)
Expand All @@ -51,7 +51,7 @@ class AudiobookshelfAuthService @Inject constructor(
.apply(it)
.let { ApiResult.Success(it) }
},
onFailure = { ApiResult.Error(it.code) }
onFailure = { ApiResult.Error(it.code) },
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.inject.Singleton

@Singleton
class RequestHeadersProvider @Inject constructor(
private val preferences: LissenSharedPreferences
private val preferences: LissenSharedPreferences,
) {

fun fetchRequestHeaders(): List<ServerRequestHeader> {
Expand Down
Loading

0 comments on commit 0ff5dc5

Please sign in to comment.