diff --git a/CHANGELOG.md b/CHANGELOG.md index d645afaa8c..f91d7ef85d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ New: - Redwood publishes what's happening in bound content through the new `Content.State` type. +- Accept a `ZiplineHttpClient` in `TreehouseAppFactory` on Android. Changed: - Drop support for non-incremental layouts in `Row` and `Column`. diff --git a/redwood-treehouse-host/api/android/redwood-treehouse-host.api b/redwood-treehouse-host/api/android/redwood-treehouse-host.api index 979d33a9fe..62dd56a0d1 100644 --- a/redwood-treehouse-host/api/android/redwood-treehouse-host.api +++ b/redwood-treehouse-host/api/android/redwood-treehouse-host.api @@ -130,7 +130,9 @@ public abstract class app/cash/redwood/treehouse/TreehouseApp$Spec { } public final class app/cash/redwood/treehouse/TreehouseAppFactoryAndroidKt { + public static final fun TreehouseAppFactory (Landroid/content/Context;Lapp/cash/zipline/loader/ZiplineHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/FileSystem;Lokio/Path;Ljava/lang/String;JLapp/cash/zipline/loader/LoaderEventListener;ILapp/cash/redwood/treehouse/StateStore;Lapp/cash/redwood/leaks/LeakDetector;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory; public static final fun TreehouseAppFactory (Landroid/content/Context;Lokhttp3/OkHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/FileSystem;Lokio/Path;Ljava/lang/String;JLapp/cash/zipline/loader/LoaderEventListener;ILapp/cash/redwood/treehouse/StateStore;Lapp/cash/redwood/leaks/LeakDetector;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory; + public static synthetic fun TreehouseAppFactory$default (Landroid/content/Context;Lapp/cash/zipline/loader/ZiplineHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/FileSystem;Lokio/Path;Ljava/lang/String;JLapp/cash/zipline/loader/LoaderEventListener;ILapp/cash/redwood/treehouse/StateStore;Lapp/cash/redwood/leaks/LeakDetector;ILjava/lang/Object;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory; public static synthetic fun TreehouseAppFactory$default (Landroid/content/Context;Lokhttp3/OkHttpClient;Lapp/cash/zipline/loader/ManifestVerifier;Lokio/FileSystem;Lokio/Path;Ljava/lang/String;JLapp/cash/zipline/loader/LoaderEventListener;ILapp/cash/redwood/treehouse/StateStore;Lapp/cash/redwood/leaks/LeakDetector;ILjava/lang/Object;)Lapp/cash/redwood/treehouse/TreehouseApp$Factory; } diff --git a/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt b/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt index cb275fb5ae..e1c19970bd 100644 --- a/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt +++ b/redwood-treehouse-host/src/androidMain/kotlin/app/cash/redwood/treehouse/treehouseAppFactoryAndroid.kt @@ -19,6 +19,7 @@ import android.content.Context import app.cash.redwood.leaks.LeakDetector import app.cash.zipline.loader.LoaderEventListener import app.cash.zipline.loader.ManifestVerifier +import app.cash.zipline.loader.ZiplineHttpClient import app.cash.zipline.loader.asZiplineHttpClient import kotlinx.coroutines.Dispatchers import okhttp3.OkHttpClient @@ -38,9 +39,36 @@ public fun TreehouseAppFactory( concurrentDownloads: Int = 8, stateStore: StateStore = MemoryStateStore(), leakDetector: LeakDetector = LeakDetector.none(), +): TreehouseApp.Factory = TreehouseAppFactory( + context = context, + httpClient = httpClient.asZiplineHttpClient(), + manifestVerifier = manifestVerifier, + embeddedFileSystem = embeddedFileSystem, + embeddedDir = embeddedDir, + cacheName = cacheName, + cacheMaxSizeInBytes = cacheMaxSizeInBytes, + loaderEventListener = loaderEventListener, + concurrentDownloads = concurrentDownloads, + stateStore = stateStore, + leakDetector = leakDetector, +) + +@Suppress("FunctionName") +public fun TreehouseAppFactory( + context: Context, + httpClient: ZiplineHttpClient, + manifestVerifier: ManifestVerifier, + embeddedFileSystem: FileSystem? = null, + embeddedDir: Path? = null, + cacheName: String = "zipline", + cacheMaxSizeInBytes: Long = 50L * 1024L * 1024L, + loaderEventListener: LoaderEventListener = LoaderEventListener.None, + concurrentDownloads: Int = 8, + stateStore: StateStore = MemoryStateStore(), + leakDetector: LeakDetector = LeakDetector.none(), ): TreehouseApp.Factory = RealTreehouseApp.Factory( platform = AndroidTreehousePlatform(context), - httpClient = httpClient.asZiplineHttpClient(), + httpClient = httpClient, frameClockFactory = AndroidChoreographerFrameClock.Factory(), manifestVerifier = manifestVerifier, embeddedFileSystem = embeddedFileSystem,