Skip to content

Commit 841a6ad

Browse files
authored
refactor: migrate [core.model] to KMP (openMF#2285)
* migrate [core.model] to KMP applied spotless and detekt rename fixed spotless fix removed parcelize * fix spotless
1 parent 5f77fdf commit 841a6ad

File tree

265 files changed

+1319
-968
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

265 files changed

+1319
-968
lines changed

core/common/build.gradle.kts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
99
*/
1010
plugins {
11-
alias(libs.plugins.mifos.android.library)
11+
alias(libs.plugins.mifos.kmp.library)
12+
id(libs.plugins.kotlin.parcelize.get().pluginId)
13+
id("kotlinx-serialization")
14+
1215
alias(libs.plugins.mifos.android.hilt)
1316
alias(libs.plugins.mifos.android.library.jacoco)
1417
alias(libs.plugins.secrets)
@@ -27,7 +30,7 @@ secrets {
2730
}
2831

2932
dependencies {
30-
implementation(projects.core.model)
33+
// implementation(projects.core.model)
3134
testImplementation(libs.kotlinx.coroutines.test)
3235
testImplementation(libs.turbine)
3336

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2024 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.common.utils
11+
12+
expect annotation class Parcelize()
13+
14+
expect interface Parcelable
15+
16+
expect annotation class IgnoredOnParcel()
17+
18+
expect interface Parceler<P> {
19+
fun create(parcel: Parcel): P
20+
21+
fun P.write(parcel: Parcel, flags: Int)
22+
}
23+
24+
expect annotation class TypeParceler<T, P : Parceler<in T>>()
25+
26+
expect class Parcel {
27+
fun readByte(): Byte
28+
fun readInt(): Int
29+
30+
fun readFloat(): Float
31+
fun readDouble(): Double
32+
fun readString(): String?
33+
34+
fun writeByte(value: Byte)
35+
fun writeInt(value: Int)
36+
37+
fun writeFloat(value: Float)
38+
39+
fun writeDouble(value: Double)
40+
fun writeString(value: String?)
41+
}

core/model/src/main/kotlin/com/mifos/core/model/ServerConfig.kt renamed to core/common/src/commonMain/kotlin/com/mifos/core/common/utils/ServerConfig.kt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77
*
88
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
99
*/
10-
package com.mifos.core.model
11-
12-
import com.google.gson.annotations.SerializedName
10+
package com.mifos.core.common.utils
1311

12+
@Serializable
1413
data class ServerConfig(
1514
val protocol: String,
16-
@SerializedName("end_point")
15+
@SerialName("end_point")
1716
val endPoint: String,
18-
@SerializedName("api_path")
17+
@SerialName("api_path")
1918
val apiPath: String,
2019
val port: String,
2120
val tenant: String,
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.common.utils
11+
12+
actual interface Parcelable
13+
actual annotation class IgnoredOnParcel
14+
actual annotation class Parcelize
15+
actual interface Parceler<P> {
16+
actual fun create(parcel: Parcel): P
17+
actual fun P.write(parcel: Parcel, flags: Int)
18+
}
19+
20+
actual annotation class TypeParceler<T, P : Parceler<in T>>
21+
22+
actual class Parcel {
23+
actual fun readString(): String? = null
24+
actual fun readByte(): Byte = 1
25+
26+
actual fun readInt(): Int = 1
27+
28+
actual fun readFloat(): Float = 1f
29+
30+
actual fun readDouble(): Double = 1.0
31+
32+
actual fun writeByte(value: Byte) {
33+
}
34+
35+
actual fun writeInt(value: Int) {
36+
}
37+
38+
actual fun writeFloat(value: Float) {
39+
}
40+
41+
actual fun writeDouble(value: Double) {
42+
}
43+
44+
actual fun writeString(value: String?) {
45+
}
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.common.utils
11+
12+
actual interface Parcelable
13+
actual annotation class IgnoredOnParcel
14+
actual annotation class Parcelize
15+
actual interface Parceler<P> {
16+
actual fun create(parcel: Parcel): P
17+
actual fun P.write(parcel: Parcel, flags: Int)
18+
}
19+
20+
actual annotation class TypeParceler<T, P : Parceler<in T>>
21+
22+
actual class Parcel {
23+
actual fun readString(): String? = null
24+
actual fun readByte(): Byte = 1
25+
26+
actual fun readInt(): Int = 1
27+
28+
actual fun readFloat(): Float = 1f
29+
30+
actual fun readDouble(): Double = 1.0
31+
32+
actual fun writeByte(value: Byte) {
33+
}
34+
35+
actual fun writeInt(value: Int) {
36+
}
37+
38+
actual fun writeFloat(value: Float) {
39+
}
40+
41+
actual fun writeDouble(value: Double) {
42+
}
43+
44+
actual fun writeString(value: String?) {
45+
}
46+
}

core/common/src/main/java/com/mifos/core/common/utils/JsonExtension.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
package com.mifos.core.common.utils
1111

1212
import com.google.gson.Gson
13-
import com.mifos.core.model.ServerConfig
13+
import core.mifos.core.model.ServerConfig
1414

15-
fun String.asServerConfig(): ServerConfig {
15+
fun String.asServerConfig(): core.mifos.core.model.ServerConfig {
1616
val jsonString = this.replace("'", "\"")
17-
return Gson().fromJson(jsonString, ServerConfig::class.java)
17+
return Gson().fromJson(jsonString, core.mifos.core.model.ServerConfig::class.java)
1818
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.common.utils
11+
12+
import android.os.Parcel
13+
import android.os.Parcelable
14+
import kotlinx.parcelize.IgnoredOnParcel
15+
import kotlinx.parcelize.Parceler
16+
import kotlinx.parcelize.Parcelize
17+
import kotlinx.parcelize.TypeParceler
18+
19+
actual typealias Parcelize = Parcelize
20+
21+
actual typealias Parcelable = Parcelable
22+
23+
actual typealias IgnoredOnParcel = IgnoredOnParcel
24+
25+
actual typealias Parceler<P> = Parceler<P>
26+
27+
actual typealias TypeParceler<T, P> = TypeParceler<T, P>
28+
29+
actual typealias Parcel = Parcel
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.common.utils
11+
12+
actual interface Parcelable
13+
actual annotation class IgnoredOnParcel
14+
actual annotation class Parcelize
15+
actual interface Parceler<P> {
16+
actual fun create(parcel: Parcel): P
17+
actual fun P.write(parcel: Parcel, flags: Int)
18+
}
19+
20+
actual annotation class TypeParceler<T, P : Parceler<in T>>
21+
22+
actual class Parcel {
23+
actual fun readString(): String? = null
24+
actual fun readByte(): Byte = 1
25+
26+
actual fun readInt(): Int = 1
27+
28+
actual fun readFloat(): Float = 1f
29+
30+
actual fun readDouble(): Double = 1.0
31+
32+
actual fun writeByte(value: Byte) {
33+
}
34+
35+
actual fun writeInt(value: Int) {
36+
}
37+
38+
actual fun writeFloat(value: Float) {
39+
}
40+
41+
actual fun writeDouble(value: Double) {
42+
}
43+
44+
actual fun writeString(value: String?) {
45+
}
46+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2025 Mifos Initiative
3+
*
4+
* This Source Code Form is subject to the terms of the Mozilla Public
5+
* License, v. 2.0. If a copy of the MPL was not distributed with this
6+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
7+
*
8+
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
9+
*/
10+
package com.mifos.core.common.utils
11+
12+
actual interface Parcelable
13+
actual annotation class IgnoredOnParcel
14+
actual annotation class Parcelize
15+
actual interface Parceler<P> {
16+
actual fun create(parcel: Parcel): P
17+
actual fun P.write(parcel: Parcel, flags: Int)
18+
}
19+
20+
actual annotation class TypeParceler<T, P : Parceler<in T>>
21+
22+
actual class Parcel {
23+
actual fun readString(): String? = null
24+
actual fun readByte(): Byte = 1
25+
26+
actual fun readInt(): Int = 1
27+
28+
actual fun readFloat(): Float = 1f
29+
30+
actual fun readDouble(): Double = 1.0
31+
32+
actual fun writeByte(value: Byte) {
33+
}
34+
35+
actual fun writeInt(value: Int) {
36+
}
37+
38+
actual fun writeFloat(value: Float) {
39+
}
40+
41+
actual fun writeDouble(value: Double) {
42+
}
43+
44+
actual fun writeString(value: String?) {
45+
}
46+
}

core/data/src/main/java/com/mifos/core/data/repository/CheckerInboxTasksRepository.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
package com.mifos.core.data.repository
1111

1212
import com.mifos.core.objects.checkerinboxtask.CheckerTask
13-
import com.mifos.core.objects.checkerinboxtask.RescheduleLoansTask
1413
import kotlinx.coroutines.flow.Flow
1514

1615
/**
@@ -19,7 +18,7 @@ import kotlinx.coroutines.flow.Flow
1918

2019
interface CheckerInboxTasksRepository {
2120

22-
suspend fun getRescheduleLoansTaskList(): Flow<List<RescheduleLoansTask>>
21+
suspend fun getRescheduleLoansTaskList(): Flow<List<com.mifos.core.model.objects.checkerinboxtask.RescheduleLoansTask>>
2322

2423
suspend fun getCheckerTaskList(
2524
actionName: String? = null,

0 commit comments

Comments
 (0)