Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - expose enableOnUserRequest and disableOnUserRequest on Te…
Browse files Browse the repository at this point in the history
…lemetry
  • Loading branch information
tobrun committed May 30, 2018
1 parent 7193a43 commit 4894093
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
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;
Expand Down Expand Up @@ -99,8 +97,7 @@ private void showTelemetryDialog() {
builder.setPositiveButton(R.string.mapbox_attributionTelemetryPositive, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.ENABLED);
Telemetry.obtainTelemetry().enable();
Telemetry.enableOnUserRequest();
dialog.cancel();
}
});
Expand All @@ -114,8 +111,7 @@ public void onClick(DialogInterface dialog, int which) {
builder.setNegativeButton(R.string.mapbox_attributionTelemetryNegative, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Telemetry.obtainTelemetry().disable();
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.DISABLED);
Telemetry.disableOnUserRequest();
dialog.cancel();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,41 @@ public static void initialize() {
obtainTelemetry();
}

/**
* Set the debug logging state of telemetry.
*
* @param debugLoggingEnabled true to enable logging
*/
public static void updateDebugLoggingEnabled(boolean debugLoggingEnabled) {
TelemetryHolder.INSTANCE.telemetry.updateDebugLoggingEnabled(debugLoggingEnabled);
}

/**
* Update the telemetry rotation session id interval
*
* @param interval the selected session interval
* @return true if rotation session id was updated
*/
public static boolean updateSessionIdRotationInterval(SessionInterval interval) {
return TelemetryHolder.INSTANCE.telemetry.updateSessionIdRotationInterval(interval);
}

/**
* Method to be called when an end-user has selected to participate in telemetry collection.
*/
public static void enableOnUserRequest() {
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.ENABLED);
TelemetryHolder.INSTANCE.telemetry.enable();
}

/**
* Method to be called when an end-user has selected to opt-out of telemetry collection.
*/
public static void disableOnUserRequest() {
Telemetry.obtainTelemetry().disable();
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.DISABLED);
}

private static class TelemetryHolder {
private static final Telemetry INSTANCE = new Telemetry();
}
Expand Down

0 comments on commit 4894093

Please sign in to comment.