diff --git a/.github/workflows/internal.yml b/.github/workflows/internal.yml index f2190d8146..5d4c8f2d54 100644 --- a/.github/workflows/internal.yml +++ b/.github/workflows/internal.yml @@ -25,7 +25,7 @@ jobs: uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff # v3 with: cache-read-only: false - arguments: testDebug detekt lint + arguments: testDebugUnitTest desktopTest detekt lint build_number: name: Generate build number runs-on: ubuntu-latest diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 22537474d9..e1249cd0ec 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -45,7 +45,7 @@ jobs: - name: Unit test uses: gradle/gradle-build-action@4c39dd82cd5e1ec7c6fa0173bb41b4b6bb3b86ff # v3 with: - arguments: testDebug + arguments: testDebugUnitTest desktopTest detekt: name: "Check project by detekt" runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa30eab77..e7a2cf0df6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ # 1.6.10 - In Progress -- +- [KMP] Migration core:activityholder, core:di, core:progpress, core:ui:decompose # 1.6.9 diff --git a/build-logic/plugins/convention/build.gradle.kts b/build-logic/plugins/convention/build.gradle.kts index 5e2a3b6926..4ff5519ecc 100644 --- a/build-logic/plugins/convention/build.gradle.kts +++ b/build-logic/plugins/convention/build.gradle.kts @@ -1,5 +1,6 @@ plugins { `kotlin-dsl` + id("java-gradle-plugin") } dependencies { @@ -17,3 +18,12 @@ dependencies { implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) } + +gradlePlugin { + plugins { + create("flipper.multiplatform-dependencies") { + id = name + implementationClass = "com.flipperdevices.buildlogic.plugin.FlipperMultiplatformDependenciesPlugin" + } + } +} diff --git a/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/ApkConfig.kt b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/ApkConfig.kt index 82bf3e0a08..b1b39ef214 100644 --- a/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/ApkConfig.kt +++ b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/ApkConfig.kt @@ -1,5 +1,6 @@ package com.flipperdevices.buildlogic +import com.flipperdevices.buildlogic.model.FlavorType import org.gradle.api.Project object ApkConfig { @@ -49,6 +50,21 @@ object ApkConfig { val Project.IS_SENTRY_ENABLED get() = prop("is_metric_enabled", true).toBoolean() + + val Project.CURRENT_FLAVOR_TYPE: FlavorType + get() { + val default = FlavorType.DEV + val key = "CURRENT_FLAVOR_TYPE" + val propValue = propOrNull(key) + if (propValue == null) { + logger.warn("Property $key was not found, writing default $default") + } + return FlavorType.values().find { it.name == propValue } ?: default + } +} + +internal fun Project.propOrNull(key: String): String? { + return providers.gradleProperty(key).orNull } internal fun Project.prop(key: String, default: Any): String { diff --git a/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/model/FlavorType.kt b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/model/FlavorType.kt new file mode 100644 index 0000000000..96572d8cac --- /dev/null +++ b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/model/FlavorType.kt @@ -0,0 +1,14 @@ +package com.flipperdevices.buildlogic.model + +/** + * This enum is used to define new kotlin-generated BuildKonfig + * + * We already have multiple flavors for android - debug, internal, release + * but android's flavor BuildConfig generation isn't compatible with KMP, + * so in the end, when project will e KMP-full, this will be final version + * of BuildKonfig field values + */ +enum class FlavorType(val isLogEnabled: Boolean) { + DEV(isLogEnabled = true), + PROD(isLogEnabled = false) +} diff --git a/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesPlugin.kt b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesPlugin.kt new file mode 100644 index 0000000000..e8e0b41682 --- /dev/null +++ b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesPlugin.kt @@ -0,0 +1,36 @@ +package com.flipperdevices.buildlogic.plugin + +import com.flipperdevices.buildlogic.util.ProjectExt.kotlin +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.create + +class FlipperMultiplatformDependenciesPlugin : Plugin { + override fun apply(target: Project) { + target.kotlin.sourceSets.forEach { sourceSet -> + val fullSourceSetName = sourceSet.name + val noMainSourceSetName = if (fullSourceSetName.endsWith(MAIN_SOURCE_SET_POSTFIX)) { + fullSourceSetName.replace( + oldValue = MAIN_SOURCE_SET_POSTFIX, + newValue = "" + ) + } else { + fullSourceSetName + } + + target.extensions.create( + "${noMainSourceSetName}Dependencies", + FlipperMultiplatformDependenciesScope::class, + target, + fullSourceSetName + ) + } + } + + companion object { + /** + * The postfix of default source set naming aka commonMain, androidMain etc + */ + private const val MAIN_SOURCE_SET_POSTFIX = "Main" + } +} diff --git a/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesScope.kt b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesScope.kt new file mode 100644 index 0000000000..5ed6495c65 --- /dev/null +++ b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/plugin/FlipperMultiplatformDependenciesScope.kt @@ -0,0 +1,14 @@ +package com.flipperdevices.buildlogic.plugin + +import com.flipperdevices.buildlogic.util.ProjectExt.kotlin +import org.gradle.api.Project +import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler +import org.jetbrains.kotlin.gradle.plugin.mpp.DefaultKotlinDependencyHandler + +open class FlipperMultiplatformDependenciesScope( + project: Project, + name: String +) : KotlinDependencyHandler by DefaultKotlinDependencyHandler( + parent = project.kotlin.sourceSets.getByName(name), + project = project +) diff --git a/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/util/ProjectExt.kt b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/util/ProjectExt.kt new file mode 100644 index 0000000000..1f20f57aee --- /dev/null +++ b/build-logic/plugins/convention/src/main/kotlin/com/flipperdevices/buildlogic/util/ProjectExt.kt @@ -0,0 +1,16 @@ +package com.flipperdevices.buildlogic.util + +import org.gradle.api.Project +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension + +internal object ProjectExt { + /** + * Required to remove gradle.kotlin.dsl.accessors dependency + */ + val Project.kotlin: KotlinMultiplatformExtension + get() { + val extensionAware = (this as org.gradle.api.plugins.ExtensionAware) + val kotlinExtension = extensionAware.extensions.getByName("kotlin") + return kotlinExtension as KotlinMultiplatformExtension + } +} diff --git a/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform-compose.gradle.kts b/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform-compose.gradle.kts index f4645f6550..d7d1f0f428 100644 --- a/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform-compose.gradle.kts +++ b/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform-compose.gradle.kts @@ -21,7 +21,27 @@ kotlin { jvm("desktop") sourceSets { - val desktopMain by getting + val commonMain by getting + + /** + * We shouldn't create sources, which is named as original targets sourcesets. + * + * As an example - jvm() target will create sourceSet jvmMain - and we would have conflicts + * with our create jvmMain sourceSet + * + * This is the reason to name it `jvmSharedMain` + */ + val jvmSharedMain by creating { + dependsOn(commonMain) + } + + val androidMain by getting { + dependsOn(jvmSharedMain) + } + + val desktopMain by getting { + dependsOn(jvmSharedMain) + } androidMain.dependencies { implementation(libs.compose.tooling) @@ -36,5 +56,22 @@ kotlin { desktopMain.dependencies { implementation(compose.desktop.currentOs) } + + // Testing + val commonTest by getting + + val jvmSharedTest by creating { + dependsOn(commonTest) + } + + @Suppress("UnusedPrivateProperty") + val androidUnitTest by getting { + dependsOn(jvmSharedTest) + } + + @Suppress("UnusedPrivateProperty") + val desktopTest by getting { + dependsOn(jvmSharedTest) + } } } diff --git a/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform.gradle.kts b/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform.gradle.kts index 0f78281ad1..264bd0a4d5 100644 --- a/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform.gradle.kts +++ b/build-logic/plugins/convention/src/main/kotlin/flipper.multiplatform.gradle.kts @@ -20,7 +20,27 @@ kotlin { jvm("desktop") sourceSets { - val desktopMain by getting + val commonMain by getting + + /** + * We shouldn't create sources, which is named as original targets sourcesets. + * + * As an example - jvm() target will create sourceSet jvmMain - and we would have conflicts + * with our create jvmMain sourceSet + * + * This is the reason to name it `jvmSharedMain` + */ + val jvmSharedMain by creating { + dependsOn(commonMain) + } + + val androidMain by getting { + dependsOn(jvmSharedMain) + } + + val desktopMain by getting { + dependsOn(jvmSharedMain) + } androidMain.dependencies { } @@ -28,5 +48,22 @@ kotlin { } desktopMain.dependencies { } + + // Testing + val commonTest by getting + + val jvmSharedTest by creating { + dependsOn(commonTest) + } + + @Suppress("UnusedPrivateProperty") + val androidUnitTest by getting { + dependsOn(jvmSharedTest) + } + + @Suppress("UnusedPrivateProperty") + val desktopTest by getting { + dependsOn(jvmSharedTest) + } } } diff --git a/build.gradle.kts b/build.gradle.kts index c5d1af325d..94b4610a82 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,4 +10,5 @@ plugins { id("flipper.lint") alias(libs.plugins.android.test) apply false alias(libs.plugins.baselineprofile) apply false + alias(libs.plugins.buildkonfig) apply false } diff --git a/components/core/activityholder/build.gradle.kts b/components/core/activityholder/build.gradle.kts index 50934aa55d..e14a97d192 100644 --- a/components/core/activityholder/build.gradle.kts +++ b/components/core/activityholder/build.gradle.kts @@ -1,9 +1,10 @@ plugins { - id("flipper.android-lib") + id("flipper.multiplatform") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.activityholder" -dependencies { +androidDependencies { implementation(libs.appcompat) } diff --git a/components/core/activityholder/src/main/java/com/flipperdevices/core/activityholder/CurrentActivityHolder.kt b/components/core/activityholder/src/androidMain/kotlin/com/flipperdevices/core/activityholder/CurrentActivityHolder.kt similarity index 100% rename from components/core/activityholder/src/main/java/com/flipperdevices/core/activityholder/CurrentActivityHolder.kt rename to components/core/activityholder/src/androidMain/kotlin/com/flipperdevices/core/activityholder/CurrentActivityHolder.kt diff --git a/components/core/build-konfig/build.gradle.kts b/components/core/build-konfig/build.gradle.kts new file mode 100644 index 0000000000..2a29d2ddd1 --- /dev/null +++ b/components/core/build-konfig/build.gradle.kts @@ -0,0 +1,19 @@ +import com.flipperdevices.buildlogic.ApkConfig.CURRENT_FLAVOR_TYPE + +plugins { + id("flipper.multiplatform") + id("flipper.multiplatform-dependencies") + alias(libs.plugins.buildkonfig) +} + +group = "com.flipperdevices.core.buildkonfig" + +android.namespace = "$group" + +buildConfig { + className("BuildKonfig") + packageName("$group") + useKotlinOutput { internalVisibility = false } + buildConfigField(String::class.java, "PACKAGE", "$group") + buildConfigField(Boolean::class.java, "IS_LOG_ENABLED", CURRENT_FLAVOR_TYPE.isLogEnabled) +} diff --git a/components/core/data/build.gradle.kts b/components/core/data/build.gradle.kts index 643fd674f0..aa3981b5a3 100644 --- a/components/core/data/build.gradle.kts +++ b/components/core/data/build.gradle.kts @@ -1,20 +1,17 @@ plugins { id("flipper.multiplatform") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.data" -kotlin { - sourceSets { - commonMain.dependencies { - implementation(libs.kotlin.immutable.collections) - implementation(libs.compose.ui) - } +commonDependencies { + implementation(libs.kotlin.immutable.collections) + implementation(libs.compose.ui) +} - commonTest.dependencies { - implementation(libs.junit) - implementation(libs.mockito.kotlin) - implementation(libs.ktx.testing) - } - } +commonTestDependencies { + implementation(libs.junit) + implementation(libs.mockito.kotlin) + implementation(libs.ktx.testing) } diff --git a/components/core/di/build.gradle.kts b/components/core/di/build.gradle.kts index bc54296ce0..25423b93c9 100644 --- a/components/core/di/build.gradle.kts +++ b/components/core/di/build.gradle.kts @@ -1,9 +1,15 @@ plugins { - id("flipper.android-lib") + id("flipper.multiplatform") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.di" -dependencies { +commonDependencies { implementation(libs.dagger) } + +jvmSharedTestDependencies { + implementation(libs.junit) + implementation(libs.kotlin.coroutines.test) +} diff --git a/components/core/di/src/main/java/com/flipperdevices/core/di/ApplicationParams.kt b/components/core/di/src/androidMain/kotlin/com/flipperdevices/core/di/ApplicationParams.kt similarity index 100% rename from components/core/di/src/main/java/com/flipperdevices/core/di/ApplicationParams.kt rename to components/core/di/src/androidMain/kotlin/com/flipperdevices/core/di/ApplicationParams.kt diff --git a/components/core/di/src/main/java/com/flipperdevices/core/di/AppGraph.kt b/components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/AppGraph.kt similarity index 100% rename from components/core/di/src/main/java/com/flipperdevices/core/di/AppGraph.kt rename to components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/AppGraph.kt diff --git a/components/core/di/src/main/java/com/flipperdevices/core/di/ComponentHolder.kt b/components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/ComponentHolder.kt similarity index 100% rename from components/core/di/src/main/java/com/flipperdevices/core/di/ComponentHolder.kt rename to components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/ComponentHolder.kt diff --git a/components/core/di/src/main/java/com/flipperdevices/core/di/ProviderKtx.kt b/components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/ProviderKtx.kt similarity index 100% rename from components/core/di/src/main/java/com/flipperdevices/core/di/ProviderKtx.kt rename to components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/ProviderKtx.kt diff --git a/components/core/di/src/main/java/com/flipperdevices/core/di/SingleIn.kt b/components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/SingleIn.kt similarity index 100% rename from components/core/di/src/main/java/com/flipperdevices/core/di/SingleIn.kt rename to components/core/di/src/commonMain/kotlin/com/flipperdevices/core/di/SingleIn.kt diff --git a/components/core/di/src/jvmSharedTest/kotlin/com/flipperdevices/core/di/ComponentHolderJvmSharedSampleTest.kt b/components/core/di/src/jvmSharedTest/kotlin/com/flipperdevices/core/di/ComponentHolderJvmSharedSampleTest.kt new file mode 100644 index 0000000000..7b85833e01 --- /dev/null +++ b/components/core/di/src/jvmSharedTest/kotlin/com/flipperdevices/core/di/ComponentHolderJvmSharedSampleTest.kt @@ -0,0 +1,18 @@ +@file:Suppress("FunctionNaming") + +package com.flipperdevices.core.di + +import org.junit.Assert +import org.junit.Test + +/** + * This is a sample test class to demonstrate how to use jvmSharedTest source set + */ +class ComponentHolderJvmSharedSampleTest { + @Test + fun GIVEN_empty_holder_WHEN_taking_int_class_THEN_throws() { + Assert.assertThrows(Throwable::class.java) { + ComponentHolder.component() + } + } +} diff --git a/components/core/ktx/build.gradle.kts b/components/core/ktx/build.gradle.kts index 65138d1315..1212933982 100644 --- a/components/core/ktx/build.gradle.kts +++ b/components/core/ktx/build.gradle.kts @@ -1,29 +1,22 @@ plugins { id("flipper.multiplatform-compose") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.ktx" -kotlin { - sourceSets { - commonMain.dependencies { - implementation(projects.components.core.log) +commonDependencies { + implementation(projects.components.core.log) + implementation(projects.components.core.buildKonfig) - implementation(libs.appcompat) - implementation(libs.kotlin.coroutines) - - implementation(libs.kotlin.coroutines) + implementation(libs.kotlin.coroutines) +} - // Compose - implementation(libs.compose.ui) - implementation(libs.compose.tooling) - implementation(libs.compose.foundation) - implementation(libs.compose.material) - } +androidDependencies { + implementation(libs.appcompat) +} - commonTest.dependencies { - implementation(projects.components.core.test) - implementation(libs.junit) - } - } +commonTestDependencies { + implementation(projects.components.core.test) + implementation(libs.junit) } diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/UriKtx.kt b/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/android/UriKtx.kt similarity index 98% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/UriKtx.kt rename to components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/android/UriKtx.kt index 868931b2e7..b9831bccfb 100644 --- a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/UriKtx.kt +++ b/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/android/UriKtx.kt @@ -1,4 +1,4 @@ -package com.flipperdevices.core.ktx.jre +package com.flipperdevices.core.ktx.android import android.content.ContentResolver import android.net.Uri diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/AtomicInt.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/AtomicInt.kt similarity index 100% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/AtomicInt.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/AtomicInt.kt diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/BoundedInputStream.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/BoundedInputStream.kt similarity index 100% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/BoundedInputStream.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/BoundedInputStream.kt diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/ByteArrayKtx.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/ByteArrayKtx.kt similarity index 100% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/ByteArrayKtx.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/ByteArrayKtx.kt diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/CoroutineLogKtx.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/CoroutineLogKtx.kt similarity index 95% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/CoroutineLogKtx.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/CoroutineLogKtx.kt index 83f40e5e7a..ace1d4840f 100644 --- a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/CoroutineLogKtx.kt +++ b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/CoroutineLogKtx.kt @@ -1,6 +1,6 @@ package com.flipperdevices.core.ktx.jre -import com.flipperdevices.core.log.BuildConfig +import com.flipperdevices.core.buildkonfig.BuildKonfig import com.flipperdevices.core.log.LogTagProvider import com.flipperdevices.core.log.info import com.flipperdevices.core.log.verbose @@ -15,7 +15,7 @@ fun LogTagProvider.runBlockingWithLog( block: suspend CoroutineScope.() -> T ): T { var startTime: Long = 0 - if (BuildConfig.INTERNAL) { + if (BuildKonfig.IS_LOG_ENABLED) { startTime = System.currentTimeMillis() } return runBlocking { diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/FileKtx.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/FileKtx.kt similarity index 100% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/FileKtx.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/FileKtx.kt diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/MD5Ktx.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/MD5Ktx.kt similarity index 100% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/MD5Ktx.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/MD5Ktx.kt diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/StreamKtx.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/StreamKtx.kt similarity index 100% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/StreamKtx.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/StreamKtx.kt diff --git a/components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/TimeHelper.kt b/components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/TimeHelper.kt similarity index 100% rename from components/core/ktx/src/androidMain/kotlin/com/flipperdevices/core/ktx/jre/TimeHelper.kt rename to components/core/ktx/src/jvmSharedMain/kotlin/com/flipperdevices/core/ktx/jre/TimeHelper.kt diff --git a/components/core/log/build.gradle.kts b/components/core/log/build.gradle.kts index b074fda46a..da4295f5ea 100644 --- a/components/core/log/build.gradle.kts +++ b/components/core/log/build.gradle.kts @@ -1,15 +1,10 @@ plugins { id("flipper.multiplatform") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.log" -kotlin { - sourceSets { - commonMain.dependencies { - } - androidMain.dependencies { - implementation(libs.timber) - } - } +androidDependencies { + implementation(libs.timber) } diff --git a/components/core/progress/build.gradle.kts b/components/core/progress/build.gradle.kts index ea1c7874d4..c96954063e 100644 --- a/components/core/progress/build.gradle.kts +++ b/components/core/progress/build.gradle.kts @@ -1,13 +1,16 @@ plugins { - id("flipper.android-lib") + id("flipper.multiplatform") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.progress" -dependencies { +commonDependencies { + implementation(projects.components.core.buildKonfig) +} - // Testing - testImplementation(libs.junit) - testImplementation(libs.mockk) - testImplementation(libs.kotlin.coroutines.test) +commonTestDependencies { + implementation(libs.junit) + implementation(libs.mockk) + implementation(libs.kotlin.coroutines.test) } diff --git a/components/core/progress/src/main/java/com/flipperdevices/core/progress/ProgressListener.kt b/components/core/progress/src/commonMain/kotlin/com/flipperdevices/core/progress/ProgressListener.kt similarity index 100% rename from components/core/progress/src/main/java/com/flipperdevices/core/progress/ProgressListener.kt rename to components/core/progress/src/commonMain/kotlin/com/flipperdevices/core/progress/ProgressListener.kt diff --git a/components/core/progress/src/main/java/com/flipperdevices/core/progress/ProgressWrapperTracker.kt b/components/core/progress/src/commonMain/kotlin/com/flipperdevices/core/progress/ProgressWrapperTracker.kt similarity index 88% rename from components/core/progress/src/main/java/com/flipperdevices/core/progress/ProgressWrapperTracker.kt rename to components/core/progress/src/commonMain/kotlin/com/flipperdevices/core/progress/ProgressWrapperTracker.kt index 460b4fde56..07141f3a07 100644 --- a/components/core/progress/src/main/java/com/flipperdevices/core/progress/ProgressWrapperTracker.kt +++ b/components/core/progress/src/commonMain/kotlin/com/flipperdevices/core/progress/ProgressWrapperTracker.kt @@ -1,5 +1,6 @@ package com.flipperdevices.core.progress +import com.flipperdevices.core.buildkonfig.BuildKonfig import java.lang.Float.min private const val MAX_PERCENT = 1.0f @@ -24,14 +25,14 @@ class ProgressWrapperTracker( suspend fun report(current: Long, max: Long) { if (current > max) { onProgress(MAX_PERCENT) - if (BuildConfig.DEBUG) { + if (BuildKonfig.IS_LOG_ENABLED) { error("Current larger then max (current: $current, max: $max)") } return } if (max == 0L) { onProgress(MAX_PERCENT) - if (BuildConfig.DEBUG) { + if (BuildKonfig.IS_LOG_ENABLED) { error("Max is zero") } return diff --git a/components/core/progress/src/test/java/com/flipperdevices/core/progress/ProgressWrapperTrackerTest.kt b/components/core/progress/src/commonTest/kotlin/com/flipperdevices/core/progress/ProgressWrapperTrackerTest.kt similarity index 100% rename from components/core/progress/src/test/java/com/flipperdevices/core/progress/ProgressWrapperTrackerTest.kt rename to components/core/progress/src/commonTest/kotlin/com/flipperdevices/core/progress/ProgressWrapperTrackerTest.kt diff --git a/components/core/test/build.gradle.kts b/components/core/test/build.gradle.kts index 0e41acbe86..21c10a2513 100644 --- a/components/core/test/build.gradle.kts +++ b/components/core/test/build.gradle.kts @@ -1,22 +1,19 @@ plugins { id("flipper.multiplatform") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.test" -kotlin { - sourceSets { - commonMain.dependencies { - implementation(libs.kotlin.coroutines) - implementation(libs.mockk) +commonDependencies { + implementation(libs.kotlin.coroutines) + implementation(libs.mockk) - implementation(projects.components.core.ui.lifecycle) - } + implementation(projects.components.core.ui.lifecycle) +} - androidMain.dependencies { - implementation(libs.junit) - implementation(libs.timber) - implementation(libs.roboelectric) - } - } +androidDependencies { + implementation(libs.junit) + implementation(libs.timber) + implementation(libs.roboelectric) } diff --git a/components/core/ui/decompose/build.gradle.kts b/components/core/ui/decompose/build.gradle.kts index dbb4185154..65ebdfe082 100644 --- a/components/core/ui/decompose/build.gradle.kts +++ b/components/core/ui/decompose/build.gradle.kts @@ -1,22 +1,24 @@ plugins { - id("flipper.android-compose") + id("flipper.multiplatform-compose") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.ui.decompose" -dependencies { +commonDependencies { implementation(projects.components.core.activityholder) implementation(libs.compose.ui) implementation(libs.compose.foundation) - implementation(libs.compose.activity) - - implementation(libs.lifecycle.compose) - - implementation(libs.lifecycle.runtime.ktx) - implementation(libs.lifecycle.viewmodel.ktx) implementation(libs.bundles.decompose) implementation(libs.essenty.lifecycle.coroutines) implementation(libs.kotlin.serialization.json) } + +androidDependencies { + implementation(libs.compose.activity) + + implementation(libs.lifecycle.runtime.ktx) + implementation(libs.lifecycle.viewmodel.ktx) +} diff --git a/components/core/ui/decompose/src/androidMain/kotlin/com/flipperdevices/ui/decompose/AndroidWindowDecorator.kt b/components/core/ui/decompose/src/androidMain/kotlin/com/flipperdevices/ui/decompose/AndroidWindowDecorator.kt new file mode 100644 index 0000000000..7febcaa1ad --- /dev/null +++ b/components/core/ui/decompose/src/androidMain/kotlin/com/flipperdevices/ui/decompose/AndroidWindowDecorator.kt @@ -0,0 +1,50 @@ +package com.flipperdevices.ui.decompose + +import android.content.res.Configuration +import android.os.Build +import android.view.View +import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS +import com.flipperdevices.core.activityholder.CurrentActivityHolder +import com.flipperdevices.ui.decompose.internal.StatusBarIconStyleProvider +import com.flipperdevices.ui.decompose.internal.WindowDecorator + +internal class AndroidWindowDecorator( + private val statusBarIconStyleProvider: StatusBarIconStyleProvider +) : WindowDecorator { + + @Suppress("Deprecated") + private fun changeStatusBarContrastStyle(decor: View, isLightIcons: Boolean) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + val windowInsetsController = decor.windowInsetsController ?: return + windowInsetsController.setSystemBarsAppearance( + if (isLightIcons) { + 0 + } else { + APPEARANCE_LIGHT_STATUS_BARS + }, + APPEARANCE_LIGHT_STATUS_BARS + ) + } else { + if (isLightIcons) { + decor.systemUiVisibility = + decor.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() + } else { + decor.systemUiVisibility = + decor.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR + } + } + } + + override fun decorate() { + val activity = CurrentActivityHolder.getCurrentActivity() ?: return + val decor = activity.window?.decorView ?: return + val uiMode = activity.resources.configuration.uiMode + val systemIsDark = + (uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES + + changeStatusBarContrastStyle( + decor, + statusBarIconStyleProvider.isStatusBarIconLight(systemIsDark) + ) + } +} diff --git a/components/core/ui/decompose/src/androidMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt b/components/core/ui/decompose/src/androidMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt new file mode 100644 index 0000000000..a49b19eebe --- /dev/null +++ b/components/core/ui/decompose/src/androidMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt @@ -0,0 +1,7 @@ +package com.flipperdevices.ui.decompose.internal + +import com.flipperdevices.ui.decompose.AndroidWindowDecorator + +internal actual fun createWindowDecorator( + statusBarIconStyleProvider: StatusBarIconStyleProvider +): WindowDecorator = AndroidWindowDecorator(statusBarIconStyleProvider) diff --git a/components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/CompositeDecomposeComponent.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/CompositeDecomposeComponent.kt similarity index 100% rename from components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/CompositeDecomposeComponent.kt rename to components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/CompositeDecomposeComponent.kt diff --git a/components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/DecomposeComponent.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/DecomposeComponent.kt similarity index 100% rename from components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/DecomposeComponent.kt rename to components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/DecomposeComponent.kt diff --git a/components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/DecomposeOnBackParameter.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/DecomposeOnBackParameter.kt similarity index 100% rename from components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/DecomposeOnBackParameter.kt rename to components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/DecomposeOnBackParameter.kt diff --git a/components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/NavigationKtx.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/NavigationKtx.kt similarity index 100% rename from components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/NavigationKtx.kt rename to components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/NavigationKtx.kt diff --git a/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/ScreenDecomposeComponent.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/ScreenDecomposeComponent.kt new file mode 100644 index 0000000000..f1fa4e44df --- /dev/null +++ b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/ScreenDecomposeComponent.kt @@ -0,0 +1,29 @@ +package com.flipperdevices.ui.decompose + +import com.arkivanov.decompose.ComponentContext +import com.arkivanov.essenty.lifecycle.Lifecycle +import com.flipperdevices.ui.decompose.internal.StatusBarIconStyleProvider +import com.flipperdevices.ui.decompose.internal.WindowDecorator +import com.flipperdevices.ui.decompose.internal.createWindowDecorator + +abstract class ScreenDecomposeComponent( + componentContext: ComponentContext +) : DecomposeComponent(), + ComponentContext by componentContext, + Lifecycle.Callbacks, + StatusBarIconStyleProvider { + private val windowDecorator: WindowDecorator by lazy { + createWindowDecorator(statusBarIconStyleProvider = this) + } + + init { + lifecycle.subscribe(this) + } + + override fun onResume() { + super.onResume() + windowDecorator.decorate() + } + + override fun isStatusBarIconLight(systemIsDark: Boolean) = false +} diff --git a/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/StatusBarIconStyleProvider.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/StatusBarIconStyleProvider.kt new file mode 100644 index 0000000000..4ab3910c25 --- /dev/null +++ b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/StatusBarIconStyleProvider.kt @@ -0,0 +1,5 @@ +package com.flipperdevices.ui.decompose.internal + +internal interface StatusBarIconStyleProvider { + fun isStatusBarIconLight(systemIsDark: Boolean): Boolean +} diff --git a/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecorator.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecorator.kt new file mode 100644 index 0000000000..86fce7f7bf --- /dev/null +++ b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecorator.kt @@ -0,0 +1,5 @@ +package com.flipperdevices.ui.decompose.internal + +internal interface WindowDecorator { + fun decorate() +} diff --git a/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt new file mode 100644 index 0000000000..6f4cf2ba4a --- /dev/null +++ b/components/core/ui/decompose/src/commonMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt @@ -0,0 +1,5 @@ +package com.flipperdevices.ui.decompose.internal + +internal expect fun createWindowDecorator( + statusBarIconStyleProvider: StatusBarIconStyleProvider +): WindowDecorator diff --git a/components/core/ui/decompose/src/desktopMain/kotlin/com/flipperdevices/ui/decompose/internal/DesktopWindowDecorator.kt b/components/core/ui/decompose/src/desktopMain/kotlin/com/flipperdevices/ui/decompose/internal/DesktopWindowDecorator.kt new file mode 100644 index 0000000000..ab42999d74 --- /dev/null +++ b/components/core/ui/decompose/src/desktopMain/kotlin/com/flipperdevices/ui/decompose/internal/DesktopWindowDecorator.kt @@ -0,0 +1,5 @@ +package com.flipperdevices.ui.decompose.internal + +internal class DesktopWindowDecorator : WindowDecorator { + override fun decorate() = Unit +} diff --git a/components/core/ui/decompose/src/desktopMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt b/components/core/ui/decompose/src/desktopMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt new file mode 100644 index 0000000000..5e8e1b7425 --- /dev/null +++ b/components/core/ui/decompose/src/desktopMain/kotlin/com/flipperdevices/ui/decompose/internal/WindowDecoratorFactory.kt @@ -0,0 +1,5 @@ +package com.flipperdevices.ui.decompose.internal + +internal actual fun createWindowDecorator( + statusBarIconStyleProvider: StatusBarIconStyleProvider +): WindowDecorator = DesktopWindowDecorator() diff --git a/components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/ScreenDecomposeComponent.kt b/components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/ScreenDecomposeComponent.kt deleted file mode 100644 index 403a05ace7..0000000000 --- a/components/core/ui/decompose/src/main/java/com/flipperdevices/ui/decompose/ScreenDecomposeComponent.kt +++ /dev/null @@ -1,56 +0,0 @@ -package com.flipperdevices.ui.decompose - -import android.content.res.Configuration -import android.os.Build -import android.view.View -import android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS -import com.arkivanov.decompose.ComponentContext -import com.arkivanov.essenty.lifecycle.Lifecycle -import com.flipperdevices.core.activityholder.CurrentActivityHolder - -abstract class ScreenDecomposeComponent( - componentContext: ComponentContext -) : DecomposeComponent(), - ComponentContext by componentContext, - Lifecycle.Callbacks { - init { - lifecycle.subscribe(this) - } - - override fun onResume() { - super.onResume() - val activity = CurrentActivityHolder.getCurrentActivity() ?: return - val decor = activity.window?.decorView ?: return - val uiMode = activity.resources.configuration.uiMode - val systemIsDark = - (uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES - - changeStatusBarContrastStyle(decor, isStatusBarIconLight(systemIsDark)) - } - - @Suppress("FunctionOnlyReturningConstant") - protected open fun isStatusBarIconLight(systemIsDark: Boolean) = false -} - -@Suppress("Deprecated") -private fun changeStatusBarContrastStyle(decor: View, isLightIcons: Boolean) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - val windowInsetsController = decor.windowInsetsController ?: return - windowInsetsController.setSystemBarsAppearance( - if (isLightIcons) { - 0 - } else { - APPEARANCE_LIGHT_STATUS_BARS - }, - APPEARANCE_LIGHT_STATUS_BARS - ) - } else { - if (isLightIcons) { - decor.systemUiVisibility = - decor.systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv() - } else { - decor.systemUiVisibility = - decor.systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR - } - } -} diff --git a/components/core/ui/lifecycle/build.gradle.kts b/components/core/ui/lifecycle/build.gradle.kts index dfee38ecb9..589ef42794 100644 --- a/components/core/ui/lifecycle/build.gradle.kts +++ b/components/core/ui/lifecycle/build.gradle.kts @@ -1,27 +1,25 @@ plugins { id("flipper.multiplatform-compose") + id("flipper.multiplatform-dependencies") } android.namespace = "com.flipperdevices.core.ui.lifecycle" -kotlin { - sourceSets { - commonMain.dependencies { - implementation(projects.components.core.ktx) - implementation(projects.components.core.log) +commonDependencies { + implementation(projects.components.core.ktx) + implementation(projects.components.core.log) - // Compose - implementation(libs.compose.ui) - implementation(libs.compose.foundation) + // Compose + implementation(libs.compose.ui) + implementation(libs.compose.foundation) - api(libs.decompose) - implementation(libs.kotlin.coroutines) - api(libs.essenty.lifecycle) - implementation(libs.essenty.lifecycle.coroutines) - } - androidMain.dependencies { - implementation(projects.components.bridge.service.api) - implementation(libs.annotations) - } - } + api(libs.decompose) + implementation(libs.kotlin.coroutines) + api(libs.essenty.lifecycle) + implementation(libs.essenty.lifecycle.coroutines) +} + +androidDependencies { + implementation(projects.components.bridge.service.api) + implementation(libs.annotations) } diff --git a/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriCopy.kt b/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriCopy.kt index b743215064..b67ce3a94d 100644 --- a/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriCopy.kt +++ b/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriCopy.kt @@ -5,7 +5,7 @@ import android.content.Context import android.content.Intent import android.net.Uri import com.flipperdevices.core.di.AppGraph -import com.flipperdevices.core.ktx.jre.filename +import com.flipperdevices.core.ktx.android.filename import com.flipperdevices.core.log.LogTagProvider import com.flipperdevices.core.log.error import com.flipperdevices.deeplink.api.DeepLinkParserDelegate diff --git a/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriGrantPermission.kt b/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriGrantPermission.kt index b51346f142..a0a18bc956 100644 --- a/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriGrantPermission.kt +++ b/components/deeplink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkFileUriGrantPermission.kt @@ -5,8 +5,8 @@ import android.content.Context import android.content.Intent import android.net.Uri import com.flipperdevices.core.di.AppGraph -import com.flipperdevices.core.ktx.jre.filename -import com.flipperdevices.core.ktx.jre.length +import com.flipperdevices.core.ktx.android.filename +import com.flipperdevices.core.ktx.android.length import com.flipperdevices.deeplink.api.DeepLinkParserDelegate import com.flipperdevices.deeplink.model.DeepLinkParserDelegatePriority import com.flipperdevices.deeplink.model.Deeplink diff --git a/components/updater/card/src/main/java/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModel.kt b/components/updater/card/src/main/java/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModel.kt index f072ae53ec..b37e20de40 100644 --- a/components/updater/card/src/main/java/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModel.kt +++ b/components/updater/card/src/main/java/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModel.kt @@ -5,8 +5,8 @@ import com.flipperdevices.bridge.service.api.provider.FlipperBleServiceConsumer import com.flipperdevices.bridge.service.api.provider.FlipperServiceProvider import com.flipperdevices.bridge.synchronization.api.SynchronizationApi import com.flipperdevices.bridge.synchronization.api.SynchronizationState -import com.flipperdevices.core.ktx.jre.filename -import com.flipperdevices.core.ktx.jre.length +import com.flipperdevices.core.ktx.android.filename +import com.flipperdevices.core.ktx.android.length import com.flipperdevices.core.ui.lifecycle.DecomposeViewModel import com.flipperdevices.updater.card.model.BatteryState import com.flipperdevices.updater.card.model.SyncingState diff --git a/components/updater/card/src/test/kotlin/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModelTest.kt b/components/updater/card/src/test/kotlin/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModelTest.kt index cb106e49c5..dca46de66c 100644 --- a/components/updater/card/src/test/kotlin/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModelTest.kt +++ b/components/updater/card/src/test/kotlin/com/flipperdevices/updater/card/viewmodel/UpdateRequestViewModelTest.kt @@ -10,9 +10,9 @@ import com.flipperdevices.bridge.service.api.FlipperServiceApi import com.flipperdevices.bridge.service.api.provider.FlipperServiceProvider import com.flipperdevices.bridge.synchronization.api.SynchronizationApi import com.flipperdevices.bridge.synchronization.api.SynchronizationState +import com.flipperdevices.core.ktx.android.filename +import com.flipperdevices.core.ktx.android.length import com.flipperdevices.core.ktx.jre.FlipperDispatchers -import com.flipperdevices.core.ktx.jre.filename -import com.flipperdevices.core.ktx.jre.length import com.flipperdevices.updater.card.model.BatteryState import com.flipperdevices.updater.card.model.SyncingState import com.flipperdevices.updater.card.model.UpdatePending @@ -59,7 +59,7 @@ class UpdateRequestViewModelTest { fun setup() { mockkObject(FlipperDispatchers) every { FlipperDispatchers.workStealingDispatcher } returns Dispatchers.Main.immediate - mockkStatic("com.flipperdevices.core.ktx.jre.UriKtxKt") + mockkStatic("com.flipperdevices.core.ktx.android.UriKtxKt") serviceProvider = mockk(relaxUnitFun = true) serviceApi = mockk(relaxUnitFun = true) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9a741c0c63..d0a5fc6db4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -89,6 +89,9 @@ detekt-ruleset-compose = "0.4.1" # https://github.com/mrmans0n/compose-rules/rel google-gms-gradle = "4.4.1" # https://developers.google.com/android/guides/google-services-plugin google-gms-firebase = "24.0.0" # https://firebase.google.com/docs/android/setup#kotlin:~:text=com.google.firebase%3Afirebase%2Dmessaging +# Build Config +buildkonfig = "5.3.5" + [libraries] # Gradle - Core android-gradle = { module = "com.android.tools.build:gradle", version.ref = "android-gradle" } @@ -287,3 +290,4 @@ protobuf = { id = "com.google.protobuf", version.ref = "protobuf-gradle" } square-anvil = { id = "com.squareup.anvil", version.ref = "anvil" } google-gms = { id = "com.google.gms.google-services", version.ref = "google-gms-gradle" } baselineprofile = { id = "androidx.baselineprofile", version.ref = "baselineprofile" } +buildkonfig = { id = "com.github.gmazzo.buildconfig", version.ref = "buildkonfig" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 23fdf3c6fa..e2c13227d8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -80,6 +80,7 @@ include( ":components:core:log", ":components:core:preference", ":components:core:data", + ":components:core:build-konfig", ":components:core:ui:ktx", ":components:core:ui:res", ":components:core:ui:dialog",