Merge pull request #6714 from thundernest/add_core_common_modules
Add core common modules
This commit is contained in:
commit
97feede785
20 changed files with 102 additions and 17 deletions
|
@ -8,6 +8,7 @@ dependencies {
|
||||||
api(projects.mail.common)
|
api(projects.mail.common)
|
||||||
api(projects.backend.api)
|
api(projects.backend.api)
|
||||||
api(projects.app.htmlCleaner)
|
api(projects.app.htmlCleaner)
|
||||||
|
api(projects.core.android.common)
|
||||||
|
|
||||||
implementation(projects.plugins.openpgpApiLib.openpgpApi)
|
implementation(projects.plugins.openpgpApiLib.openpgpApi)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.fsck.k9
|
package com.fsck.k9
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import app.k9mail.core.android.common.coreCommonAndroidModule
|
||||||
import com.fsck.k9.helper.Contacts
|
import com.fsck.k9.helper.Contacts
|
||||||
import com.fsck.k9.helper.DefaultTrustedSocketFactory
|
import com.fsck.k9.helper.DefaultTrustedSocketFactory
|
||||||
import com.fsck.k9.mail.ssl.LocalKeyStore
|
import com.fsck.k9.mail.ssl.LocalKeyStore
|
||||||
|
@ -15,6 +16,7 @@ import org.koin.core.qualifier.named
|
||||||
import org.koin.dsl.module
|
import org.koin.dsl.module
|
||||||
|
|
||||||
val mainModule = module {
|
val mainModule = module {
|
||||||
|
includes(coreCommonAndroidModule)
|
||||||
single<CoroutineScope>(named("AppCoroutineScope")) { GlobalScope }
|
single<CoroutineScope>(named("AppCoroutineScope")) { GlobalScope }
|
||||||
single {
|
single {
|
||||||
Preferences(
|
Preferences(
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.HashMap;
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -15,6 +14,7 @@ import android.provider.ContactsContract.CommonDataKinds.Photo;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
import app.k9mail.core.android.common.database.EmptyCursor;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import timber.log.Timber;
|
import timber.log.Timber;
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import androidx.annotation.Nullable;
|
||||||
import androidx.loader.content.AsyncTaskLoader;
|
import androidx.loader.content.AsyncTaskLoader;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.fsck.k9.helper.EmptyCursor;
|
import app.k9mail.core.android.common.database.EmptyCursor;
|
||||||
import com.fsck.k9.ui.R;
|
import com.fsck.k9.ui.R;
|
||||||
import com.fsck.k9.mail.Address;
|
import com.fsck.k9.mail.Address;
|
||||||
import com.fsck.k9.view.RecipientSelectView.Recipient;
|
import com.fsck.k9.view.RecipientSelectView.Recipient;
|
||||||
|
|
|
@ -27,5 +27,6 @@ android {
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.bundles.shared.jvm.main)
|
implementation(libs.bundles.shared.jvm.main)
|
||||||
|
implementation(libs.bundles.shared.jvm.android)
|
||||||
testImplementation(libs.bundles.shared.jvm.test)
|
testImplementation(libs.bundles.shared.jvm.test)
|
||||||
}
|
}
|
||||||
|
|
12
core/android/common/build.gradle.kts
Normal file
12
core/android/common/build.gradle.kts
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
plugins {
|
||||||
|
id(ThunderbirdPlugins.Library.android)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "app.k9mail.core.android.common"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(projects.core.common)
|
||||||
|
testImplementation(projects.core.testing)
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package app.k9mail.core.android.common
|
||||||
|
|
||||||
|
import app.k9mail.core.common.coreCommonModule
|
||||||
|
import org.koin.core.module.Module
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
val coreCommonAndroidModule: Module = module {
|
||||||
|
includes(coreCommonModule)
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.fsck.k9.helper
|
package app.k9mail.core.android.common.database
|
||||||
|
|
||||||
import android.database.AbstractCursor
|
import android.database.AbstractCursor
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package app.k9mail.core.android.common
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.koin.dsl.koinApplication
|
||||||
|
import org.koin.test.check.checkModules
|
||||||
|
|
||||||
|
internal class CoreCommonAndroidModuleTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should have a valid di module`() {
|
||||||
|
koinApplication {
|
||||||
|
modules(coreCommonAndroidModule)
|
||||||
|
checkModules()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
7
core/common/build.gradle.kts
Normal file
7
core/common/build.gradle.kts
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
plugins {
|
||||||
|
id(ThunderbirdPlugins.Library.jvm)
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
testImplementation(projects.core.testing)
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package app.k9mail.core.common
|
||||||
|
|
||||||
|
import kotlinx.datetime.Clock
|
||||||
|
import org.koin.core.module.Module
|
||||||
|
import org.koin.dsl.module
|
||||||
|
|
||||||
|
val coreCommonModule: Module = module {
|
||||||
|
single<Clock> { Clock.System }
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package com.fsck.k9.cache
|
package app.k9mail.core.common.cache
|
||||||
|
|
||||||
interface Cache<KEY : Any, VALUE : Any> {
|
interface Cache<KEY : Any, VALUE : Any> {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.fsck.k9.cache
|
package app.k9mail.core.common.cache
|
||||||
|
|
||||||
import kotlinx.datetime.Clock
|
import kotlinx.datetime.Clock
|
||||||
import kotlinx.datetime.Instant
|
import kotlinx.datetime.Instant
|
||||||
|
|
||||||
internal class ExpiringCache<KEY : Any, VALUE : Any>(
|
class ExpiringCache<KEY : Any, VALUE : Any>(
|
||||||
private val clock: Clock,
|
private val clock: Clock,
|
||||||
private val delegateCache: Cache<KEY, VALUE> = InMemoryCache(),
|
private val delegateCache: Cache<KEY, VALUE> = InMemoryCache(),
|
||||||
private var lastClearTime: Instant = clock.now(),
|
private var lastClearTime: Instant = clock.now(),
|
|
@ -1,6 +1,6 @@
|
||||||
package com.fsck.k9.cache
|
package app.k9mail.core.common.cache
|
||||||
|
|
||||||
internal class InMemoryCache<KEY : Any, VALUE : Any>(
|
class InMemoryCache<KEY : Any, VALUE : Any>(
|
||||||
private val cache: MutableMap<KEY, VALUE> = mutableMapOf(),
|
private val cache: MutableMap<KEY, VALUE> = mutableMapOf(),
|
||||||
) : Cache<KEY, VALUE> {
|
) : Cache<KEY, VALUE> {
|
||||||
override fun get(key: KEY): VALUE? {
|
override fun get(key: KEY): VALUE? {
|
|
@ -1,6 +1,6 @@
|
||||||
package com.fsck.k9.cache
|
package app.k9mail.core.common.cache
|
||||||
|
|
||||||
internal class SynchronizedCache<KEY : Any, VALUE : Any>(
|
class SynchronizedCache<KEY : Any, VALUE : Any>(
|
||||||
private val delegateCache: Cache<KEY, VALUE>,
|
private val delegateCache: Cache<KEY, VALUE>,
|
||||||
) : Cache<KEY, VALUE> {
|
) : Cache<KEY, VALUE> {
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package app.k9mail.core.common
|
||||||
|
|
||||||
|
import org.junit.Test
|
||||||
|
import org.koin.dsl.koinApplication
|
||||||
|
import org.koin.test.check.checkModules
|
||||||
|
|
||||||
|
internal class CoreCommonModuleTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `should have a valid di module`() {
|
||||||
|
koinApplication {
|
||||||
|
modules(coreCommonModule)
|
||||||
|
checkModules()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,8 +1,12 @@
|
||||||
package com.fsck.k9.cache
|
package app.k9mail.core.common.cache
|
||||||
|
|
||||||
import app.k9mail.core.testing.TestClock
|
import app.k9mail.core.testing.TestClock
|
||||||
import com.google.common.truth.Truth.assertThat
|
import assertk.assertThat
|
||||||
import org.junit.Test
|
import assertk.assertions.isEqualTo
|
||||||
|
import assertk.assertions.isFalse
|
||||||
|
import assertk.assertions.isNull
|
||||||
|
import assertk.assertions.isTrue
|
||||||
|
import kotlin.test.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
import org.junit.runners.Parameterized
|
import org.junit.runners.Parameterized
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package com.fsck.k9.cache
|
package app.k9mail.core.common.cache
|
||||||
|
|
||||||
import app.k9mail.core.testing.TestClock
|
import app.k9mail.core.testing.TestClock
|
||||||
import com.google.common.truth.Truth.assertThat
|
import assertk.assertThat
|
||||||
|
import assertk.assertions.isEqualTo
|
||||||
|
import assertk.assertions.isFalse
|
||||||
|
import assertk.assertions.isNull
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.time.Duration.Companion.milliseconds
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
|
@ -69,7 +69,6 @@ androidx-constraintlayout = { module = "androidx.constraintlayout:constraintlayo
|
||||||
androidx-work-ktx = "androidx.work:work-runtime-ktx:2.7.1"
|
androidx-work-ktx = "androidx.work:work-runtime-ktx:2.7.1"
|
||||||
androidx-fragment = { module = "androidx.fragment:fragment", version.ref = "androidxFragment" }
|
androidx-fragment = { module = "androidx.fragment:fragment", version.ref = "androidxFragment" }
|
||||||
androidx-localbroadcastmanager = "androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"
|
androidx-localbroadcastmanager = "androidx.localbroadcastmanager:localbroadcastmanager:1.1.0"
|
||||||
androidx-core = { module = "androidx.core:core", version.ref = "androidxCore" }
|
|
||||||
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidxCore" }
|
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidxCore" }
|
||||||
androidx-preference = { module = "androidx.preference:preference", version.ref = "androidxPreference" }
|
androidx-preference = { module = "androidx.preference:preference", version.ref = "androidxPreference" }
|
||||||
androidx-swiperefreshlayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
androidx-swiperefreshlayout = "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
||||||
|
@ -137,8 +136,12 @@ detekt-plugin-compose = "io.nlopez.compose.rules:detekt:0.1.1"
|
||||||
|
|
||||||
[bundles]
|
[bundles]
|
||||||
shared-jvm-main = [
|
shared-jvm-main = [
|
||||||
|
"koin-core",
|
||||||
"kotlinx-datetime",
|
"kotlinx-datetime",
|
||||||
]
|
]
|
||||||
|
shared-jvm-android = [
|
||||||
|
"androidx-core-ktx",
|
||||||
|
]
|
||||||
shared-jvm-test = [
|
shared-jvm-test = [
|
||||||
"junit",
|
"junit",
|
||||||
"truth",
|
"truth",
|
||||||
|
|
|
@ -39,10 +39,12 @@ include(
|
||||||
)
|
)
|
||||||
|
|
||||||
include(
|
include(
|
||||||
|
":core:common",
|
||||||
|
":core:testing",
|
||||||
|
":core:android:common",
|
||||||
":core:ui:compose:demo",
|
":core:ui:compose:demo",
|
||||||
":core:ui:compose:designsystem",
|
":core:ui:compose:designsystem",
|
||||||
":core:ui:compose:theme",
|
":core:ui:compose:theme",
|
||||||
":core:testing",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
include(
|
include(
|
||||||
|
|
Loading…
Reference in a new issue