Skip to content

Commit

Permalink
Remove deprecated tile service dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bubelov committed Oct 11, 2024
1 parent b3b14c8 commit 801bb9e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 43 deletions.
2 changes: 0 additions & 2 deletions app/src/androidMain/kotlin/area/AreaAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import androidx.recyclerview.widget.ListAdapter
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import icons.iconTypeface
import map.enableDarkModeIfNecessary
import map.showPolygons
import okhttp3.HttpUrl
import org.btcmap.databinding.ItemAreaDescriptionBinding
Expand Down Expand Up @@ -137,7 +136,6 @@ class AreaAdapter(
listener: Listener,
) {
if (item is Item.Map && binding is ItemMapBinding) {
binding.map.enableDarkModeIfNecessary()
binding.map.showPolygons(item.polygons, item.paddingPx)
binding.root.setOnClickListener { listener.onMapClick() }
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/androidMain/kotlin/element/ElementFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import icons.iconTypeface
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.runBlocking
import map.MapMarkersRepo
import map.enableDarkModeIfNecessary
import map.getErrorColor
import map.getOnSurfaceColor
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
Expand Down Expand Up @@ -99,7 +98,6 @@ class ElementFragment : Fragment() {
element.tags.optString("icon:android").ifBlank { "question_mark" }
)
binding.map.overlays.add(marker)
binding.map.enableDarkModeIfNecessary()
}
}

Expand Down
1 change: 0 additions & 1 deletion app/src/androidMain/kotlin/map/MapFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class MapFragment : Fragment() {
setMultiTouchControls(true)
addLocationOverlay()
addCancelSelectionOverlay()
enableDarkModeIfNecessary()
}

bottomSheetBehavior = BottomSheetBehavior.from(binding.elementDetails)
Expand Down
33 changes: 0 additions & 33 deletions app/src/androidMain/kotlin/map/MapViewExtensions.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package map

import android.content.res.Configuration
import android.graphics.Color
import org.locationtech.jts.geom.Polygon
import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase
import org.osmdroid.util.GeoPoint
import org.osmdroid.util.MapTileIndex
import org.osmdroid.views.MapView

fun MapView.showPolygons(polygons: List<Polygon>, paddingPx: Int) {
Expand All @@ -26,34 +23,4 @@ fun MapView.showPolygons(polygons: List<Polygon>, paddingPx: Int) {
paddingPx,
)
}
}

fun MapView.enableDarkModeIfNecessary() {
val nightMode =
resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES

if (nightMode) {
setTileSource(
object : OnlineTileSourceBase(
"stadia_alidade_smooth_dark",
0,
20,
256,
"png",
arrayOf("https://api.btcmap.org/tiles")
) {
override fun getTileURLString(pMapTileIndex: Long): String {
val zoom = MapTileIndex.getZoom(pMapTileIndex)
val x = MapTileIndex.getX(pMapTileIndex)
val y = MapTileIndex.getY(pMapTileIndex)
return "$baseUrl?theme=alidade_smooth_dark&zoom=$zoom&x=$x&y=$y"
}
}
)

overlayManager.tilesOverlay.apply {
loadingBackgroundColor = android.R.color.black
loadingLineColor = Color.DKGRAY
}
}
}
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
# https://developer.android.com/build/releases/gradle-plugin
agp = "8.6.1"
agp = "8.7.0"
# https://github.com/JetBrains/kotlin/releases
kotlin = "1.9.25"
# Allows suspending functions
Expand Down Expand Up @@ -34,8 +34,8 @@ jts = "1.20.0"
# https://github.com/PhilJay/MPAndroidChart/releases
mpandroidchart = "v3.1.0"
# Used to cache data and store user preferences
# https://developer.android.com/kotlin/ktx#sqlite
sqlite = "2.5.0-alpha08"
# https://developer.android.com/jetpack/androidx/releases/sqlite
sqlite = "2.5.0-alpha09"
# Used to download, cache and display images
# https://github.com/coil-kt/coil/releases
coil = "2.7.0"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=544c35d6bd849ae8a5ed0bcea39ba677dc40f49df7d1835561582da2009b961d
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down

0 comments on commit 801bb9e

Please sign in to comment.