Skip to content

Commit

Permalink
Merge branch 'main' into correcting-sample-tutorial4
Browse files Browse the repository at this point in the history
  • Loading branch information
sssurvey authored Jul 18, 2023
2 parents df02894 + 9a5bd11 commit 58e2d72
Show file tree
Hide file tree
Showing 27 changed files with 217 additions and 176 deletions.
77 changes: 44 additions & 33 deletions .github/actions/gradle-tasks-with-emulator/action.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name : Run Android Instrumentation Tests with Artifact and AVD Caching
description: This action sets up Gradle, runs a preparatory task, runs Android tests on an emulator, and uploads test results.
description : This action sets up Gradle, runs a preparatory task, runs Android tests on an emulator, and uploads test results.

inputs:
prepare-task:
description: 'Gradle task for preparing necessary artifacts. Supports multi-line input.'
required: true
test-task:
description: 'Gradle task for running instrumentation tests. Supports multi-line input.'
required: true
inputs :
prepare-task :
description : 'Gradle task for preparing necessary artifacts. Supports multi-line input.'
required : true
test-task :
description : 'Gradle task for running instrumentation tests. Supports multi-line input.'
required : true
api-level :
description : 'The Android SDK api level, like `29`'
required : true
Expand Down Expand Up @@ -43,40 +43,51 @@ runs :
write-cache-key : ${{ inputs.write-cache-key }}

# Get the AVD if it's already cached.
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
- name : AVD cache
uses : actions/cache/restore@v3
id : restore-avd-cache
with :
path : |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
key : avd-${{ matrix.api-level }}

# If the AVD cache didn't exist, create an AVD and cache it.
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ inputs.api-level }}
# If the AVD cache didn't exist, create an AVD
- name : create AVD and generate snapshot for caching
if : steps.restore-avd-cache.outputs.cache-hit != 'true'
uses : reactivecircus/android-emulator-runner@v2
with :
api-level : ${{ inputs.api-level }}
arch : x86_64
disable-animations: false
emulator-boot-timeout: 12000
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations : false
emulator-boot-timeout : 12000
emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation : false
profile : Galaxy Nexus
ram-size: 4096M
script: echo "Generated AVD snapshot."
ram-size : 4096M
script : echo "Generated AVD snapshot."

