diff --git a/android/README.md b/android/README.md index 356bb4ce..9ef07364 100644 --- a/android/README.md +++ b/android/README.md @@ -14,7 +14,8 @@ To run the demo app, you'll need a Stadia Maps API key (free for development and evaluation use; no credit card required; get one at https://client.stadiamaps.com/). You can also modify it to work with your preferred maps and routing vendor by editing `AppModule.kt`. -Set your API key in `local.properties` to run the demo app: +Set your API key in `local.properties` to run the demo app +(it is functional with demo tiles and routing, but only for limited testing): ```properties stadiaApiKey=YOUR-API-KEY diff --git a/android/demo-app/build.gradle b/android/demo-app/build.gradle index eb588330..ffe78c66 100644 --- a/android/demo-app/build.gradle +++ b/android/demo-app/build.gradle @@ -3,7 +3,6 @@ plugins { alias libs.plugins.jetbrainsKotlinAndroid alias libs.plugins.ktfmt alias libs.plugins.compose.compiler - alias libs.plugins.mapsplatform.secrets.plugin } android { @@ -21,6 +20,12 @@ android { vectorDrawables { useSupportLibrary true } + + Properties properties = new Properties() + properties.load(project.rootProject.file("local.properties").newDataInputStream()) + + android.buildFeatures.buildConfig true + buildConfigField "String", "stadiaApiKey", "\"${properties.getProperty("stadiaApiKey")}\"" } buildTypes { diff --git a/android/demo-app/src/main/AndroidManifest.xml b/android/demo-app/src/main/AndroidManifest.xml index 9821568b..dcdc85d7 100644 --- a/android/demo-app/src/main/AndroidManifest.xml +++ b/android/demo-app/src/main/AndroidManifest.xml @@ -21,12 +21,6 @@ android:theme="@style/Theme.Ferrostar" tools:targetApi="31"> - - - - feature.center()?.let { center -> - // Fetch a route in the background - scope.launch(Dispatchers.IO) { - // TODO: Fail gracefully - val routes = - AppModule.ferrostarCore.getRoutes( - loc, - listOf( - Waypoint( - coordinate = - GeographicCoordinate( - center.latitude, center.longitude), - kind = WaypointKind.BREAK), - )) + AppModule.stadiaApiKey?.let { apiKey -> + AutocompleteSearch(apiKey = apiKey, userLocation = loc.toAndroidLocation()) { + feature -> + feature.center()?.let { center -> + // Fetch a route in the background + scope.launch(Dispatchers.IO) { + // TODO: Fail gracefully + val routes = + AppModule.ferrostarCore.getRoutes( + loc, + listOf( + Waypoint( + coordinate = + GeographicCoordinate(center.latitude, center.longitude), + kind = WaypointKind.BREAK), + )) - val route = routes.first() - viewModel = AppModule.ferrostarCore.startNavigation(route = route) + val route = routes.first() + viewModel = AppModule.ferrostarCore.startNavigation(route = route) - if (locationProvider is SimulatedLocationProvider) { - locationProvider.setSimulatedRoute(route) - } + if (locationProvider is SimulatedLocationProvider) { + locationProvider.setSimulatedRoute(route) } } } + } + } }) } }) { uiState -> diff --git a/android/gradle/libs.versions.toml b/android/gradle/libs.versions.toml index 4aacc790..f2e394ec 100644 --- a/android/gradle/libs.versions.toml +++ b/android/gradle/libs.versions.toml @@ -22,7 +22,6 @@ junitCompose = "1.7.3" espressoCore = "3.6.1" okhttp-mock = "2.0.0" mavenPublish = "0.29.0" -secretsGradlePlugin = "2.0.1" material = "1.12.0" stadiaAutocompleteSearch = "1.0.0" @@ -78,4 +77,3 @@ ktfmt = { id = "com.ncorti.ktfmt.gradle", version.ref = "ktfmt" } paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } mavenPublish = { id = "com.vanniktech.maven.publish", version.ref = "mavenPublish" } kotlinSerialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } -mapsplatform-secrets-plugin = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secretsGradlePlugin" }