Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions platform/android/MapboxGLAndroidSDK/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ dependencies {
implementation dependenciesList.mapboxJavaTurf
implementation dependenciesList.supportAnnotations
implementation dependenciesList.supportFragmentV4
implementation dependenciesList.timber
implementation dependenciesList.okhttp3
testImplementation dependenciesList.junit
testImplementation dependenciesList.mockito
Expand Down Expand Up @@ -160,4 +159,4 @@ apply from: "${rootDir}/gradle/gradle-javadoc.gradle"
apply from: "${rootDir}/gradle/gradle-publish.gradle"
apply from: "${rootDir}/gradle/gradle-checkstyle.gradle"
apply from: "${rootDir}/gradle/gradle-tests-staticblockremover.gradle"
apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle"
apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mapbox.mapboxsdk;

import timber.log.Timber;
import com.mapbox.mapboxsdk.log.Logger;

/**
* Loads the mapbox-gl shared library
Expand All @@ -11,6 +11,8 @@
*/
public abstract class LibraryLoader {

private static final String TAG = "Mbgl-LibraryLoader";

private static final LibraryLoader DEFAULT = new LibraryLoader() {
@Override
public void load(String name) {
Expand Down Expand Up @@ -39,7 +41,7 @@ public static void load() {
try {
loader.load("mapbox-gl");
} catch (UnsatisfiedLinkError error) {
Timber.e(error, "Failed to load native shared library.");
Logger.e(TAG, "Failed to load native shared library.", error);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
import android.support.annotation.UiThread;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
import com.mapbox.mapboxsdk.maps.Telemetry;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.mapboxsdk.utils.ThreadUtils;

import timber.log.Timber;

/**
* The entry point to initialize the Mapbox Android SDK.
* <p>
Expand All @@ -25,13 +24,18 @@
* </p>
*/
@UiThread
@SuppressLint("StaticFieldLeak")
public final class Mapbox {

@SuppressLint("StaticFieldLeak")
private static final String TAG = "Mbgl-Mapbox";

private static ModuleProvider moduleProvider;
private static Mapbox INSTANCE;

private Context context;
private String accessToken;
private Boolean connected;
private TelemetryDefinition telemetry;

/**
* Get an instance of Mapbox.
Expand Down Expand Up @@ -121,10 +125,33 @@ public static synchronized Boolean isConnected() {
*/
private static void initializeTelemetry() {
try {
Telemetry.initialize();
INSTANCE.telemetry = getModuleProvider().obtainTelemetry();
} catch (Exception exception) {
Timber.e(exception);
Logger.e(TAG, "Error occured while initializing telemetry", exception);
}
}

/**
* Get an instance of Telemetry if initialised
*
* @return instance of telemetry
*/
@Nullable
public static TelemetryDefinition getTelemetry() {
return INSTANCE.telemetry;
}

/**
* Get the module provider
*
* @return moduleProvider
*/
@NonNull
public static ModuleProvider getModuleProvider() {
if (moduleProvider == null) {
moduleProvider = new ModuleProviderImpl();
}
return moduleProvider;
}

/**
Expand All @@ -150,4 +177,4 @@ static boolean isAccessTokenValid(String accessToken) {
accessToken = accessToken.trim().toLowerCase(MapboxConstants.MAPBOX_LOCALE);
return accessToken.length() != 0 && (accessToken.startsWith("pk.") || accessToken.startsWith("sk."));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.mapbox.mapboxsdk;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.http.HttpRequest;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;

/**
* Injects concrete instances of configurable abstractions
*/
public interface ModuleProvider {

/**
* Create a new concrete implementation of HttpRequest.
*
* @return a new instance of an HttpRequest
*/
@NonNull
HttpRequest createHttpRequest();

/**
* Get the concrete implementation of TelemetryDefinition
*
* @return a single instance of Telemetry
*/
@Nullable
TelemetryDefinition obtainTelemetry();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.mapbox.mapboxsdk;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import com.mapbox.mapboxsdk.http.HttpRequest;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;
import com.mapbox.mapboxsdk.module.http.HttpRequestImpl;
import com.mapbox.mapboxsdk.module.telemetry.TelemetryImpl;

public class ModuleProviderImpl implements ModuleProvider {

@Override
@NonNull
public HttpRequest createHttpRequest() {
return new HttpRequestImpl();
}

@Override
@Nullable
public TelemetryDefinition obtainTelemetry() {
// TODO remove singleton with next major release,
// this is needed to make static methods on TelemetryImpl
// backwards compatible without breaking semver
return TelemetryImpl.getInstance();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mapbox.mapboxsdk.constants;

public class TelemetryConstants {

public static final String TWO_FINGER_TAP = "TwoFingerTap";
public static final String DOUBLE_TAP = "DoubleTap";
public static final String SINGLE_TAP = "SingleTap";
public static final String PAN = "Pan";
public static final String PINCH = "Pinch";
public static final String ROTATION = "Rotation";
public static final String PITCH = "Pitch";

}
Loading