Skip to content

Commit b798b1e

Browse files
vitoficoclaude
andcommitted
feat: ✨ route Coil image loads through authenticated OPDS OkHttp client
Coil's default singleton ImageLoader has no awareness of the OPDS BasicAuthInterceptor, so cover requests against authenticated calibre-web instances 401 silently and the catalog grid only ever shows the gradient+initials fallback. Implement coil.ImageLoaderFactory on EReaderApp with an ImageLoader built against the existing OpdsHttpClient.okHttp, so Coil inherits Basic auth (and any future interceptors) automatically. AppContainer's opdsHttp is promoted from private to public to be reachable from the Application class. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dba3079 commit b798b1e

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
package io.theficos.ereader
22

33
import android.app.Application
4+
import coil.ImageLoader
5+
import coil.ImageLoaderFactory
46
import io.theficos.ereader.di.AppContainer
57

6-
class EReaderApp : Application() {
8+
class EReaderApp : Application(), ImageLoaderFactory {
79
lateinit var container: AppContainer
810
private set
911

1012
override fun onCreate() {
1113
super.onCreate()
1214
container = AppContainer(this)
1315
}
16+
17+
override fun newImageLoader(): ImageLoader =
18+
ImageLoader.Builder(this)
19+
.okHttpClient(container.opdsHttp.okHttp)
20+
.build()
1421
}

app/src/main/java/io/theficos/ereader/di/AppContainer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class AppContainer(context: Context) {
2020

2121
val credentialStore: CalibreCredentialStore = CalibreCredentialStore(appContext)
2222

23-
private val opdsHttp = OpdsHttpClient(credentialStore)
23+
val opdsHttp = OpdsHttpClient(credentialStore)
2424
val opdsClient: OpdsClient = OpdsClient(opdsHttp.okHttp)
2525
val bookDownloader: BookDownloader = BookDownloader(
2626
okHttp = opdsHttp.okHttp,

0 commit comments

Comments
 (0)