Skip to content

Commit

Permalink
Merge pull request #3 from droidknights/feature/#2
Browse files Browse the repository at this point in the history
  • Loading branch information
wisemuji authored Jun 13, 2023
2 parents 3007ff9 + f0cb806 commit 5cd121a
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
versionName = "1.0"
}

packagingOptions {
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
Expand Down
14 changes: 6 additions & 8 deletions app/src/test/java/com/droidknights/app2023/ExampleUnitTest.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.droidknights.app2023

import org.junit.Test

import org.junit.Assert.*
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
class ExampleUnitTest : StringSpec({
"addition is correct" {
4 shouldBe 2 + 2
}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ internal class HiltKotlinPlugin : Plugin<Project> {
configureHiltKotlin()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.droidknights.app2023

import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies

internal fun Project.configureKotestAndroid() {
configureKotest()
configureJUnitAndroid()
}

internal fun Project.configureJUnitAndroid() {
androidExtension.apply {
testOptions {
unitTests.all { it.useJUnitPlatform() }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.droidknights.app2023

import org.gradle.api.Project
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.withType

internal fun Project.configureKotest() {
configureJUnit()
val libs = extensions.libs
dependencies {
"testImplementation"(libs.findLibrary("kotest.runner").get())
"testImplementation"(libs.findLibrary("kotest.assertions").get())
}
}

internal fun Project.configureJUnit() {
tasks.withType<Test>().configureEach {
useJUnitPlatform()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ package com.droidknights.app2023

import org.gradle.api.JavaVersion
import org.gradle.api.Project
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.provideDelegate
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.droidknights.app2023.configureHiltAndroid
import com.droidknights.app2023.configureKotestAndroid
import com.droidknights.app2023.configureKotlinAndroid

plugins {
Expand All @@ -7,3 +8,4 @@ plugins {

configureKotlinAndroid()
configureHiltAndroid()
configureKotestAndroid()
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import com.droidknights.app2023.configureKotest
import com.droidknights.app2023.configureKotlin

plugins {
Expand All @@ -6,3 +7,4 @@ plugins {
}

configureKotlin()
configureKotest()
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,24 @@ private val LightColorScheme = lightColorScheme(
secondary = PurpleGrey40,
tertiary = Pink40

/* Other default colors to override
/*
Other default colors to override
background = Color(0xFFFFFBFE),
surface = Color(0xFFFFFBFE),
onPrimary = Color.White,
onSecondary = Color.White,
onTertiary = Color.White,
onBackground = Color(0xFF1C1B1F),
onSurface = Color(0xFF1C1B1F),
*/
*/
)

@Composable
fun DroidKnights2023Theme(
darkTheme: Boolean = isSystemInDarkTheme(),
// Dynamic color is available on Android 12+
dynamicColor: Boolean = true,
content: @Composable () -> Unit
content: @Composable () -> Unit,
) {
val colorScheme = when {
dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> {
Expand All @@ -67,4 +68,4 @@ fun DroidKnights2023Theme(
typography = Typography,
content = content
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ val Typography = Typography(
lineHeight = 24.sp,
letterSpacing = 0.5.sp
)
/* Other default text styles to override
/*
Other default text styles to override
titleLarge = TextStyle(
fontFamily = FontFamily.Default,
fontWeight = FontWeight.Normal,
Expand All @@ -30,5 +31,5 @@ val Typography = Typography(
lineHeight = 16.sp,
letterSpacing = 0.5.sp
)
*/
)
*/
)
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ junit4 = "4.13.2"
kotlin = "1.8.21"
androidxTestExt = "1.1.4"
androidxEspresso = "3.5.0"
kotest = "5.6.2"
# https://github.com/detekt/detekt
detekt = "1.23.0"

Expand Down Expand Up @@ -45,6 +46,8 @@ junit4 = { group = "junit", name = "junit", version.ref = "junit4" }
androidx-test-ext = { group = "androidx.test.ext", name = "junit-ktx", version.ref = "androidxTestExt" }
androidx-test-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "androidxEspresso" }
inject = "javax.inject:javax.inject:1"
kotest-runner = { group = "io.kotest", name = "kotest-runner-junit5", version.ref = "kotest" }
kotest-assertions = { group = "io.kotest", name = "kotest-assertions-core", version.ref = "kotest" }

# verify
verify-detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
Expand All @@ -60,4 +63,4 @@ android-library = { id = "com.android.library", version.ref = "androidGradlePlug
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
hilt = { id = "com.google.dagger.hilt.android", version.ref = "hilt" }
verify-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
verify-detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }

0 comments on commit 5cd121a

Please sign in to comment.