[android] bump mapbox-android-telemetry version to 3.0.0-beta.2 and adapt events related code

This commit is contained in:
Guardiola31337
2018-03-16 20:55:34 +01:00
committed by Tobrun
parent 2464520da1
commit 7d5304ebc1
6 changed files with 14 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import com.mapbox.android.telemetry.TelemetryUtils;
import com.mapbox.mapboxsdk.BuildConfig;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
@@ -30,7 +31,6 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import okhttp3.internal.Util;
import timber.log.Timber;
import static android.util.Log.DEBUG;
@@ -224,7 +224,7 @@ class HTTPRequest implements Callback {
private String getUserAgent() {
if (userAgentString == null) {
userAgentString = Util.toHumanReadableAscii(
userAgentString = TelemetryUtils.toHumanReadableAscii(
String.format("%s %s (%s) Android/%s (%s)",
getApplicationIdentifier(),
BuildConfig.MAPBOX_VERSION_STRING,

View File

@@ -12,6 +12,7 @@ import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Toast;
import com.mapbox.android.telemetry.TelemetryEnabler;
import com.mapbox.mapboxsdk.R;
import com.mapbox.mapboxsdk.attribution.Attribution;
import com.mapbox.mapboxsdk.attribution.AttributionParser;
@@ -98,6 +99,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt
builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.ENABLED);
Events.obtainTelemetry().enable();
dialog.cancel();
}
@@ -113,6 +115,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt
@Override
public void onClick(DialogInterface dialog, int which) {
Events.obtainTelemetry().disable();
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.DISABLED);
dialog.cancel();
}
});

View File

@@ -20,8 +20,7 @@ public class Events {
telemetry = new MapboxTelemetry(Mapbox.getApplicationContext(), Mapbox.getAccessToken(),
BuildConfig.MAPBOX_EVENTS_USER_AGENT);
TelemetryEnabler.State telemetryState = TelemetryEnabler.retrieveTelemetryStateFromPreferences();
if (TelemetryEnabler.State.NOT_INITIALIZED.equals(telemetryState)
|| TelemetryEnabler.State.ENABLED.equals(telemetryState)) {
if (TelemetryEnabler.State.ENABLED.equals(telemetryState)) {
telemetry.enable();
}
}