# If we just created an AVD because there wasn't one in the cache, then cache that AVD.
- name : cache new AVD before tests
if : steps.restore-avd-cache.outputs.cache-hit != 'true'
id : save-avd-cache
uses : actions/cache/save@v3
with :
path : |
~/.android/avd/*
~/.android/adb*
key : avd-${{ matrix.api-level }}

# Run the actual emulator tests.
# At this point every task should be up-to-date and the AVD should be ready to go.
- name: run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ inputs.api-level }}
- name : run tests
uses : reactivecircus/android-emulator-runner@v2
with :
api-level : ${{ inputs.api-level }}
arch : x86_64
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation: false
disable-animations : true
emulator-options : -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
force-avd-creation : false
profile : Galaxy Nexus
script : ./gradlew ${{ inputs.test-task }}

Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ androidx-compose-compiler = "1.4.4"
# see https://developer.android.com/jetpack/compose/bom/bom-mapping
androidx-compose-bom = "2023.01.00"
androidx-constraintlayout = "2.1.4"
androidx-core = "1.6.0"
androidx-core = "1.10.0"
androidx-fragment = "1.3.6"
androidx-gridlayout = "1.0.0"
androidx-lifecycle = "2.5.1"
androidx-lifecycle = "2.6.1"
androidx-navigation = "2.4.0-alpha09"
androidx-paging = "3.0.1"
androidx-profileinstaller = "1.2.0-alpha02"
Expand All @@ -33,7 +33,7 @@ androidx-test-truth-ext = "1.5.0"
androidx-tracing = "1.1.0"
androidx-transition = "1.4.1"
androidx-viewbinding = "4.2.1"
androidx-work = "2.6.0"
androidx-work = "2.7.0"

detekt = "1.19.0"
dokka = "1.8.20"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
androidx.activity:activity-compose:1.6.1
androidx.activity:activity-ktx:1.6.1
androidx.activity:activity:1.6.1
androidx.annotation:annotation-experimental:1.1.0
androidx.annotation:annotation:1.5.0
androidx.arch.core:core-common:2.1.0
androidx.arch.core:core-runtime:2.1.0
androidx.annotation:annotation-experimental:1.3.0
androidx.annotation:annotation-jvm:1.6.0
androidx.annotation:annotation:1.6.0
androidx.arch.core:core-common:2.2.0
androidx.arch.core:core-runtime:2.2.0
androidx.autofill:autofill:1.0.0
androidx.collection:collection:1.1.0
androidx.compose.animation:animation-core:1.3.3
Expand All @@ -21,19 +22,20 @@ androidx.compose.ui:ui-unit:1.3.3
androidx.compose.ui:ui-util:1.3.3
androidx.compose.ui:ui:1.3.3
androidx.compose:compose-bom:2023.01.00
androidx.concurrent:concurrent-futures:1.0.0
androidx.core:core-ktx:1.6.0
androidx.core:core:1.8.0
androidx.concurrent:concurrent-futures:1.1.0
androidx.core:core-ktx:1.10.0
androidx.core:core:1.10.0
androidx.customview:customview-poolingcontainer:1.0.0
androidx.lifecycle:lifecycle-common-java8:2.5.1
androidx.lifecycle:lifecycle-common:2.5.1
androidx.lifecycle:lifecycle-livedata-core:2.5.1
androidx.lifecycle:lifecycle-runtime-ktx:2.5.1
androidx.lifecycle:lifecycle-runtime:2.5.1
androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1
androidx.lifecycle:lifecycle-viewmodel:2.5.1
androidx.profileinstaller:profileinstaller:1.2.0
androidx.interpolator:interpolator:1.0.0
androidx.lifecycle:lifecycle-common-java8:2.6.1
androidx.lifecycle:lifecycle-common:2.6.1
androidx.lifecycle:lifecycle-livedata-core:2.6.1
androidx.lifecycle:lifecycle-runtime-ktx:2.6.1
androidx.lifecycle:lifecycle-runtime:2.6.1
androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1
androidx.lifecycle:lifecycle-viewmodel:2.6.1
androidx.profileinstaller:profileinstaller:1.3.0
androidx.savedstate:savedstate-ktx:1.2.1
androidx.savedstate:savedstate:1.2.1
androidx.startup:startup-runtime:1.1.1
Expand Down
34 changes: 18 additions & 16 deletions workflow-ui/compose/dependencies/releaseRuntimeClasspath.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
androidx.activity:activity-compose:1.6.1
androidx.activity:activity-ktx:1.6.1
androidx.activity:activity:1.6.1
androidx.annotation:annotation-experimental:1.1.0
androidx.annotation:annotation:1.5.0
androidx.arch.core:core-common:2.1.0
androidx.arch.core:core-runtime:2.1.0
androidx.annotation:annotation-experimental:1.3.0
androidx.annotation:annotation-jvm:1.6.0
androidx.annotation:annotation:1.6.0
androidx.arch.core:core-common:2.2.0
androidx.arch.core:core-runtime:2.2.0
androidx.autofill:autofill:1.0.0
androidx.collection:collection:1.1.0
androidx.compose.animation:animation-core:1.3.3
Expand All @@ -18,19 +19,20 @@ androidx.compose.ui:ui-unit:1.3.3
androidx.compose.ui:ui-util:1.3.3
androidx.compose.ui:ui:1.3.3
androidx.compose:compose-bom:2023.01.00
androidx.concurrent:concurrent-futures:1.0.0
androidx.core:core-ktx:1.6.0
androidx.core:core:1.8.0
androidx.concurrent:concurrent-futures:1.1.0
androidx.core:core-ktx:1.10.0
androidx.core:core:1.10.0
androidx.customview:customview-poolingcontainer:1.0.0
androidx.lifecycle:lifecycle-common-java8:2.5.1
androidx.lifecycle:lifecycle-common:2.5.1
androidx.lifecycle:lifecycle-livedata-core:2.5.1
androidx.lifecycle:lifecycle-runtime-ktx:2.5.1
androidx.lifecycle:lifecycle-runtime:2.5.1
androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1
androidx.lifecycle:lifecycle-viewmodel:2.5.1
androidx.profileinstaller:profileinstaller:1.2.0
androidx.interpolator:interpolator:1.0.0
androidx.lifecycle:lifecycle-common-java8:2.6.1
androidx.lifecycle:lifecycle-common:2.6.1
androidx.lifecycle:lifecycle-livedata-core:2.6.1
androidx.lifecycle:lifecycle-runtime-ktx:2.6.1
androidx.lifecycle:lifecycle-runtime:2.6.1
androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1
androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1
androidx.lifecycle:lifecycle-viewmodel:2.6.1
androidx.profileinstaller:profileinstaller:1.3.0
androidx.savedstate:savedstate-ktx:1.2.1
androidx.savedstate:savedstate:1.2.1
androidx.startup:startup-runtime:1.1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import androidx.lifecycle.Lifecycle.State.STARTED
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.lifecycle.findViewTreeLifecycleOwner
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
Expand Down Expand Up @@ -239,7 +239,7 @@ internal class LegacyWorkflowRenderingTest {

override fun onAttachedToWindow() {
super.onAttachedToWindow()
val lifecycle = ViewTreeLifecycleOwner.get(this)!!.lifecycle
val lifecycle = this.findViewTreeLifecycleOwner()!!.lifecycle
lifecycle.addObserver(
LifecycleEventObserver { _, event ->
lifecycleEvents += event
Expand Down Expand Up @@ -277,7 +277,8 @@ internal class LegacyWorkflowRenderingTest {
val states = mutableListOf<State>()
val parentOwner = object : LifecycleOwner {
val registry = LifecycleRegistry(this)
override fun getLifecycle(): Lifecycle = registry
override val lifecycle: Lifecycle
get() = registry
}

composeRule.setContent {
Expand Down Expand Up @@ -319,7 +320,8 @@ internal class LegacyWorkflowRenderingTest {
val states = mutableListOf<State>()
val parentOwner = object : LifecycleOwner {
val registry = LifecycleRegistry(this)
override fun getLifecycle(): Lifecycle = registry
override val lifecycle: Lifecycle
get() = registry
}
composeRule.runOnIdle {
// Cannot go directly to DESTROYED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import androidx.lifecycle.Lifecycle.State.STARTED
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.lifecycle.findViewTreeLifecycleOwner
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
Expand Down Expand Up @@ -236,7 +236,7 @@ internal class WorkflowRenderingTest {
val view = object : View(context) {
override fun onAttachedToWindow() {
super.onAttachedToWindow()
val lifecycle = ViewTreeLifecycleOwner.get(this)!!.lifecycle
val lifecycle = this.findViewTreeLifecycleOwner()!!.lifecycle
lifecycle.addObserver(
LifecycleEventObserver { _, event -> lifecycleEvents += event }
)
Expand Down Expand Up @@ -273,7 +273,8 @@ internal class WorkflowRenderingTest {
val states = mutableListOf<State>()
val parentOwner = object : LifecycleOwner {
val registry = LifecycleRegistry(this)
override fun getLifecycle(): Lifecycle = registry
override val lifecycle: Lifecycle
get() = registry
}

composeRule.setContent {
Expand Down Expand Up @@ -315,7 +316,8 @@ internal class WorkflowRenderingTest {
val states = mutableListOf<State>()
val parentOwner = object : LifecycleOwner {
val registry = LifecycleRegistry(this)
override fun getLifecycle(): Lifecycle = registry
override val lifecycle: Lifecycle
get() = registry
}
composeRule.runOnIdle {
// Cannot go directly to DESTROYED
Expand Down Expand Up @@ -533,7 +535,6 @@ internal class WorkflowRenderingTest {
}
}

@Suppress("UNCHECKED_CAST")
private interface ComposableRendering<RenderingT : ComposableRendering<RenderingT>> :
AndroidScreen<RenderingT> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import androidx.lifecycle.Lifecycle.State.INITIALIZED
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.lifecycle.setViewTreeLifecycleOwner
import com.squareup.workflow1.ui.Compatible
import com.squareup.workflow1.ui.ViewEnvironment
import com.squareup.workflow1.ui.ViewFactory
Expand Down Expand Up @@ -90,7 +90,8 @@ public fun WorkflowRendering(
val lifecycleOwner = remember {
object : LifecycleOwner {
val registry = LifecycleRegistry(this)
override fun getLifecycle(): Lifecycle = registry
override val lifecycle: Lifecycle
get() = registry
}
}
val parentLifecycle = LocalLifecycleOwner.current.lifecycle
Expand All @@ -107,7 +108,7 @@ public fun WorkflowRendering(

// If we're leaving the composition it means the WorkflowRendering is either going away itself
// or about to switch to an incompatible rendering – either way, this lifecycle is dead. Note
// that we can't transition from INITIALIZED to DESTROYED – the LifecycelRegistry will throw.
// that we can't transition from INITIALIZED to DESTROYED – the LifecycleRegistry will throw.
// WorkflowLifecycleOwner has this same check.
if (lifecycleOwner.registry.currentState != INITIALIZED) {
lifecycleOwner.registry.currentState = DESTROYED
Expand Down Expand Up @@ -168,7 +169,7 @@ private fun <R : Any> ViewFactory<R>.asComposeViewFactory() =
}

// Unfortunately AndroidView doesn't propagate this itself.
ViewTreeLifecycleOwner.set(view, lifecycleOwner)
view.setViewTreeLifecycleOwner(lifecycleOwner)
// We don't propagate the (non-compose) SavedStateRegistryOwner, or the (compose)
// SaveableStateRegistry, because currently all our navigation is implemented as
// Android views, which ensures there is always an Android view between any state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import androidx.lifecycle.Lifecycle.State.INITIALIZED
import androidx.lifecycle.LifecycleEventObserver
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
import androidx.lifecycle.ViewTreeLifecycleOwner
import androidx.lifecycle.setViewTreeLifecycleOwner
import com.squareup.workflow1.ui.Compatible
import com.squareup.workflow1.ui.OnBackPressedDispatcherOwnerKey
import com.squareup.workflow1.ui.Screen
Expand Down Expand Up @@ -123,7 +123,8 @@ public fun WorkflowRendering(
val lifecycleOwner = remember {
object : LifecycleOwner {
val registry = LifecycleRegistry(this)
override fun getLifecycle(): Lifecycle = registry
override val lifecycle: Lifecycle
get() = registry
}
}
val parentLifecycle = LocalLifecycleOwner.current.lifecycle
Expand Down Expand Up @@ -213,7 +214,7 @@ private fun <ScreenT : Screen> ScreenViewFactory<ScreenT>.asComposeViewFactory()
viewHolder.view.setTag(R.id.workflow_screen_view_holder, viewHolder)

// Unfortunately AndroidView doesn't propagate these itself.
ViewTreeLifecycleOwner.set(viewHolder.view, lifecycleOwner)
viewHolder.view.setViewTreeLifecycleOwner(lifecycleOwner)
onBackOrNull?.let {
viewHolder.view.setViewTreeOnBackPressedDispatcherOwner(it)
}
Expand Down
Loading

0 comments on commit 58e2d72

Please sign in to comment.