From 6c8af2003c739b7f3da8c8ab8bfbc408d04c6934 Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Wed, 30 Aug 2017 16:40:01 -0600 Subject: [PATCH] Wrap BuildConfig reference for sdk version --- .../com/mapzen/android/core/GenericHttpHandler.java | 4 +--- .../java/com/mapzen/android/core/MapzenManager.java | 10 ++++++++++ .../com/mapzen/android/core/MapzenManagerTest.java | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java b/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java index 3d8c1e15..bffbe43e 100644 --- a/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java +++ b/core/src/main/java/com/mapzen/android/core/GenericHttpHandler.java @@ -1,7 +1,5 @@ package com.mapzen.android.core; -import com.mapzen.BuildConfig; - import android.os.Build; import java.util.Map; @@ -12,7 +10,7 @@ public interface GenericHttpHandler { String HEADER_USER_AGENT = "User-Agent"; - String USER_AGENT = "android-sdk;" + BuildConfig.SDK_VERSION + ";" + Build.VERSION.RELEASE; + String USER_AGENT = "android-sdk;" + MapzenManager.getSdkVersion() + ";" + Build.VERSION.RELEASE; /** * Return query parameters to be appended to every request. diff --git a/core/src/main/java/com/mapzen/android/core/MapzenManager.java b/core/src/main/java/com/mapzen/android/core/MapzenManager.java index 4aeec53a..da4d517e 100644 --- a/core/src/main/java/com/mapzen/android/core/MapzenManager.java +++ b/core/src/main/java/com/mapzen/android/core/MapzenManager.java @@ -1,5 +1,7 @@ package com.mapzen.android.core; +import com.mapzen.BuildConfig; + import android.content.Context; import android.content.res.Resources; @@ -79,4 +81,12 @@ public String getApiKey() { public void setApiKey(String apiKey) { this.apiKey = apiKey; } + + /** + * Returns the maven artifact version. + * @return + */ + public static String getSdkVersion() { + return BuildConfig.SDK_VERSION; + } } diff --git a/core/src/test/java/com/mapzen/android/core/MapzenManagerTest.java b/core/src/test/java/com/mapzen/android/core/MapzenManagerTest.java index 75bd44d1..b98e45d0 100644 --- a/core/src/test/java/com/mapzen/android/core/MapzenManagerTest.java +++ b/core/src/test/java/com/mapzen/android/core/MapzenManagerTest.java @@ -71,6 +71,10 @@ public void getApiKey_shouldReturnThrowIfResourceNotFound() throws Exception { assertThat(mapzenManager.getApiKey()).isEqualTo("mapzen-fake-api-key-2"); } + @Test public void getSdkVersion() throws Exception { + assertThat(MapzenManager.getSdkVersion()).isNotEmpty(); + } + private class TestResources extends Resources { private String testApiKey;