Skip to content

Commit 120872f

Browse files
committed
Remove processMaps step
Maplibre can read assets directly and so doesn't need the file copying done by processMaps. processMaps could be time consuming and so this improves start up.
1 parent 8abc49f commit 120872f

6 files changed

Lines changed: 5 additions & 146 deletions

File tree

app/src/androidTest/java/org/scottishtecharmy/soundscape/DocumentationScreens.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import org.scottishtecharmy.soundscape.screens.markers_routes.screens.addandedit
3636
import org.scottishtecharmy.soundscape.screens.markers_routes.screens.routedetailsscreen.RouteDetailsScreen
3737
import org.scottishtecharmy.soundscape.screens.markers_routes.screens.routedetailsscreen.RouteDetailsUiState
3838
import org.scottishtecharmy.soundscape.services.RoutePlayerState
39-
import org.scottishtecharmy.soundscape.utils.processMaps
4039
import org.scottishtecharmy.soundscape.viewmodels.home.HomeState
4140
import java.io.File
4241
import java.io.FileOutputStream
@@ -104,9 +103,6 @@ class DocumentationScreens {
104103

105104
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
106105

107-
// Unpack map assets
108-
processMaps(targetContext)
109-
110106
val themeStateFlow = MutableStateFlow(ThemeState())
111107
composeTestRule.setContent {
112108
SoundscapeTheme(themeStateFlow) {

app/src/main/assets/osm-liberty-accessible/originalStyle.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"maputnik:renderer": "mbgljs",
77
"openmaptiles:version": "3.x"
88
},
9-
"sprite": "file:///data/user/0/org.scottishtecharmy.soundscape/files/osm-liberty-accessible/osm-liberty",
10-
"glyphs": "file:///data/user/0/org.scottishtecharmy.soundscape/files/osm-liberty-accessible/fonts/{fontstack}/{range}.pbf",
9+
"sprite": "asset://osm-liberty-accessible/osm-liberty",
10+
"glyphs": "asset://osm-liberty-accessible/fonts/{fontstack}/{range}.pbf",
1111
"layers": [
1212
{
1313
"id": "background",

app/src/main/assets/osm-liberty-accessible/style.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"maputnik:renderer": "mbgljs",
77
"openmaptiles:version": "3.x"
88
},
9-
"sprite": "file:///data/user/0/org.scottishtecharmy.soundscape/files/osm-liberty-accessible/osm-liberty",
10-
"glyphs": "file:///data/user/0/org.scottishtecharmy.soundscape/files/osm-liberty-accessible/fonts/{fontstack}/{range}.pbf",
9+
"sprite": "asset://osm-liberty-accessible/osm-liberty",
10+
"glyphs": "asset://osm-liberty-accessible/fonts/{fontstack}/{range}.pbf",
1111
"layers": [
1212
{
1313
"id": "background",

app/src/main/java/org/scottishtecharmy/soundscape/MainActivity.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ import org.scottishtecharmy.soundscape.utils.LogcatHelper
6161
import org.scottishtecharmy.soundscape.database.local.model.RouteEntity
6262
import org.scottishtecharmy.soundscape.utils.findExtracts
6363
import org.scottishtecharmy.soundscape.utils.getOfflineMapStorage
64-
import org.scottishtecharmy.soundscape.utils.processMaps
6564
import java.io.File
6665
import java.util.Locale
6766
import javax.inject.Inject
@@ -416,9 +415,6 @@ class MainActivity : AppCompatActivity() {
416415
// Validate offline map directory
417416
getOfflineMapStorage(this)
418417

419-
// Unpack map assets
420-
processMaps(applicationContext)
421-
422418
// When opening a JSON file containing a route from Android File we can end up with two
423419
// instances of the app running. This check ensures that we have only one instance.
424420
if (!isTaskRoot) {

app/src/main/java/org/scottishtecharmy/soundscape/screens/home/home/MapContainerLibre.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.scottishtecharmy.soundscape.screens.home.home
33
import android.content.Context
44
import android.graphics.Color
55
import android.graphics.drawable.Drawable
6-
import android.net.Uri
76
import android.os.Environment
87
import android.util.Log
98
import android.view.Gravity
@@ -314,7 +313,6 @@ fun MapContainerLibre(
314313
val currentBeaconIndex = remember { mutableStateOf(currentBeaconWaypointIndex) }
315314
val symbol = remember { mutableStateOf<Symbol?>(null) }
316315
val symbolManager = remember { mutableStateOf<SymbolManager?>(null) }
317-
val filesDir = remember { context.filesDir.toString() }
318316

319317
val res = context.resources
320318
val userPositionDrawable = remember {
@@ -381,8 +379,7 @@ fun MapContainerLibre(
381379
if (mapDestroyed.get()) return@getMapAsync
382380
val styleName =
383381
if (accessibleMapEnabled) "style.json" else "originalStyle.json"
384-
val styleUrl =
385-
Uri.fromFile(File("$filesDir/osm-liberty-accessible/$styleName")).toString()
382+
val styleUrl = "asset://osm-liberty-accessible/$styleName"
386383
mapLibre.setStyle(styleUrl) { style ->
387384
// The style load is asynchronous, so the map may have been destroyed
388385
// between requesting the style and it loading. Bail out before touching any

app/src/main/java/org/scottishtecharmy/soundscape/utils/ExtractAssets.kt

Lines changed: 0 additions & 130 deletions
This file was deleted.

0 commit comments

Comments
 (0)