summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2017-01-04 12:15:26 +0100
committerGitHub <noreply@github.com>2017-01-04 12:15:26 +0100
commitb38710541941797c2937ea262e9905abccf56287 (patch)
treed4536b0e53ffb92e18562e549359095c340e1b14 /platform/android
parent654061c7d1596a3de0a40233c08ccea007ffc2e5 (diff)
downloadqtlocation-mapboxgl-b38710541941797c2937ea262e9905abccf56287.tar.gz
[android] - remove deprecated setAccessToken and getAccessToken from OfflineManager, make validating the access token a part of getAccessToken in Mapbox. (#7582)
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java19
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java1
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java28
4 files changed, 11 insertions, 39 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
index d9cf407677..90f52604df 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java
@@ -39,22 +39,16 @@ public final class Mapbox {
* @return Mapbox Access Token
*/
public static String getAccessToken() {
+ validateAccessToken();
return INSTANCE.accessToken;
}
/**
- * Application context
- */
- public static Context getApplicationContext() {
- return INSTANCE.context;
- }
-
- /**
* Runtime validation of Access Token.
*
- * @throws InvalidAccessTokenException the exception thrown
+ * @throws InvalidAccessTokenException exception thrown when not using a valid accessToken
*/
- public static void validateAccessToken() throws InvalidAccessTokenException {
+ private static void validateAccessToken() throws InvalidAccessTokenException {
String accessToken = INSTANCE.accessToken;
if (TextUtils.isEmpty(accessToken) || (!accessToken.toLowerCase(MapboxConstants.MAPBOX_LOCALE).startsWith("pk.")
&& !accessToken.toLowerCase(MapboxConstants.MAPBOX_LOCALE).startsWith("sk."))) {
@@ -63,6 +57,13 @@ public final class Mapbox {
}
/**
+ * Application context
+ */
+ public static Context getApplicationContext() {
+ return INSTANCE.context;
+ }
+
+ /**
* Manually sets the connectivity state of the app. This is useful for apps that control their
* own connectivity state and want to bypass any checks to the ConnectivityManager.
*
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
index f9bf485c2c..47a5000de1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java
@@ -202,7 +202,6 @@ public class MapView extends FrameLayout {
*/
@UiThread
public void onCreate(@Nullable Bundle savedInstanceState) {
- Mapbox.validateAccessToken();
nativeMapView.setAccessToken(Mapbox.getAccessToken());
if (savedInstanceState == null) {
@@ -411,7 +410,6 @@ public class MapView extends FrameLayout {
// stopgap for https://github.com/mapbox/mapbox-gl-native/issues/6242
if (TextUtils.isEmpty(nativeMapView.getAccessToken())) {
- Mapbox.validateAccessToken();
nativeMapView.setAccessToken(Mapbox.getAccessToken());
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
index 31ed5ab6ae..dd310776e9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java
@@ -839,7 +839,6 @@ public final class MapboxMap {
if (!TextUtils.isEmpty(style)) {
// stopgap for https://github.com/mapbox/mapbox-gl-native/issues/6242
if (TextUtils.isEmpty(nativeMapView.getAccessToken())) {
- Mapbox.validateAccessToken();
nativeMapView.setAccessToken(Mapbox.getAccessToken());
}
setStyleUrl(style);
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
index 1a396f6897..beaea73024 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineManager.java
@@ -7,7 +7,6 @@ import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.support.annotation.NonNull;
-import android.text.TextUtils;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -97,10 +96,7 @@ public class OfflineManager {
String assetRoot = getDatabasePath(context);
String cachePath = assetRoot + File.separator + DATABASE_NAME;
mDefaultFileSourcePtr = createDefaultFileSource(cachePath, assetRoot, DEFAULT_MAX_CACHE_SIZE);
-
- if (!TextUtils.isEmpty(Mapbox.getAccessToken())) {
- setAccessToken(mDefaultFileSourcePtr, Mapbox.getAccessToken());
- }
+ setAccessToken(mDefaultFileSourcePtr, Mapbox.getAccessToken());
// Delete any existing previous ambient cache database
deleteAmbientDatabase(context);
@@ -191,28 +187,6 @@ public class OfflineManager {
return instance;
}
- /**
- * Access token getter/setter
- *
- * @param accessToken the accessToken to be used by the offline manager.
- * @deprecated As of release 4.1.0, replaced by {@link Mapbox#getInstance(Context, String)}}
- */
- @Deprecated
- public void setAccessToken(String accessToken) {
- setAccessToken(mDefaultFileSourcePtr, accessToken);
- }
-
- /**
- * Get Access Token
- *
- * @return Access Token
- * @deprecated As of release 4.1.0, replaced by {@link Mapbox#getAccessToken()}
- */
- @Deprecated
- public String getAccessToken() {
- return getAccessToken(mDefaultFileSourcePtr);
- }
-
private Handler getHandler() {
if (handler == null) {
handler = new Handler(Looper.getMainLooper());