Skip to content

Commit

Permalink
Merge branch 'update/material-1.7.0' into develop
Browse files Browse the repository at this point in the history
LDRAlighieri committed Oct 20, 2022
2 parents eb07768 + 4bfa78c commit 0f474e3
Showing 61 changed files with 472 additions and 110 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,19 @@
# ChangeLog


## Version 1.6.0

* New: Fragment module
* New: Bindings list:
* AndroidX library bindings:
* `corbind-fragment`:
* `FragmentManager`:
* `resultEvents`
* Update: Kotlin modules dependency to v1.7.20.
* Update: Material components dependency to v1.7.0.
* Update: Minor update of other libraries.


## Version 1.5.5

* New: Build logic module.
33 changes: 17 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![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.7.10-blue.svg)](https://kotlinlang.org)
[![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.7.20-blue.svg)](https://kotlinlang.org)
[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.6.4-blue.svg)](https://kotlinlang.org/docs/reference/coroutines-overview.html)
[![GitHub license](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](https://www.apache.org/licenses/LICENSE-2.0)

@@ -25,28 +25,29 @@ This library is for Android applications only. Help you to transform Android UI

Platform bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind:1.6.0'
```

AndroidX library bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-core:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-activity:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-core:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-fragment:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.6.0'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.6.0'
```

Google 'material' library bindings:
```groovy
implementation 'ru.ldralighieri.corbind:corbind-material:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-material:1.6.0'
```

Snapshot build:
@@ -56,7 +57,7 @@ repositories {
}
dependencies {
implementation 'ru.ldralighieri.corbind:{module}:1.5.6-SNAPSHOT'
implementation 'ru.ldralighieri.corbind:{module}:1.6.1-SNAPSHOT'
}
```

Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ import com.android.build.gradle.LibraryExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.provideDelegate
import ru.ldralighieri.corbind.configureKotlinAndroid

@Suppress("unused")
@@ -32,8 +33,10 @@ class LibraryConventionPlugin : Plugin<Project> {
}

extensions.configure<LibraryExtension> {
val targetSdk: String by project

configureKotlinAndroid(this)
defaultConfig.targetSdk = findProperty("android.targetSdk").toString().toInt()
defaultConfig.targetSdk = targetSdk.toInt()

buildTypes {
release {
Original file line number Diff line number Diff line change
@@ -22,16 +22,20 @@ 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.provideDelegate
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions

internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *>,
) {
val compileSdk: String by project
val minSdk: String by project

commonExtension.apply {
compileSdk = findProperty("android.compileSdk").toString().toInt()
this.compileSdk = compileSdk.toInt()

defaultConfig {
minSdk = findProperty("android.minSdk").toString().toInt()
this.minSdk = minSdk.toInt()
}

compileOptions {
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ detekt {
"corbind-appcompat/src/main/kotlin",
"corbind-core/src/main/kotlin",
"corbind-drawerlayout/src/main/kotlin",
"corbind-fragment/src/main/kotlin",
"corbind-leanback/src/main/kotlin",
"corbind-lifecycle/src/main/kotlin",
"corbind-material/src/main/kotlin",
@@ -65,8 +66,7 @@ tasks.withType<Detekt>().configureEach {

// Dependency updates
fun isNonStable(version: String): Boolean {
val stableKeyword = listOf("RELEASE", "FINAL")
.any { version.toUpperCase().contains(it) }
val stableKeyword = listOf("RELEASE", "FINAL").any { version.toUpperCase().contains(it) }
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
val isStable = stableKeyword || regex.matches(version)
return isStable.not()
4 changes: 2 additions & 2 deletions corbind-activity/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx activity bindings, import `corbind-activity` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-activity:1.6.0'
```

## List of extensions
@@ -17,7 +17,7 @@ Component | Extension | Description
## Simple examples

```kotlin
requireActivity().onBackPressedDispatcher.backPresses()
onBackPressedDispatcher.backPresses(lifecycleOwner = this)
.onEach { /* handle onBackPressed event */ }
.flowWithLifecycle(lifecycle)
.launchIn(lifecycleScope) // lifecycle-runtime-ktx
6 changes: 5 additions & 1 deletion corbind-activity/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.activity"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.activity)
}
2 changes: 1 addition & 1 deletion corbind-activity/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.activity" />
<manifest />
Original file line number Diff line number Diff line change
@@ -36,38 +36,38 @@ import ru.ldralighieri.corbind.internal.corbindReceiveChannel
* Perform an action on [OnBackPressedDispatcher.onBackPressed] 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 owner The LifecycleOwner which controls when the callback should be invoked
* @param action An action to perform
*/
fun OnBackPressedDispatcher.backPresses(
scope: CoroutineScope,
lifecycleOwner: LifecycleOwner,
capacity: Int = Channel.RENDEZVOUS,
owner: LifecycleOwner,
action: suspend () -> Unit
) {
val events = scope.actor<Unit>(Dispatchers.Main.immediate, capacity) {
for (ignored in channel) action()
}

val callback = callback(scope, events::trySend)
addCallback(owner, callback)
addCallback(lifecycleOwner, callback)
events.invokeOnClose { callback.remove() }
}

/**
* Perform an action on [OnBackPressedDispatcher.onBackPressed] 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 owner The LifecycleOwner which controls when the callback should be invoked
* @param action An action to perform
*/
suspend fun OnBackPressedDispatcher.backPresses(
lifecycleOwner: LifecycleOwner,
capacity: Int = Channel.RENDEZVOUS,
owner: LifecycleOwner,
action: suspend () -> Unit
) = coroutineScope {
backPresses(this, capacity, owner, action)
backPresses(this, lifecycleOwner, capacity, action)
}

/**
@@ -77,22 +77,22 @@ suspend fun OnBackPressedDispatcher.backPresses(
*
* ```
* launch {
* requireActivity().onBackPressedDispatcher.backPresses()
* onBackPressedDispatcher.backPresses(lifecycleOwner = this)
* .consumeEach { /* handle onBackPressed 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)
* @param owner The LifecycleOwner which controls when the callback should be invoked
*/
fun OnBackPressedDispatcher.backPresses(
scope: CoroutineScope,
capacity: Int = Channel.RENDEZVOUS,
owner: LifecycleOwner
lifecycleOwner: LifecycleOwner,
capacity: Int = Channel.RENDEZVOUS
): ReceiveChannel<Unit> = corbindReceiveChannel(capacity) {
val callback = callback(scope, ::trySend)
addCallback(owner, callback)
addCallback(lifecycleOwner, callback)
invokeOnClose { callback.remove() }
}

@@ -102,17 +102,17 @@ fun OnBackPressedDispatcher.backPresses(
* Example:
*
* ```
* requireActivity().onBackPressedDispatcher.backPresses()
* onBackPressedDispatcher.backPresses(lifecycleOwner = this)
* .onEach { /* handle onBackPressed event */ }
* .flowWithLifecycle(lifecycle)
* .launchIn(lifecycleScope) // lifecycle-runtime-ktx
* ```
*
* @param owner The LifecycleOwner which controls when the callback should be invoked
* @param lifecycleOwner The LifecycleOwner which controls when the callback should be invoked
*/
fun OnBackPressedDispatcher.backPresses(owner: LifecycleOwner): Flow<Unit> = channelFlow {
fun OnBackPressedDispatcher.backPresses(lifecycleOwner: LifecycleOwner): Flow<Unit> = channelFlow {
val callback = callback(this, ::trySend)
addCallback(owner, callback)
addCallback(lifecycleOwner, callback)
awaitClose { callback.remove() }
}

2 changes: 1 addition & 1 deletion corbind-appcompat/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx appcompat bindings, import `corbind-appcompat` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-appcompat/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.appcompat"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.appcompat)
}
2 changes: 1 addition & 1 deletion corbind-appcompat/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.appcompat" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-core/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx core bindings, import `corbind-core` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-core:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-core:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.core"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.core)
}
2 changes: 1 addition & 1 deletion corbind-core/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.core" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-drawerlayout/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx drawerlayout bindings, import `corbind-drawerlayout` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-drawerlayout/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.drawerlayout"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.drawerlayout)
}
2 changes: 1 addition & 1 deletion corbind-drawerlayout/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.drawerlayout" />
<manifest />
1 change: 1 addition & 0 deletions corbind-fragment/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
30 changes: 30 additions & 0 deletions corbind-fragment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# corbind-activity

To add androidx fragment bindings, import `corbind-fragment` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-fragment:1.6.0'
```

## List of extensions

Component | Extension | Description
--|---|--
**FragmentManager** | `resultEvents` | Called when any results set by setFragmentResult using the same requestKey.


## Simple examples

```kotlin
lifecycleScope.launchWhenStarted {
parentFragmentManager.resultEvents(
requestKey = FRAGMENT_REQUEST_KEY,
lifecycleOwner = this@CurrentFragment
)
.onEach { event -> /* handle result event */ }
.launchIn(this@launchWhenStarted) // lifecycle-runtime-ktx
}
```

More examples in source code
30 changes: 30 additions & 0 deletions corbind-fragment/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2022 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.
*/

plugins {
id("corbind.library")
id("corbind.spotless")
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.fragment"
}

dependencies {
api(projects.corbind)
api(libs.androidx.fragment)
}
20 changes: 20 additions & 0 deletions corbind-fragment/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright 2022 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.
#


POM_ARTIFACT_ID=corbind-fragment
POM_NAME=Corbind (fragment)
POM_PACKAGING=aar
21 changes: 21 additions & 0 deletions corbind-fragment/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
17 changes: 17 additions & 0 deletions corbind-fragment/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!--
~ Copyright 2022 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.
-->

<manifest />
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* Copyright 2022 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.fragment

import android.os.Bundle
import androidx.annotation.CheckResult
import androidx.fragment.app.FragmentManager
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

data class FragmentResultEvent(
val requestKey: String,
val bundle: Bundle
)

/**
* Perform an action on any results set by setFragmentResult using the [requestKey], once the given
* [lifecycleOwner][LifecycleOwner] is at least in the STARTED state
*
* *Warning:* The created actor uses [FragmentManager.setFragmentResultListener]. Only one flow can
* be used at a time
*
* @param scope Root coroutine scope
* @param requestKey Used to identify the result
* @param lifecycleOwner The LifecycleOwner for handling the result
* @param capacity Capacity of the channel's buffer (no buffer by default)
* @param action An action to perform
*/
fun FragmentManager.resultEvents(
scope: CoroutineScope,
requestKey: String,
lifecycleOwner: LifecycleOwner,
capacity: Int = Channel.RENDEZVOUS,
action: suspend (FragmentResultEvent) -> Unit
) {
val events = scope.actor<FragmentResultEvent>(Dispatchers.Main.immediate, capacity) {
for (event in channel) action(event)
}

val listener = listener(scope, events::trySend)
setFragmentResultListener(requestKey, lifecycleOwner, listener)
events.invokeOnClose { clearFragmentResultListener(requestKey) }
}

/**
* Perform an action inside new [CoroutineScope] on any results set by setFragmentResult using the
* [requestKey], once the given [lifecycleOwner][LifecycleOwner] is at least in the STARTED state
*
* *Warning:* The created actor uses [FragmentManager.setFragmentResultListener]. Only one flow can
* be used at a time
*
* @param requestKey Used to identify the result
* @param lifecycleOwner The LifecycleOwner for handling the result
* @param capacity Capacity of the channel's buffer (no buffer by default)
* @param action An action to perform
*/
suspend fun FragmentManager.resultEvents(
requestKey: String,
lifecycleOwner: LifecycleOwner,
capacity: Int = Channel.RENDEZVOUS,
action: suspend (FragmentResultEvent) -> Unit
) = coroutineScope {
resultEvents(this, requestKey, lifecycleOwner, capacity, action)
}

/**
* Create a channel which emits any results set by setFragmentResult using the [requestKey], once
* the given [lifecycleOwner][LifecycleOwner] is at least in the STARTED state
*
* *Warning:* The created channel uses [FragmentManager.setFragmentResultListener]. Only one flow
* can be used at a time
*
* Example:
*
* ```
* launch {
* parentFragmentManager.resultEvents(
* requestKey = FRAGMENT_REQUEST_KEY,
* lifecycleOwner = this@CurrentFragment
* )
* .consumeEach { /* handle result event */ }
* }
* ```
*
* @param scope Root coroutine scope
* @param requestKey Used to identify the result
* @param lifecycleOwner The LifecycleOwner for handling the result
*/
fun FragmentManager.resultEvents(
scope: CoroutineScope,
requestKey: String,
lifecycleOwner: LifecycleOwner,
capacity: Int = Channel.RENDEZVOUS
): ReceiveChannel<FragmentResultEvent> = corbindReceiveChannel(capacity) {
val listener = listener(scope, ::trySend)
setFragmentResultListener(requestKey, lifecycleOwner, listener)
invokeOnClose { clearFragmentResultListener(requestKey) }
}

/**
* Create a flow which emits any results set by setFragmentResult using the [requestKey], once the
* given [lifecycleOwner][LifecycleOwner] is at least in the STARTED state
*
* *Warning:* The created flow uses [FragmentManager.setFragmentResultListener]. Only one flow can
* be used at a time
*
* Example:
* ```
* lifecycleScope.launchWhenStarted {
* parentFragmentManager.resultEvents(
* requestKey = FRAGMENT_REQUEST_KEY,
* lifecycleOwner = this@CurrentFragment
* )
* .onEach { event -> /* handle result event */ }
* .launchIn(this@launchWhenStarted) // lifecycle-runtime-ktx
* }
* ```
*
* @param requestKey Used to identify the result
* @param lifecycleOwner The LifecycleOwner for handling the result
*/
fun FragmentManager.resultEvents(
requestKey: String,
lifecycleOwner: LifecycleOwner
): Flow<FragmentResultEvent> = channelFlow {
val listener = listener(this, ::trySend)
setFragmentResultListener(requestKey, lifecycleOwner, listener)
awaitClose { clearFragmentResultListener(requestKey) }
}

@CheckResult
private fun listener(
scope: CoroutineScope,
emitter: (FragmentResultEvent) -> Unit
) = { requestKey: String, bundle: Bundle ->
if (scope.isActive) { emitter(FragmentResultEvent(requestKey, bundle)) }
}
2 changes: 1 addition & 1 deletion corbind-leanback/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx leanback bindings, import `corbind-leanback` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-leanback:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-leanback/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.leanback"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.leanback)
}
3 changes: 2 additions & 1 deletion corbind-leanback/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,5 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.leanback" />
<manifest xmlns:tools="http://schemas.android.com/tools"
tools:ignore="ImpliedTouchscreenHardware,MissingLeanbackLauncher,MissingLeanbackSupport" />
2 changes: 1 addition & 1 deletion corbind-lifecycle/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx lifecycle bindings, import `corbind-lifecycle` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-lifecycle/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.lifecycle"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.lifecycle.runtime.ktx)
}
2 changes: 1 addition & 1 deletion corbind-lifecycle/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.lifecycle" />
<manifest />
7 changes: 2 additions & 5 deletions corbind-material/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add material bindings, import `corbind-material` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-material:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-material:1.6.0'
```

## List of extensions
@@ -54,10 +54,7 @@ Component | Extension | Description

```kotlin
chipGroup.checkedChanges() // Flow<Int>
.onEach {
tv_message =
if (it != View.NO_ID) "Chip #$it selected" else "No one сhip selected"
}
.onEach { /* handle checked ids */ }
.flowWithLifecycle(lifecycle)
.launchIn(lifecycleScope) // lifecycle-runtime-ktx
```
6 changes: 5 additions & 1 deletion corbind-material/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.material"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.material)
}
2 changes: 1 addition & 1 deletion corbind-material/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.material" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-navigation/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx navigation bindings, import `corbind-navigation` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-navigation:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-navigation/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.navigation"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.navigation)
}
2 changes: 1 addition & 1 deletion corbind-navigation/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.navigation" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-recyclerview/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx recyclerview bindings, import `corbind-recyclerview` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-recyclerview/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.recyclerview"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.recyclerview)
}
2 changes: 1 addition & 1 deletion corbind-recyclerview/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.recyclerview" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-slidingpanelayout/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx slidingpanelayout bindings, import `corbind-slidingpanelayout` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-slidingpanelayout/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.slidingpanelayout"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.slidingpanelayout)
}
2 changes: 1 addition & 1 deletion corbind-slidingpanelayout/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.slidingpanelayout" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-swiperefreshlayout/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx swiperefreshlayout bindings, import `corbind-swiperefreshlayout` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-swiperefreshlayout/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.swiperefreshlayout"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.swiperefreshlayout)
}
2 changes: 1 addition & 1 deletion corbind-swiperefreshlayout/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.swiperefreshlayout" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-viewpager/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx viewpager bindings, import `corbind-viewpager` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-viewpager/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.viewpager"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.viewpager)
}
2 changes: 1 addition & 1 deletion corbind-viewpager/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.viewpager" />
<manifest />
2 changes: 1 addition & 1 deletion corbind-viewpager2/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add androidx viewpager2 bindings, import `corbind-viewpager2` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.6.0'
```

## List of extensions
6 changes: 5 additions & 1 deletion corbind-viewpager2/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,7 +20,11 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind.viewpager2"
}

dependencies {
api(project(":corbind"))
api(projects.corbind)
api(libs.androidx.viewpager2)
}
2 changes: 1 addition & 1 deletion corbind-viewpager2/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,4 +14,4 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind.viewpager2" />
<manifest />
2 changes: 1 addition & 1 deletion corbind/README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
To add platform bindings, import `corbind` module:

```groovy
implementation 'ru.ldralighieri.corbind:corbind:1.5.5'
implementation 'ru.ldralighieri.corbind:corbind:1.6.0'
```

## List of extensions
4 changes: 4 additions & 0 deletions corbind/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@ plugins {
id("corbind.dokka")
}

android {
namespace = "ru.ldralighieri.corbind"
}

dependencies {
api(libs.kotlin.stdlib)
api(libs.kotlin.coroutines.android)
2 changes: 1 addition & 1 deletion corbind/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -14,5 +14,5 @@
~ limitations under the License.
-->

<manifest package="ru.ldralighieri.corbind" />
<manifest />

8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -4,17 +4,17 @@ org.gradle.jvmargs=-XX:MaxMetaspaceSize=3G

# AndroidX
android.useAndroidX=true
android.compileSdk=32
android.targetSdk=32
android.minSdk=14
compileSdk=33
targetSdk=33
minSdk=14


# Maven
SONATYPE_HOST=DEFAULT
RELEASE_SIGNING_ENABLED=true

GROUP=ru.ldralighieri.corbind
VERSION_NAME=1.5.6-SNAPSHOT
VERSION_NAME=1.6.0

POM_DESCRIPTION=Kotlin Coroutines binding APIs for Android UI widgets from the platform and support libraries.

26 changes: 14 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
[versions]
spotless = "6.8.0"
gver = "0.42.0"
gver = "0.43.0"
detekt = "1.21.0"
dokka = "1.6.10"
maven-publish = "0.21.0"
dokka = "1.7.20"
maven-publish = "0.22.0"

plugin-android = "7.2.1"
plugin-android = "7.3.1"

kotlin = "1.7.10"
kotlin = "1.7.20"
kotlin-coroutines = "1.6.4"

androidx-core = "1.8.0"
androidx-annotation = "1.4.0"
androidx-appcompat = "1.4.2"
androidx-core = "1.9.0"
androidx-annotation = "1.5.0"
androidx-appcompat = "1.5.1"
androidx-drawerlayout = "1.1.1"
androidx-leanback = "1.0.0"
androidx-navigation = "2.5.0"
androidx-navigation = "2.5.2"
androidx-recyclerview = "1.2.1"
androidx-slidingpanelayout = "1.2.0"
androidx-swiperefreshlayout = "1.1.0"
androidx-viewpager = "1.0.0"
androidx-viewpager2 = "1.0.0"
androidx-lifecycle = "2.5.0"
androidx-activity = "1.5.0"
androidx-lifecycle = "2.5.1"
androidx-activity = "1.6.0"
androidx-fragment = "1.5.3"
androidx-constraintlayout = "2.1.4"

material = "1.6.1"
material = "1.7.0"

ktlint = "0.46.1"

@@ -60,6 +61,7 @@ androidx-viewpager = { module = "androidx.viewpager:viewpager", version.ref = "a
androidx-viewpager2 = { module = "androidx.viewpager2:viewpager2", version.ref = "androidx-viewpager2" }
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle" }
androidx-activity = { module = "androidx.activity:activity", version.ref = "androidx-activity" }
androidx-fragment = { module = "androidx.fragment:fragment", version.ref = "androidx-fragment" }
androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref = "androidx-constraintlayout" }

material = { module = "com.google.android.material:material", version.ref = "material" }
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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-7.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
17 changes: 12 additions & 5 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -20,13 +20,20 @@ plugins {
}

android {
compileSdk = findProperty("android.compileSdk").toString().toInt()
val compileSdk: String by project
val minSdk: String by project
val targetSdk: String by project
@Suppress("LocalVariableName") val VERSION_NAME: String by project

namespace = "ru.ldralighieri.corbind.sample"

this.compileSdk = compileSdk.toInt()
defaultConfig {
applicationId = "ru.ldralighieri.corbind.example"
minSdk = findProperty("android.minSdk").toString().toInt()
targetSdk = findProperty("android.targetSdk").toString().toInt()
this.minSdk = minSdk.toInt()
this.targetSdk = targetSdk.toInt()
versionCode = 1
versionName = findProperty("VERSION_NAME").toString()
versionName = VERSION_NAME

vectorDrawables.useSupportLibrary = true
}
@@ -68,7 +75,7 @@ android {
}

dependencies {
implementation(project(":corbind-swiperefreshlayout"))
implementation(projects.corbindSwiperefreshlayout)

implementation(libs.androidx.appcompat)
implementation(libs.androidx.lifecycle.runtime.ktx)
9 changes: 3 additions & 6 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -15,18 +15,15 @@
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ru.ldralighieri.corbind.sample">
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="false"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Corbind"
tools:ignore="GoogleAppIndexingWarning"
android:fullBackupContent="false" >
tools:ignore="GoogleAppIndexingWarning">

<activity
android:name=".LoginActivity"
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ include(":corbind-activity")
include(":corbind-appcompat")
include(":corbind-core")
include(":corbind-drawerlayout")
include(":corbind-fragment")
include(":corbind-leanback")
include(":corbind-lifecycle")
include(":corbind-material")

0 comments on commit 0f474e3

Please sign in to comment.