Skip to content

Commit

Permalink
Improve dependency management
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed May 1, 2024
1 parent cef9da4 commit 742addc
Show file tree
Hide file tree
Showing 21 changed files with 219 additions and 119 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

## 🌍 Help with Translation

In order to translate the app to your language, you should click on a language link below and then press an edit button.
In order to translate the app to your language, you should click on a language link below and then
press an edit button.

- [Afrikaans](app/src/main/res/values-af/strings.xml)
- [Arabic](/app/src/main/res/values-ar/strings.xml)
Expand Down Expand Up @@ -78,14 +79,16 @@ https://www.openstreetmap.org

### Can I add or edit places?

Absolutely, you are very welcome to do that. This is a good place to start:
Absolutely, you are very welcome to do that. This is a good place to start:

[Tagging Instructions](https://wiki.btcmap.org/general/tagging-instructions.html)

### BTC Map shows a place which doesn't exist, how can I delete it?

You can delete such places from OpenStreetMap and BTC Map will pick up all your changes within 10 minutes.
You can delete such places from OpenStreetMap and BTC Map will pick up all your changes within 10
minutes.

### I've found a place on BTC Map but it doesn't accept bitcoins

OpenStreetMap might have outdated information about some places, you can delete the `currency:XBT` tag or set it to `no` in order to remove this place from BTC Map.
OpenStreetMap might have outdated information about some places, you can delete the `currency:XBT`
tag or set it to `no` in order to remove this place from BTC Map.
118 changes: 33 additions & 85 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import java.net.URL

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
}

android {
Expand All @@ -18,13 +18,14 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = "17"
jvmTarget = "1.8"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.DelicateCoroutinesApi"
freeCompilerArgs += "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
}

signingConfigs {
Expand All @@ -37,7 +38,10 @@ android {
}

packaging {
resources.excludes += "DebugProbesKt.bin"
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
excludes += "DebugProbesKt.bin"
}

// 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).
Expand Down Expand Up @@ -114,83 +118,27 @@ tasks.register("bundleData") {
}

dependencies {
// Allows suspending functions
// https://github.com/Kotlin/kotlinx.coroutines/releases
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0")

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

// Helps with keeping our view hierarchies flat
// https://developer.android.com/jetpack/androidx/releases/constraintlayout
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

// Used by osmdroid (original prefs API is deprecated)
// https://developer.android.com/jetpack/androidx/releases/preference
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.11.0")

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

// Modern HTTP client
// https://github.com/square/okhttp/blob/master/CHANGELOG.md
val okhttpVer = "5.0.0-alpha.14"
implementation("com.squareup.okhttp3:okhttp-coroutines:$okhttpVer")
implementation("com.squareup.okhttp3:okhttp-brotli:$okhttpVer")
testImplementation("com.squareup.okhttp3:mockwebserver:$okhttpVer")

// Injection library
// https://github.com/InsertKoinIO/koin/blob/main/CHANGELOG.md
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.18")

// Map utilities
// https://github.com/locationtech/jts/releases
implementation("org.locationtech.jts:jts-core:1.19.0")

// Charts
// https://github.com/PhilJay/MPAndroidChart/releases
implementation("com.github.PhilJay:MPAndroidChart:v3.1.0")

// Used to cache data and store user preferences
// https://developer.android.com/kotlin/ktx#sqlite
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).
// API 33 -> 3.32
// API 34 -> 3.39 (~45% of our install base)
// https://www.sqlite.org/json1.html
implementation("com.github.requery:sqlite-android:3.45.0")

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

// Background job scheduler
// Used to fetch new data in background
// https://developer.android.com/jetpack/androidx/releases/work
val workVer = "2.9.0"
implementation("androidx.work:work-runtime-ktx:$workVer")

// Common test dependencies
// https://junit.org/junit4/
val junitVer = "4.13.2"
testImplementation("junit:junit:$junitVer")
testImplementation("org.json:json:20231013")
implementation(libs.kotlinx.coroutines)

implementation(libs.androidx.navigation.fragment.ktx)
implementation(libs.androidx.navigation.ui.ktx)
implementation(libs.androidx.preference.ktx)
implementation(libs.androidx.sqlite.ktx)
implementation(libs.androidx.constraintlayout)

implementation(libs.material)
implementation(libs.okhttp.coroutines)
implementation(libs.okhttp.brotli)
implementation(libs.okhttp.mockwebserver)
implementation(libs.koin)
implementation(libs.osmdroid)
implementation(libs.jts)
implementation(libs.mpandroidchart)
implementation(libs.sqlite)
implementation(libs.coil.core)
implementation(libs.coil.svg)
implementation(libs.androidx.work.runtime.ktx)

testImplementation(libs.junit)
testImplementation(libs.json)
}
14 changes: 7 additions & 7 deletions app/src/main/kotlin/app/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ package app
import android.content.Context
import api.Api
import api.ApiImpl
import area.AreaModel
import area.AreaQueries
import area.AreaResultModel
import area.AreasModel
import area.AreaModel
import area.AreasRepo
import conf.ConfQueries
import conf.ConfRepo
import db.Database
import element.ElementQueries
import element.ElementsRepo
import event.EventQueries
import event.EventsModel
import event.EventsRepo
import io.requery.android.database.sqlite.SQLiteOpenHelper
import issue.IssuesModel
import location.UserLocationRepository
import map.MapModel
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.OkHttpClient
import okhttp3.brotli.BrotliInterceptor
import org.koin.androidx.viewmodel.dsl.viewModelOf
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.bind
import org.koin.dsl.module
import reports.ReportQueries
import reports.ReportsModel
import reports.ReportsRepo
import search.SearchModel
import search.SearchResultModel
import sync.Sync
import sync.BackgroundSyncScheduler
import sync.Sync
import sync.SyncNotificationController
import user.UserQueries
import user.UsersModel
import user.UsersRepo
import okhttp3.HttpUrl.Companion.toHttpUrl
import org.koin.dsl.bind
import issue.IssuesModel
import db.Database
import io.requery.android.database.sqlite.SQLiteOpenHelper

