From ead5e82df2bced8e58e0da5e93bf29de8f7246b4 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Thu, 21 Nov 2024 13:00:04 -0500 Subject: [PATCH] Remove old ZiplineTreehouseUi.start overloads These have been deprecated for more than one year. --- CHANGELOG.md | 1 + .../redwood/treehouse/treehouseCompose.kt | 51 +------------------ .../redwood/treehouse/TreehouseAppContent.kt | 12 +---- .../treehouse/FakeZiplineTreehouseUi.kt | 21 -------- .../api/android/redwood-treehouse.api | 2 - .../api/jvm/redwood-treehouse.api | 2 - .../api/redwood-treehouse.klib.api | 2 - redwood-treehouse/api/zipline-api.toml | 6 --- .../redwood/treehouse/ZiplineTreehouseUi.kt | 18 ------- 9 files changed, 3 insertions(+), 112 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87a62456db..ee1002a344 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Breaking: - Treehouse hosts running Redwood 0.11.0 or older are not longer actively supported. They will continue to work, but they will experience indefinite memory leaks of native widgets. +- Old, deprecated overloads of `ZiplineTreehouseUi.start` have been removed. The new overloads have been available since Redwood 0.8.0 for over a year. New: - `UIConfiguration.viewInsets` tracks the safe area of the specific `RedwoodView` being targeted. This is currently implemented for views on Android and UIViews on iOS. diff --git a/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/treehouseCompose.kt b/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/treehouseCompose.kt index 8d1663fef0..40ec17e125 100644 --- a/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/treehouseCompose.kt +++ b/redwood-treehouse-guest/src/commonMain/kotlin/app/cash/redwood/treehouse/treehouseCompose.kt @@ -17,21 +17,18 @@ package app.cash.redwood.treehouse import androidx.compose.runtime.saveable.SaveableStateRegistry import app.cash.redwood.compose.RedwoodComposition -import app.cash.redwood.protocol.Change import app.cash.redwood.protocol.EventSink import app.cash.redwood.protocol.guest.GuestProtocolAdapter import app.cash.redwood.protocol.guest.ProtocolRedwoodComposition import app.cash.redwood.ui.Cancellable import app.cash.redwood.ui.OnBackPressedCallback import app.cash.redwood.ui.OnBackPressedDispatcher -import app.cash.redwood.ui.UiConfiguration import app.cash.zipline.ZiplineScope import app.cash.zipline.ZiplineScoped import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.job import kotlinx.coroutines.plus @@ -79,46 +76,7 @@ private class RedwoodZiplineTreehouseUi( private lateinit var saveableStateRegistry: SaveableStateRegistry - @Suppress("OVERRIDE_DEPRECATION") - override fun start( - changesSink: ChangesSinkService, - uiConfigurations: StateFlow, - stateSnapshot: StateSnapshot?, - ) { - start(changesSink, NullOnBackPressedDispatcherService, uiConfigurations, stateSnapshot) - } - - @Suppress("OVERRIDE_DEPRECATION") - override fun start( - changesSink: ChangesSinkService, - onBackPressedDispatcher: OnBackPressedDispatcherService, - uiConfigurations: StateFlow, - stateSnapshot: StateSnapshot?, - ) { - val host = object : ZiplineTreehouseUi.Host { - override val uiConfigurations = uiConfigurations - override val stateSnapshot = stateSnapshot - - override fun sendChanges(changes: List) { - changesSink.sendChanges(changes) - } - - override fun addOnBackPressedCallback( - onBackPressedCallbackService: OnBackPressedCallbackService, - ): CancellableService = onBackPressedDispatcher.addCallback(onBackPressedCallbackService) - } - - start(host, changesSink) - } - override fun start(host: ZiplineTreehouseUi.Host) { - start(host, host) - } - - private fun start( - host: ZiplineTreehouseUi.Host, - changesSink: ChangesSinkService, - ) { this.saveableStateRegistry = SaveableStateRegistry( restoredValues = host.stateSnapshot?.content, // Note: values will only be restored by SaveableStateRegistry if `canBeSaved` returns true. @@ -128,7 +86,7 @@ private class RedwoodZiplineTreehouseUi( canBeSaved = { true }, ) - guestAdapter.initChangesSink(changesSink) + guestAdapter.initChangesSink(host) appLifecycle.addFrameListener(this) @@ -190,10 +148,3 @@ private fun OnBackPressedCallback.asService() = object : OnBackPressedCallbackSe enabledChangedCallback = null } } - -private object NullOnBackPressedDispatcherService : OnBackPressedDispatcherService { - override fun addCallback(onBackPressedCallback: OnBackPressedCallbackService) = - object : CancellableService { - override fun cancel() = Unit - } -} diff --git a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseAppContent.kt b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseAppContent.kt index 6c2e9fe92c..077f959aa3 100644 --- a/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseAppContent.kt +++ b/redwood-treehouse-host/src/commonMain/kotlin/app/cash/redwood/treehouse/TreehouseAppContent.kt @@ -27,7 +27,6 @@ import app.cash.redwood.ui.OnBackPressedCallback import app.cash.redwood.ui.OnBackPressedDispatcher import app.cash.redwood.ui.UiConfiguration import app.cash.redwood.widget.Widget -import app.cash.zipline.ZiplineApiMismatchException import app.cash.zipline.ZiplineScope import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope @@ -500,16 +499,7 @@ private class ViewContentCodeBinding( stateSnapshot = viewOrNull?.stateSnapshotId?.let { stateStore.get(it.value.orEmpty()) } - try { - treehouseUi.start(this@ViewContentCodeBinding) - } catch (e: ZiplineApiMismatchException) { - // Fall back to calling the function that doesn't have a back pressed dispatcher. - treehouseUi.start( - changesSink = this@ViewContentCodeBinding, - uiConfigurations = uiConfigurationFlow, - stateSnapshot = stateSnapshot, - ) - } + treehouseUi.start(this@ViewContentCodeBinding) } } diff --git a/redwood-treehouse-host/src/commonTest/kotlin/app/cash/redwood/treehouse/FakeZiplineTreehouseUi.kt b/redwood-treehouse-host/src/commonTest/kotlin/app/cash/redwood/treehouse/FakeZiplineTreehouseUi.kt index 3378fbcbff..3476fa4e0f 100644 --- a/redwood-treehouse-host/src/commonTest/kotlin/app/cash/redwood/treehouse/FakeZiplineTreehouseUi.kt +++ b/redwood-treehouse-host/src/commonTest/kotlin/app/cash/redwood/treehouse/FakeZiplineTreehouseUi.kt @@ -23,9 +23,7 @@ import app.cash.redwood.protocol.Id import app.cash.redwood.protocol.PropertyChange import app.cash.redwood.protocol.PropertyTag import app.cash.redwood.protocol.WidgetTag -import app.cash.redwood.ui.UiConfiguration import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.StateFlow import kotlinx.serialization.json.JsonPrimitive /** @@ -90,25 +88,6 @@ class FakeZiplineTreehouseUi( return result } - @Suppress("OVERRIDE_DEPRECATION") - override fun start( - changesSink: ChangesSinkService, - onBackPressedDispatcher: OnBackPressedDispatcherService, - uiConfigurations: StateFlow, - stateSnapshot: StateSnapshot?, - ) { - error("unexpected call") - } - - @Suppress("OVERRIDE_DEPRECATION") - override fun start( - changesSink: ChangesSinkService, - uiConfigurations: StateFlow, - stateSnapshot: StateSnapshot?, - ) { - error("unexpected call") - } - override fun close() { for (cancellableService in extraServicesToClose) { cancellableService.close() diff --git a/redwood-treehouse/api/android/redwood-treehouse.api b/redwood-treehouse/api/android/redwood-treehouse.api index 6644039318..42412054ab 100644 --- a/redwood-treehouse/api/android/redwood-treehouse.api +++ b/redwood-treehouse/api/android/redwood-treehouse.api @@ -215,8 +215,6 @@ public final class app/cash/redwood/treehouse/StateSnapshotKt { public abstract interface class app/cash/redwood/treehouse/ZiplineTreehouseUi : app/cash/redwood/protocol/EventSink, app/cash/zipline/ZiplineService { public static final field Companion Lapp/cash/redwood/treehouse/ZiplineTreehouseUi$Companion; public fun snapshotState ()Lapp/cash/redwood/treehouse/StateSnapshot; - public abstract fun start (Lapp/cash/redwood/treehouse/ChangesSinkService;Lapp/cash/redwood/treehouse/OnBackPressedDispatcherService;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/redwood/treehouse/StateSnapshot;)V - public abstract fun start (Lapp/cash/redwood/treehouse/ChangesSinkService;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/redwood/treehouse/StateSnapshot;)V public abstract fun start (Lapp/cash/redwood/treehouse/ZiplineTreehouseUi$Host;)V } diff --git a/redwood-treehouse/api/jvm/redwood-treehouse.api b/redwood-treehouse/api/jvm/redwood-treehouse.api index 6644039318..42412054ab 100644 --- a/redwood-treehouse/api/jvm/redwood-treehouse.api +++ b/redwood-treehouse/api/jvm/redwood-treehouse.api @@ -215,8 +215,6 @@ public final class app/cash/redwood/treehouse/StateSnapshotKt { public abstract interface class app/cash/redwood/treehouse/ZiplineTreehouseUi : app/cash/redwood/protocol/EventSink, app/cash/zipline/ZiplineService { public static final field Companion Lapp/cash/redwood/treehouse/ZiplineTreehouseUi$Companion; public fun snapshotState ()Lapp/cash/redwood/treehouse/StateSnapshot; - public abstract fun start (Lapp/cash/redwood/treehouse/ChangesSinkService;Lapp/cash/redwood/treehouse/OnBackPressedDispatcherService;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/redwood/treehouse/StateSnapshot;)V - public abstract fun start (Lapp/cash/redwood/treehouse/ChangesSinkService;Lkotlinx/coroutines/flow/StateFlow;Lapp/cash/redwood/treehouse/StateSnapshot;)V public abstract fun start (Lapp/cash/redwood/treehouse/ZiplineTreehouseUi$Host;)V } diff --git a/redwood-treehouse/api/redwood-treehouse.klib.api b/redwood-treehouse/api/redwood-treehouse.klib.api index caf098dfcb..28e0a3e475 100644 --- a/redwood-treehouse/api/redwood-treehouse.klib.api +++ b/redwood-treehouse/api/redwood-treehouse.klib.api @@ -59,8 +59,6 @@ abstract interface app.cash.redwood.treehouse/OnBackPressedDispatcherService : a } abstract interface app.cash.redwood.treehouse/ZiplineTreehouseUi : app.cash.redwood.protocol/EventSink, app.cash.zipline/ZiplineService { // app.cash.redwood.treehouse/ZiplineTreehouseUi|null[0] - abstract fun start(app.cash.redwood.treehouse/ChangesSinkService, app.cash.redwood.treehouse/OnBackPressedDispatcherService, kotlinx.coroutines.flow/StateFlow, app.cash.redwood.treehouse/StateSnapshot?) // app.cash.redwood.treehouse/ZiplineTreehouseUi.start|start(app.cash.redwood.treehouse.ChangesSinkService;app.cash.redwood.treehouse.OnBackPressedDispatcherService;kotlinx.coroutines.flow.StateFlow;app.cash.redwood.treehouse.StateSnapshot?){}[0] - abstract fun start(app.cash.redwood.treehouse/ChangesSinkService, kotlinx.coroutines.flow/StateFlow, app.cash.redwood.treehouse/StateSnapshot?) // app.cash.redwood.treehouse/ZiplineTreehouseUi.start|start(app.cash.redwood.treehouse.ChangesSinkService;kotlinx.coroutines.flow.StateFlow;app.cash.redwood.treehouse.StateSnapshot?){}[0] abstract fun start(app.cash.redwood.treehouse/ZiplineTreehouseUi.Host) // app.cash.redwood.treehouse/ZiplineTreehouseUi.start|start(app.cash.redwood.treehouse.ZiplineTreehouseUi.Host){}[0] open fun snapshotState(): app.cash.redwood.treehouse/StateSnapshot? // app.cash.redwood.treehouse/ZiplineTreehouseUi.snapshotState|snapshotState(){}[0] diff --git a/redwood-treehouse/api/zipline-api.toml b/redwood-treehouse/api/zipline-api.toml index 2a73ae8ffd..0e81f8ba18 100644 --- a/redwood-treehouse/api/zipline-api.toml +++ b/redwood-treehouse/api/zipline-api.toml @@ -101,12 +101,6 @@ functions = [ # fun snapshotState(): app.cash.redwood.treehouse.StateSnapshot "mPBGCHFl", - # fun start(app.cash.redwood.treehouse.ChangesSinkService, app.cash.redwood.treehouse.OnBackPressedDispatcherService, kotlinx.coroutines.flow.StateFlow, app.cash.redwood.treehouse.StateSnapshot): kotlin.Unit - "UkTy28z8", - - # fun start(app.cash.redwood.treehouse.ChangesSinkService, kotlinx.coroutines.flow.StateFlow, app.cash.redwood.treehouse.StateSnapshot): kotlin.Unit - "FiVQXMQW", - # fun start(app.cash.redwood.treehouse.ZiplineTreehouseUi.Host): kotlin.Unit "h9yZr91W", ] diff --git a/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/ZiplineTreehouseUi.kt b/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/ZiplineTreehouseUi.kt index 746dbff881..e1b70537e1 100644 --- a/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/ZiplineTreehouseUi.kt +++ b/redwood-treehouse/src/commonMain/kotlin/app/cash/redwood/treehouse/ZiplineTreehouseUi.kt @@ -32,24 +32,6 @@ public interface ZiplineTreehouseUi : EventSink { public fun start(host: Host) - @Deprecated("Use `start` method that takes in a Host") - public fun start( - changesSink: ChangesSinkService, - onBackPressedDispatcher: OnBackPressedDispatcherService, - uiConfigurations: StateFlow, - stateSnapshot: StateSnapshot?, - ) - - @Deprecated( - "Use `start` method that takes in an `OnBackPressedDispatcherService` instead.", - ReplaceWith("start(changesSink, TODO(), uiConfigurations, stateSnapshot)"), - ) - public fun start( - changesSink: ChangesSinkService, - uiConfigurations: StateFlow, - stateSnapshot: StateSnapshot?, - ) - public fun snapshotState(): StateSnapshot? = null /** Access to the host that presents this UI. */