Skip to content

Commit

Permalink
Bump deps and get rid of more codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Dec 21, 2023
1 parent 6b3d493 commit 7680ab8
Show file tree
Hide file tree
Showing 45 changed files with 693 additions and 658 deletions.
32 changes: 14 additions & 18 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import java.net.URL
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.serialization")
}

android {
namespace = "org.btcmap"
compileSdk = 33
compileSdk = 34

defaultConfig {
applicationId = "org.btcmap"
minSdk = 27
targetSdk = 33
targetSdk = 34
versionCode = 46
versionName = "0.6.6"

Expand Down Expand Up @@ -92,7 +91,7 @@ android {

tasks.register("bundleData") {
doLast {
val src = URL("https://api.btcmap.org/v2/elements")
val src = URL("https://static.btcmap.org/elements-v3-2023-12-21.json")
val destDir = File(projectDir, "src/main/assets")
destDir.mkdirs()
val destFile = File(destDir, "elements.json")
Expand All @@ -103,15 +102,11 @@ tasks.register("bundleData") {
dependencies {
// Allows suspending functions
// https://github.com/Kotlin/kotlinx.coroutines/releases
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.0")

// Platform-agnostic JSON serialization
// https://github.com/Kotlin/kotlinx.serialization/releases
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0-RC")

// Simplifies in-app navigation
// https://developer.android.com/jetpack/androidx/releases/navigation
val navVer = "2.5.3"
val navVer = "2.7.5"
implementation("androidx.navigation:navigation-fragment-ktx:$navVer")
implementation("androidx.navigation:navigation-ui-ktx:$navVer")

Expand All @@ -121,15 +116,15 @@ dependencies {

// Used by osmdroid (original prefs API is deprecated)
// https://developer.android.com/jetpack/androidx/releases/preference
implementation("androidx.preference:preference-ktx:1.2.0")
implementation("androidx.preference:preference-ktx:1.2.1")

// Material design components
// https://github.com/material-components/material-components-android/releases
implementation("com.google.android.material:material:1.9.0")
implementation("com.google.android.material:material:1.10.0")

// Helps to split the app into multiple independent screens
// https://developer.android.com/jetpack/androidx/releases/fragment
debugImplementation("androidx.fragment:fragment-testing:1.5.7")
debugImplementation("androidx.fragment:fragment-testing:1.6.2")

// Modern HTTP client
// https://github.com/square/okhttp/blob/master/CHANGELOG.md
Expand All @@ -139,11 +134,11 @@ dependencies {

// Injection library
// https://github.com/InsertKoinIO/koin/blob/main/CHANGELOG.md
implementation("io.insert-koin:koin-android:3.4.0")
implementation("io.insert-koin:koin-android:3.5.0")

// Open Street Map widget
// https://github.com/osmdroid/osmdroid/releases
implementation("org.osmdroid:osmdroid-android:6.1.16")
implementation("org.osmdroid:osmdroid-android:6.1.17")

// Map utilities
// https://github.com/locationtech/jts/releases
Expand All @@ -155,18 +150,18 @@ dependencies {

// Used to cache data and store user preferences
// https://developer.android.com/kotlin/ktx#sqlite
implementation("androidx.sqlite:sqlite-ktx:2.3.1")
implementation("androidx.sqlite:sqlite-ktx:2.4.0")

// Bundle SQLite binaries
// https://github.com/requery/sqlite-android/releases
// TODO remove bundled SQLite when Android bumps its deps
// > The JSON functions and operators are built into SQLite by default, as of SQLite version 3.38.0 (2022-02-22).
// https://www.sqlite.org/json1.html
implementation("com.github.requery:sqlite-android:3.41.1")
implementation("com.github.requery:sqlite-android:3.43.0")

// Used to download, cache and display images
// https://github.com/coil-kt/coil/releases
val coilVer = "2.3.0"
val coilVer = "2.5.0"
implementation("io.coil-kt:coil:$coilVer")
implementation("io.coil-kt:coil-svg:$coilVer")

Expand All @@ -175,6 +170,7 @@ dependencies {
val junitVer = "4.13.2"
testImplementation("junit:junit:$junitVer")
androidTestImplementation("junit:junit:$junitVer")
testImplementation("org.json:json:20231013")

// Common instrumented test dependencies
// https://developer.android.com/jetpack/androidx/releases/test
Expand Down
186 changes: 93 additions & 93 deletions app/src/androidTest/kotlin/area/AreaFragmentTest.kt
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
package area

import androidx.core.os.bundleOf
import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.platform.app.InstrumentationRegistry
import app.App
import kotlinx.coroutines.runBlocking
import kotlinx.serialization.json.Json
import org.btcmap.R
import org.junit.Test
import org.koin.android.ext.android.get
import java.time.ZonedDateTime

class AreaFragmentTest {

@Test
fun launch() {
val app =
InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as App
val areaQueries = app.get<AreaQueries>()

val area = Area(
id = "test",
tags = AreaTags(
mapOf(
"geo_json" to Json.Default.parseToJsonElement(
"""
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
[
[
22.13883023642984,
3.2294073255228852
],
[
22.17600937988118,
3.284691070754846
],
[
22.069218223160163,
3.305487499546132
],
[
21.994596254388597,
3.2986431532554406
],
[
22.011471893969883,
3.224405313608429
],
[
22.13883023642984,
3.2294073255228852
]
]
],
"type": "Polygon"
}
}
]
}
""".trimIndent()
)
)
),
createdAt = ZonedDateTime.now(),
updatedAt = ZonedDateTime.now(),
deletedAt = null,
)

runBlocking {
areaQueries.insertOrReplace(listOf(area))
}

launchFragmentInContainer<AreaFragment>(
themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight,
fragmentArgs = bundleOf(Pair("area_id", area.id)),
).use {
onView(withId(R.id.toolbar)).check(matches(isDisplayed()))
onView(withId(R.id.progress)).check(matches(isEnabled()))
onView(withId(R.id.list)).check(matches(isEnabled()))
}
}
}
//package area
//
//import androidx.core.os.bundleOf
//import androidx.fragment.app.testing.launchFragmentInContainer
//import androidx.test.espresso.Espresso.onView
//import androidx.test.espresso.assertion.ViewAssertions.matches
//import androidx.test.espresso.matcher.ViewMatchers.*
//import androidx.test.platform.app.InstrumentationRegistry
//import app.App
//import kotlinx.coroutines.runBlocking
//import kotlinx.serialization.json.Json
//import org.btcmap.R
//import org.junit.Test
//import org.koin.android.ext.android.get
//import java.time.ZonedDateTime
//
//class AreaFragmentTest {
//
// @Test
// fun launch() {
// val app =
// InstrumentationRegistry.getInstrumentation().targetContext.applicationContext as App
// val areaQueries = app.get<AreaQueries>()
//
// val area = Area(
// id = "test",
// tags = AreaTags(
// mapOf(
// "geo_json" to Json.Default.parseToJsonElement(
// """
// {
// "type": "FeatureCollection",
// "features": [
// {
// "type": "Feature",
// "properties": {},
// "geometry": {
// "coordinates": [
// [
// [
// 22.13883023642984,
// 3.2294073255228852
// ],
// [
// 22.17600937988118,
// 3.284691070754846
// ],
// [
// 22.069218223160163,
// 3.305487499546132
// ],
// [
// 21.994596254388597,
// 3.2986431532554406
// ],
// [
// 22.011471893969883,
// 3.224405313608429
// ],
// [
// 22.13883023642984,
// 3.2294073255228852
// ]
// ]
// ],
// "type": "Polygon"
// }
// }
// ]
// }
// """.trimIndent()
// )
// )
// ),
// createdAt = ZonedDateTime.now(),
// updatedAt = ZonedDateTime.now(),
// deletedAt = null,
// )
//
// runBlocking {
// areaQueries.insertOrReplace(listOf(area))
// }
//
// launchFragmentInContainer<AreaFragment>(
// themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight,
// fragmentArgs = bundleOf(Pair("area_id", area.id)),
// ).use {
// onView(withId(R.id.toolbar)).check(matches(isDisplayed()))
// onView(withId(R.id.progress)).check(matches(isEnabled()))
// onView(withId(R.id.list)).check(matches(isEnabled()))
// }
// }
//}
94 changes: 47 additions & 47 deletions app/src/androidTest/kotlin/element/ElementFragmentTest.kt
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
package element

import androidx.fragment.app.testing.launchFragmentInContainer
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import org.btcmap.R
import org.hamcrest.Matchers.not
import org.junit.Test
import java.time.ZoneOffset
import java.time.ZonedDateTime
import kotlin.random.Random

class ElementFragmentTest {

@Test
fun launch() {
launchFragmentInContainer<ElementFragment>(
themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight,
).use { scenario ->
val tags = mutableMapOf<String, JsonPrimitive>()

val element = Element(
id = "${arrayOf("node", "way", "relation").random()}:${Random.nextLong()}",
lat = Random.nextDouble(-90.0, 90.0),
lon = Random.nextDouble(-180.0, 180.0),
osmJson = JsonObject(mapOf("tags" to JsonObject(tags))),
tags = JsonObject(emptyMap()),
createdAt = ZonedDateTime.now(ZoneOffset.UTC)
.minusMinutes(Random.nextLong(60 * 24 * 30)),
updatedAt = ZonedDateTime.now(ZoneOffset.UTC)
.minusMinutes(Random.nextLong(60 * 24 * 30)),
deletedAt = null,
)

scenario.onFragment { it.setElement(element) }
onView(withId(R.id.address)).check(matches(not(isDisplayed())))

tags["addr:housenumber"] = JsonPrimitive("1")
scenario.onFragment { it.setElement(element) }
onView(withId(R.id.address)).check(matches(isDisplayed()))
}
}
}
//package element
//
//import androidx.fragment.app.testing.launchFragmentInContainer
//import androidx.test.espresso.Espresso.onView
//import androidx.test.espresso.assertion.ViewAssertions.matches
//import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
//import androidx.test.espresso.matcher.ViewMatchers.withId
//import kotlinx.serialization.json.JsonObject
//import kotlinx.serialization.json.JsonPrimitive
//import org.btcmap.R
//import org.hamcrest.Matchers.not
//import org.junit.Test
//import java.time.ZoneOffset
//import java.time.ZonedDateTime
//import kotlin.random.Random
//
//class ElementFragmentTest {
//
// @Test
// fun launch() {
// launchFragmentInContainer<ElementFragment>(
// themeResId = com.google.android.material.R.style.Theme_Material3_DynamicColors_DayNight,
// ).use { scenario ->
// val tags = mutableMapOf<String, JsonPrimitive>()
//
// val element = Element(
// id = "${arrayOf("node", "way", "relation").random()}:${Random.nextLong()}",
// lat = Random.nextDouble(-90.0, 90.0),
// lon = Random.nextDouble(-180.0, 180.0),
// osmJson = JsonObject(mapOf("tags" to JsonObject(tags))),
// tags = JsonObject(emptyMap()),
// createdAt = ZonedDateTime.now(ZoneOffset.UTC)
// .minusMinutes(Random.nextLong(60 * 24 * 30)),
// updatedAt = ZonedDateTime.now(ZoneOffset.UTC)
// .minusMinutes(Random.nextLong(60 * 24 * 30)),
// deletedAt = null,
// )
//
// scenario.onFragment { it.setElement(element) }
// onView(withId(R.id.address)).check(matches(not(isDisplayed())))
//
// tags["addr:housenumber"] = JsonPrimitive("1")
// scenario.onFragment { it.setElement(element) }
// onView(withId(R.id.address)).check(matches(isDisplayed()))
// }
// }
//}
Loading

0 comments on commit 7680ab8

Please sign in to comment.