Skip to content
Open
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
1 change: 1 addition & 0 deletions collect_app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ dependencies {
implementation(libs.androidXComposeMaterialIcons)
implementation(libs.androidXComposePreview)
implementation(libs.coil)
implementation(libs.coil.gif)

testImplementation project(':forms-test')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package org.odk.collect.android.application.initialization

import android.app.Application
import android.os.Build
import androidx.appcompat.app.AppCompatDelegate
import androidx.startup.AppInitializer
import coil3.ImageLoader
import coil3.SingletonImageLoader
import coil3.gif.AnimatedImageDecoder
import coil3.gif.GifDecoder
import net.danlew.android.joda.JodaTimeInitializer
import org.odk.collect.analytics.Analytics
import org.odk.collect.android.BuildConfig
Expand Down Expand Up @@ -63,6 +68,21 @@ class ApplicationInitializer(
initializeLogging()
AppInitializer.getInstance(context).initializeComponent(JodaTimeInitializer::class.java)
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)
initializeImageLoader()
}

private fun initializeImageLoader() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a specific initializer class (CoilInitializer) for this and run it in runInitializer`. Even if we construct it on-demand, it's sill nice to have the logic container in a separate file.

SingletonImageLoader.setSafe { context ->
ImageLoader.Builder(context)
.components {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a note for testers: there's different implementations for Android 9 and above, so we should check Android 8.

add(AnimatedImageDecoder.Factory())
} else {
add(GifDecoder.Factory())
}
}
.build()
}
}

private fun initializeLocale() {
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ jsoup = { group = "org.jsoup", name = "jsoup", version = "1.22.1" }
mlkit-barcodescanning = { group = "com.google.android.gms", name = "play-services-mlkit-barcode-scanning", version = "18.3.1" }
runtime-livedata = { group = "androidx.compose.runtime", name = "runtime-livedata" }
coil = { group = "io.coil-kt.coil3", name = "coil-compose", version = "3.4.0" }
coil-gif = { group = "io.coil-kt.coil3", name = "coil-gif", version = "3.4.0" }

# Test dependencies
junit = { group = "junit", name = "junit", version = "4.13.2" }
Expand Down