Commit e970a16d authored by Deployer's avatar Deployer

Updated to Mapbox SDK version 6.8.0

parent 184b6f25
...@@ -3,7 +3,7 @@ apply plugin: 'signing' ...@@ -3,7 +3,7 @@ apply plugin: 'signing'
apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.github.dcendents.android-maven'
group = "com.cedarmaps" group = "com.cedarmaps"
version = "3.1.2" version = "3.2.0"
def siteUrl = 'http://cedarmaps.com' def siteUrl = 'http://cedarmaps.com'
def gitUrl = 'http://cedarmaps.com/git' def gitUrl = 'http://cedarmaps.com/git'
...@@ -17,7 +17,7 @@ android { ...@@ -17,7 +17,7 @@ android {
} }
dependencies { dependencies {
api 'com.cedarmaps:mapbox-android-sdk:6.5.0' api 'com.cedarmaps:mapbox-android-sdk:6.8.0'
implementation 'com.squareup.okhttp3:okhttp:3.11.0' implementation 'com.squareup.okhttp3:okhttp:3.11.0'
implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.google.code.gson:gson:2.8.5'
} }
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.cedarstudios.cedarmapssdk"> package="com.cedarstudios.cedarmapssdk">
<application android:allowBackup="true"> <application>
</application> </application>
</manifest> </manifest>
package com.cedarstudios.cedarmapssdk; package com.cedarstudios.cedarmapssdk;
import android.annotation.SuppressLint;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -24,6 +25,7 @@ import java.net.URLDecoder; ...@@ -24,6 +25,7 @@ import java.net.URLDecoder;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.FormBody; import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
...@@ -38,6 +40,7 @@ final class AuthenticationManager { ...@@ -38,6 +40,7 @@ final class AuthenticationManager {
private static final String defaultBaseURL = "https://api.cedarmaps.com/v1/"; private static final String defaultBaseURL = "https://api.cedarmaps.com/v1/";
private static final String SAVED_ACCESS_TOKEN_KEY = "com.cedarstudios.cedarmapssdk.saved_access_token"; private static final String SAVED_ACCESS_TOKEN_KEY = "com.cedarstudios.cedarmapssdk.saved_access_token";
@SuppressLint("StaticFieldLeak")
private static AuthenticationManager instance; private static AuthenticationManager instance;
private String mClientID; private String mClientID;
...@@ -52,7 +55,11 @@ final class AuthenticationManager { ...@@ -52,7 +55,11 @@ final class AuthenticationManager {
private BroadcastReceiver mapViewError401BroadcastReceiver = new BroadcastReceiver() { private BroadcastReceiver mapViewError401BroadcastReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
regenerateAccessToken(); try {
regenerateAccessToken();
} catch (CedarMapsException e) {
e.printStackTrace();
}
} }
}; };
...@@ -149,19 +156,21 @@ final class AuthenticationManager { ...@@ -149,19 +156,21 @@ final class AuthenticationManager {
} }
} }
void regenerateAccessToken() { void regenerateAccessToken() throws CedarMapsException {
if (isFetchingNewAccessToken) { if (isFetchingNewAccessToken) {
return; return;
} }
isFetchingNewAccessToken = true; isFetchingNewAccessToken = true;
invalidateCredentials(); invalidateCredentials();
Mapbox.getInstance(getContext(), Constants.INITIAL_TOKEN);
fetchAccessTokenFromServer(new AccessTokenListener() { fetchAccessTokenFromServer(new AccessTokenListener() {
@Override @Override
public void onSuccess(@NonNull String accessToken) { public void onSuccess(@NonNull String accessToken) {
isFetchingNewAccessToken = false; isFetchingNewAccessToken = false;
if (!TextUtils.isEmpty(accessToken)) { if (!TextUtils.isEmpty(accessToken)) {
Mapbox.getInstance(getContext(), accessToken); Mapbox.setAccessToken("pk." + accessToken);
Intent intent = new Intent(ACCESS_TOKEN_READY_INTENT); Intent intent = new Intent(ACCESS_TOKEN_READY_INTENT);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent); LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
...@@ -175,7 +184,7 @@ final class AuthenticationManager { ...@@ -175,7 +184,7 @@ final class AuthenticationManager {
}); });
} }
private boolean saveAccessToken() throws CedarMapsException { private void saveAccessToken() throws CedarMapsException {
if (TextUtils.isEmpty(mAccessToken)) { if (TextUtils.isEmpty(mAccessToken)) {
throw new CedarMapsException("AccessToken is not available to save. Try calling 'getAccessToken' first."); throw new CedarMapsException("AccessToken is not available to save. Try calling 'getAccessToken' first.");
} }
...@@ -186,7 +195,6 @@ final class AuthenticationManager { ...@@ -186,7 +195,6 @@ final class AuthenticationManager {
SharedPreferences.Editor editor = sharedPreferences.edit(); SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString(SAVED_ACCESS_TOKEN_KEY, mAccessToken); editor.putString(SAVED_ACCESS_TOKEN_KEY, mAccessToken);
editor.apply(); editor.apply();
return true;
} }
@Nullable @Nullable
...@@ -215,9 +223,13 @@ final class AuthenticationManager { ...@@ -215,9 +223,13 @@ final class AuthenticationManager {
} }
} }
private void fetchAccessTokenFromServer(final AccessTokenListener completionHandler) { private void fetchAccessTokenFromServer(final AccessTokenListener completionHandler) throws CedarMapsException {
if (mContext == null) {
throw new CedarMapsException("Context is not set. Please call 'setContext' method on CedarMaps.getInstance()");
}
CedarOkHttpClient client = CedarOkHttpClient.getInstance(); OkHttpClient client = CedarOkHttpClient.getSharedInstance(mContext);
final Handler handler = new Handler(Looper.getMainLooper()); final Handler handler = new Handler(Looper.getMainLooper());
String url = mBaseURL + "token"; String url = mBaseURL + "token";
......
...@@ -34,6 +34,7 @@ import java.util.Locale; ...@@ -34,6 +34,7 @@ import java.util.Locale;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import okhttp3.ResponseBody; import okhttp3.ResponseBody;
...@@ -49,6 +50,7 @@ public class CedarMaps { ...@@ -49,6 +50,7 @@ public class CedarMaps {
private String mMapID; private String mMapID;
private String mDirectionID; private String mDirectionID;
private static CedarMaps instance; private static CedarMaps instance;
private AuthenticationManager authManager = AuthenticationManager.getInstance();
//endregion //endregion
//region Initializers //region Initializers
...@@ -95,7 +97,7 @@ public class CedarMaps { ...@@ -95,7 +97,7 @@ public class CedarMaps {
* @return AuthenticationManager singleton object; You could use this to continue setting the other parameters such as clientSecret and context. * @return AuthenticationManager singleton object; You could use this to continue setting the other parameters such as clientSecret and context.
*/ */
public CedarMaps setClientID(@NonNull String clientID) { public CedarMaps setClientID(@NonNull String clientID) {
AuthenticationManager.getInstance().setClientID(clientID); authManager.setClientID(clientID);
return CedarMaps.getInstance(); return CedarMaps.getInstance();
} }
...@@ -106,7 +108,7 @@ public class CedarMaps { ...@@ -106,7 +108,7 @@ public class CedarMaps {
* @return AuthenticationManager singleton object; You could use this to continue setting the other parameters such as context. * @return AuthenticationManager singleton object; You could use this to continue setting the other parameters such as context.
*/ */
public CedarMaps setClientSecret(@NonNull String clientSecret) { public CedarMaps setClientSecret(@NonNull String clientSecret) {
AuthenticationManager.getInstance().setClientSecret(clientSecret); authManager.setClientSecret(clientSecret);
return CedarMaps.getInstance(); return CedarMaps.getInstance();
} }
...@@ -119,7 +121,7 @@ public class CedarMaps { ...@@ -119,7 +121,7 @@ public class CedarMaps {
* @return AuthenticationManager singleton object. * @return AuthenticationManager singleton object.
*/ */
public CedarMaps setContext(@NonNull Context context) { public CedarMaps setContext(@NonNull Context context) {
AuthenticationManager.getInstance().setContext(context); authManager.setContext(context);
return CedarMaps.getInstance(); return CedarMaps.getInstance();
} }
...@@ -131,13 +133,13 @@ public class CedarMaps { ...@@ -131,13 +133,13 @@ public class CedarMaps {
* @return AuthenticationManager singleton object. * @return AuthenticationManager singleton object.
*/ */
public CedarMaps setAPIBaseURL(@Nullable String url) { public CedarMaps setAPIBaseURL(@Nullable String url) {
AuthenticationManager.getInstance().setAPIBaseURL(url); authManager.setAPIBaseURL(url);
return CedarMaps.getInstance(); return CedarMaps.getInstance();
} }
//endregion //endregion
public String getSavedAccessToken() throws CedarMapsException { public String getSavedAccessToken() throws CedarMapsException {
return AuthenticationManager.getInstance().getSavedAccessToken(); return authManager.getSavedAccessToken();
} }
/** /**
...@@ -247,7 +249,7 @@ public class CedarMaps { ...@@ -247,7 +249,7 @@ public class CedarMaps {
return; return;
} }
String url = String.format(Locale.ENGLISH, String url = String.format(Locale.ENGLISH,
AuthenticationManager.getInstance().getAPIBaseURL() + "geocode/%s/%s.json", authManager.getAPIBaseURL() + "geocode/%s/%s.json",
mMapID, mMapID,
term); term);
...@@ -304,7 +306,7 @@ public class CedarMaps { ...@@ -304,7 +306,7 @@ public class CedarMaps {
*/ */
public void reverseGeocode(LatLng coordinate, final ReverseGeocodeResultListener completionHandler) { public void reverseGeocode(LatLng coordinate, final ReverseGeocodeResultListener completionHandler) {
String url = String.format(Locale.ENGLISH, String url = String.format(Locale.ENGLISH,
AuthenticationManager.getInstance().getAPIBaseURL() + "geocode/%1$s/%2$s,%3$s.json", authManager.getAPIBaseURL() + "geocode/%1$s/%2$s,%3$s.json",
mMapID, mMapID,
coordinate.getLatitude(), coordinate.getLongitude()); coordinate.getLatitude(), coordinate.getLongitude());
...@@ -347,7 +349,7 @@ public class CedarMaps { ...@@ -347,7 +349,7 @@ public class CedarMaps {
public void distance(LatLng start, LatLng end, final GeoRoutingResultListener completionHandler) { public void distance(LatLng start, LatLng end, final GeoRoutingResultListener completionHandler) {
String url = String.format(Locale.ENGLISH, String url = String.format(Locale.ENGLISH,
AuthenticationManager.getInstance().getAPIBaseURL() + "distance/%1$s/%2$s,%3$s;%4$s,%5$s", authManager.getAPIBaseURL() + "distance/%1$s/%2$s,%3$s;%4$s,%5$s",
mDirectionID, mDirectionID,
start.getLatitude(), start.getLongitude(), end.getLatitude(), end.getLongitude()); start.getLatitude(), start.getLongitude(), end.getLatitude(), end.getLongitude());
...@@ -398,7 +400,7 @@ public class CedarMaps { ...@@ -398,7 +400,7 @@ public class CedarMaps {
} }
String url = String.format(Locale.ENGLISH, String url = String.format(Locale.ENGLISH,
AuthenticationManager.getInstance().getAPIBaseURL() + "distance/%1$s/%2$s", authManager.getAPIBaseURL() + "distance/%1$s/%2$s",
mDirectionID, pairs.toString()); mDirectionID, pairs.toString());
getResponseBodyFromURL(url, new NetworkResponseBodyCompletionHandler() { getResponseBodyFromURL(url, new NetworkResponseBodyCompletionHandler() {
...@@ -497,7 +499,7 @@ public class CedarMaps { ...@@ -497,7 +499,7 @@ public class CedarMaps {
} }
String url = String.format(Locale.ENGLISH, String url = String.format(Locale.ENGLISH,
AuthenticationManager.getInstance().getAPIBaseURL() + "direction/%1$s/%2$s?instructions=%3$s&locale=%4$s", authManager.getAPIBaseURL() + "direction/%1$s/%2$s?instructions=%3$s&locale=%4$s",
mDirectionID, mDirectionID,
pairs.toString(), pairs.toString(),
shouldShowInstructions ? "true" : "false", shouldShowInstructions ? "true" : "false",
...@@ -568,7 +570,7 @@ public class CedarMaps { ...@@ -568,7 +570,7 @@ public class CedarMaps {
} }
String url = String.format(Locale.ENGLISH, String url = String.format(Locale.ENGLISH,
AuthenticationManager.getInstance().getAPIBaseURL() + "static/light/%s/%s%s%s", paramPosition, paramDimension, paramScale, paramMarkers); authManager.getAPIBaseURL() + "static/light/%s/%s%s%s", paramPosition, paramDimension, paramScale, paramMarkers);
getResponseBodyFromURL(url, new NetworkResponseBodyCompletionHandler() { getResponseBodyFromURL(url, new NetworkResponseBodyCompletionHandler() {
@Override @Override
...@@ -627,10 +629,10 @@ public class CedarMaps { ...@@ -627,10 +629,10 @@ public class CedarMaps {
private void getResponseBodyFromURL(final String url, final NetworkResponseBodyCompletionHandler completionHandler) { private void getResponseBodyFromURL(final String url, final NetworkResponseBodyCompletionHandler completionHandler) {
AuthenticationManager.getInstance().getAccessToken(new AccessTokenListener() { authManager.getAccessToken(new AccessTokenListener() {
@Override @Override
public void onSuccess(@NonNull String accessToken) { public void onSuccess(@NonNull String accessToken) {
CedarOkHttpClient client = CedarOkHttpClient.getInstance(); OkHttpClient client = CedarOkHttpClient.getSharedInstance(authManager.getContext());
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
.tag(url) .tag(url)
...@@ -646,7 +648,11 @@ public class CedarMaps { ...@@ -646,7 +648,11 @@ public class CedarMaps {
if (response.code() == 400) { if (response.code() == 400) {
completionHandler.onFailure(new CedarMapsException("Invalid Request. Missing Parameters.", response).getMessage()); completionHandler.onFailure(new CedarMapsException("Invalid Request. Missing Parameters.", response).getMessage());
} else if (response.code() == 401) { } else if (response.code() == 401) {
AuthenticationManager.getInstance().regenerateAccessToken(); try {
authManager.regenerateAccessToken();
} catch (CedarMapsException e) {
e.printStackTrace();
}
completionHandler.onFailure(new CedarMapsException("Obtaining Bearer Token Failed.", response).getMessage()); completionHandler.onFailure(new CedarMapsException("Obtaining Bearer Token Failed.", response).getMessage());
} else if (response.code() == 500) { } else if (response.code() == 500) {
completionHandler.onFailure(new CedarMapsException("Internal Server Error.", response).getMessage()); completionHandler.onFailure(new CedarMapsException("Internal Server Error.", response).getMessage());
......
package com.cedarstudios.cedarmapssdk; package com.cedarstudios.cedarmapssdk;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.v4.os.ConfigurationCompat;
import java.io.IOException;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Response;
final class CedarOkHttpClient {
final class CedarOkHttpClient extends OkHttpClient { private static OkHttpClient sharedInstance;
static OkHttpClient getSharedInstance(final Context applicationContext) {
if (sharedInstance != null) {
return sharedInstance;
}
sharedInstance = new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.addNetworkInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
String userAgent;
if (userAgent(applicationContext) != null) {
userAgent = userAgent(applicationContext);
} else {
userAgent = "CedarMaps SDK";
}
assert userAgent != null;
return chain.proceed(
chain.request().newBuilder().header(
"User-Agent",
userAgent
).build()
);
}
})
.build();
return sharedInstance;
}
private static CedarOkHttpClient client = new CedarOkHttpClient(); private static String userAgent(Context applicationContext) {
String abi;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
abi = Build.SUPPORTED_ABIS[0];
} else {
abi = Build.CPU_ABI;
}
public static CedarOkHttpClient getInstance() { try {
return client; return String.format(
Locale.US, "%s/%s (%d) %s Android/%s %s-%s (%s)",
applicationContext.getPackageName(),
applicationContext.getPackageManager().getPackageInfo(
applicationContext.getPackageName(),
0
).versionName,
applicationContext.getPackageManager().getPackageInfo(
applicationContext.getPackageName(),
0
).versionCode,
ConfigurationCompat
.getLocales(applicationContext.getResources().getConfiguration()).get(0),
Build.VERSION.RELEASE,
Build.MANUFACTURER,
Build.MODEL,
abi
);
} catch (PackageManager.NameNotFoundException e) {
return null;
}
} }
} }
package com.cedarstudios.cedarmapssdk;
class Constants {
static final String INITIAL_TOKEN = "pk.spamradecrofnekotxobpamekafasisiht";
}
...@@ -10,11 +10,9 @@ import android.support.v4.content.LocalBroadcastManager; ...@@ -10,11 +10,9 @@ import android.support.v4.content.LocalBroadcastManager;
import android.util.AttributeSet; import android.util.AttributeSet;
import com.cedarstudios.cedarmapssdk.listeners.AccessTokenListener; import com.cedarstudios.cedarmapssdk.listeners.AccessTokenListener;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.MapboxMapOptions; import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
public class MapView extends com.mapbox.mapboxsdk.maps.MapView { public class MapView extends com.mapbox.mapboxsdk.maps.MapView {
...@@ -58,7 +56,7 @@ public class MapView extends com.mapbox.mapboxsdk.maps.MapView { ...@@ -58,7 +56,7 @@ public class MapView extends com.mapbox.mapboxsdk.maps.MapView {
} }
}; };
LocalBroadcastManager.getInstance(Mapbox.getApplicationContext()) LocalBroadcastManager.getInstance(getContext().getApplicationContext())
.registerReceiver(mBroadcastReceiver, new IntentFilter(AuthenticationManager.ACCESS_TOKEN_READY_INTENT)); .registerReceiver(mBroadcastReceiver, new IntentFilter(AuthenticationManager.ACCESS_TOKEN_READY_INTENT));
} }
} }
...@@ -107,7 +105,7 @@ public class MapView extends com.mapbox.mapboxsdk.maps.MapView { ...@@ -107,7 +105,7 @@ public class MapView extends com.mapbox.mapboxsdk.maps.MapView {
@Override @Override
public void onDestroy() { public void onDestroy() {
LocalBroadcastManager.getInstance(Mapbox.getApplicationContext()).unregisterReceiver(mBroadcastReceiver); LocalBroadcastManager.getInstance(getContext().getApplicationContext()).unregisterReceiver(mBroadcastReceiver);
super.onDestroy(); super.onDestroy();
} }
} }
...@@ -26,10 +26,12 @@ final class TileConfigurator { ...@@ -26,10 +26,12 @@ final class TileConfigurator {
}); });
} }
} else { } else {
Mapbox.getInstance(context, Constants.INITIAL_TOKEN);
AuthenticationManager.getInstance().getAccessToken(new AccessTokenListener() { AuthenticationManager.getInstance().getAccessToken(new AccessTokenListener() {
@Override @Override
public void onSuccess(@NonNull String accessToken) { public void onSuccess(@NonNull String accessToken) {
Mapbox.getInstance(context, accessToken); Mapbox.setAccessToken("pk." + accessToken);
if (completionHandler != null) { if (completionHandler != null) {
completionHandler.onSuccess(); completionHandler.onSuccess();
} }
......
package com.cedarstudios.cedarmapssdk.listeners; package com.cedarstudios.cedarmapssdk.listeners;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
/** /**
* The listener for obtaining the Access Token needed in using CedarMaps API. * The listener for obtaining the Access Token needed in using CedarMaps API.
*/ */
......
...@@ -4,7 +4,6 @@ package com.cedarstudios.cedarmapssdk.model.geocoder.forward; ...@@ -4,7 +4,6 @@ package com.cedarstudios.cedarmapssdk.model.geocoder.forward;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
......
...@@ -7,8 +7,8 @@ android { ...@@ -7,8 +7,8 @@ android {
applicationId "com.cedarmaps.sdksampleapp" applicationId "com.cedarmaps.sdksampleapp"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 28 targetSdkVersion 28
versionCode 97071210 versionCode 97100410
versionName "1.2.1" versionName "1.4.0"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
} }
...@@ -21,6 +21,7 @@ android { ...@@ -21,6 +21,7 @@ android {
} }
lintOptions { lintOptions {
disable 'MissingTranslation'
abortOnError false abortOnError false
} }
...@@ -33,7 +34,7 @@ android { ...@@ -33,7 +34,7 @@ android {
abi { abi {
enable true enable true
reset() reset()
// include "armeabi-v7a", "arm64-v8a", "x86", "x86_64" include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
universalApk true universalApk true
} }
} }
...@@ -44,14 +45,14 @@ android { ...@@ -44,14 +45,14 @@ android {
def STRING = "String" def STRING = "String"
def MARKET = "MARKET" def MARKET = "MARKET"
def GOOGLE_PLAY = '"GooglePlay"' def GOOGLE_PLAY = '"googleplay"'
def CAFE_BAZAAR = '"CafeBazaar"' def CAFE_BAZAAR = '"cafebazaar"'
googlePlay { googlePlay {
buildConfigField STRING, MARKET, GOOGLE_PLAY buildConfigField STRING, MARKET, GOOGLE_PLAY
dimension "dimension" dimension "dimension"
ndk { ndk {
abiFilters "armeabi-v7a","arm64-v8a","x86","x86_64" abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
} }
} }
...@@ -59,13 +60,13 @@ android { ...@@ -59,13 +60,13 @@ android {
buildConfigField STRING, MARKET, CAFE_BAZAAR buildConfigField STRING, MARKET, CAFE_BAZAAR
dimension "dimension" dimension "dimension"
ndk { ndk {
abiFilters "armeabi-v7a","arm64-v8a" abiFilters "armeabi-v7a", "arm64-v8a"
} }
} }
} }
} }
ext.abiCodes = ['armeabi-v7a':1, 'arm64-v8a':2, 'x86':3, 'x86_64':4] ext.abiCodes = ['x86':1, 'x86_64':2, 'armeabi-v7a':3, 'arm64-v8a':4]
android.applicationVariants.all { variant -> android.applicationVariants.all { variant ->
variant.outputs.each { output -> variant.outputs.each { output ->
def baseAbiVersionCode = def baseAbiVersionCode =
...@@ -78,10 +79,6 @@ android.applicationVariants.all { variant -> ...@@ -78,10 +79,6 @@ android.applicationVariants.all { variant ->
dependencies { dependencies {
implementation (project(':CedarMapsSDK')) implementation (project(':CedarMapsSDK'))
implementation("com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.8.2") {
exclude group: 'com.mapbox.mapboxsdk'
}
implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0' implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-vector-drawable:28.0.0' implementation 'com.android.support:support-vector-drawable:28.0.0'
......
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
<application <application
android:allowClearUserData="true" android:allowClearUserData="true"
android:appCategory="maps" android:appCategory="maps"
android:fullBackupContent="true" android:allowBackup="false"
android:allowBackup="true"
android:name=".SampleApp" android:name=".SampleApp"
android:icon="@mipmap/ic_launcher" android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
...@@ -27,7 +26,6 @@ ...@@ -27,7 +26,6 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<meta-data android:name="android.max_aspect" android:value="2.1" />
</application> </application>
</manifest> </manifest>
\ No newline at end of file
...@@ -6,8 +6,9 @@ public class Constants { ...@@ -6,8 +6,9 @@ public class Constants {
public static final int PERMISSION_LOCATION_REQUEST_CODE = 100; public static final int PERMISSION_LOCATION_REQUEST_CODE = 100;
static final String CLIENT_ID = "CLIENT_ID"; // TODO: Add your clientID and clientSecret here.
static final String CLIENT_SECRET = "CLIENT_SECRET"; static final String CLIENT_ID = "YOUR_CLIENT_ID";
static final String CLIENT_SECRET = "YOUR_CLIENT_SECRET";
public static final LatLng VANAK_SQUARE = new LatLng(35.7572, 51.4099); public static final LatLng VANAK_SQUARE = new LatLng(35.7572, 51.4099);
} }
...@@ -2,11 +2,13 @@ package com.cedarmaps.sdksampleapp; ...@@ -2,11 +2,13 @@ package com.cedarmaps.sdksampleapp;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView; import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.util.Log; import android.view.MenuItem;
import android.widget.Toast;
import com.cedarmaps.sdksampleapp.fragments.DirectionFragment; import com.cedarmaps.sdksampleapp.fragments.DirectionFragment;
import com.cedarmaps.sdksampleapp.fragments.ForwardGeocodeFragment; import com.cedarmaps.sdksampleapp.fragments.ForwardGeocodeFragment;
...@@ -16,45 +18,9 @@ import com.cedarmaps.sdksampleapp.fragments.StaticMapFragment; ...@@ -16,45 +18,9 @@ import com.cedarmaps.sdksampleapp.fragments.StaticMapFragment;
import com.cedarstudios.cedarmapssdk.CedarMaps; import com.cedarstudios.cedarmapssdk.CedarMaps;
import com.cedarstudios.cedarmapssdk.listeners.OnTilesConfigured; import com.cedarstudios.cedarmapssdk.listeners.OnTilesConfigured;
public class MainActivity extends AppCompatActivity { import java.util.Locale;
private Integer currentlySelectedMenuID = null;
private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener
= item -> {
Fragment fragment = null;
switch (item.getItemId()) {
case R.id.navigation_map:
setTitle(R.string.title_map);
fragment = new MapFragment();
break;
case R.id.navigation_reverse:
setTitle(R.string.title_reverse);
fragment = new ReverseGeocodeFragment();
break;
case R.id.navigation_forward:
setTitle("");
fragment = new ForwardGeocodeFragment();
break;
case R.id.navigation_direction:
setTitle(R.string.title_direction);
fragment = new DirectionFragment();
break;
case R.id.navigation_static:
setTitle(R.string.title_static);
fragment = new StaticMapFragment();
break;
}
if (fragment != null && (currentlySelectedMenuID == null || currentlySelectedMenuID != item.getItemId())) {
invalidateOptionsMenu();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
currentlySelectedMenuID = item.getItemId();
transaction.add(R.id.content, fragment).commit();
return true;
}
return false; public class MainActivity extends AppCompatActivity implements BottomNavigationView.OnNavigationItemSelectedListener {
};
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
...@@ -64,16 +30,55 @@ public class MainActivity extends AppCompatActivity { ...@@ -64,16 +30,55 @@ public class MainActivity extends AppCompatActivity {
CedarMaps.getInstance().prepareTiles(new OnTilesConfigured() { CedarMaps.getInstance().prepareTiles(new OnTilesConfigured() {
@Override @Override
public void onSuccess() { public void onSuccess() {
BottomNavigationView navigation = findViewById(R.id.navigation); BottomNavigationView navigation = findViewById(R.id.navigationView);
navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); navigation.setOnNavigationItemSelectedListener(MainActivity.this);
navigation.setSelectedItemId(R.id.navigation_map); navigation.setSelectedItemId(R.id.navigation_map);
currentlySelectedMenuID = navigation.getSelectedItemId();
} }
@Override @Override
public void onFailure(@NonNull String error) { public void onFailure(@NonNull String error) {
Log.e("MainActivity", error); Toast.makeText(MainActivity.this, R.string.error_preparing_tiles, Toast.LENGTH_LONG).show();
} }
}); });
} }
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
Fragment fragment = null;
switch (item.getItemId()) {
case R.id.navigation_map:
setTitle(R.string.title_map);
fragment = new MapFragment();
break;
case R.id.navigation_reverse:
setTitle(R.string.title_reverse);
fragment = new ReverseGeocodeFragment();
break;
case R.id.navigation_forward:
setTitle("");
fragment = new ForwardGeocodeFragment();
break;
case R.id.navigation_direction:
setTitle(R.string.title_direction);
fragment = new DirectionFragment();
break;
case R.id.navigation_static:
setTitle(R.string.title_static);
fragment = new StaticMapFragment();
break;
}
if (fragment != null) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (getSupportFragmentManager().getFragments().isEmpty()) {
transaction.add(R.id.content, fragment, String.format(Locale.US, "item: %d", item.getItemId())).commit();
} else {
transaction.replace(R.id.content, fragment, String.format(Locale.US, "item: %d", item.getItemId())).commit();
invalidateOptionsMenu();
}
return true;
}
return false;
}
} }
package com.cedarmaps.sdksampleapp; package com.cedarmaps.sdksampleapp;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -30,10 +31,10 @@ public class SearchViewAdapter extends RecyclerView.Adapter<SearchViewAdapter.Se ...@@ -30,10 +31,10 @@ public class SearchViewAdapter extends RecyclerView.Adapter<SearchViewAdapter.Se
SearchViewHolder(View v) { SearchViewHolder(View v) {
super(v); super(v);
mNameTextView = (TextView) v.findViewById(R.id.search_view_list_item_name); mNameTextView = v.findViewById(R.id.search_view_list_item_name);
mTypeTextView = (TextView) v.findViewById(R.id.search_view_list_item_type); mTypeTextView = v.findViewById(R.id.search_view_list_item_type);
mCityTextView = (TextView) v.findViewById(R.id.search_view_list_city); mCityTextView = v.findViewById(R.id.search_view_list_city);
mLocalityTextView = (TextView) v.findViewById(R.id.search_view_list_item_locality); mLocalityTextView = v.findViewById(R.id.search_view_list_item_locality);
v.setOnClickListener(this); v.setOnClickListener(this);
} }
......
...@@ -215,8 +215,8 @@ public class DirectionFragment extends Fragment { ...@@ -215,8 +215,8 @@ public class DirectionFragment extends Fragment {
} }
@Override @Override
public void onDestroy() { public void onDestroyView() {
super.onDestroy(); super.onDestroyView();
mMapView.onDestroy(); mMapView.onDestroy();
} }
......
...@@ -251,8 +251,8 @@ public class ForwardGeocodeFragment extends Fragment { ...@@ -251,8 +251,8 @@ public class ForwardGeocodeFragment extends Fragment {
} }
@Override @Override
public void onDestroy() { public void onDestroyView() {
super.onDestroy(); super.onDestroyView();
mMapView.onDestroy(); mMapView.onDestroy();
} }
......
...@@ -8,17 +8,14 @@ import android.support.annotation.NonNull; ...@@ -8,17 +8,14 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Toast; import android.widget.Toast;
import com.cedarmaps.sdksampleapp.Constants; import com.cedarmaps.sdksampleapp.Constants;
import com.cedarmaps.sdksampleapp.R; import com.cedarmaps.sdksampleapp.R;
import com.cedarstudios.cedarmapssdk.MapView; import com.cedarstudios.cedarmapssdk.MapView;
import com.mapbox.android.core.location.LocationEngine; import com.mapbox.android.core.location.LocationEngine;
import com.mapbox.android.core.location.LocationEngineListener; import com.mapbox.android.core.location.LocationEngineListener;
...@@ -29,9 +26,8 @@ import com.mapbox.mapboxsdk.annotations.MarkerOptions; ...@@ -29,9 +26,8 @@ import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin;
import com.mapbox.mapboxsdk.plugins.locationlayer.modes.RenderMode;
import static android.support.v4.content.PermissionChecker.PERMISSION_GRANTED; import static android.support.v4.content.PermissionChecker.PERMISSION_GRANTED;
...@@ -40,7 +36,6 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -40,7 +36,6 @@ public class MapFragment extends Fragment implements LocationEngineListener {
private MapView mMapView; private MapView mMapView;
private MapboxMap mMapboxMap; private MapboxMap mMapboxMap;
private LocationEngine mLocationEngine = null; private LocationEngine mLocationEngine = null;
private LocationLayerPlugin mLocationLayerPlugin = null;
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
...@@ -61,14 +56,16 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -61,14 +56,16 @@ public class MapFragment extends Fragment implements LocationEngineListener {
mMapboxMap.setMaxZoomPreference(17); mMapboxMap.setMaxZoomPreference(17);
mMapboxMap.setMinZoomPreference(6); mMapboxMap.setMinZoomPreference(6);
mMapboxMap.setCameraPosition(
if (hasLocationPermissions()) { new CameraPosition.Builder()
enableLocationPlugin(); .target(Constants.VANAK_SQUARE)
.zoom(15)
.build());
if (PermissionsManager.areLocationPermissionsGranted(getActivity())) {
enableLocationComponent();
} }
//Move map to a certain position
animateToCoordinate(Constants.VANAK_SQUARE, 15);
//Add marker to map //Add marker to map
addMarkerToMapViewAtPosition(Constants.VANAK_SQUARE); addMarkerToMapViewAtPosition(Constants.VANAK_SQUARE);
...@@ -106,39 +103,37 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -106,39 +103,37 @@ public class MapFragment extends Fragment implements LocationEngineListener {
private void setupCurrentLocationButton() { private void setupCurrentLocationButton() {
FloatingActionButton fb = getView().findViewById(R.id.showCurrentLocationButton); FloatingActionButton fb = getView().findViewById(R.id.showCurrentLocationButton);
fb.setOnClickListener(v -> { fb.setOnClickListener(v -> {
if (!hasLocationPermissions()) { enableLocationComponent();
enableLocationPlugin();
return;
}
toggleCurrentLocationButton(); toggleCurrentLocationButton();
}); });
} }
@SuppressLint("MissingPermission")
private void toggleCurrentLocationButton() { private void toggleCurrentLocationButton() {
if (mLocationLayerPlugin == null) { if (!mMapboxMap.getLocationComponent().isLocationComponentEnabled()) {
return; return;
} }
Location location = mLocationLayerPlugin.getLastKnownLocation(); Location location = mMapboxMap.getLocationComponent().getLastKnownLocation();
if (location != null) { if (location != null) {
animateToCoordinate(new LatLng(location.getLatitude(),location.getLongitude()), 16); animateToCoordinate(new LatLng(location.getLatitude(),location.getLongitude()), 16);
} }
switch (mLocationLayerPlugin.getRenderMode()) { switch (mMapboxMap.getLocationComponent().getRenderMode()) {
case RenderMode.NORMAL: case RenderMode.NORMAL:
mLocationLayerPlugin.setRenderMode(RenderMode.COMPASS); mMapboxMap.getLocationComponent().setRenderMode(RenderMode.COMPASS);
break; break;
case RenderMode.GPS: case RenderMode.GPS:
mLocationLayerPlugin.setRenderMode(RenderMode.NORMAL); mMapboxMap.getLocationComponent().setRenderMode(RenderMode.NORMAL);
break; break;
case RenderMode.COMPASS: case RenderMode.COMPASS:
mLocationLayerPlugin.setRenderMode(RenderMode.NORMAL); mMapboxMap.getLocationComponent().setRenderMode(RenderMode.NORMAL);
break; break;
} }
} }
@SuppressWarnings( {"MissingPermission"}) @SuppressWarnings( {"MissingPermission"})
private void enableLocationPlugin() { private void enableLocationComponent() {
if (getActivity() == null) { if (getActivity() == null) {
return; return;
} }
...@@ -147,8 +142,8 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -147,8 +142,8 @@ public class MapFragment extends Fragment implements LocationEngineListener {
// Create a location engine instance // Create a location engine instance
initializeLocationEngine(); initializeLocationEngine();
mLocationLayerPlugin = new LocationLayerPlugin(mMapView, mMapboxMap, mLocationEngine); mMapboxMap.getLocationComponent().activateLocationComponent(getActivity());
mLocationLayerPlugin.setLocationLayerEnabled(true); mMapboxMap.getLocationComponent().setLocationComponentEnabled(true);
} else { } else {
requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, Constants.PERMISSION_LOCATION_REQUEST_CODE); requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, Constants.PERMISSION_LOCATION_REQUEST_CODE);
} }
...@@ -160,15 +155,7 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -160,15 +155,7 @@ public class MapFragment extends Fragment implements LocationEngineListener {
mLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY); mLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
mLocationEngine.activate(); mLocationEngine.activate();
Location lastLocation = mLocationEngine.getLastLocation(); mLocationEngine.addLocationEngineListener(this);
if (lastLocation == null) {
mLocationEngine.addLocationEngineListener(this);
}
}
private boolean hasLocationPermissions() {
//Request Location Permission
return getActivity() != null && ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) == PERMISSION_GRANTED;
} }
@Override @Override
...@@ -181,8 +168,10 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -181,8 +168,10 @@ public class MapFragment extends Fragment implements LocationEngineListener {
@SuppressWarnings( {"MissingPermission"}) @SuppressWarnings( {"MissingPermission"})
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
if (mLocationLayerPlugin != null) { if (PermissionsManager.areLocationPermissionsGranted(getActivity())) {
mLocationLayerPlugin.onStart(); if (mLocationEngine != null) {
mLocationEngine.activate();
}
} }
mMapView.onStart(); mMapView.onStart();
} }
...@@ -192,11 +181,8 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -192,11 +181,8 @@ public class MapFragment extends Fragment implements LocationEngineListener {
super.onStop(); super.onStop();
if (mLocationEngine != null) { if (mLocationEngine != null) {
mLocationEngine.removeLocationUpdates(); mLocationEngine.removeLocationUpdates();
mLocationEngine.removeLocationEngineListener(this);
} }
if (mLocationLayerPlugin != null) {
mLocationLayerPlugin.onStop();
}
mMapView.onStop(); mMapView.onStop();
} }
...@@ -219,8 +205,8 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -219,8 +205,8 @@ public class MapFragment extends Fragment implements LocationEngineListener {
} }
@Override @Override
public void onDestroy() { public void onDestroyView() {
super.onDestroy(); super.onDestroyView();
mMapView.onDestroy(); mMapView.onDestroy();
if (mLocationEngine != null) { if (mLocationEngine != null) {
mLocationEngine.deactivate(); mLocationEngine.deactivate();
...@@ -241,7 +227,7 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -241,7 +227,7 @@ public class MapFragment extends Fragment implements LocationEngineListener {
if (!(grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED)) { if (!(grantResults.length > 0 && grantResults[0] == PERMISSION_GRANTED)) {
Toast.makeText(getActivity(), R.string.location_is_needed_to_function, Toast.LENGTH_LONG).show(); Toast.makeText(getActivity(), R.string.location_is_needed_to_function, Toast.LENGTH_LONG).show();
} else { } else {
enableLocationPlugin(); enableLocationComponent();
toggleCurrentLocationButton(); toggleCurrentLocationButton();
} }
break; break;
...@@ -253,7 +239,7 @@ public class MapFragment extends Fragment implements LocationEngineListener { ...@@ -253,7 +239,7 @@ public class MapFragment extends Fragment implements LocationEngineListener {
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
@Override @Override
public void onConnected() { public void onConnected() {
if (mLocationEngine != null && hasLocationPermissions()) { if (mLocationEngine != null && PermissionsManager.areLocationPermissionsGranted(getActivity())) {
mLocationEngine.requestLocationUpdates(); mLocationEngine.requestLocationUpdates();
} }
} }
......
...@@ -3,6 +3,7 @@ package com.cedarmaps.sdksampleapp.fragments; ...@@ -3,6 +3,7 @@ package com.cedarmaps.sdksampleapp.fragments;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.AppCompatTextView; import android.support.v7.widget.AppCompatTextView;
import android.text.TextUtils; import android.text.TextUtils;
...@@ -20,7 +21,6 @@ import com.cedarstudios.cedarmapssdk.listeners.ReverseGeocodeResultListener; ...@@ -20,7 +21,6 @@ import com.cedarstudios.cedarmapssdk.listeners.ReverseGeocodeResultListener;
import com.cedarstudios.cedarmapssdk.model.geocoder.reverse.ReverseGeocode; import com.cedarstudios.cedarmapssdk.model.geocoder.reverse.ReverseGeocode;
import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.maps.MapboxMap; import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
public class ReverseGeocodeFragment extends Fragment { public class ReverseGeocodeFragment extends Fragment {
...@@ -174,8 +174,8 @@ public class ReverseGeocodeFragment extends Fragment { ...@@ -174,8 +174,8 @@ public class ReverseGeocodeFragment extends Fragment {
} }
@Override @Override
public void onDestroy() { public void onDestroyView() {
super.onDestroy(); super.onDestroyView();
mMapView.onDestroy(); mMapView.onDestroy();
} }
......
...@@ -30,7 +30,6 @@ import java.util.ArrayList; ...@@ -30,7 +30,6 @@ import java.util.ArrayList;
public class StaticMapFragment extends Fragment { public class StaticMapFragment extends Fragment {
private Button createMapButton;
private ImageView mapImageView; private ImageView mapImageView;
private ProgressBar progressBar; private ProgressBar progressBar;
private TextView howToTextView; private TextView howToTextView;
...@@ -53,7 +52,7 @@ public class StaticMapFragment extends Fragment { ...@@ -53,7 +52,7 @@ public class StaticMapFragment extends Fragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
createMapButton = view.findViewById(R.id.static_map_create_button); Button createMapButton = view.findViewById(R.id.static_map_create_button);
mapImageView = view.findViewById(R.id.static_map_image_view); mapImageView = view.findViewById(R.id.static_map_image_view);
progressBar = view.findViewById(R.id.static_map_progress_bar); progressBar = view.findViewById(R.id.static_map_progress_bar);
howToTextView = view.findViewById(R.id.static_map_hint); howToTextView = view.findViewById(R.id.static_map_hint);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</FrameLayout> </FrameLayout>
<android.support.design.widget.BottomNavigationView <android.support.design.widget.BottomNavigationView
android:id="@+id/navigation" android:id="@+id/navigationView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
......
...@@ -29,4 +29,5 @@ ...@@ -29,4 +29,5 @@
<string name="province">استان</string> <string name="province">استان</string>
<string name="comma">،</string> <string name="comma">،</string>
<string name="location_is_needed_to_function">نرم‌افزار برای عملکرد این ویژگی به موقعیت مکانی نیاز دارد</string> <string name="location_is_needed_to_function">نرم‌افزار برای عملکرد این ویژگی به موقعیت مکانی نیاز دارد</string>
<string name="error_preparing_tiles">خطا در آماده‌سازی نقشه</string>
</resources> </resources>
...@@ -32,4 +32,5 @@ ...@@ -32,4 +32,5 @@
<string name="longitude_example" translatable="false">51.3572</string> <string name="longitude_example" translatable="false">51.3572</string>
<string name="zoom_example" translatable="false">13</string> <string name="zoom_example" translatable="false">13</string>
<string name="location_is_needed_to_function">App needs location to function</string> <string name="location_is_needed_to_function">App needs location to function</string>
<string name="error_preparing_tiles">Error in preparing map tiles</string>
</resources> </resources>
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
This guide will take you through the process of integrating CedarMaps into your Android application. This guide will take you through the process of integrating CedarMaps into your Android application.
All the mentioned methods and tools in this document are tested on Android Studio v3.2.0. All the mentioned methods and tools in this document are tested on Android Studio v3.2.1.
## Table of Contents ## Table of Contents
- [Installation](#installation) - [Installation](#installation)
...@@ -38,7 +38,7 @@ Then, add this to the `build.gradle` of your **app** module: ...@@ -38,7 +38,7 @@ Then, add this to the `build.gradle` of your **app** module:
```groovy ```groovy
dependencies { dependencies {
implementation 'com.cedarmaps:CedarMapsSDK:3.1.2' implementation 'com.cedarmaps:CedarMapsSDK:3.2.0'
} }
``` ```
...@@ -97,7 +97,7 @@ CedarMaps.getInstance() ...@@ -97,7 +97,7 @@ CedarMaps.getInstance()
### Mapbox ### Mapbox
CedarMaps SDK is based on [Mapbox GL Android SDK v6.3.0](https://github.com/mapbox/mapbox-gl-native) and provides extra API methods over Mapbox. CedarMaps SDK is based on [Mapbox GL Android SDK v6.8.0](https://github.com/mapbox/mapbox-gl-native) and provides extra API methods over Mapbox.
For more information about how to use MapView and other components such as **Adding Markers**, **Showing Current Location**, etc., please see [Mapbox Getting Started](https://www.mapbox.com/help/first-steps-android-sdk/). For more information about how to use MapView and other components such as **Adding Markers**, **Showing Current Location**, etc., please see [Mapbox Getting Started](https://www.mapbox.com/help/first-steps-android-sdk/).
#### MapView #### MapView
...@@ -174,21 +174,6 @@ mMapView.setStyleUrl("STYLE_URL"); ...@@ -174,21 +174,6 @@ mMapView.setStyleUrl("STYLE_URL");
``` ```
Make sure to use your base URL if you have one. Make sure to use your base URL if you have one.
#### Plugins
Mapbox uses [Plugins](https://github.com/mapbox/mapbox-plugins-android) to add extra functionality to the base SDK.
Each plugin is added as a new dependency in `build.gradle`.
```groovy
dependencies {
implementation ('com.mapbox.mapboxsdk:PLUGIN_NAME:PLUGIN_VERSION_NUMBER') {
exclude group: 'com.mapbox.mapboxsdk'
}
}
```
**Note:** Since CedarMaps uses a forked version of Mapbox SDK, make sure to exclude `group: 'com.mapbox.mapboxsdk'` when adding a new plugin.
### APK Size ### APK Size
......
...@@ -6,7 +6,7 @@ buildscript { ...@@ -6,7 +6,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.2.0' classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
...@@ -18,9 +18,9 @@ allprojects { ...@@ -18,9 +18,9 @@ allprojects {
repositories { repositories {
jcenter() jcenter()
mavenCentral() mavenCentral()
google()
maven { maven {
url "https://repo.cedarmaps.com/android/" url "https://repo.cedarmaps.com/android/"
} }
google()
} }
} }
GROUP=com.cedarmaps GROUP=com.cedarmaps
VERSION_NAME=3.1.0 VERSION_NAME=3.2.0
# Project-wide Gradle settings. # Project-wide Gradle settings.
......
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