diff --git a/README.md b/README.md index 6f91f6a6..506e492c 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.5.20-blue.svg)](https://kotlinlang.org) -[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.5.0-blue.svg)](https://kotlinlang.org/docs/reference/coroutines-overview.html) +[![Kotlin Version](https://img.shields.io/badge/Kotlin-v1.6.10-blue.svg)](https://kotlinlang.org) +[![Kotlin Coroutines Version](https://img.shields.io/badge/Coroutines-v1.6.0-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) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/a1c9a1b1d1ce4ca7a201ab93492bf6e0)](https://www.codacy.com/app/LDRAlighieri/Corbind?utm_source=github.com&utm_medium=referral&utm_content=LDRAlighieri/Corbind&utm_campaign=Badge_Grade) @@ -25,28 +25,28 @@ This library is for Android applications only. Help you to transform Android UI Platform bindings: ```groovy -implementation 'ru.ldralighieri.corbind:corbind:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind:1.5.3' ``` AndroidX library bindings: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-core:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.2' -implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-core:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.3' +implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.3' ``` Google 'material' library bindings: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-material:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-material:1.5.3' ``` Snapshot build: @@ -56,12 +56,13 @@ repositories { } dependencies { - implementation 'ru.ldralighieri.corbind:{module}:1.5.3-SNAPSHOT' + implementation 'ru.ldralighieri.corbind:{module}:1.5.4-SNAPSHOT' } ``` ## List of extensions + You can find a list of extensions in the description of each module: [corbind] [corbind-activity] @@ -86,6 +87,7 @@ If you need to get a text change events of EditText widget, simple use case with findViewById(R.id.et_name) .textChanges() // Flow .onEach { /* handle text change events */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` @@ -122,6 +124,7 @@ combine( transform = { email, password -> email && password } ) .onEach { bt_login.isEnabled = it } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` @@ -141,7 +144,7 @@ If I forgot something or you have any ideas what can be added or corrected, plea ## License ``` -Copyright 2019-2021 Vladimir Raupov +Copyright 2019-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. diff --git a/corbind-activity/README.md b/corbind-activity/README.md index 6a14d25a..1806e1dd 100644 --- a/corbind-activity/README.md +++ b/corbind-activity/README.md @@ -4,7 +4,7 @@ To add androidx activity bindings, import `corbind-activity` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-activity:1.5.3' ``` ## List of extensions @@ -19,6 +19,7 @@ Component | Extension | Description ```kotlin requireActivity().onBackPressedDispatcher.backPresses() .onEach { /* handle onBackPressed event */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-appcompat/README.md b/corbind-appcompat/README.md index 5da1672d..bcf23873 100644 --- a/corbind-appcompat/README.md +++ b/corbind-appcompat/README.md @@ -4,7 +4,7 @@ To add androidx appcompat bindings, import `corbind-appcompat` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-appcompat:1.5.3' ``` ## List of extensions @@ -25,6 +25,7 @@ Component | Extension | Description ```kotlin toolbar.itemClicks() // Flow .onEach { /* handle menu item clicks events */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-core/README.md b/corbind-core/README.md index f9bd886d..e3ccb6e6 100644 --- a/corbind-core/README.md +++ b/corbind-core/README.md @@ -4,7 +4,7 @@ To add androidx core bindings, import `corbind-core` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-core:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-core:1.5.3' ``` ## List of extensions @@ -19,6 +19,7 @@ Component | Extension | Description ```kotlin scrollView.scrollChangeEvents() // Flow .onEach { /* handle scroll change events */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-drawerlayout/README.md b/corbind-drawerlayout/README.md index 0e6a9dbd..e5ec246e 100644 --- a/corbind-drawerlayout/README.md +++ b/corbind-drawerlayout/README.md @@ -4,7 +4,7 @@ To add androidx drawerlayout bindings, import `corbind-drawerlayout` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-drawerlayout:1.5.3' ``` ## List of extensions @@ -21,6 +21,7 @@ drawer.drawerOpens() // Flow .onEach { isOpen -> tv_message = "Drawer completely ${ if (isOpen) "open" else "close"}" } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-leanback/README.md b/corbind-leanback/README.md index 72a6bc79..c47fc406 100644 --- a/corbind-leanback/README.md +++ b/corbind-leanback/README.md @@ -4,7 +4,7 @@ To add androidx leanback bindings, import `corbind-leanback` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-leanback:1.5.3' ``` ## List of extensions @@ -22,6 +22,7 @@ Component | Extension | Description search.searchQueryChanges() // Flow .map { it.toLowerCase(Locale.getDefault()) } .onEach { query -> filter.updateItems(query) } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-lifecycle/README.md b/corbind-lifecycle/README.md index c9301123..8078e7e9 100644 --- a/corbind-lifecycle/README.md +++ b/corbind-lifecycle/README.md @@ -4,7 +4,7 @@ To add androidx lifecycle bindings, import `corbind-lifecycle` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-lifecycle:1.5.3' ``` ## List of extensions @@ -20,6 +20,7 @@ Component | Extension | Description lifecycle.events() .filter { it == Lifecycle.Event.ON_RESUME } .onEach { /* handle lifecycle onResume event */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-material/README.md b/corbind-material/README.md index d85d9a7b..71ad28df 100644 --- a/corbind-material/README.md +++ b/corbind-material/README.md @@ -4,7 +4,7 @@ To add material bindings, import `corbind-material` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-material:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-material:1.5.3' ``` ## List of extensions @@ -58,6 +58,7 @@ chipGroup.checkedChanges() // Flow tv_message = if (it != View.NO_ID) "Chip #$it selected" else "No one сhip selected" } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-navigation/README.md b/corbind-navigation/README.md index ccbed574..fb1deb8d 100644 --- a/corbind-navigation/README.md +++ b/corbind-navigation/README.md @@ -4,7 +4,7 @@ To add androidx navigation bindings, import `corbind-navigation` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-navigation:1.5.3' ``` ## List of extensions @@ -24,6 +24,7 @@ navController.destinationChanges() // Flow hideSoftInput() } } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-recyclerview/README.md b/corbind-recyclerview/README.md index fcade37a..abf6ef00 100644 --- a/corbind-recyclerview/README.md +++ b/corbind-recyclerview/README.md @@ -4,7 +4,7 @@ To add androidx recyclerview bindings, import `corbind-recyclerview` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-recyclerview:1.5.3' ``` ## List of extensions @@ -23,6 +23,7 @@ Component | Extension | Description ```kotlin rv.scrollStateChanges() // Flow .onEach { /* handle RecyclerView scroll state change events */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-slidingpanelayout/README.md b/corbind-slidingpanelayout/README.md index 8619df05..67bffd48 100644 --- a/corbind-slidingpanelayout/README.md +++ b/corbind-slidingpanelayout/README.md @@ -4,7 +4,7 @@ To add androidx slidingpanelayout bindings, import `corbind-slidingpanelayout` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-slidingpanelayout:1.5.3' ``` ## List of extensions @@ -22,6 +22,7 @@ slider.panelOpens() // Flow .onEach { isOpen -> tv_message = "Panel completely ${ if (isOpen) "open" else "close"}" } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-swiperefreshlayout/README.md b/corbind-swiperefreshlayout/README.md index cbbb4dcb..27561436 100644 --- a/corbind-swiperefreshlayout/README.md +++ b/corbind-swiperefreshlayout/README.md @@ -4,7 +4,7 @@ To add androidx swiperefreshlayout bindings, import `corbind-swiperefreshlayout` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-swiperefreshlayout:1.5.3' ``` ## List of extensions @@ -19,6 +19,7 @@ Component | Extension | Description ```kotlin swipe.refreshes() // Flow .onEach { /* handle refresh events */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-viewpager/README.md b/corbind-viewpager/README.md index fa908c09..d6c6ec04 100644 --- a/corbind-viewpager/README.md +++ b/corbind-viewpager/README.md @@ -4,7 +4,7 @@ To add androidx viewpager bindings, import `corbind-viewpager` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-viewpager:1.5.3' ``` ## List of extensions @@ -21,6 +21,7 @@ Component | Extension | Description ```kotlin vp_slides.pageSelections() // Flow .onEach { tv_message = "Page #$it selected" } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind-viewpager2/README.md b/corbind-viewpager2/README.md index d9dd4a83..047121ee 100644 --- a/corbind-viewpager2/README.md +++ b/corbind-viewpager2/README.md @@ -4,7 +4,7 @@ To add androidx viewpager2 bindings, import `corbind-viewpager2` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind-viewpager2:1.5.3' ``` ## List of extensions @@ -21,6 +21,7 @@ Component | Extension | Description ```kotlin vp_slides.pageSelections() // Flow .onEach { tv_message = "Page #$it selected" } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/corbind/README.md b/corbind/README.md index 82af0c62..e3d21a9f 100644 --- a/corbind/README.md +++ b/corbind/README.md @@ -4,7 +4,7 @@ To add platform bindings, import `corbind` module: ```groovy -implementation 'ru.ldralighieri.corbind:corbind:1.5.2' +implementation 'ru.ldralighieri.corbind:corbind:1.5.3' ``` ## List of extensions @@ -99,6 +99,7 @@ combine( transform = { email, password -> email && password } ) .onEach { bt_login.isEnabled = it } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` @@ -113,6 +114,7 @@ flowOf( ) .flattenMerge() .onEach { /* handle an authorization event */} + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` @@ -123,6 +125,7 @@ context IntentFilter(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED) ) .onEach { /* handle nfc adapter state changed */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` @@ -138,6 +141,7 @@ window.decorView.windowInsetsApplyEvents() insets.isVisible(WindowInsets.Type.statusBars() or WindowInsets.Type.navigationBars()) } .onEach { /* handle status bars or navigation bars visibility */ } + .flowWithLifecycle(lifecycle) .launchIn(lifecycleScope) // lifecycle-runtime-ktx ``` diff --git a/sample/src/main/kotlin/ru/ldralighieri/corbind/sample/LoginActivity.kt b/sample/src/main/kotlin/ru/ldralighieri/corbind/sample/LoginActivity.kt index 70247912..c88b9664 100644 --- a/sample/src/main/kotlin/ru/ldralighieri/corbind/sample/LoginActivity.kt +++ b/sample/src/main/kotlin/ru/ldralighieri/corbind/sample/LoginActivity.kt @@ -20,10 +20,10 @@ import android.annotation.SuppressLint import android.os.Build import android.os.Bundle import android.util.Patterns -import android.view.View import android.view.inputmethod.EditorInfo import android.widget.Toast import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.WindowCompat import androidx.lifecycle.Lifecycle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.repeatOnLifecycle @@ -48,14 +48,8 @@ class LoginActivity : AppCompatActivity() { @SuppressLint("InlinedApi") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (Build.VERSION.SDK_INT in Build.VERSION_CODES.JELLY_BEAN until Build.VERSION_CODES.R) { - val view = window.decorView - @Suppress("DEPRECATION") - view.systemUiVisibility = view.systemUiVisibility or - View.SYSTEM_UI_FLAG_LAYOUT_STABLE or - View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - window.setDecorFitsSystemWindows(false) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { + WindowCompat.setDecorFitsSystemWindows(window, false) } binding = ActivityLoginBinding.inflate(layoutInflater)