Skip to content

Commit 15343f4

Browse files
yamidragutadriangl
andauthored
Upgrade dependencies. Migrate to Kodein 7 (#15)
Co-authored-by: Adrián García <[email protected]>
1 parent 06e4300 commit 15343f4

File tree

13 files changed

+69
-62
lines changed

13 files changed

+69
-62
lines changed

CHANGELOG.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
### Security
1919
- No security issues fixed!
2020

21+
## [1.4.0] - 2020-12-15
22+
### Added
23+
- Upgrade Kotlin to 1.4.21 and Kodein to 7.1.0, apart from other Android dependencies.
24+
2125
## [1.3.3] - 2020-08-13
2226
### Added
2327
- Add proguard rules for most modules that need them.
@@ -105,8 +109,9 @@ state (`success` or `failure`)
105109
### Added
106110
- Initial architecture release.
107111

108-
[Unreleased]: https://github.com/bq/mini-kotlin/compare/1.3.3...HEAD
109-
[1.3.3]: https://github.com/bq/mini-kotlin/compare/1.3.1...1.3.2
112+
[Unreleased]: https://github.com/bq/mini-kotlin/compare/1.4.0...HEAD
113+
[1.4.0]: https://github.com/bq/mini-kotlin/compare/1.3.3...1.4.0
114+
[1.3.3]: https://github.com/bq/mini-kotlin/compare/1.3.2...1.3.3
110115
[1.3.2]: https://github.com/bq/mini-kotlin/compare/1.3.1...1.3.2
111116
[1.3.1]: https://github.com/bq/mini-kotlin/compare/1.3.0...1.3.1
112117
[1.3.0]: https://github.com/bq/mini-kotlin/compare/1.2.0...1.3.0

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Add the following dependencies to your app's `build.gradle`:
184184

185185
```groovy
186186
dependencies {
187-
def mini_version = "1.3.3"
187+
def mini_version = "1.4.0"
188188
// Minimum working dependencies
189189
implementation "com.github.bq.mini-kotlin:mini-android:$mini_version"
190190
kapt "com.github.bq.mini-kotlin:mini-processor:$mini_version"

app/build.gradle

+6-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ repositories {
77
apply plugin: 'com.android.application'
88
apply plugin: 'kotlin-android'
99
apply plugin: 'kotlin-kapt'
10-
apply plugin: 'kotlin-android-extensions'
1110

1211
//Android
1312
android {
@@ -24,6 +23,10 @@ android {
2423
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2524
}
2625

26+
buildFeatures {
27+
viewBinding = true
28+
}
29+
2730
buildTypes {
2831
release {
2932
minifyEnabled false
@@ -71,8 +74,8 @@ dependencies {
7174
implementation "io.reactivex.rxjava2:rxjava:$rx_version"
7275

7376
//Support
74-
implementation "androidx.core:core:1.2.0"
75-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
77+
implementation "androidx.core:core:1.3.2"
78+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
7679

7780
//Kotlin
7881
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

app/src/main/java/org/sample/SampleActivity.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,28 @@ import android.os.Bundle
44
import com.mini.android.FluxActivity
55
import com.minikorp.grove.ConsoleLogTree
66
import com.minikorp.grove.Grove
7-
import kotlinx.android.synthetic.main.home_activity.*
87
import mini.LoggerInterceptor
98
import mini.MiniGen
9+
import org.sample.databinding.HomeActivityBinding
1010

1111
class SampleActivity : FluxActivity() {
1212

1313
private val dispatcher = MiniGen.newDispatcher()
1414
private val dummyStore = DummyStore()
1515

16+
private lateinit var binding: HomeActivityBinding
17+
1618
override fun onCreate(savedInstanceState: Bundle?) {
1719
super.onCreate(savedInstanceState)
18-
setContentView(R.layout.home_activity)
20+
binding = HomeActivityBinding.inflate(layoutInflater)
21+
setContentView(binding.root)
1922

2023
val stores = listOf(dummyStore)
2124
MiniGen.subscribe(dispatcher, stores).track()
2225
stores.forEach { it.initialize() }
2326

2427
dummyStore.subscribe {
25-
demo_text.text = it.text
28+
binding.demoText.text = it.text
2629
}
2730

2831
Grove.plant(ConsoleLogTree())

app/src/main/java/org/sample/SampleRxActivity.kt

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,31 @@ package org.sample
33
import android.os.Bundle
44
import com.minikorp.grove.ConsoleLogTree
55
import com.minikorp.grove.Grove
6-
import kotlinx.android.synthetic.main.home_activity.*
76
import mini.LoggerInterceptor
87
import mini.MiniGen
98
import mini.rx.android.activities.FluxRxActivity
109
import mini.rx.flowable
10+
import org.sample.databinding.HomeActivityBinding
1111

1212
class SampleRxActivity : FluxRxActivity() {
1313

1414
private val dispatcher = MiniGen.newDispatcher()
1515
private val dummyStore = DummyStore()
1616

17+
private lateinit var binding: HomeActivityBinding
18+
1719
override fun onCreate(savedInstanceState: Bundle?) {
1820
super.onCreate(savedInstanceState)
19-
setContentView(R.layout.home_activity)
21+
binding = HomeActivityBinding.inflate(layoutInflater)
22+
setContentView(binding.root)
2023

2124
val stores = listOf(dummyStore)
2225
MiniGen.subscribe(dispatcher, stores)
2326
stores.forEach { it.initialize() }
2427

2528
dummyStore.flowable()
2629
.subscribe {
27-
demo_text.text = it.text
30+
binding.demoText.text = it.text
2831
}
2932
.track()
3033

build.gradle

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ apply plugin: 'com.gladed.androidgitversion'
33

44
buildscript {
55
ext {
6-
kotlin_version = "1.3.72"
6+
kotlin_version = "1.4.21"
77

8-
android_compile_sdk = 29
9-
android_target_sdk = 29
10-
android_build_tools_version = "29.0.1"
8+
android_compile_sdk = 30
9+
android_target_sdk = 30
10+
android_build_tools_version = "30.0.2"
1111

1212
lifecycle_version = "2.2.0"
1313
rx_version = "2.2.6"
14-
coroutines_version = "1.3.3"
14+
coroutines_version = "1.4.2"
1515
}
1616

1717
repositories {
@@ -22,7 +22,7 @@ buildscript {
2222
}
2323

2424
dependencies {
25-
classpath "com.android.tools.build:gradle:3.6.3"
25+
classpath "com.android.tools.build:gradle:4.1.1"
2626
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2727
classpath "org.junit.platform:junit-platform-gradle-plugin:1.2.0"
2828
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Mon Jul 22 11:10:54 CEST 2019
1+
#Mon Dec 14 20:31:47 CET 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

mini-android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ dependencies {
2727
api project(":mini-common")
2828

2929
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version"
30-
api "androidx.appcompat:appcompat:1.1.0"
30+
api "androidx.appcompat:appcompat:1.2.0"
3131
api "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
3232

3333
testImplementation "junit:junit:4.13"
34-
androidTestImplementation "androidx.test:runner:1.2.0"
35-
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
34+
androidTestImplementation "androidx.test:runner:1.3.0"
35+
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
3636
}
3737

3838
apply from: "../jitpack-android.gradle"

mini-kodein-android/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ dependencies {
3838
api "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
3939

4040
testImplementation "junit:junit:4.13"
41-
androidTestImplementation "androidx.test:runner:1.2.0"
42-
androidTestImplementation "androidx.test.espresso:espresso-core:3.2.0"
41+
androidTestImplementation "androidx.test:runner:1.3.0"
42+
androidTestImplementation "androidx.test.espresso:espresso-core:3.3.0"
4343
}
4444

4545
apply from: "../jitpack-android.gradle"

mini-kodein-android/src/main/java/mini/kodein/android/KodeinAndroidUtils.kt

+22-25
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,23 @@ import androidx.fragment.app.Fragment
55
import androidx.fragment.app.FragmentActivity
66
import androidx.lifecycle.ViewModel
77
import androidx.lifecycle.ViewModelProvider
8-
import org.kodein.di.DKodein
9-
import org.kodein.di.Kodein
10-
import org.kodein.di.KodeinAware
11-
import org.kodein.di.bindings.BindingKodein
12-
import org.kodein.di.bindings.NoArgBindingKodein
13-
import org.kodein.di.direct
14-
import org.kodein.di.generic.*
8+
import org.kodein.di.*
9+
import org.kodein.di.bindings.BindingDI
10+
import org.kodein.di.bindings.NoArgBindingDI
1511

1612
/**
1713
* Binds a ViewModel to a Kotlin module, assuming that it's a provided dependency.
1814
*/
19-
inline fun <reified VM : ViewModel> Kodein.Builder.bindViewModel(overrides: Boolean? = null,
20-
noinline creator: NoArgBindingKodein<*>.() -> VM) {
15+
inline fun <reified VM : ViewModel> DI.Builder.bindViewModel(overrides: Boolean? = null,
16+
noinline creator: NoArgBindingDI<*>.() -> VM) {
2117
bind<VM>(VM::class.java.simpleName, overrides) with provider(creator)
2218
}
2319

2420
/**
2521
* Binds a ViewModel factory to a Kotlin module in order to create new ViewModels.
2622
*/
27-
inline fun <reified VM : ViewModel, reified F : ViewModelProvider.Factory> Kodein.Builder.bindViewModelFactory(overrides: Boolean? = null,
28-
noinline creator: BindingKodein<*>.(Any) -> F) {
23+
inline fun <reified VM : ViewModel, reified F : ViewModelProvider.Factory> DI.Builder.bindViewModelFactory(overrides: Boolean? = null,
24+
noinline creator: BindingDI<*>.(Any) -> F) {
2925
bind<F>(VM::class.java, overrides) with factory(creator = creator)
3026
}
3127

@@ -37,7 +33,7 @@ inline fun <reified VM : ViewModel, reified F : ViewModelProvider.Factory> Kodei
3733
* if you allow creating new instances of them via [Class.newInstance] with [allowNewInstance].
3834
* The default is true to mimic the default behaviour of [ViewModelProvider].
3935
*/
40-
class KodeinViewModelFactory(private val injector: DKodein,
36+
class DIViewModelFactory(private val injector: DirectDI,
4137
private val allowNewInstance: Boolean = true) : ViewModelProvider.Factory {
4238
@Suppress("UNCHECKED_CAST")
4339
override fun <T : ViewModel> create(modelClass: Class<T>): T {
@@ -51,71 +47,72 @@ class KodeinViewModelFactory(private val injector: DKodein,
5147
}
5248

5349
/**
54-
* Injects a [ViewModel] into a [FragmentActivity] that implements [KodeinAware].
50+
* Injects a [ViewModel] into a [FragmentActivity] that implements [DIAware].
5551
*/
5652
@MainThread
57-
inline fun <reified VM : ViewModel, A> A.viewModel(): Lazy<VM> where A : KodeinAware, A : FragmentActivity {
53+
inline fun <reified VM : ViewModel, A> A.viewModel(): Lazy<VM> where A : DIAware, A : FragmentActivity {
5854
return lazy {
5955
ViewModelProvider(this, direct.instance()).get(VM::class.java)
6056
}
6157
}
6258

6359
/**
64-
* Injects a [ViewModel] into a [Fragment] that implements [KodeinAware].
60+
* Injects a [ViewModel] into a [Fragment] that implements [DIAware].
6561
*/
6662
@MainThread
67-
inline fun <reified VM : ViewModel, F> F.viewModel(): Lazy<VM> where F : KodeinAware, F : Fragment {
63+
inline fun <reified VM : ViewModel, F> F.viewModel(): Lazy<VM> where F : DIAware, F : Fragment {
6864
return lazy {
6965
ViewModelProvider(this, direct.instance()).get(VM::class.java)
7066
}
7167
}
7268

7369
/**
74-
* Injects a [ViewModel] into a [FragmentActivity] that implements [KodeinAware].
70+
* Injects a [ViewModel] into a [FragmentActivity] that implements [DIAware].
7571
*
7672
* Requires previous [ViewModelProvider.Factory] injection for the [ViewModel] via [bindViewModelFactory]
7773
* to work and a [TypedViewModel] to be used.
7874
*/
7975
@MainThread
80-
inline fun <reified T, reified VM : TypedViewModel<T>, A> A.viewModel(params: T): Lazy<VM> where A : KodeinAware, A : FragmentActivity {
76+
inline fun <reified T : Any, reified VM : TypedViewModel<T>, A> A.viewModel(params: T): Lazy<VM> where A : DIAware, A : FragmentActivity {
8177
return lazy {
8278
ViewModelProvider(this, direct.instance(VM::class.java, params)).get(VM::class.java)
8379
}
8480
}
8581

8682
/**
87-
* Injects a [ViewModel] into a [Fragment] that implements [KodeinAware].
83+
* Injects a [ViewModel] into a [Fragment] that implements [DIAware].
8884
*
8985
* Requires previous [ViewModelProvider.Factory] injection for the [ViewModel] via [bindViewModelFactory]
9086
* to work and a [TypedViewModel] to be used.
9187
*/
9288
@MainThread
93-
inline fun <reified T, reified VM : TypedViewModel<T>, F> F.viewModel(params: T): Lazy<VM> where F : KodeinAware, F : Fragment {
89+
inline fun <reified T : Any, reified VM : TypedViewModel<T>, F> F.viewModel(params: T): Lazy<VM> where F : DIAware, F : Fragment {
9490
return lazy {
9591
ViewModelProvider(this, direct.instance(VM::class.java, params)).get(VM::class.java)
9692
}
9793
}
9894

9995
/**
100-
* Injects a [ViewModel] with an [Activity] context that implements [KodeinAware], in order to share it between
96+
* Injects a [ViewModel] with an [Activity] context that implements [DIAware
97+
* ], in order to share it between
10198
* different fragments hosted by that same [Activity].
10299
*/
103100
@MainThread
104-
inline fun <reified VM : ViewModel, F> F.sharedActivityViewModel(): Lazy<VM> where F : KodeinAware, F : Fragment {
101+
inline fun <reified VM : ViewModel, F> F.sharedActivityViewModel(): Lazy<VM> where F : DIAware, F : Fragment {
105102
return lazy {
106103
ViewModelProvider(this.requireActivity(), direct.instance()).get(VM::class.java)
107104
}
108105
}
109106

110107
/**
111-
* Injects a [ViewModel] with an [Activity] context that implements [KodeinAware], in order to share it between
108+
* Injects a [ViewModel] with an [Activity] context that implements [DIAware], in order to share it between
112109
* different fragments hosted by that same [Activity].
113110
*
114111
* Requires previous [ViewModelProvider.Factory] injection for the [ViewModel] via [bindViewModelFactory]
115112
* to work and a [TypedViewModel] to be used.
116113
*/
117114
@MainThread
118-
inline fun <reified T, reified VM : TypedViewModel<T>, F> F.sharedActivityViewModel(params: T): Lazy<VM> where F : KodeinAware, F : Fragment {
115+
inline fun <reified T: Any, reified VM : TypedViewModel<T>, F> F.sharedActivityViewModel(params: T): Lazy<VM> where F : DIAware, F : Fragment {
119116
return lazy {
120117
ViewModelProvider(this.requireActivity(), direct.instance(VM::class.java, params)).get(VM::class.java)
121118
}
@@ -125,4 +122,4 @@ inline fun <reified T, reified VM : TypedViewModel<T>, F> F.sharedActivityViewMo
125122
* Generic [ViewModel] that adds support for adding a single [params] object to ease parameter
126123
* injection.
127124
*/
128-
open class TypedViewModel<T>(private val params: T) : ViewModel()
125+
open class TypedViewModel<T>(private val params: T) : ViewModel()

mini-kodein/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies {
1414
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
1515
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
1616

17-
def kodein_version = "6.5.5"
18-
api "org.kodein.di:kodein-di-generic-jvm:$kodein_version"
17+
def kodein_version = "7.1.0"
18+
api "org.kodein.di:kodein-di-jvm:$kodein_version"
1919
api "org.kodein.di:kodein-di-framework-android-x:$kodein_version"
2020
}
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
package mini.kodein
22

33
import mini.Store
4-
import org.kodein.di.Kodein
5-
import org.kodein.di.bindings.NoArgSimpleBindingKodein
6-
import org.kodein.di.generic.bind
7-
import org.kodein.di.generic.inSet
8-
import org.kodein.di.generic.instance
9-
import org.kodein.di.generic.singleton
4+
import org.kodein.di.*
5+
import org.kodein.di.bindings.NoArgBindingDI
106

117
/**
128
* Work based on: https://proandroiddev.com/android-viewmodel-dependency-injection-with-kodein-249f80f083c9
@@ -15,7 +11,7 @@ import org.kodein.di.generic.singleton
1511
/**
1612
* Binds a store in a Kodein module, assuming that it's a singleton dependency.
1713
*/
18-
inline fun <reified T : Store<*>> Kodein.Builder.bindStore(noinline creator: NoArgSimpleBindingKodein<*>.() -> T) {
14+
inline fun <reified T : Store<*>> DI.Builder.bindStore(noinline creator: NoArgBindingDI<*>.() -> T) {
1915
bind<T>() with singleton(creator = creator)
2016
bind<Store<*>>().inSet() with singleton { instance<T>() }
2117
}

mini-rx2-android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ dependencies {
3131
api project(":mini-android")
3232

3333
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
34-
implementation 'androidx.appcompat:appcompat:1.1.0'
34+
implementation 'androidx.appcompat:appcompat:1.2.0'
3535

3636
api "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
3737
api "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
3838

3939
testImplementation 'junit:junit:4.13'
40-
androidTestImplementation 'androidx.test:runner:1.2.0'
41-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
40+
androidTestImplementation 'androidx.test:runner:1.3.0'
41+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
4242
}
4343

4444
apply from: "../jitpack-android.gradle"

0 commit comments

Comments
 (0)