From 560ceed2e565f124f7461598fdad18629336acb0 Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 22:47:45 +0300 Subject: [PATCH 01/13] Update gradle to v8.4 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 3f551a75..8c9a61a7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -18,4 +18,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip From 7a1013258de91918ab3a7c9d1f79aa6dda04f381 Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 23:07:31 +0300 Subject: [PATCH 02/13] Update plugins --- .../corbind/Project+configureKotlinAndroid.kt | 4 ++-- gradle/libs.versions.toml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt b/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt index 30fbf613..d82f5faa 100644 --- a/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt +++ b/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt @@ -28,7 +28,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions internal fun Project.configureKotlinAndroid( - commonExtension: CommonExtension<*, *, *, *>, + commonExtension: CommonExtension<*, *, *, *, *>, ) { val compileSdk: String by project val minSdk: String by project @@ -63,6 +63,6 @@ internal fun Project.configureKotlinAndroid( private fun Project.kotlin(action: KotlinAndroidProjectExtension.() -> Unit) = extensions.configure(action) -private fun CommonExtension<*, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { +private fun CommonExtension<*, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) { (this as ExtensionAware).extensions.configure("kotlinOptions", block) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index aed63b23..d8bf5b24 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,11 +1,11 @@ [versions] # Plugins -agp = "8.0.1" -dokka = "1.8.10" -spotless = "6.18.0" -mavenPublish = "0.25.2" -bcv = "0.13.1" -gver = "0.46.0" +agp = "8.1.2" +dokka = "1.8.20" +spotless = "6.22.0" +mavenPublish = "0.25.3" +bcv = "0.13.2" +gver = "0.48.0" # Kotlin kotlin = "1.8.21" From 863a62da991a7b5f0fe5cdd946540a33ea58b21d Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 23:10:04 +0300 Subject: [PATCH 03/13] Update kotlin to v1.9.10 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d8bf5b24..e5a5e934 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ bcv = "0.13.2" gver = "0.48.0" # Kotlin -kotlin = "1.8.21" +kotlin = "1.9.10" kotlinCoroutines = "1.7.0" # Androidx From d4678ce460a2b1e62767629845b06b24f373bbcd Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 23:18:28 +0300 Subject: [PATCH 04/13] Update kotlin coroutines to v1.7.3 --- gradle/libs.versions.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e5a5e934..2ce29160 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] # Plugins agp = "8.1.2" -dokka = "1.8.20" +dokka = "1.9.0" spotless = "6.22.0" mavenPublish = "0.25.3" bcv = "0.13.2" @@ -9,7 +9,7 @@ gver = "0.48.0" # Kotlin kotlin = "1.9.10" -kotlinCoroutines = "1.7.0" +kotlinCoroutines = "1.7.3" # Androidx androidxCore = "1.9.0" From ebe41eda3712ed6fb40ae7f17879d09dbea03f4a Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 23:20:56 +0300 Subject: [PATCH 05/13] Update navigation to v2.7.4 --- gradle/libs.versions.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2ce29160..b9772632 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -12,12 +12,12 @@ kotlin = "1.9.10" kotlinCoroutines = "1.7.3" # Androidx -androidxCore = "1.9.0" -androidxAnnotation = "1.6.0" +androidxCore = "1.12.0" +androidxAnnotation = "1.7.0" androidxAppcompat = "1.6.1" androidxDrawerlayout = "1.2.0" androidxLeanback = "1.0.0" -androidxNavigation = "2.5.3" +androidxNavigation = "2.7.4" androidxRecyclerview = "1.3.0" androidxSlidingpanelayout = "1.2.0" androidxSwiperefreshlayout = "1.1.0" From 5a79bfeb43b0be54e23f49471f6b4e921432a98e Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 23:23:28 +0300 Subject: [PATCH 06/13] Update activity to v1.8.0 --- gradle/libs.versions.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b9772632..08a4b39d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -18,13 +18,13 @@ androidxAppcompat = "1.6.1" androidxDrawerlayout = "1.2.0" androidxLeanback = "1.0.0" androidxNavigation = "2.7.4" -androidxRecyclerview = "1.3.0" +androidxRecyclerview = "1.3.1" androidxSlidingpanelayout = "1.2.0" androidxSwiperefreshlayout = "1.1.0" androidxViewpager = "1.0.0" androidxViewpager2 = "1.0.0" -androidxLifecycle = "2.6.1" -androidxActivity = "1.7.1" +androidxLifecycle = "2.6.2" +androidxActivity = "1.8.0" androidxFragment = "1.5.7" androidxConstraintlayout = "2.1.4" From 4cb7ec5561eb2dd5647920d11f91e4f2dedd7a95 Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 23:24:04 +0300 Subject: [PATCH 07/13] Update fragment to v1.6.1 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 08a4b39d..9297047c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -25,7 +25,7 @@ androidxViewpager = "1.0.0" androidxViewpager2 = "1.0.0" androidxLifecycle = "2.6.2" androidxActivity = "1.8.0" -androidxFragment = "1.5.7" +androidxFragment = "1.6.1" androidxConstraintlayout = "2.1.4" # Google From 17c76f21541376ced7b8bf11eb36671e1cbdd55c Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sat, 7 Oct 2023 23:28:44 +0300 Subject: [PATCH 08/13] Update material to v1.10.0 and targetSdk to 34 --- .../corbind/Project+configureKotlinAndroid.kt | 8 -------- gradle.properties | 6 +++--- gradle/libs.versions.toml | 2 +- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt b/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt index d82f5faa..b09023d1 100644 --- a/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt +++ b/build-logic/convention/src/main/kotlin/ru/ldralighieri/corbind/Project+configureKotlinAndroid.kt @@ -19,7 +19,6 @@ package ru.ldralighieri.corbind import com.android.build.api.dsl.CommonExtension -import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.api.plugins.ExtensionAware import org.gradle.kotlin.dsl.configure @@ -44,13 +43,6 @@ internal fun Project.configureKotlinAndroid( jvmToolchain(17) } - // Remove this after https://issuetracker.google.com/issues/260059413 is fixed - // https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - kotlinOptions { allWarningsAsErrors = true freeCompilerArgs = freeCompilerArgs + listOf( diff --git a/gradle.properties b/gradle.properties index 620e5155..913315fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -31,9 +31,9 @@ SONATYPE_AUTOMATIC_RELEASE=true # Android android.useAndroidX=true -buildTools=33.0.2 -compileSdk=33 -targetSdk=33 +buildTools=34.0.0 +compileSdk=34 +targetSdk=34 minSdk=14 # Build features diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9297047c..f4725d76 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -29,7 +29,7 @@ androidxFragment = "1.6.1" androidxConstraintlayout = "2.1.4" # Google -material = "1.9.0" +material = "1.10.0" # Lint ktlint = "0.46.1" From bce5248dacafb0dc82f6325f8afb454551208c81 Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sun, 8 Oct 2023 22:15:54 +0300 Subject: [PATCH 09/13] Added OnBackPressedDispatcher backProgressed extensions --- .../OnBackPressedDispatcherBackProgressed.kt | 135 ++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackProgressed.kt diff --git a/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackProgressed.kt b/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackProgressed.kt new file mode 100644 index 00000000..67c0fffc --- /dev/null +++ b/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackProgressed.kt @@ -0,0 +1,135 @@ +/* + * Copyright 2023 Vladimir Raupov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ru.ldralighieri.corbind.activity + +import androidx.activity.BackEventCompat +import androidx.activity.OnBackPressedCallback +import androidx.activity.OnBackPressedDispatcher +import androidx.annotation.CheckResult +import androidx.lifecycle.LifecycleOwner +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.channels.ReceiveChannel +import kotlinx.coroutines.channels.actor +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.channelFlow +import kotlinx.coroutines.isActive +import ru.ldralighieri.corbind.internal.corbindReceiveChannel + +/** + * Perform an action on [OnBackPressedDispatcher.dispatchOnBackProgressed] call. + * + * @param scope Root coroutine scope + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + * @param capacity Capacity of the channel's buffer (no buffer by default) + * @param action An action to perform + */ +fun OnBackPressedDispatcher.backProgressed( + scope: CoroutineScope, + lifecycleOwner: LifecycleOwner, + capacity: Int = Channel.RENDEZVOUS, + action: suspend (Float) -> Unit +) { + val events = scope.actor(Dispatchers.Main.immediate, capacity) { + for (progress in channel) action(progress) + } + + val callback = callback(scope, events::trySend) + addCallback(lifecycleOwner, callback) + events.invokeOnClose { callback.remove() } +} + +/** + * Perform an action on [OnBackPressedDispatcher.dispatchOnBackProgressed] call, inside new + * [CoroutineScope]. + * + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + * @param capacity Capacity of the channel's buffer (no buffer by default) + * @param action An action to perform + */ +suspend fun OnBackPressedDispatcher.backProgressed( + lifecycleOwner: LifecycleOwner, + capacity: Int = Channel.RENDEZVOUS, + action: suspend (Float) -> Unit +) = coroutineScope { + backProgressed(this, lifecycleOwner, capacity, action) +} + +/** + * Create a channel which emits back progress on [OnBackPressedDispatcher.dispatchOnBackProgressed] + * call. + * + * Example: + * + * ``` + * launch { + * onBackPressedDispatcher.backProgressed(scope, lifecycleOwner = this) + * .consumeEach { /* handle back progressed event */ } + * } + * ``` + * + * @param scope Root coroutine scope + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + * @param capacity Capacity of the channel's buffer (no buffer by default) + */ +fun OnBackPressedDispatcher.backProgressed( + scope: CoroutineScope, + lifecycleOwner: LifecycleOwner, + capacity: Int = Channel.RENDEZVOUS +): ReceiveChannel = corbindReceiveChannel(capacity) { + val callback = callback(scope, ::trySend) + addCallback(lifecycleOwner, callback) + invokeOnClose { callback.remove() } +} + +/** + * Create a flow which emits back progress on [OnBackPressedDispatcher.dispatchOnBackProgressed] + * call. + * + * Example: + * + * ``` + * onBackPressedDispatcher.backProgressed(lifecycleOwner = this) + * .onEach { /* handle back progressed event */ } + * .flowWithLifecycle(lifecycle) + * .launchIn(lifecycleScope) // lifecycle-runtime-ktx + * ``` + * + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + */ +fun OnBackPressedDispatcher.backProgressed(lifecycleOwner: LifecycleOwner): Flow = + channelFlow { + val callback = callback(this, ::trySend) + addCallback(lifecycleOwner, callback) + awaitClose { callback.remove() } + } + +@CheckResult +private fun callback( + scope: CoroutineScope, + emitter: (Float) -> Unit +) = object : OnBackPressedCallback(true) { + + override fun handleOnBackProgressed(backEvent: BackEventCompat) { + if (scope.isActive) { emitter(backEvent.progress) } + } + + override fun handleOnBackPressed() = Unit +} From 6aa4e11fe28d88d50fc9dcc022bc28bf06894eb6 Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sun, 8 Oct 2023 22:18:10 +0300 Subject: [PATCH 10/13] Added OnBackPressedDispatcher backEvents extensions --- .../OnBackPressedDispatcherBackPresses.kt | 6 +- .../OnBackPressedDispatcherOnBackEvents.kt | 171 ++++++++++++++++++ sample/build.gradle.kts | 1 + sample/src/main/AndroidManifest.xml | 4 +- .../corbind/sample/LoginActivity.kt | 29 +++ .../sample/core/extensions/Number+toPx.kt | 10 + sample/src/main/res/layout/activity_login.xml | 10 +- 7 files changed, 222 insertions(+), 9 deletions(-) create mode 100644 corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherOnBackEvents.kt create mode 100644 sample/src/main/kotlin/ru/ldralighieri/corbind/sample/core/extensions/Number+toPx.kt diff --git a/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackPresses.kt b/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackPresses.kt index 4b3ad8e1..6dd08a21 100644 --- a/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackPresses.kt +++ b/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackPresses.kt @@ -77,8 +77,8 @@ suspend fun OnBackPressedDispatcher.backPresses( * * ``` * launch { - * onBackPressedDispatcher.backPresses(lifecycleOwner = this) - * .consumeEach { /* handle onBackPressed event */ } + * onBackPressedDispatcher.backPresses(scope, lifecycleOwner = this) + * .consumeEach { /* handle back pressed event */ } * } * ``` * @@ -103,7 +103,7 @@ fun OnBackPressedDispatcher.backPresses( * * ``` * onBackPressedDispatcher.backPresses(lifecycleOwner = this) - * .onEach { /* handle onBackPressed event */ } + * .onEach { /* handle back pressed event */ } * .flowWithLifecycle(lifecycle) * .launchIn(lifecycleScope) // lifecycle-runtime-ktx * ``` diff --git a/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherOnBackEvents.kt b/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherOnBackEvents.kt new file mode 100644 index 00000000..b2a7b72b --- /dev/null +++ b/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherOnBackEvents.kt @@ -0,0 +1,171 @@ +/* + * Copyright 2023 Vladimir Raupov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ru.ldralighieri.corbind.activity + +import androidx.activity.BackEventCompat +import androidx.activity.OnBackPressedCallback +import androidx.activity.OnBackPressedDispatcher +import androidx.annotation.CheckResult +import androidx.lifecycle.LifecycleOwner +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.channels.ReceiveChannel +import kotlinx.coroutines.channels.actor +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.channelFlow +import kotlinx.coroutines.isActive +import ru.ldralighieri.corbind.internal.corbindReceiveChannel + +sealed interface OnBackEvent +data object OnBackPressed : OnBackEvent +data object OnBackCanceled : OnBackEvent +data class OnBackStarted(val backEvent: BackEventCompat) : OnBackEvent +data class OnBackProgressed(val backEvent: BackEventCompat) : OnBackEvent + +/** + * Perform an action on back events. + * + * @param scope Root coroutine scope + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + * @param capacity Capacity of the channel's buffer (no buffer by default) + * @param action An action to perform + */ +fun OnBackPressedDispatcher.backEvents( + scope: CoroutineScope, + lifecycleOwner: LifecycleOwner, + capacity: Int = Channel.RENDEZVOUS, + action: suspend (OnBackEvent) -> Unit +) { + val events = scope.actor(Dispatchers.Main.immediate, capacity) { + for (event in channel) action(event) + } + + val callback = callback(scope, events::trySend) + addCallback(lifecycleOwner, callback) + events.invokeOnClose { callback.remove() } +} + +/** + * Perform an action on back events, inside new [CoroutineScope]. + * + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + * @param capacity Capacity of the channel's buffer (no buffer by default) + * @param action An action to perform + */ +suspend fun OnBackPressedDispatcher.backEvents( + lifecycleOwner: LifecycleOwner, + capacity: Int = Channel.RENDEZVOUS, + action: suspend (OnBackEvent) -> Unit +) = coroutineScope { + backEvents(this, lifecycleOwner, capacity, action) +} + +/** + * Create a channel which emit back events. + * + * Example: + * + * ``` + * launch { + * onBackPressedDispatcher.backEvents(scope, lifecycleOwner = this) + * .consumeEach { event -> + * when (event) { + * is OnBackPressed -> { /* handle back pressed event */ } + * is OnBackCanceled -> { /* handle back cancel event */ } + * is OnBackStarted -> { /* handle back started event */ } + * is OnBackProgressed -> { /* handle back progressed event */ } + * } + * } + * } + * + * // handle one event + * launch { + * tabLayout.backEvents(scope, lifecycleOwner = this) + * .filterIsInstance() + * .consumeEach { /* handle back progressed event */ } + * } + * ``` + * + * @param scope Root coroutine scope + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + * @param capacity Capacity of the channel's buffer (no buffer by default) + */ +fun OnBackPressedDispatcher.backEvents( + scope: CoroutineScope, + lifecycleOwner: LifecycleOwner, + capacity: Int = Channel.RENDEZVOUS +): ReceiveChannel = corbindReceiveChannel(capacity) { + val callback = callback(scope, ::trySend) + addCallback(lifecycleOwner, callback) + invokeOnClose { callback.remove() } +} + +/** + * Create a flow which emit back events. + * + * Example: + * + * ``` + * onBackPressedDispatcher.backEvents(lifecycleOwner = this) + * .onEach { event -> + * when (event) { + * is OnBackPressed -> { /* handle back pressed event */ } + * is OnBackCanceled -> { /* handle back cancel event */ } + * is OnBackStarted -> { /* handle back started event */ } + * is OnBackProgressed -> { /* handle back progressed event */ } + * } + * } + * .flowWithLifecycle(lifecycle) + * .launchIn(lifecycleScope) // lifecycle-runtime-ktx + * ``` + * + * // handle one event + * onBackPressedDispatcher.backEvents(lifecycleOwner = this) + * .filterIsInstance() + * .onEach { /* handle back progressed event */ } + * .flowWithLifecycle(lifecycle) + * .launchIn(lifecycleScope) // lifecycle-runtime-ktx + * ``` + * + * @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked + */ +fun OnBackPressedDispatcher.backEvents(lifecycleOwner: LifecycleOwner): Flow = + channelFlow { + val callback = callback(this, ::trySend) + addCallback(lifecycleOwner, callback) + awaitClose { callback.remove() } + } + +@CheckResult +private fun callback( + scope: CoroutineScope, + emitter: (OnBackEvent) -> Unit +) = object : OnBackPressedCallback(true) { + + override fun handleOnBackPressed() = onEvent(OnBackPressed) + override fun handleOnBackCancelled() = onEvent(OnBackCanceled) + override fun handleOnBackStarted(backEvent: BackEventCompat) = onEvent(OnBackStarted(backEvent)) + override fun handleOnBackProgressed(backEvent: BackEventCompat) = + onEvent(OnBackProgressed(backEvent)) + + private fun onEvent(event: OnBackEvent) { + if (scope.isActive) { emitter(event) } + } +} diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 6d61e8ea..9566534f 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -79,6 +79,7 @@ android { dependencies { implementation(projects.corbindSwiperefreshlayout) + implementation(projects.corbindActivity) implementation(libs.androidx.appcompat) implementation(libs.androidx.lifecycle.runtime.ktx) diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index 5f292616..e82266d3 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -23,7 +23,9 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.Corbind" - tools:ignore="GoogleAppIndexingWarning"> + android:enableOnBackInvokedCallback="true" + tools:ignore="GoogleAppIndexingWarning" + tools:targetApi="tiramisu"> + when { + event is OnBackPressed -> finish() + event is OnBackProgressed -> { + with (event) { + val direction: Int = + if (backEvent.swipeEdge == BackEventCompat.EDGE_LEFT) 1 + else -1 + + tvTitle.translationX = + direction * transitionXThresholdPx * backEvent.progress + } + } + } + } + .launchIn(this) } } } diff --git a/sample/src/main/kotlin/ru/ldralighieri/corbind/sample/core/extensions/Number+toPx.kt b/sample/src/main/kotlin/ru/ldralighieri/corbind/sample/core/extensions/Number+toPx.kt new file mode 100644 index 00000000..145aa200 --- /dev/null +++ b/sample/src/main/kotlin/ru/ldralighieri/corbind/sample/core/extensions/Number+toPx.kt @@ -0,0 +1,10 @@ +package ru.ldralighieri.corbind.sample.core.extensions + +import android.content.res.Resources +import android.util.TypedValue + +val Number.toPx get() = TypedValue.applyDimension( + /* unit = */ TypedValue.COMPLEX_UNIT_DIP, + /* value = */ toFloat(), + /* metrics = */ Resources.getSystem().displayMetrics +) \ No newline at end of file diff --git a/sample/src/main/res/layout/activity_login.xml b/sample/src/main/res/layout/activity_login.xml index 107765d6..a243090d 100644 --- a/sample/src/main/res/layout/activity_login.xml +++ b/sample/src/main/res/layout/activity_login.xml @@ -73,17 +73,17 @@ From 20fc756f3e2980934c09a3a9c0b3068e534408b4 Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sun, 8 Oct 2023 22:18:30 +0300 Subject: [PATCH 11/13] sealed class -> sealed interface --- corbind-activity/README.md | 21 ++++++++++++++----- .../SearchBarSearchQueryChangeEvents.kt | 12 +++++------ .../material/TabLayoutSelectionEvents.kt | 12 +++++------ ...ecyclerViewChildAttachStateChangeEvents.kt | 10 ++++----- .../corbind/view/MenuItemActionViewEvents.kt | 8 +++---- .../corbind/view/ViewAttachEvents.kt | 8 +++---- .../view/ViewGroupHierarchyChangeEvents.kt | 10 ++++----- .../widget/AdapterViewSelectionEvents.kt | 8 +++---- .../corbind/widget/SeekBarChangeEvents.kt | 10 ++++----- gradle/libs.versions.toml | 2 +- 10 files changed, 56 insertions(+), 45 deletions(-) diff --git a/corbind-activity/README.md b/corbind-activity/README.md index 358ee811..584537e9 100644 --- a/corbind-activity/README.md +++ b/corbind-activity/README.md @@ -13,18 +13,29 @@ dependencies { Component | Extension | Description --|---|-- -**OnBackPressedDispatcher** | [`backPresses`][OnBackPressedDispatcher_backPresses] | Called when OnBackPressedDispatcher.onBackPressed triggered. +**OnBackPressedDispatcher** | [`backPresses`][OnBackPressedDispatcher_backPresses] | Called when OnBackPressedDispatcher.onBackPressed triggered. OnBackPressed events only +**OnBackPressedDispatcher** | [`backProgressed`][OnBackPressedDispatcher_backProgressed] | Called when OnBackPressedDispatcher.dispatchOnBackProgressed triggered. OnBackProgressed event only +**OnBackPressedDispatcher** | [`backEvents`][OnBackPressedDispatcher_backEvents] | Called when any callback event triggered. All events ## Simple examples ```kotlin -onBackPressedDispatcher.backPresses(lifecycleOwner = this) // Flow - .onEach { /* handle onBackPressed event */ } - .flowWithLifecycle(lifecycle) - .launchIn(lifecycleScope) // lifecycle-runtime-ktx +onBackPressedDispatcher.backEvents(lifecycleOwner = this) + .onEach { event -> + when (event) { + is OnBackPressed -> { /* handle back pressed event */ } + is OnBackCanceled -> { /* handle back cancel event */ } + is OnBackStarted -> { /* handle back started event */ } + is OnBackProgressed -> { /* handle back progressed event */ } + } + } + .flowWithLifecycle(lifecycle) + .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` More examples in source code [OnBackPressedDispatcher_backPresses]: https://github.com/LDRAlighieri/Corbind/blob/master/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackPresses.kt +[OnBackPressedDispatcher_backProgressed]: https://github.com/LDRAlighieri/Corbind/blob/master/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackProgressed.kt +[OnBackPressedDispatcher_backEvents]: https://github.com/LDRAlighieri/Corbind/blob/master/corbind-activity/src/main/kotlin/ru/ldralighieri/corbind/activity/OnBackPressedDispatcherOnBackEvents.kt diff --git a/corbind-leanback/src/main/kotlin/ru/ldralighieri/corbind/leanback/SearchBarSearchQueryChangeEvents.kt b/corbind-leanback/src/main/kotlin/ru/ldralighieri/corbind/leanback/SearchBarSearchQueryChangeEvents.kt index da4c6080..36ce4a7b 100644 --- a/corbind-leanback/src/main/kotlin/ru/ldralighieri/corbind/leanback/SearchBarSearchQueryChangeEvents.kt +++ b/corbind-leanback/src/main/kotlin/ru/ldralighieri/corbind/leanback/SearchBarSearchQueryChangeEvents.kt @@ -30,25 +30,25 @@ import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.isActive import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class SearchBarSearchQueryEvent { - abstract val view: SearchBar - abstract val searchQuery: String +sealed interface SearchBarSearchQueryEvent { + val view: SearchBar + val searchQuery: String } data class SearchBarSearchQueryChangedEvent( override val view: SearchBar, override val searchQuery: String -) : SearchBarSearchQueryEvent() +) : SearchBarSearchQueryEvent data class SearchBarSearchQueryKeyboardDismissedEvent( override val view: SearchBar, override val searchQuery: String -) : SearchBarSearchQueryEvent() +) : SearchBarSearchQueryEvent data class SearchBarSearchQuerySubmittedEvent( override val view: SearchBar, override val searchQuery: String -) : SearchBarSearchQueryEvent() +) : SearchBarSearchQueryEvent /** * Perform an action on [search query events][SearchBarSearchQueryEvent] on [SearchBar]. diff --git a/corbind-material/src/main/kotlin/ru/ldralighieri/corbind/material/TabLayoutSelectionEvents.kt b/corbind-material/src/main/kotlin/ru/ldralighieri/corbind/material/TabLayoutSelectionEvents.kt index b24c6de1..97e0849c 100644 --- a/corbind-material/src/main/kotlin/ru/ldralighieri/corbind/material/TabLayoutSelectionEvents.kt +++ b/corbind-material/src/main/kotlin/ru/ldralighieri/corbind/material/TabLayoutSelectionEvents.kt @@ -30,25 +30,25 @@ import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.isActive import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class TabLayoutSelectionEvent { - abstract val view: TabLayout - abstract val tab: TabLayout.Tab +sealed interface TabLayoutSelectionEvent { + val view: TabLayout + val tab: TabLayout.Tab } data class TabLayoutSelectionSelectedEvent( override val view: TabLayout, override val tab: TabLayout.Tab -) : TabLayoutSelectionEvent() +) : TabLayoutSelectionEvent data class TabLayoutSelectionReselectedEvent( override val view: TabLayout, override val tab: TabLayout.Tab -) : TabLayoutSelectionEvent() +) : TabLayoutSelectionEvent data class TabLayoutSelectionUnselectedEvent( override val view: TabLayout, override val tab: TabLayout.Tab -) : TabLayoutSelectionEvent() +) : TabLayoutSelectionEvent /** * Perform an action on selection, reselection, and unselection [events][TabLayoutSelectionEvent] diff --git a/corbind-recyclerview/src/main/kotlin/ru/ldralighieri/corbind/recyclerview/RecyclerViewChildAttachStateChangeEvents.kt b/corbind-recyclerview/src/main/kotlin/ru/ldralighieri/corbind/recyclerview/RecyclerViewChildAttachStateChangeEvents.kt index 7553007a..f245c603 100644 --- a/corbind-recyclerview/src/main/kotlin/ru/ldralighieri/corbind/recyclerview/RecyclerViewChildAttachStateChangeEvents.kt +++ b/corbind-recyclerview/src/main/kotlin/ru/ldralighieri/corbind/recyclerview/RecyclerViewChildAttachStateChangeEvents.kt @@ -31,20 +31,20 @@ import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.isActive import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class RecyclerViewChildAttachStateChangeEvent { - abstract val view: RecyclerView - abstract val child: View +sealed interface RecyclerViewChildAttachStateChangeEvent { + val view: RecyclerView + val child: View } data class RecyclerViewChildAttachEvent( override val view: RecyclerView, override val child: View -) : RecyclerViewChildAttachStateChangeEvent() +) : RecyclerViewChildAttachStateChangeEvent data class RecyclerViewChildDetachEvent( override val view: RecyclerView, override val child: View -) : RecyclerViewChildAttachStateChangeEvent() +) : RecyclerViewChildAttachStateChangeEvent /** * Perform an action on [child attach state change events][RecyclerViewChildAttachStateChangeEvent] diff --git a/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/MenuItemActionViewEvents.kt b/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/MenuItemActionViewEvents.kt index fb5166d0..acb6c1b7 100644 --- a/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/MenuItemActionViewEvents.kt +++ b/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/MenuItemActionViewEvents.kt @@ -31,17 +31,17 @@ import kotlinx.coroutines.isActive import ru.ldralighieri.corbind.internal.AlwaysTrue import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class MenuItemActionViewEvent { - abstract val menuItem: MenuItem +sealed interface MenuItemActionViewEvent { + val menuItem: MenuItem } data class MenuItemActionViewCollapseEvent( override val menuItem: MenuItem -) : MenuItemActionViewEvent() +) : MenuItemActionViewEvent data class MenuItemActionViewExpandEvent( override val menuItem: MenuItem -) : MenuItemActionViewEvent() +) : MenuItemActionViewEvent /** * Perform an action on [action view events][MenuItemActionViewEvent] for [MenuItem]. diff --git a/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewAttachEvents.kt b/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewAttachEvents.kt index 9d0eee12..1e4aae38 100644 --- a/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewAttachEvents.kt +++ b/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewAttachEvents.kt @@ -30,17 +30,17 @@ import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.isActive import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class ViewAttachEvent { - abstract val view: View +sealed interface ViewAttachEvent { + val view: View } data class ViewAttachAttachedEvent( override val view: View -) : ViewAttachEvent() +) : ViewAttachEvent data class ViewAttachDetachedEvent( override val view: View -) : ViewAttachEvent() +) : ViewAttachEvent /** * Perform an action on [attach and detach events][ViewAttachEvent] on [View]. diff --git a/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewGroupHierarchyChangeEvents.kt b/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewGroupHierarchyChangeEvents.kt index 3471cbcf..53764381 100644 --- a/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewGroupHierarchyChangeEvents.kt +++ b/corbind/src/main/kotlin/ru/ldralighieri/corbind/view/ViewGroupHierarchyChangeEvents.kt @@ -31,20 +31,20 @@ import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.isActive import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class ViewGroupHierarchyChangeEvent { - abstract val view: ViewGroup - abstract val child: View +sealed interface ViewGroupHierarchyChangeEvent { + val view: ViewGroup + val child: View } data class ViewGroupHierarchyChildViewAddEvent( override val view: ViewGroup, override val child: View -) : ViewGroupHierarchyChangeEvent() +) : ViewGroupHierarchyChangeEvent data class ViewGroupHierarchyChildViewRemoveEvent( override val view: ViewGroup, override val child: View -) : ViewGroupHierarchyChangeEvent() +) : ViewGroupHierarchyChangeEvent /** * Perform an action on [hierarchy change events][ViewGroupHierarchyChangeEvent] for [ViewGroup]. diff --git a/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/AdapterViewSelectionEvents.kt b/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/AdapterViewSelectionEvents.kt index 78b67adf..6425f344 100644 --- a/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/AdapterViewSelectionEvents.kt +++ b/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/AdapterViewSelectionEvents.kt @@ -33,8 +33,8 @@ import ru.ldralighieri.corbind.internal.InitialValueFlow import ru.ldralighieri.corbind.internal.asInitialValueFlow import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class AdapterViewSelectionEvent { - abstract val view: AdapterView<*> +sealed interface AdapterViewSelectionEvent { + val view: AdapterView<*> } data class AdapterViewItemSelectionEvent( @@ -42,11 +42,11 @@ data class AdapterViewItemSelectionEvent( val selectedView: View?, val position: Int, val id: Long -) : AdapterViewSelectionEvent() +) : AdapterViewSelectionEvent data class AdapterViewNothingSelectionEvent( override val view: AdapterView<*> -) : AdapterViewSelectionEvent() +) : AdapterViewSelectionEvent /** * Perform an action on [selection events][AdapterViewSelectionEvent] for [AdapterView]. diff --git a/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/SeekBarChangeEvents.kt b/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/SeekBarChangeEvents.kt index 759cb908..45d76473 100644 --- a/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/SeekBarChangeEvents.kt +++ b/corbind/src/main/kotlin/ru/ldralighieri/corbind/widget/SeekBarChangeEvents.kt @@ -31,23 +31,23 @@ import ru.ldralighieri.corbind.internal.InitialValueFlow import ru.ldralighieri.corbind.internal.asInitialValueFlow import ru.ldralighieri.corbind.internal.corbindReceiveChannel -sealed class SeekBarChangeEvent { - abstract val view: SeekBar +sealed interface SeekBarChangeEvent { + val view: SeekBar } data class SeekBarProgressChangeEvent( override val view: SeekBar, val progress: Int, val fromUser: Boolean -) : SeekBarChangeEvent() +) : SeekBarChangeEvent data class SeekBarStartChangeEvent( override val view: SeekBar -) : SeekBarChangeEvent() +) : SeekBarChangeEvent data class SeekBarStopChangeEvent( override val view: SeekBar -) : SeekBarChangeEvent() +) : SeekBarChangeEvent /** * Perform an action on [change events][SeekBarChangeEvent] for [SeekBar]. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f4725d76..74c9e89c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ dokka = "1.9.0" spotless = "6.22.0" mavenPublish = "0.25.3" bcv = "0.13.2" -gver = "0.48.0" +gver = "0.49.0" # Kotlin kotlin = "1.9.10" From 0490bb767829380fca391ddcbba35a2871926a3f Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Sun, 8 Oct 2023 22:59:45 +0300 Subject: [PATCH 12/13] Run apiDump --- corbind-activity/api/corbind-activity.api | 59 +++++++++++++++++++ corbind-leanback/api/corbind-leanback.api | 2 +- corbind-material/api/corbind-material.api | 3 +- .../api/corbind-recyclerview.api | 2 +- corbind/api/corbind.api | 10 ++-- 5 files changed, 68 insertions(+), 8 deletions(-) diff --git a/corbind-activity/api/corbind-activity.api b/corbind-activity/api/corbind-activity.api index d9a7c90d..02418eaf 100644 --- a/corbind-activity/api/corbind-activity.api +++ b/corbind-activity/api/corbind-activity.api @@ -1,3 +1,20 @@ +public final class ru/ldralighieri/corbind/activity/OnBackCanceled : ru/ldralighieri/corbind/activity/OnBackEvent { + public static final field INSTANCE Lru/ldralighieri/corbind/activity/OnBackCanceled; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public abstract interface class ru/ldralighieri/corbind/activity/OnBackEvent { +} + +public final class ru/ldralighieri/corbind/activity/OnBackPressed : ru/ldralighieri/corbind/activity/OnBackEvent { + public static final field INSTANCE Lru/ldralighieri/corbind/activity/OnBackPressed; + public fun equals (Ljava/lang/Object;)Z + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + public final class ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackPressesKt { public static final fun backPresses (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;)Lkotlinx/coroutines/flow/Flow; public static final fun backPresses (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; @@ -8,3 +25,45 @@ public final class ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackP public static synthetic fun backPresses$default (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function1;ILjava/lang/Object;)V } +public final class ru/ldralighieri/corbind/activity/OnBackPressedDispatcherBackProgressedKt { + public static final fun backProgressed (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;)Lkotlinx/coroutines/flow/Flow; + public static final fun backProgressed (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun backProgressed (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;I)Lkotlinx/coroutines/channels/ReceiveChannel; + public static final fun backProgressed (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;)V + public static synthetic fun backProgressed$default (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun backProgressed$default (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;IILjava/lang/Object;)Lkotlinx/coroutines/channels/ReceiveChannel; + public static synthetic fun backProgressed$default (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;ILjava/lang/Object;)V +} + +public final class ru/ldralighieri/corbind/activity/OnBackPressedDispatcherOnBackEventsKt { + public static final fun backEvents (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;)Lkotlinx/coroutines/flow/Flow; + public static final fun backEvents (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static final fun backEvents (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;I)Lkotlinx/coroutines/channels/ReceiveChannel; + public static final fun backEvents (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;)V + public static synthetic fun backEvents$default (Landroidx/activity/OnBackPressedDispatcher;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static synthetic fun backEvents$default (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;IILjava/lang/Object;)Lkotlinx/coroutines/channels/ReceiveChannel; + public static synthetic fun backEvents$default (Landroidx/activity/OnBackPressedDispatcher;Lkotlinx/coroutines/CoroutineScope;Landroidx/lifecycle/LifecycleOwner;ILkotlin/jvm/functions/Function2;ILjava/lang/Object;)V +} + +public final class ru/ldralighieri/corbind/activity/OnBackProgressed : ru/ldralighieri/corbind/activity/OnBackEvent { + public fun (Landroidx/activity/BackEventCompat;)V + public final fun component1 ()Landroidx/activity/BackEventCompat; + public final fun copy (Landroidx/activity/BackEventCompat;)Lru/ldralighieri/corbind/activity/OnBackProgressed; + public static synthetic fun copy$default (Lru/ldralighieri/corbind/activity/OnBackProgressed;Landroidx/activity/BackEventCompat;ILjava/lang/Object;)Lru/ldralighieri/corbind/activity/OnBackProgressed; + public fun equals (Ljava/lang/Object;)Z + public final fun getBackEvent ()Landroidx/activity/BackEventCompat; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + +public final class ru/ldralighieri/corbind/activity/OnBackStarted : ru/ldralighieri/corbind/activity/OnBackEvent { + public fun (Landroidx/activity/BackEventCompat;)V + public final fun component1 ()Landroidx/activity/BackEventCompat; + public final fun copy (Landroidx/activity/BackEventCompat;)Lru/ldralighieri/corbind/activity/OnBackStarted; + public static synthetic fun copy$default (Lru/ldralighieri/corbind/activity/OnBackStarted;Landroidx/activity/BackEventCompat;ILjava/lang/Object;)Lru/ldralighieri/corbind/activity/OnBackStarted; + public fun equals (Ljava/lang/Object;)Z + public final fun getBackEvent ()Landroidx/activity/BackEventCompat; + public fun hashCode ()I + public fun toString ()Ljava/lang/String; +} + diff --git a/corbind-leanback/api/corbind-leanback.api b/corbind-leanback/api/corbind-leanback.api index ac5b9bf0..ac78917a 100644 --- a/corbind-leanback/api/corbind-leanback.api +++ b/corbind-leanback/api/corbind-leanback.api @@ -31,7 +31,7 @@ public final class ru/ldralighieri/corbind/leanback/SearchBarSearchQueryChangesK public static synthetic fun searchQueryChanges$default (Landroidx/leanback/widget/SearchBar;Lkotlinx/coroutines/CoroutineScope;ILkotlin/jvm/functions/Function2;ILjava/lang/Object;)V } -public abstract class ru/ldralighieri/corbind/leanback/SearchBarSearchQueryEvent { +public abstract interface class ru/ldralighieri/corbind/leanback/SearchBarSearchQueryEvent { public abstract fun getSearchQuery ()Ljava/lang/String; public abstract fun getView ()Landroidx/leanback/widget/SearchBar; } diff --git a/corbind-material/api/corbind-material.api b/corbind-material/api/corbind-material.api index 8a8b5445..f8445c95 100644 --- a/corbind-material/api/corbind-material.api +++ b/corbind-material/api/corbind-material.api @@ -254,6 +254,7 @@ public final class ru/ldralighieri/corbind/material/RangeSliderSide : java/lang/ public static final field INIT Lru/ldralighieri/corbind/material/RangeSliderSide; public static final field LEFT Lru/ldralighieri/corbind/material/RangeSliderSide; public static final field RIGHT Lru/ldralighieri/corbind/material/RangeSliderSide; + public static fun getEntries ()Lkotlin/enums/EnumEntries; public static fun valueOf (Ljava/lang/String;)Lru/ldralighieri/corbind/material/RangeSliderSide; public static fun values ()[Lru/ldralighieri/corbind/material/RangeSliderSide; } @@ -440,7 +441,7 @@ public final class ru/ldralighieri/corbind/material/SwipeDismissBehaviorDragStat public static synthetic fun dragStateChanges$default (Landroid/view/View;Lkotlinx/coroutines/CoroutineScope;ILkotlin/jvm/functions/Function2;ILjava/lang/Object;)V } -public abstract class ru/ldralighieri/corbind/material/TabLayoutSelectionEvent { +public abstract interface class ru/ldralighieri/corbind/material/TabLayoutSelectionEvent { public abstract fun getTab ()Lcom/google/android/material/tabs/TabLayout$Tab; public abstract fun getView ()Lcom/google/android/material/tabs/TabLayout; } diff --git a/corbind-recyclerview/api/corbind-recyclerview.api b/corbind-recyclerview/api/corbind-recyclerview.api index 58c84038..27660bb1 100644 --- a/corbind-recyclerview/api/corbind-recyclerview.api +++ b/corbind-recyclerview/api/corbind-recyclerview.api @@ -21,7 +21,7 @@ public final class ru/ldralighieri/corbind/recyclerview/RecyclerViewChildAttachE public fun toString ()Ljava/lang/String; } -public abstract class ru/ldralighieri/corbind/recyclerview/RecyclerViewChildAttachStateChangeEvent { +public abstract interface class ru/ldralighieri/corbind/recyclerview/RecyclerViewChildAttachStateChangeEvent { public abstract fun getChild ()Landroid/view/View; public abstract fun getView ()Landroidx/recyclerview/widget/RecyclerView; } diff --git a/corbind/api/corbind.api b/corbind/api/corbind.api index 827b1cac..9a51bf65 100644 --- a/corbind/api/corbind.api +++ b/corbind/api/corbind.api @@ -46,7 +46,7 @@ public final class ru/ldralighieri/corbind/view/MenuItemActionViewCollapseEvent public fun toString ()Ljava/lang/String; } -public abstract class ru/ldralighieri/corbind/view/MenuItemActionViewEvent { +public abstract interface class ru/ldralighieri/corbind/view/MenuItemActionViewEvent { public abstract fun getMenuItem ()Landroid/view/MenuItem; } @@ -105,7 +105,7 @@ public final class ru/ldralighieri/corbind/view/ViewAttachDetachedEvent : ru/ldr public fun toString ()Ljava/lang/String; } -public abstract class ru/ldralighieri/corbind/view/ViewAttachEvent { +public abstract interface class ru/ldralighieri/corbind/view/ViewAttachEvent { public abstract fun getView ()Landroid/view/View; } @@ -167,7 +167,7 @@ public final class ru/ldralighieri/corbind/view/ViewFocusChangesKt { public static synthetic fun focusChanges$default (Landroid/view/View;Lkotlinx/coroutines/CoroutineScope;ILkotlin/jvm/functions/Function2;ILjava/lang/Object;)V } -public abstract class ru/ldralighieri/corbind/view/ViewGroupHierarchyChangeEvent { +public abstract interface class ru/ldralighieri/corbind/view/ViewGroupHierarchyChangeEvent { public abstract fun getChild ()Landroid/view/View; public abstract fun getView ()Landroid/view/ViewGroup; } @@ -544,7 +544,7 @@ public final class ru/ldralighieri/corbind/widget/AdapterViewNothingSelectionEve public fun toString ()Ljava/lang/String; } -public abstract class ru/ldralighieri/corbind/widget/AdapterViewSelectionEvent { +public abstract interface class ru/ldralighieri/corbind/widget/AdapterViewSelectionEvent { public abstract fun getView ()Landroid/widget/AdapterView; } @@ -777,7 +777,7 @@ public final class ru/ldralighieri/corbind/widget/SearchViewQueryTextEvent { public fun toString ()Ljava/lang/String; } -public abstract class ru/ldralighieri/corbind/widget/SeekBarChangeEvent { +public abstract interface class ru/ldralighieri/corbind/widget/SeekBarChangeEvent { public abstract fun getView ()Landroid/widget/SeekBar; } From 9360f912fe09a4a1302a406267972c31e4d4cb9c Mon Sep 17 00:00:00 2001 From: Vladimir Raupov Date: Mon, 9 Oct 2023 00:06:39 +0300 Subject: [PATCH 13/13] Updated README.md of each module and CHANGELOG.md for version 1.9.0 --- CHANGELOG.md | 14 ++++++++++++ README.md | 34 ++++++++++++++-------------- corbind-activity/README.md | 2 +- corbind-appcompat/README.md | 2 +- corbind-core/README.md | 2 +- corbind-drawerlayout/README.md | 2 +- corbind-fragment/README.md | 2 +- corbind-leanback/README.md | 2 +- corbind-lifecycle/README.md | 2 +- corbind-material/README.md | 2 +- corbind-navigation/README.md | 2 +- corbind-recyclerview/README.md | 2 +- corbind-slidingpanelayout/README.md | 2 +- corbind-swiperefreshlayout/README.md | 2 +- corbind-viewpager/README.md | 2 +- corbind-viewpager2/README.md | 2 +- corbind/README.md | 2 +- gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- 19 files changed, 48 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2cbaae9..ee39ea5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,20 @@ # ChangeLog +## Version 1.9.0 + +* New: Bindings list: + * AndroidX library bindings: + * `corbind-activity`: + * `OnBackPressedDispatcher`: + * `backProgressed` + * `backEvents` +* Update: Kotlin to v1.9.10. +* Update: Kotlin coroutines to v1.7.3. +* Update: Material components to v1.10.0. +* Update: Minor update of other libraries. + + ## Version 1.8.0 * New: Bindings list: diff --git a/README.md b/README.md index c7b885bc..9e37f89e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ [![Corbind](logo.svg)](https://ldralighieri.github.io/Corbind) [![Maven Central](https://img.shields.io/maven-central/v/ru.ldralighieri.corbind/corbind.svg)](https://search.maven.org/search?q=g:ru.ldralighieri.corbind) -[![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.8.21-blue.svg?logo=kotlin)](https://kotlinlang.org) -[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.7.0-blue.svg)](https://kotlinlang.org/docs/reference/coroutines-overview.html) +[![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.9.10-blue.svg?logo=kotlin)](https://kotlinlang.org) +[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.7.3-blue.svg)](https://kotlinlang.org/docs/reference/coroutines-overview.html) [![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a1c9a1b1d1ce4ca7a201ab93492bf6e0)](https://app.codacy.com/gh/LDRAlighieri/Corbind) @@ -28,33 +28,33 @@ Please consider giving this repository a star ⭐ if you like the project. Platform bindings: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind:1.8.0") + implementation("ru.ldralighieri.corbind:corbind:1.9.0") } ``` AndroidX library bindings: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-activity:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-appcompat:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-core:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-drawerlayout:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-fragment:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-leanback:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-lifecycle:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-navigation:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-recyclerview:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-slidingpanelayout:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-viewpager:1.8.0") - implementation("ru.ldralighieri.corbind:corbind-viewpager2:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-activity:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-appcompat:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-core:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-drawerlayout:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-fragment:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-leanback:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-lifecycle:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-navigation:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-recyclerview:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-slidingpanelayout:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-viewpager:1.9.0") + implementation("ru.ldralighieri.corbind:corbind-viewpager2:1.9.0") } ``` Google 'material' library bindings: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-material:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-material:1.9.0") } ``` diff --git a/corbind-activity/README.md b/corbind-activity/README.md index 584537e9..5a124e99 100644 --- a/corbind-activity/README.md +++ b/corbind-activity/README.md @@ -5,7 +5,7 @@ To add androidx activity bindings, import `corbind-activity` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-activity:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-activity:1.9.0") } ``` diff --git a/corbind-appcompat/README.md b/corbind-appcompat/README.md index 0377ef6b..22ad222f 100644 --- a/corbind-appcompat/README.md +++ b/corbind-appcompat/README.md @@ -5,7 +5,7 @@ To add androidx appcompat bindings, import `corbind-appcompat` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-appcompat:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-appcompat:1.9.0") } ``` diff --git a/corbind-core/README.md b/corbind-core/README.md index c28f9e48..19697fd8 100644 --- a/corbind-core/README.md +++ b/corbind-core/README.md @@ -5,7 +5,7 @@ To add androidx core bindings, import `corbind-core` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-core:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-core:1.9.0") } ``` diff --git a/corbind-drawerlayout/README.md b/corbind-drawerlayout/README.md index d587f94e..fa06fc0a 100644 --- a/corbind-drawerlayout/README.md +++ b/corbind-drawerlayout/README.md @@ -5,7 +5,7 @@ To add androidx drawerlayout bindings, import `corbind-drawerlayout` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-drawerlayout:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-drawerlayout:1.9.0") } ``` diff --git a/corbind-fragment/README.md b/corbind-fragment/README.md index c39b5ab0..c485959b 100644 --- a/corbind-fragment/README.md +++ b/corbind-fragment/README.md @@ -5,7 +5,7 @@ To add androidx fragment bindings, import `corbind-fragment` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-fragment:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-fragment:1.9.0") } ``` diff --git a/corbind-leanback/README.md b/corbind-leanback/README.md index 6dd70804..29457648 100644 --- a/corbind-leanback/README.md +++ b/corbind-leanback/README.md @@ -5,7 +5,7 @@ To add androidx leanback bindings, import `corbind-leanback` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-leanback:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-leanback:1.9.0") } ``` diff --git a/corbind-lifecycle/README.md b/corbind-lifecycle/README.md index ce48032d..ea494a7b 100644 --- a/corbind-lifecycle/README.md +++ b/corbind-lifecycle/README.md @@ -5,7 +5,7 @@ To add androidx lifecycle bindings, import `corbind-lifecycle` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-lifecycle:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-lifecycle:1.9.0") } ``` diff --git a/corbind-material/README.md b/corbind-material/README.md index bf9971a7..7f0586ff 100644 --- a/corbind-material/README.md +++ b/corbind-material/README.md @@ -5,7 +5,7 @@ To add material bindings, import `corbind-material` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-material:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-material:1.9.0") } ``` diff --git a/corbind-navigation/README.md b/corbind-navigation/README.md index d05e476e..e5c1a5c6 100644 --- a/corbind-navigation/README.md +++ b/corbind-navigation/README.md @@ -5,7 +5,7 @@ To add androidx navigation bindings, import `corbind-navigation` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-navigation:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-navigation:1.9.0") } ``` diff --git a/corbind-recyclerview/README.md b/corbind-recyclerview/README.md index 4983218f..d470c9b4 100644 --- a/corbind-recyclerview/README.md +++ b/corbind-recyclerview/README.md @@ -5,7 +5,7 @@ To add androidx recyclerview bindings, import `corbind-recyclerview` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-recyclerview:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-recyclerview:1.9.0") } ``` diff --git a/corbind-slidingpanelayout/README.md b/corbind-slidingpanelayout/README.md index e90611d9..fbf6f37e 100644 --- a/corbind-slidingpanelayout/README.md +++ b/corbind-slidingpanelayout/README.md @@ -5,7 +5,7 @@ To add androidx slidingpanelayout bindings, import `corbind-slidingpanelayout` m ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-slidingpanelayout:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-slidingpanelayout:1.9.0") } ``` diff --git a/corbind-swiperefreshlayout/README.md b/corbind-swiperefreshlayout/README.md index 358edb87..7f976c29 100644 --- a/corbind-swiperefreshlayout/README.md +++ b/corbind-swiperefreshlayout/README.md @@ -5,7 +5,7 @@ To add androidx swiperefreshlayout bindings, import `corbind-swiperefreshlayout` ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.9.0") } ``` diff --git a/corbind-viewpager/README.md b/corbind-viewpager/README.md index f64b40e1..57e39539 100644 --- a/corbind-viewpager/README.md +++ b/corbind-viewpager/README.md @@ -5,7 +5,7 @@ To add androidx viewpager bindings, import `corbind-viewpager` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-viewpager:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-viewpager:1.9.0") } ``` diff --git a/corbind-viewpager2/README.md b/corbind-viewpager2/README.md index 7f4b22a2..60e1f3cc 100644 --- a/corbind-viewpager2/README.md +++ b/corbind-viewpager2/README.md @@ -5,7 +5,7 @@ To add androidx viewpager2 bindings, import `corbind-viewpager2` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind-viewpager2:1.8.0") + implementation("ru.ldralighieri.corbind:corbind-viewpager2:1.9.0") } ``` diff --git a/corbind/README.md b/corbind/README.md index 4d3547d2..69907c50 100644 --- a/corbind/README.md +++ b/corbind/README.md @@ -5,7 +5,7 @@ To add platform bindings, import `corbind` module: ```kotlin dependencies { - implementation("ru.ldralighieri.corbind:corbind:1.8.0") + implementation("ru.ldralighieri.corbind:corbind:1.9.0") } ``` diff --git a/gradle.properties b/gradle.properties index 913315fb..95f77c7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ systemProp.org.gradle.internal.http.socketTimeout=120000 # Maven GROUP=ru.ldralighieri.corbind -VERSION_NAME=1.9.0-SNAPSHOT +VERSION_NAME=1.9.0 POM_DESCRIPTION=Kotlin Coroutines binding APIs for Android UI widgets from the platform and support libraries. diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 74c9e89c..653a9634 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ # Plugins agp = "8.1.2" dokka = "1.9.0" -spotless = "6.22.0" +spotless = "6.18.0" mavenPublish = "0.25.3" bcv = "0.13.2" gver = "0.49.0"