Search in sources :

Example 1 with MapboxNavigationOptions

use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions in project mapbox-navigation-android by mapbox.

the class MapboxNavigationTest method removeMilestone_correctMilestoneWithIdentifierGetsRemoved.

@Test
public void removeMilestone_correctMilestoneWithIdentifierGetsRemoved() throws Exception {
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
    MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
    Milestone milestone = new StepMilestone.Builder().setIdentifier(5678).build();
    navigationWithOptions.addMilestone(milestone);
    assertEquals(1, navigationWithOptions.getMilestones().size());
    navigationWithOptions.removeMilestone(5678);
    assertEquals(0, navigationWithOptions.getMilestones().size());
}
Also used : Context(android.content.Context) LocationEngine(com.mapbox.services.android.telemetry.location.LocationEngine) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Milestone(com.mapbox.services.android.navigation.v5.milestone.Milestone) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 2 with MapboxNavigationOptions

use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions in project mapbox-navigation-android by mapbox.

the class NavigationService method initializeNotification.

/**
 * Builds a new navigation notification instance (either custom or our default implementation)
 * and attaches it to this service.
 */
private void initializeNotification(MapboxNavigationOptions options) {
    if (options.navigationNotification() != null) {
        navigationNotification = options.navigationNotification();
        Notification notification = navigationNotification.getNotification();
        int notificationId = navigationNotification.getNotificationId();
        startForegroundNotification(notification, notificationId);
    } else {
        navigationNotification = new MapboxNavigationNotification(this, mapboxNavigation);
        Notification notification = navigationNotification.getNotification();
        int notificationId = navigationNotification.getNotificationId();
        startForegroundNotification(notification, notificationId);
    }
}
Also used : NavigationNotification(com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification) Notification(android.app.Notification)

Example 3 with MapboxNavigationOptions

use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions in project mapbox-navigation-android by mapbox.

the class MockNavigationActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mock_navigation);
    ButterKnife.bind(this);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
    // Use a custom notification
    CustomNavigationNotification customNavigationNotification = new CustomNavigationNotification(this);
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().navigationNotification(customNavigationNotification).build();
    navigation = new MapboxNavigation(this, Mapbox.getAccessToken(), options);
    navigation.addMilestone(new RouteMilestone.Builder().setIdentifier(BEGIN_ROUTE_MILESTONE).setInstruction(new BeginRouteInstruction()).setTrigger(Trigger.all(Trigger.lt(TriggerProperty.STEP_INDEX, 3), Trigger.gt(TriggerProperty.STEP_DISTANCE_TOTAL_METERS, 200), Trigger.gte(TriggerProperty.STEP_DISTANCE_TRAVELED_METERS, 75))).build());
}
Also used : CustomNavigationNotification(com.mapbox.services.android.navigation.testapp.activity.notification.CustomNavigationNotification) MapboxNavigationOptions(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation) RouteMilestone(com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)

Example 4 with MapboxNavigationOptions

use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions in project mapbox-navigation-android by mapbox.

the class RerouteActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_reroute);
    ButterKnife.bind(this);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
    // Initialize MapboxNavigation and add listeners
    MapboxNavigationOptions options = MapboxNavigationOptions.builder().isDebugLoggingEnabled(true).build();
    navigation = new MapboxNavigation(getApplicationContext(), Mapbox.getAccessToken(), options);
    navigation.addNavigationEventListener(this);
    navigation.addMilestoneEventListener(this);
}
Also used : MapboxNavigationOptions(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions) MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)

Example 5 with MapboxNavigationOptions

use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions in project mapbox-navigation-android by mapbox.

the class RouteViewModel method extractUnitType.

/**
 * Updates the request unit type based on what was set in
 * {@link NavigationViewOptions}. Must be called after extractLocale.
 *
 * @param options possibly containing unitType
 */
private void extractUnitType(NavigationViewOptions options) {
    MapboxNavigationOptions navigationOptions = options.navigationOptions();
    unitType = NavigationUnitType.getDirectionsCriteriaUnitType(navigationOptions.unitType(), locale);
}
Also used : MapboxNavigationOptions(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions)

Aggregations

Context (android.content.Context)5 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)5 Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)5 StepMilestone (com.mapbox.services.android.navigation.v5.milestone.StepMilestone)5 LocationEngine (com.mapbox.services.android.telemetry.location.LocationEngine)5 Test (org.junit.Test)5 MapboxNavigation (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)3 MapboxNavigationOptions (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions)3 Notification (android.app.Notification)1 Location (android.location.Location)1 GsonBuilder (com.google.gson.GsonBuilder)1 CustomNavigationNotification (com.mapbox.services.android.navigation.testapp.activity.notification.CustomNavigationNotification)1 LocationValidator (com.mapbox.services.android.navigation.v5.location.LocationValidator)1 RouteMilestone (com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)1 NavigationNotification (com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification)1 OffRoute (com.mapbox.services.android.navigation.v5.offroute.OffRoute)1 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)1