diff --git a/archy-android/build.gradle.kts b/archy-android/build.gradle.kts index 75d3f62..eee4730 100644 --- a/archy-android/build.gradle.kts +++ b/archy-android/build.gradle.kts @@ -17,7 +17,6 @@ val androidLibraries = listOf( androidLibs.appCompat, androidLibs.fragment, androidLibs.lifecycleViewModelSavedState, - androidLibs.annotation, androidLibs.koin ) diff --git a/archy-android/src/androidTest/java/com/merseyside/archy/ExampleInstrumentedTest.kt b/archy-android/src/androidTest/java/com/merseyside/archy/ExampleInstrumentedTest.kt deleted file mode 100644 index ffc8ae1..0000000 --- a/archy-android/src/androidTest/java/com/merseyside/archy/ExampleInstrumentedTest.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.merseyside.archy - -import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - -import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* - -/** - * Instrumented test, which will execute on an Android device. - * - * See [testing documentation](http://d.android.com/tools/testing). - */ -@RunWith(AndroidJUnit4::class) -class ExampleInstrumentedTest { - @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.merseyside.archy", appContext.packageName) - } -} \ No newline at end of file diff --git a/archy-android/src/main/java/com/merseyside/merseyLib/archy/android/presentation/fragment/BaseVMFragment.kt b/archy-android/src/main/java/com/merseyside/merseyLib/archy/android/presentation/fragment/BaseVMFragment.kt index 79a0494..cc9993b 100644 --- a/archy-android/src/main/java/com/merseyside/merseyLib/archy/android/presentation/fragment/BaseVMFragment.kt +++ b/archy-android/src/main/java/com/merseyside/merseyLib/archy/android/presentation/fragment/BaseVMFragment.kt @@ -133,7 +133,7 @@ abstract class BaseVMFragment protected open fun loadingObserver(isLoading: Boolean) {} - private fun showErrorMsg(textMessage: BaseViewModel.TextMessage) { + fun showErrorMsg(textMessage: BaseViewModel.TextMessage) { if (textMessage.actionMsg.isNullOrEmpty()) { showErrorMsg(textMessage.msg) } else { diff --git a/archy-core/build.gradle.kts b/archy-core/build.gradle.kts index d493e34..bf87906 100644 --- a/archy-core/build.gradle.kts +++ b/archy-core/build.gradle.kts @@ -9,13 +9,6 @@ plugins { `maven-publish-config` } -kotlin { - android { - publishLibraryVariants("release", "debug") - publishLibraryVariantsGroupedByFlavor = true - } -} - multiplatformResources { multiplatformResourcesPackage = Application.applicationId // required } @@ -25,6 +18,7 @@ val mppLibs = listOf( multiplatformLibs.serialization, multiplatformLibs.moko.mvvm, multiplatformLibs.moko.mvvm.livedata, + multiplatformLibs.moko.resources, multiplatformLibs.koin ) @@ -33,13 +27,14 @@ val mppModules = listOf( ) dependencies { - mppModules.forEach { module -> commonMainImplementation(module) } + mppModules.forEach { module -> commonMainApi(module) } mppLibs.forEach { commonMainApi(it) } - - compileOnly("javax.annotation:jsr250-api:1.0") } framework { mppModules.forEach { export(it) } - //mppLibs.forEach { export(it.toProvider()) } + + export(multiplatformLibs.moko.mvvm.asProvider()) + export(multiplatformLibs.moko.mvvm.livedata) + export(multiplatformLibs.moko.resources) } \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index d1a274b..5481fba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,10 +15,7 @@ allprojects { google() - maven { url = uri("https://jitpack.io") } - maven { url = uri("https://raw.githubusercontent.com/guardianproject/gpmaven/master") } - maven { url = uri("https://maven.fabric.io/public") } - maven { url = uri("https://plugins.gradle.org/m2/") } + maven("https://jitpack.io") } } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 2dd032f..052cc14 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,7 +1,5 @@ plugins { `kotlin-dsl` - kotlin("jvm") version "1.6.0" - kotlin("plugin.serialization") version "1.6.0" } repositories { @@ -12,12 +10,12 @@ repositories { } val multiplatform = "0.12.0" -val kotlin = "1.6.0" -val gradle = "7.0.3" -val resources = "0.15.1" +val kotlin = "1.6.20-RC" +val gradle = "7.3.0-alpha05" +val resources = "0.18.0" val sqldelight = "1.5.3" val nexus = "1.1.0" -val navigation = "2.4.0-beta02" +val navigation = "2.5.0-alpha01" dependencies { implementation("dev.icerock:mobile-multiplatform:$multiplatform") diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 47e2eec..4fb031e 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -3,7 +3,7 @@ object Application { const val applicationId = "com.merseyside.merseyLib" const val version = Metadata.version - const val versionCode = 141 + const val versionCode = 146 const val compileSdk = 30 const val targetSdk = 30 diff --git a/buildSrc/src/main/kotlin/commons/android-convention.gradle.kts b/buildSrc/src/main/kotlin/commons/android-convention.gradle.kts index 2890a1b..c8b2638 100644 --- a/buildSrc/src/main/kotlin/commons/android-convention.gradle.kts +++ b/buildSrc/src/main/kotlin/commons/android-convention.gradle.kts @@ -18,9 +18,6 @@ android { lint { lintConfig = rootProject.file(".lint/config.xml") - isCheckAllWarnings = true - isWarningsAsErrors = true - isAbortOnError = false } compileOptions { diff --git a/buildSrc/src/main/kotlin/commons/kotlin-multiplatform-convention.gradle.kts b/buildSrc/src/main/kotlin/commons/kotlin-multiplatform-convention.gradle.kts index 9474955..3b4eb6f 100644 --- a/buildSrc/src/main/kotlin/commons/kotlin-multiplatform-convention.gradle.kts +++ b/buildSrc/src/main/kotlin/commons/kotlin-multiplatform-convention.gradle.kts @@ -5,6 +5,24 @@ plugins { id("org.jetbrains.kotlin.multiplatform") } +kotlin { + + android { + publishLibraryVariants("release", "debug") + publishLibraryVariantsGroupedByFlavor = true + } + + ios() + // Add the ARM64 simulator target + iosSimulatorArm64() + + val iosMain by sourceSets.getting + val iosSimulatorArm64Main by sourceSets.getting + + // Set up dependencies between the source sets + iosSimulatorArm64Main.dependsOn(iosMain) +} + tasks.withType { kotlinOptions { jvmTarget = "11" diff --git a/buildSrc/src/main/kotlin/extensions/GradleExtensions.kt b/buildSrc/src/main/kotlin/extensions/GradleExtensions.kt index ccaaa04..4064247 100644 --- a/buildSrc/src/main/kotlin/extensions/GradleExtensions.kt +++ b/buildSrc/src/main/kotlin/extensions/GradleExtensions.kt @@ -1,3 +1,4 @@ +import dev.icerock.gradle.FrameworkConfig import org.gradle.api.Project import org.gradle.api.artifacts.MinimalExternalModuleDependency import org.gradle.api.internal.catalog.ExternalModuleDependencyFactory @@ -15,7 +16,7 @@ inline fun Project.findTypedProperty(propertyName: String): T { Float::class -> stringProperty else -> it } - } as? T ?: throw NotFoundException("Property $propertyName not found") + } as? T ?: throw Exception("Property $propertyName not found") } fun Project.isLocalDependencies(): Boolean = @@ -27,10 +28,14 @@ fun Project.isLocalAndroidDependencies(): Boolean = fun Project.isLocalKotlinExtLibrary(): Boolean = findTypedProperty("build.localKotlinExtLibrary") -inline fun Any.toProvider(): Provider { - return when (this) { - is Provider<*> -> this as Provider - is ExternalModuleDependencyFactory.ProviderConvertible<*> -> this.asProvider() as Provider - else -> throw Exception("Wrong type") +fun FrameworkConfig.exportVersionCatalogLib(library: Any) { + when(library) { + is Provider<*> -> { + if (library.get() is MinimalExternalModuleDependency) export(library as Provider) + else throw IllegalArgumentException() + } + + is ExternalModuleDependencyFactory.DependencyNotationSupplier -> library.asProvider() + else -> throw Exception() } -} +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/publication/Metadata.kt b/buildSrc/src/main/kotlin/publication/Metadata.kt index 2bee9ac..5c08ffc 100644 --- a/buildSrc/src/main/kotlin/publication/Metadata.kt +++ b/buildSrc/src/main/kotlin/publication/Metadata.kt @@ -1,4 +1,4 @@ object Metadata { const val groupId = "io.github.merseyside" - const val version = "1.4.5" + const val version = "1.4.6" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 158f8dd..ec6b2e7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Feb 04 15:25:14 NOVT 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index cb888cd..cdb6b8c 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -10,7 +10,7 @@ dependencyResolutionManagement { mavenLocal() } - val catalogVersions = "1.2.2" + val catalogVersions = "1.3.2" val group = "io.github.merseyside" versionCatalogs { val multiplatformLibs by creating { diff --git a/utils-core/build.gradle.kts b/utils-core/build.gradle.kts index 0bbf37c..6c36e30 100644 --- a/utils-core/build.gradle.kts +++ b/utils-core/build.gradle.kts @@ -17,13 +17,6 @@ android { } } -kotlin { - android { - publishLibraryVariants("release", "debug") - publishLibraryVariantsGroupedByFlavor = true - } -} - val mppLibs = listOf( common.merseyLib.time, multiplatformLibs.serialization, @@ -47,7 +40,7 @@ dependencies { } else { commonMainApi(common.merseyLib.kotlin.ext) } - commonMainImplementation(multiplatformLibs.bundles.moko.mvvm) + commonMainApi(multiplatformLibs.bundles.moko.mvvm) mppLibs.forEach { commonMainImplementation(it) } android.forEach { lib -> implementation(lib) } @@ -55,5 +48,7 @@ dependencies { } framework { - //mppLibs.forEach { export(it.toProvider()) } + export(multiplatformLibs.moko.mvvm.asProvider()) + export(multiplatformLibs.moko.mvvm.livedata) + export(multiplatformLibs.moko.resources) } diff --git a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ObservableField.kt b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ObservableField.kt deleted file mode 100644 index 643c014..0000000 --- a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ObservableField.kt +++ /dev/null @@ -1,62 +0,0 @@ -package com.merseyside.merseyLib.utils.core - -abstract class ObservableField { - abstract val value: T? - - protected val observableList: MutableList<(T) -> Unit> = mutableListOf() - - fun observe(block: (T) -> Unit): Disposable { - observableList.add(block) - value?.let { - block(it) - } - - return Disposable(this, block) - } - - fun removeObserver(block: (T) -> Unit) { - observableList.remove(block) - } - - fun removeAllObservers() { observableList.clear() } -} - -open class MutableObservableField(initialValue: T? = null): ObservableField() { - - override var value: T? = initialValue - set(value) { - field = value - - if (value != null) { - if (observableList.isNotEmpty()) { - observableList.forEach { it(value) } - } - } - } -} - -class SingleObservableField(initialValue: T? = null): ObservableField() { - override var value: T? = initialValue - get() { - return field.also { value = null } - } - set(value) { - field = value - - if (value != null) { - if (observableList.isNotEmpty()) { - val v = this.value ?: return - observableList.forEach { it(v) } - } - } - } -} - -class Disposable( - private val field: ObservableField, - private val observer: (T) -> Unit -) { - fun dispose() { - field.removeObserver(observer) - } -} \ No newline at end of file diff --git a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/coroutines/CountDownTimer.kt b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/coroutines/CountDownTimer.kt index 7b89835..86967d7 100644 --- a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/coroutines/CountDownTimer.kt +++ b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/coroutines/CountDownTimer.kt @@ -5,16 +5,19 @@ package com.merseyside.merseyLib.utils.core.coroutines */ import com.merseyside.merseyLib.kotlin.Logger -import com.merseyside.merseyLib.time.Seconds -import com.merseyside.merseyLib.time.TimeUnit -import com.merseyside.merseyLib.time.minus +import com.merseyside.merseyLib.time.units.Seconds +import com.merseyside.merseyLib.time.units.TimeUnit +import com.merseyside.merseyLib.time.units.minus import com.merseyside.merseyLib.utils.core.ext.delay +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.* +import kotlinx.coroutines.withContext class CountDownTimer( private val listener: CoroutineTimerListener, private val delay: TimeUnit = Seconds(1), - private val scope: CoroutineScope = CoroutineScope(Job() + Dispatchers.Unconfined)) { + private val scope: CoroutineScope = CoroutineScope(Job() + Dispatchers.Unconfined) +) { private var timerJob: Job? = null private var countDownTimer: TimeUnit = TimeUnit.getEmpty() @@ -48,7 +51,9 @@ class CountDownTimer( fun stopTimer() { val error = if (state == CurrentTimerState.STOPPED) { TimerException(TimerErrorTypes.NO_TIMER_RUNNING) - } else { null } + } else { + null + } timerJob?.cancel() state = CurrentTimerState.STOPPED listener.onStop(error) @@ -77,6 +82,7 @@ class CountDownTimer( private fun timerCanStart() { timerJob = scope.launch { + withContext(Dispatchers.Unconfined) { state = CurrentTimerState.RUNNING @@ -106,9 +112,10 @@ class CountDownTimer( } } - private suspend fun onTick(timeLeft: TimeUnit, error: Exception? = null) = withContext(Dispatchers.Main) { - listener.onTick(timeLeft, error) - } + private suspend fun onTick(timeLeft: TimeUnit, error: Exception? = null) = + withContext(Dispatchers.Main) { + listener.onTick(timeLeft, error) + } companion object { const val TAG = "CoroutineTimer" @@ -134,4 +141,4 @@ enum class TimerErrorTypes(val message: String) { DESTROYED("This timer is destroyed and can't be used anymore") } -private class TimerException(val type: TimerErrorTypes): Exception(type.message) \ No newline at end of file +private class TimerException(val type: TimerErrorTypes) : Exception(type.message) \ No newline at end of file diff --git a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ext/Coroutines.kt b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ext/Coroutines.kt deleted file mode 100644 index 8415e94..0000000 --- a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ext/Coroutines.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.merseyside.merseyLib.utils.core.ext - -import com.merseyside.merseyLib.time.TimeUnit -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.async - -suspend fun delay(timeUnit: TimeUnit) = kotlinx.coroutines.delay(timeUnit.millis) \ No newline at end of file diff --git a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ext/CoroutinesExt.kt b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ext/CoroutinesExt.kt new file mode 100644 index 0000000..3238354 --- /dev/null +++ b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ext/CoroutinesExt.kt @@ -0,0 +1,6 @@ +package com.merseyside.merseyLib.utils.core.ext + +import com.merseyside.merseyLib.time.units.TimeUnit + + +suspend fun delay(timeUnit: TimeUnit) = kotlinx.coroutines.delay(timeUnit.millis) \ No newline at end of file diff --git a/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ktor/JsonHelper.kt b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ktor/JsonHelper.kt new file mode 100644 index 0000000..e32910e --- /dev/null +++ b/utils-core/src/commonMain/kotlin/com/merseyside/merseyLib/utils/core/ktor/JsonHelper.kt @@ -0,0 +1,14 @@ +package com.merseyside.merseyLib.utils.core.ktor + +import com.merseyside.merseyLib.time.units.TimeUnit +import kotlinx.serialization.json.JsonElement +import kotlinx.serialization.json.JsonObjectBuilder +import kotlinx.serialization.json.put + +fun JsonObjectBuilder.put(key: String, timeUnit: TimeUnit): JsonElement? { + return put(key, timeUnit.value) +} + +fun JsonObjectBuilder.putSafe(key: String, timeUnit: TimeUnit?): JsonElement? { + return timeUnit?.let { put(key, timeUnit) } +} \ No newline at end of file