Skip to content

Commit

Permalink
Merge branch 'master' into grs-fix-offroute-false-positive
Browse files Browse the repository at this point in the history
* master:
  Resolves several code issues (mapbox#287)
  removed OSRM-Text-Instructions (mapbox#288)
  readme bump to 0.6.1 (mapbox#282)
  0.6.1 Release (mapbox#283)
  fix navigation events so that use the correct sdk identifier depending on where they come from (navigation or navigation-ui) (mapbox#277)
  • Loading branch information
Adrien Grsmto committed Oct 2, 2017
2 parents 7eb288d + b95ecb7 commit c7014a5
Show file tree
Hide file tree
Showing 338 changed files with 155 additions and 7,550 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

Mapbox welcomes participation and contributions from everyone.

### v0.6.1 - September 28, 2017
* Telemetry Updates

### v0.6.0 - September 21, 2017
* First iteration of the Navigation UI
* Optimized Navigation features which were causing slowdowns on long steps - [219](https://github.com/mapbox/mapbox-navigation-android/pull/219)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The snippet to add to your `build.gradle` file to use this SDK is the following:
```
// Mapbox Navigation SDK for Android
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.6.1'
```

Expand Down
2 changes: 1 addition & 1 deletion navigation/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ext {
dep = [
// mapbox
mapboxMapSdk : 'com.mapbox.mapboxsdk:mapbox-android-sdk:5.1.3',
mapboxServices : 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.4',
mapboxServices : 'com.mapbox.mapboxsdk:mapbox-android-services:2.2.5',
locationLayerPlugin : 'com.mapbox.mapboxsdk:mapbox-android-plugin-locationlayer:0.1.0',

// unit test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
import com.mapbox.services.android.navigation.ui.v5.voice.NavigationInstructionPlayer;
import com.mapbox.services.android.navigation.v5.milestone.MilestoneEventListener;
import com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation;
import com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions;
import com.mapbox.services.android.navigation.v5.navigation.NavigationConstants;
import com.mapbox.services.android.navigation.v5.navigation.NavigationRoute;
import com.mapbox.services.android.navigation.v5.offroute.OffRouteListener;
import com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener;
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress;
import com.mapbox.services.android.telemetry.MapboxTelemetry;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEngineListener;
import com.mapbox.services.api.directions.v5.models.DirectionsResponse;
Expand Down Expand Up @@ -424,8 +424,8 @@ public void onSlide(@NonNull View bottomSheet, float slideOffset) {
* Initializes {@link MapboxNavigation} and adds all views that implement listeners.
*/
private void initNavigation() {
navigation = new MapboxNavigation(this, Mapbox.getAccessToken());
MapboxTelemetry.getInstance().newUserAgent(BuildConfig.MAPBOX_NAVIGATION_EVENTS_USER_AGENT);
navigation = new MapboxNavigation(this, Mapbox.getAccessToken(),
MapboxNavigationOptions.builder().isFromNavigationUi(true).build());
navigation.addProgressChangeListener(this);
navigation.addProgressChangeListener(instructionView);
navigation.addProgressChangeListener(summaryBottomSheet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public Milestone(Builder builder) {
}

/**
* Milestone specific identifier as an {@code int} value, useful for deciphering which milestone invoked
* {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}.
* Milestone specific identifier as an {@code int} value, useful for deciphering which milestone
* invoked {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}.
*
* @return {@code int} representing the identifier
* @since 0.4.0
Expand All @@ -31,7 +31,7 @@ public int getIdentifier() {

/**
* Milestone specific {@link Instruction}, which can be used to build a {@link String}
* instruction specified by the superclass
* instruction specified by the superclass.
*
* @return {@link Instruction} to be used to build the {@link String} passed to
* {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}
Expand All @@ -46,13 +46,14 @@ public Instruction getInstruction() {
* {@link com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation} object
* (recommended) or validated directly inside your activity.
*
* @param previousRouteProgress last locations generated {@link RouteProgress} object used to determine certain
* {@link TriggerProperty}s
* @param previousRouteProgress last locations generated {@link RouteProgress} object used to
* determine certain {@link TriggerProperty}s
* @param routeProgress used to determine certain {@link TriggerProperty}s
* @return true if the milestone trigger's valid, else false
* @since 0.4.0
*/
public abstract boolean isOccurring(RouteProgress previousRouteProgress, RouteProgress routeProgress);
public abstract boolean isOccurring(RouteProgress previousRouteProgress,
RouteProgress routeProgress);

/**
* Build a new {@link Milestone}
Expand All @@ -68,8 +69,8 @@ public Builder() {
}

/**
* Milestone specific identifier as an {@code int} value, useful for deciphering which milestone invoked
* {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}.
* Milestone specific identifier as an {@code int} value, useful for deciphering which milestone
* invoked {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}.
*
* @return {@code int} representing the identifier
* @since 0.4.0
Expand All @@ -79,8 +80,8 @@ public int getIdentifier() {
}

/**
* Milestone specific identifier as an {@code int} value, useful for deciphering which milestone invoked
* {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}.
* Milestone specific identifier as an {@code int} value, useful for deciphering which milestone
* invoked {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}.
*
* @param identifier an {@code int} used to identify this milestone instance
* @return this builder
Expand Down Expand Up @@ -126,7 +127,6 @@ public Builder setInstruction(Instruction instruction) {
* @throws NavigationException if an invalid value has been set on the milestone
* @since 0.4.0
*/
public abstract Milestone build() throws NavigationException;
public abstract Milestone build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@
*/
class Operation {

private Operation() {
// Private constructor to prevent initialization of class.
}

static boolean greaterThan(Number[] valueOne, Number valueTwo) {
if (valueOne.length > 1) {
if (valueTwo.equals(TriggerProperty.TRUE)) {
return valueOne[0].doubleValue() > valueOne[1].doubleValue();
} else {
return !(valueOne[0].doubleValue() > valueOne[1].doubleValue());
return valueOne[0].doubleValue() <= valueOne[1].doubleValue();
}
}
return valueOne[0].doubleValue() > valueTwo.doubleValue();
Expand All @@ -23,7 +27,7 @@ static boolean lessThan(Number[] valueOne, Number valueTwo) {
if (valueTwo.equals(TriggerProperty.TRUE)) {
return valueOne[0].doubleValue() < valueOne[1].doubleValue();
} else {
return !(valueOne[0].doubleValue() < valueOne[1].doubleValue());
return valueOne[0].doubleValue() >= valueOne[1].doubleValue();
}
}
return valueOne[0].doubleValue() < valueTwo.doubleValue();
Expand Down Expand Up @@ -56,7 +60,7 @@ static boolean greaterThanEqual(Number[] valueOne, Number valueTwo) {
if (valueTwo.equals(TriggerProperty.TRUE)) {
return valueOne[0].doubleValue() >= valueOne[1].doubleValue();
} else {
return !(valueOne[0].doubleValue() >= valueOne[1].doubleValue());
return valueOne[0].doubleValue() < valueOne[1].doubleValue();
}
}
return valueOne[0].doubleValue() >= valueTwo.doubleValue();
Expand All @@ -67,7 +71,7 @@ static boolean lessThanEqual(Number[] valueOne, Number valueTwo) {
if (valueTwo.equals(TriggerProperty.TRUE)) {
return valueOne[0].doubleValue() <= valueOne[1].doubleValue();
} else {
return !(valueOne[0].doubleValue() <= valueOne[1].doubleValue());
return valueOne[0].doubleValue() > valueOne[1].doubleValue();
}
}
return valueOne[0].doubleValue() <= valueTwo.doubleValue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.mapbox.services.android.navigation.v5.milestone;

import com.mapbox.services.android.navigation.v5.exception.NavigationException;
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress;

/**
* Using a Route Milestone will result in {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)}
* being invoked only once during a navigation session.
* Using a Route Milestone will result in
* {@link MilestoneEventListener#onMilestoneEvent(RouteProgress, String, int)} being invoked only
* once during a navigation session.
*
* @since 0.4.0
*/
public class RouteMilestone extends Milestone {


private Builder builder;
private boolean called;

Expand Down Expand Up @@ -56,7 +55,7 @@ Trigger.Statement getTrigger() {
}

@Override
public RouteMilestone build() throws NavigationException {
public RouteMilestone build() {
return new RouteMilestone(this);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
*/
public class Trigger {

private Trigger() {
// Empty private constructor to prevent users creating an instance of this class.
}

/**
* Base Trigger statement. Subclassed to provide concrete statements.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress;
import com.mapbox.services.android.navigation.v5.snap.Snap;
import com.mapbox.services.android.navigation.v5.snap.SnapToRoute;
import com.mapbox.services.android.telemetry.MapboxEvent;
import com.mapbox.services.android.telemetry.MapboxTelemetry;
import com.mapbox.services.android.telemetry.location.LocationEngine;
import com.mapbox.services.android.telemetry.location.LocationEnginePriority;
Expand All @@ -46,7 +47,8 @@
* @since 0.1.0
*/
public class MapboxNavigation implements ServiceConnection, ProgressChangeListener {

private static final String MAPBOX_NAVIGATION_SDK_IDENTIFIER = "mapbox-navigation-android";
private static final String MAPBOX_NAVIGATION_UI_SDK_IDENTIFIER = "mapbox-navigation-ui-android";
private NavigationEventDispatcher navigationEventDispatcher;

private NavigationService navigationService;
Expand All @@ -60,6 +62,7 @@ public class MapboxNavigation implements ServiceConnection, ProgressChangeListen
private Snap snapEngine;
private Context context;
private boolean isBound;
private boolean isFromNavigationUi = false;

/**
* Constructs a new instance of this class using the default options. This should be used over
Expand Down Expand Up @@ -102,6 +105,7 @@ public MapboxNavigation(@NonNull Context context, @NonNull String accessToken,
this.accessToken = accessToken;
this.context = context;
this.options = options;
this.isFromNavigationUi = options.isFromNavigationUi();
initialize();
}

Expand All @@ -111,10 +115,7 @@ public MapboxNavigation(@NonNull Context context, @NonNull String accessToken,
* to prevent users from removing it.
*/
private void initialize() {
validateAccessToken(accessToken);
MapboxTelemetry.getInstance().initialize(context, accessToken,
BuildConfig.MAPBOX_NAVIGATION_EVENTS_USER_AGENT);
NavigationMetricsWrapper.turnstileEvent();
initializeTelemetry();

// Initialize event dispatcher and add internal listeners
navigationEventDispatcher = new NavigationEventDispatcher();
Expand All @@ -138,6 +139,24 @@ private void initialize() {
}
}

private void initializeTelemetry() {
validateAccessToken(accessToken);
String sdkIdentifier = MAPBOX_NAVIGATION_SDK_IDENTIFIER;
if (isFromNavigationUi) {
sdkIdentifier = MAPBOX_NAVIGATION_UI_SDK_IDENTIFIER;
}
String userAgent = String.format("%s/%s", sdkIdentifier, BuildConfig.MAPBOX_NAVIGATION_VERSION_NAME);
MapboxTelemetry.getInstance().initialize(context, accessToken, userAgent, sdkIdentifier,
BuildConfig.MAPBOX_NAVIGATION_VERSION_NAME);
MapboxTelemetry.getInstance().newUserAgent(userAgent);

NavigationMetricsWrapper.sdkIdentifier = sdkIdentifier;
NavigationMetricsWrapper.turnstileEvent();
// TODO This should be removed when we figure out a solution in Telemetry
// Force pushing a TYPE_MAP_LOAD event to ensure that the Nav turnstile event is sent
MapboxTelemetry.getInstance().pushEvent(MapboxEvent.buildMapLoadEvent());
}

/**
* Runtime validation of access token.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.auto.value.AutoValue;

/**
*
* Immutable and can't be changed after passing into {@link MapboxNavigation}.
*/
@AutoValue
Expand Down Expand Up @@ -35,6 +34,8 @@ public abstract class MapboxNavigationOptions {

public abstract double metersRemainingTillArrival();

public abstract boolean isFromNavigationUi();

@AutoValue.Builder
public abstract static class Builder {

Expand All @@ -54,7 +55,7 @@ public abstract static class Builder {

public abstract Builder defaultMilestonesEnabled(boolean defaultMilestonesEnabled);

public abstract Builder snapToRoute(boolean snapToRoute);
public abstract Builder snapToRoute(boolean snapToRoute);

public abstract Builder enableOffRouteDetection(boolean enableOffRouteDetection);

Expand All @@ -64,6 +65,8 @@ public abstract static class Builder {

public abstract Builder metersRemainingTillArrival(double metersRemainingTillArrival);

public abstract Builder isFromNavigationUi(boolean isFromNavigationUi);

public abstract MapboxNavigationOptions build();
}

Expand All @@ -81,6 +84,7 @@ public static Builder builder() {
.manuallyEndNavigationUponCompletion(false)
.defaultMilestonesEnabled(true)
.metersRemainingTillArrival(NavigationConstants.METERS_REMAINING_TILL_ARRIVAL)
.enableNotification(true);
.enableNotification(true)
.isFromNavigationUi(false);
}
}
Loading

0 comments on commit c7014a5

Please sign in to comment.