Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
LDRAlighieri committed Oct 20, 2022
2 parents 7b7b99f + 0f474e3 commit ffcf70e
Show file tree
Hide file tree
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
Expand Up @@ -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.
Expand Down
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)

Expand All @@ -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:
Expand All @@ -56,7 +57,7 @@ repositories {
}
dependencies {
implementation 'ru.ldralighieri.corbind:{module}:1.5.6-SNAPSHOT'
implementation 'ru.ldralighieri.corbind:{module}:1.6.1-SNAPSHOT'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions corbind-activity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion corbind-activity/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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)
}

/**
Expand All @@ -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() }
}

Expand All @@ -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() }
}

Expand Down
2 changes: 1 addition & 1 deletion corbind-appcompat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion corbind-appcompat/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion corbind-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion corbind-drawerlayout/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Loading

0 comments on commit ffcf70e

Please sign in to comment.