Commit 3d80fded authored by Drahomír Karchňák's avatar Drahomír Karchňák

Better way of handling google maps api key.

parent 9ae8d102
......@@ -80,7 +80,7 @@
<service android:enabled="true" android:name="at.alladin.rmbt.android.test.RMBTService" android:exported="false" />
<service android:enabled="true" android:name="at.alladin.rmbt.android.test.RMBTLoopService" android:exported="false" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="GOOGLEMAPS_APIKEY"/>
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="${GOOGLE_MAPS_API_KEY}"/>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<meta-data android:name="cz.nic.labs.rmbt.android.test.RMBTBugReport" android:value="RMBT_USE_BUGREPORT"/>
</application>
......
......@@ -160,14 +160,16 @@ android {
}
buildTypes {
release {
release { //Release version of an app
debuggable false
resValue 'string', 'app_name', 'NetMetr'
buildConfigField 'Boolean', 'DEVELOPER_OPTIONS', 'false'
buildConfigField "String", "CLIENT_SECRET", project.hasProperty('RMBT_CLIENT_SECRET_RELEASE') ? String.format("\"%s\"", RMBT_CLIENT_SECRET_RELEASE) : "null"
initializeResValues(
initGoogleMapsApiKey(buildTypes.release, 'RMBT_GOOGLE_MAPS_API_KEY_RELEASE')
initResValues(
buildTypes.release,
'RMBT_CONTROL_IPV4_HOST_RELEASE',
'RMBT_CONTROL_IPV6_HOST_RELEASE',
......@@ -177,15 +179,17 @@ android {
'RMBT_CONTROL_SSL_RELEASE',
'RMBT_QOS_SSL_RELEASE')
}
debug {
debug { //Acts as release, but is not signed and allows developer options
applicationIdSuffix = '.debug'
resValue 'string', 'app_name', 'NetMetr Debug'
//These build config fields are inherited by dev build type
buildConfigField 'Boolean', 'DEVELOPER_OPTIONS', 'true'
buildConfigField 'String', 'CLIENT_SECRET', project.hasProperty('RMBT_CLIENT_SECRET_DEV') ? String.format("\"%s\"", RMBT_CLIENT_SECRET_DEV) : "null"
buildConfigField 'String', 'CLIENT_SECRET', project.hasProperty('RMBT_CLIENT_SECRET_RELEASE') ? String.format("\"%s\"", RMBT_CLIENT_SECRET_RELEASE) : "null"
initGoogleMapsApiKey(buildTypes.debug, 'RMBT_GOOGLE_MAPS_API_KEY_RELEASE')
initializeResValues(
initResValues(
buildTypes.debug,
'RMBT_CONTROL_IPV4_HOST_RELEASE',
'RMBT_CONTROL_IPV6_HOST_RELEASE',
......@@ -200,7 +204,9 @@ android {
applicationIdSuffix = '.dev'
resValue 'string', 'app_name', 'NetMetr Devel'
initializeResValues(
initGoogleMapsApiKey(buildTypes.dev, 'RMBT_GOOGLE_MAPS_API_KEY_DEV')
initResValues(
buildTypes.dev,
'RMBT_CONTROL_IPV4_HOST_DEV',
'RMBT_CONTROL_IPV6_HOST_DEV',
......@@ -220,10 +226,10 @@ android {
&& project.hasProperty('RMBT_RELEASE_KEY_ALIAS') && project.hasProperty('RMBT_RELEASE_KEY_PASSWORD')) {
signingConfigs {
release {
storeFile file(RMBT_RELEASE_KEYSTORE)
storePassword RMBT_RELEASE_KEYSTORE_PASSWORD
keyAlias RMBT_RELEASE_KEY_ALIAS
keyPassword RMBT_RELEASE_KEY_PASSWORD
storeFile file(RMBT_RELEASE_KEYSTORE)
storePassword RMBT_RELEASE_KEYSTORE_PASSWORD
keyAlias RMBT_RELEASE_KEY_ALIAS
keyPassword RMBT_RELEASE_KEY_PASSWORD
}
}
......@@ -235,7 +241,14 @@ android {
}
}
def initializeResValues(buildType, IPv4Host, IPv6Host, IPv4CheckHost, IPv6CheckHost, ControlServerPort, ControlServerSSL, QoSServerSSL) {
def initGoogleMapsApiKey(buildType, mapsApiKey) {
if(project.hasProperty(mapsApiKey)) {
//Key: "GOOGLE_MAPS_API_KEY has to have a same name as in manifest file.
buildType.manifestPlaceholders = [GOOGLE_MAPS_API_KEY: project.property(mapsApiKey)]
}
}
def initResValues(buildType, IPv4Host, IPv6Host, IPv4CheckHost, IPv6CheckHost, ControlServerPort, ControlServerSSL, QoSServerSSL) {
if(project.hasProperty(IPv4Host)) {
buildType.resValue 'string', 'default_control_host', project.property(IPv4Host)
buildType.resValue 'string', 'default_control_host_ipv4_only', project.property(IPv4Host)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment