Skip to content

Commit

Permalink
Merge pull request #382 from KovalevAndrey/1.x-update-androidx-lifecycle
Browse files Browse the repository at this point in the history
1.x update androidx lifecycle
  • Loading branch information
KovalevAndrey authored Mar 25, 2023
2 parents dcf7147 + c2c8dc5 commit 71279fa
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 38 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Pending changes

- [#376](https://github.com/bumble-tech/appyx/issues/376)**Changed**: Androidx lifecycle version updated to 2.6.1.
- [#376](https://github.com/bumble-tech/appyx/issues/376)**Updated**: Kotlin and Compose compiler version updated to 1.8.10 to align kotlin version used in androidx lifecycle
- [#375](https://github.com/bumble-tech/appyx/issues/375)**Fixed**: SaveableStateHolder does no longer save state for destroyed elements

---
Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ androidCompileSdk = "33"
androidMinSdk = "21"
androidTargetSdk = "32"
accompanist = "0.28.0"
androidx-lifecycle = "2.5.1"
androidx-lifecycle = "2.6.1"
androidx-navigation-compose = "2.5.1"
coil = "2.2.1"
composeBom = "2023.01.00"
composeCompiler = "1.3.1"
ribs = "0.36.1"
composeCompiler = "1.4.4"
ribs = "0.38.0"
mvicore = "1.2.6"
coroutines = "1.6.4"
kotlin = "1.7.10"
kotlin = "1.8.10"
junit5 = "5.8.2"
detekt = "1.21.0"
dependencyAnalysis = "1.13.1"
Expand Down Expand Up @@ -74,7 +74,7 @@ junit-vintage = { module = "org.junit.vintage:junit-vintage-engine", version.ref

plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
plugin-detekt = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
plugin-android = "com.android.tools.build:gradle:7.3.1"
plugin-android = "com.android.tools.build:gradle:7.4.0"

detekt-compose = "com.twitter.compose.rules:detekt:0.0.26"
toolargetool = "com.gu.android:toolargetool:0.3.0"
Expand Down
4 changes: 2 additions & 2 deletions libraries/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ dependencies {

api(composeBom)
api(project(":libraries:customisations"))
api(libs.kotlin.coroutines.android)
api(libs.androidx.lifecycle.common)
api(libs.compose.animation.core)
api(libs.compose.runtime)
api(libs.androidx.appcompat)
api(libs.kotlin.coroutines.android)

implementation(composeBom)
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.lifecycle.java8)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.compose.foundation.layout)


testImplementation(project(":libraries:testing-junit4"))
testImplementation(libs.androidx.arch.core.testing)
testImplementation(libs.junit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ internal class MinimumCombinedLifecycle(
lifecycles.sortedBy { it.currentState }.forEach { manage(it) }
}

override fun getLifecycle(): Lifecycle =
registry
override val lifecycle: Lifecycle
get() = registry

fun manage(lifecycle: Lifecycle) {
lifecycles += lifecycle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ internal class NodeLifecycleImpl(owner: LifecycleOwner) : NodeLifecycle {

private val lifecycleRegistry = LifecycleRegistry(owner)

override fun getLifecycle(): Lifecycle =
lifecycleRegistry
override val lifecycle: Lifecycle
get() = lifecycleRegistry

override fun updateLifecycleState(state: Lifecycle.State) {
lifecycleRegistry.currentState = state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ open class Node @VisibleForTesting internal constructor(
}
}

override fun getLifecycle(): Lifecycle =
nodeLifecycle.lifecycle
override val lifecycle: Lifecycle
get() = nodeLifecycle.lifecycle

override fun updateLifecycleState(state: Lifecycle.State) {
if (lifecycle.currentState == state) return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class TestLifecycle() : LifecycleOwner {
registry.currentState = value
}

override fun getLifecycle(): Lifecycle = registry
override val lifecycle: Lifecycle
get() = registry

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.lifecycle.LifecycleObserver
import com.bumble.appyx.core.modality.BuildContext
import com.bumble.appyx.core.node.Node
import com.bumble.appyx.core.node.build
import com.bumble.appyx.core.plugin.NodeLifecycleAware
import com.bumble.appyx.testing.junit4.util.MainDispatcherRule
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotEquals
Expand All @@ -32,7 +31,8 @@ class NodeLifecycleAwareTest {
// no-op
}

override fun getCurrentState() = State.DESTROYED
override val currentState: State = State.DESTROYED

}

private val nodeLifecycleAwarePlugin = object : NodeLifecycleAware {
Expand Down
2 changes: 1 addition & 1 deletion libraries/interop-ribs/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ android {
dependencies {
api(project(":libraries:core"))
api(libs.ribs.base)
api(libs.ribs.compose)

val composeBom = platform(libs.compose.bom)

Expand All @@ -36,7 +37,6 @@ dependencies {
implementation(libs.androidx.lifecycle.java8)
implementation(libs.androidx.activity.compose)
implementation(libs.compose.ui.ui)
implementation(libs.ribs.compose)

androidTestImplementation(composeBom)
androidTestImplementation(libs.androidx.activity.compose)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ internal class InteropBackPressHandler :
NodeLifecycleAware {

private val dispatcher = OnBackPressedDispatcher()
private lateinit var lifecycle: Lifecycle
private lateinit var nodeLifecycle: Lifecycle

override fun onCreate(nodeLifecycle: Lifecycle) {
lifecycle = nodeLifecycle
this.nodeLifecycle = nodeLifecycle
}

override fun handleBackPress(): Boolean =
Expand All @@ -37,7 +37,8 @@ internal class InteropBackPressHandler :
false
}

override fun getLifecycle(): Lifecycle = lifecycle
override val lifecycle: Lifecycle
get() = nodeLifecycle

override fun getOnBackPressedDispatcher(): OnBackPressedDispatcher =
dispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Rx2NodeConnectorTest {
private val lifecycle = object : Lifecycle() {

private val lifecycleOwner = object : LifecycleOwner {
override fun getLifecycle(): Lifecycle = LifecycleRegistry(this)
override val lifecycle: Lifecycle = LifecycleRegistry(this)
}

override fun addObserver(observer: LifecycleObserver) {
Expand All @@ -40,7 +40,8 @@ class Rx2NodeConnectorTest {
// Deliberately empty
}

override fun getCurrentState() = lifecycleState
override val currentState: State
get() = lifecycleState
}

sealed class Output {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.bumble.appyx.interop.rx3.connectable

import android.annotation.SuppressLint
import androidx.lifecycle.Lifecycle
import com.bumble.appyx.core.lifecycle.subscribe
import com.jakewharton.rxrelay3.PublishRelay
Expand Down Expand Up @@ -53,6 +54,7 @@ class NodeConnector<Input, Output : Any>(
}
}

@SuppressLint("CheckResult")
private fun switchToExhaust() {
intake.subscribe { exhaust.accept(it) }
cacheSubscription.dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ internal class Rx3NodeConnectorTest {
private val lifecycle = object : Lifecycle() {

private val lifecycleOwner = object : LifecycleOwner {
override fun getLifecycle(): Lifecycle = LifecycleRegistry(this)
override val lifecycle: Lifecycle
get() = LifecycleRegistry(this)
}

override fun addObserver(observer: LifecycleObserver) {
Expand All @@ -39,7 +40,8 @@ internal class Rx3NodeConnectorTest {
// Deliberately empty
}

override fun getCurrentState() = lifecycleState
override val currentState: State
get() = lifecycleState
}

sealed class Output {
Expand Down
1 change: 0 additions & 1 deletion samples/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ dependencies {
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core.splashscreen)
implementation(libs.androidx.lifecycle.java8)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.compose.material)
implementation(libs.compose.ui.tooling)
implementation(libs.compose.ui.ui)
Expand Down
1 change: 0 additions & 1 deletion samples/sandbox/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.appcompat)
implementation(libs.androidx.lifecycle.java8)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.compose.material)
implementation(libs.compose.ui.tooling)
implementation(libs.compose.ui.ui)
Expand Down
35 changes: 23 additions & 12 deletions samples/sandbox/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.1.3" type="baseline" client="gradle" dependencies="false" name="AGP (7.1.3)" variant="all" version="7.1.3">

<issue
id="ModifierFactoryExtensionFunction"
message="Modifier factory functions should be extensions on Modifier"
errorLine1=" override fun createModifier("
errorLine2=" ~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/bumble/appyx/sandbox/client/backstack/BackStackExampleTransitionHandler.kt"
line="20"
column="18"/>
</issue>
<issues format="6" by="lint 7.4.0" type="baseline" client="gradle" dependencies="false" name="AGP (7.4.0)" variant="all" version="7.4.0">

<issue
id="Overdraw"
Expand All @@ -23,4 +12,26 @@
column="5"/>
</issue>

<issue
id="MonochromeLauncherIcon"
message="The application adaptive icon is missing a monochrome tag"
errorLine1="&lt;adaptive-icon xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;>"
errorLine2="^">
<location
file="src/main/res/mipmap-anydpi-v26/ic_launcher.xml"
line="2"
column="1"/>
</issue>

<issue
id="MonochromeLauncherIcon"
message="The application adaptive roundIcon is missing a monochrome tag"
errorLine1="&lt;adaptive-icon xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;>"
errorLine2="^">
<location
file="src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml"
line="2"
column="1"/>
</issue>

</issues>

0 comments on commit 71279fa

Please sign in to comment.