Skip to content

Commit

Permalink
#58 control tokens for android by gradle properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex009 committed Jul 7, 2021
1 parent b27aae2 commit f2554d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
7 changes: 7 additions & 0 deletions sample/android-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ android {
versionName = "0.1.0"

multiDexEnabled = true

val googleMapsApiKey: String = (extra["googleMaps.apiKey"] as? String).orEmpty()
val mapboxPublicToken: String = (extra["mapbox.publicToken"] as? String).orEmpty()

manifestPlaceholders["googleMapsApiKey"] = googleMapsApiKey
buildConfigField("String", "GOOGLE_MAPS_API_KEY", "\"$googleMapsApiKey\"")
buildConfigField("String", "MAPBOX_PUBLIC_TOKEN", "\"$mapboxPublicToken\"")
}
}

Expand Down
3 changes: 1 addition & 2 deletions sample/android-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<activity android:name=".GoogleMapsActivity" />
<activity android:name=".MapboxActivity" />

<!-- TODO: Replace with your API Key from https://developers.google.com/maps/documentation/ios-sdk/ -->
<meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR-API-KEY"/>
<meta-data android:name="com.google.android.geo.API_KEY" android:value="${googleMapsApiKey}"/>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class GoogleMapsActivity : MvvmActivity<ActivityGoogleMapsBinding, GoogleMapView
applicationContext = applicationContext
),
googleMapController = GoogleMapController(
// TODO: Replace with your API Key from https://developers.google.com/maps/documentation/android-sdk/
geoApiKey = "YOUR-API-KEY"
geoApiKey = BuildConfig.GOOGLE_MAPS_API_KEY
)
).apply { start() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MapboxActivity : MvvmActivity<ActivityMapboxBinding, MapboxViewModel>() {
override val viewModelVariableId: Int = BR.viewModel
override val viewModelClass: Class<MapboxViewModel> = MapboxViewModel::class.java

private val mapboxToken = "YOUR-ACCESS-TOKEN"
private val mapboxToken = BuildConfig.MAPBOX_PUBLIC_TOKEN

override fun viewModelFactory(): ViewModelProvider.Factory {
return createViewModelFactory {
Expand Down

0 comments on commit f2554d5

Please sign in to comment.