val appModule = module {
single {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/area/AreaAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class AreaAdapter(
text.text = item.text
}
}

if (item is Item.Contact && binding is ItemContactBinding) {
binding.apply {
website.isVisible = item.website != null
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/kotlin/area/AreaFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import androidx.core.view.*
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/kotlin/area/AreaTags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import org.json.JSONObject
import org.locationtech.jts.geom.Coordinate
import org.locationtech.jts.geom.GeometryFactory
import org.locationtech.jts.geom.Polygon
import java.util.*
import java.util.Locale

typealias AreaTags = JSONObject

Expand Down Expand Up @@ -50,7 +50,8 @@ fun AreaTags.polygons(): List<Polygon> {
}

if (geometry.getString("type") == "Polygon") {
val coordinates = geometry.getJSONArray("coordinates").getJSONArray(0).toListOfArrays()
val coordinates =
geometry.getJSONArray("coordinates").getJSONArray(0).toListOfArrays()

res += geoFactory.createPolygon(coordinates.map {
Coordinate(
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/kotlin/area/AreasFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import androidx.core.view.*
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -61,6 +64,7 @@ class AreasFragment : Fragment() {
binding.progress.isVisible = true
binding.list.isVisible = false
}

is AreasModel.State.Loaded -> {
binding.progress.isVisible = false
binding.list.isVisible = true
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/kotlin/donation/DonationFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ class DonationFragment : Fragment() {
listOf(lnQr, lnPay).forEach {
it.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("lightning:${getString(R.string.donation_address_lightning)}")
intent.data =
Uri.parse("lightning:${getString(R.string.donation_address_lightning)}")
runCatching {
startActivity(intent)
}.onFailure {
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/kotlin/event/EventsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.os.bundleOf
import androidx.core.view.*
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -42,7 +44,8 @@ class EventsFragment : Fragment() {
}
} else {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse("https://www.openstreetmap.org/${item.osmId.replace(":", "/")}")
intent.data =
Uri.parse("https://www.openstreetmap.org/${item.osmId.replace(":", "/")}")
startActivity(intent)
}
}
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/kotlin/icons/ContextExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ fun Context.createFontIconBitmap(iconId: String, sizePx: Int): Bitmap {
bitmap.applyCanvas {
drawRect(0f, 0f, sizePx.toFloat(), sizePx.toFloat(), Paint().apply { color = Color.RED })
val textWidth = paint.measureText(iconId)
drawText(iconId, width.toFloat() / 2f - textWidth / 2f, height.toFloat() / 2f - (paint.fontMetrics.ascent + paint.fontMetrics.descent) / 2f, paint)
drawText(
iconId,
width.toFloat() / 2f - textWidth / 2f,
height.toFloat() / 2f - (paint.fontMetrics.ascent + paint.fontMetrics.descent) / 2f,
paint,
)
}

return bitmap
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/kotlin/issue/IssuesFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.*
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
Expand Down
12 changes: 10 additions & 2 deletions app/src/main/kotlin/map/MapFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import androidx.core.graphics.drawable.DrawableCompat
import androidx.core.graphics.drawable.toBitmap
import androidx.core.graphics.drawable.toDrawable
import androidx.core.os.bundleOf
import androidx.core.view.*
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.core.widget.doAfterTextChanged
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
Expand All @@ -40,7 +43,12 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
import element.ElementFragment
import element.ElementsCluster
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
import org.btcmap.R
import org.btcmap.databinding.FragmentMapBinding
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/kotlin/map/MapMarkersRepo.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package map

import android.content.Context
import android.graphics.*
import android.graphics.Bitmap
import android.graphics.Color
import android.graphics.Paint
import android.graphics.drawable.BitmapDrawable
import android.util.TypedValue
import androidx.core.content.ContextCompat
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/kotlin/settings/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.view.*
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.findNavController
import androidx.work.WorkManager
Expand Down
Loading

0 comments on commit 742addc

Please sign in to comment.