Skip to content

Commit

Permalink
Merge branch 'master' into mapbox_navigation_android_rx
Browse files Browse the repository at this point in the history
* master:
  Update Strings with Transifex Translations (mapbox#657)
  Added embedded navigation example (mapbox#654)
  Release 0.9.0 (mapbox#663)
  Update README.md for 0.9.0 (mapbox#664)
  Add Maneuver type exit rotary constant (mapbox#653)
  Update Maps and Services dependencies  (mapbox#661)
  Add FasterRouteDetector to check for quicker routes while navigating  (mapbox#638)
  Directions API Banner instructions (mapbox#582)
  NavigationTelemetry update cue for changing configurations (mapbox#648)
  Moved WaypointNavigationActivity from the SDK to the test app (mapbox#652)
  Exposes the MapboxMap in NavigationView with a getter method (mapbox#642)
  Add language to NavigationViewOptions with default from RouteOptions (mapbox#635)

# Conflicts:
#	libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationEngine.java
#	libandroid-navigation/src/main/java/com/mapbox/services/android/navigation/v5/navigation/NavigationService.java
  • Loading branch information
Tran Thuong Tien committed Jan 26, 2018
2 parents 193656d + d058f7c commit 5d92047
Show file tree
Hide file tree
Showing 87 changed files with 2,503 additions and 518 deletions.
12 changes: 10 additions & 2 deletions .tx/config
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
[main]
host = https://www.transifex.com
minimum_perc = 80
minimum_perc = 20
lang_map = pt_BR: pt-rBR

[mapbox-navigation-sdk-for-android.stringsxml]
[mapbox-navigation-sdk-for-android.libandroid-navigation-strings-file]
file_filter = libandroid-navigation/src/main/res/values-<lang>/strings.xml
source_file = libandroid-navigation/src/main/res/values/strings.xml
source_lang = en
type = ANDROID

[mapbox-navigation-sdk-for-android.libandroid-navigation-ui-strings-file]
file_filter = libandroid-navigation-ui/src/main/res/values-<lang>/strings.xml
source_file = libandroid-navigation-ui/src/main/res/values/strings.xml
source_lang = en
type = ANDROID

25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

Mapbox welcomes participation and contributions from everyone.

### v0.9.0 - January 23, 2018

* Update Maps and Services dependencies [#661](https://github.com/mapbox/mapbox-navigation-android/pull/661)
* Add Maneuver type exit rotary constant [#653](https://github.com/mapbox/mapbox-navigation-android/pull/653)
* Moved WaypointNavigationActivity from the SDK to the test app [#652](https://github.com/mapbox/mapbox-navigation-android/pull/652)
* NavigationTelemetry update cue for changing configurations [#648](https://github.com/mapbox/mapbox-navigation-android/pull/648)
* Remove duplicate ViewModel updates [#647](https://github.com/mapbox/mapbox-navigation-android/pull/647)
* Track initialization of NavigationView [#646](https://github.com/mapbox/mapbox-navigation-android/pull/646)
* Update Maps SDK to 5.3.1 [#645](https://github.com/mapbox/mapbox-navigation-android/pull/645)
* Check for null directions route or geometry in SessionState [#643](https://github.com/mapbox/mapbox-navigation-android/pull/643)
* Remove NavigationViewModel as lifecycle observer [#643](https://github.com/mapbox/mapbox-navigation-android/pull/643)
* Exposes the MapboxMap in NavigationView with a getter method [#642](https://github.com/mapbox/mapbox-navigation-android/pull/642)
* Package delivery/ride sharing waypoint demo [#641](https://github.com/mapbox/mapbox-navigation-android/pull/641)
* Removed boolean that was preventing subsequent navigation sessions [#640](https://github.com/mapbox/mapbox-navigation-android/pull/640)
* Add FasterRouteDetector to check for quicker routes while navigating [#638](https://github.com/mapbox/mapbox-navigation-android/pull/638)
* Notification check for valid BannerInstructions before updating [#637](https://github.com/mapbox/mapbox-navigation-android/pull/637)
* Check for at least two coordinates when creating snapped location [#636](https://github.com/mapbox/mapbox-navigation-android/pull/636)
* Add language to NavigationViewOptions with default from RouteOptions [#635](https://github.com/mapbox/mapbox-navigation-android/pull/635)
* Add onDestroy as a method that must be implemented for NavigationView [#632](https://github.com/mapbox/mapbox-navigation-android/pull/632)
* Check for network connection before setting off-route [#631](https://github.com/mapbox/mapbox-navigation-android/pull/631)
* Add NavigationView style attribute for custom LocationLayer [#627](https://github.com/mapbox/mapbox-navigation-android/pull/627)
* Replace setOnScroll (now deprecated) with addOnScroll [#626](https://github.com/mapbox/mapbox-navigation-android/pull/626)
* Check for IndexOutOfBounds when calculating foreground percentage [#625](https://github.com/mapbox/mapbox-navigation-android/pull/625)
* Fix for listener bug [#620](https://github.com/mapbox/mapbox-navigation-android/pull/620)

### v0.8.0 - December 20, 2017

* Update Maps SDK to 5.3.0 [#617](https://github.com/mapbox/mapbox-navigation-android/pull/617)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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.8.0'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.9.0'
```

Expand All @@ -53,7 +53,7 @@ repositories {
}
dependencies {
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.8.1-SNAPSHOT'
compile 'com.mapbox.mapboxsdk:mapbox-android-navigation:0.9.1-SNAPSHOT'
}
```

Expand Down
10 changes: 9 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@
</activity>

<activity
android:name="com.mapbox.services.android.navigation.ui.v5.WaypointNavigationActivity"
android:name=".activity.WaypointNavigationActivity"
android:label="@string/title_waypoint_navigation">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>

<activity
android:name=".EmbeddedNavigationActivity"
android:label="@string/title_embedded_navigation">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
package com.mapbox.services.android.navigation.testapp;

import android.location.Location;
import android.os.Bundle;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.CoordinatorLayout;
import android.support.v7.app.AppCompatActivity;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.AbsoluteSizeSpan;
import android.view.View;
import android.widget.TextView;

import com.mapbox.geojson.Point;
import com.mapbox.services.android.navigation.ui.v5.NavigationView;
import com.mapbox.services.android.navigation.ui.v5.NavigationViewOptions;
import com.mapbox.services.android.navigation.ui.v5.OnNavigationReadyCallback;
import com.mapbox.services.android.navigation.ui.v5.listeners.NavigationListener;
import com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener;
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress;

public class EmbeddedNavigationActivity extends AppCompatActivity implements OnNavigationReadyCallback,
NavigationListener, ProgressChangeListener {

private NavigationView navigationView;
private View spacer;
private TextView speedWidget;
private Point origin = Point.fromLngLat(-77.03194990754128, 38.909664963450105);
private Point destination = Point.fromLngLat(-77.0270025730133, 38.91057077063121);
private boolean bottomSheetVisible = true;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
setTheme(R.style.Theme_AppCompat_Light_NoActionBar);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_embedded_navigation);
navigationView = findViewById(R.id.navigationView);
navigationView.onCreate(savedInstanceState);

speedWidget = findViewById(R.id.speed_limit);
spacer = findViewById(R.id.spacer);
setSpeedWidgetAnchor(R.id.summaryBottomSheet);

navigationView.getNavigationAsync(this);
}

/**
* Sets the anchor of the spacer for the speed widget, thus setting the anchor for the speed widget
* (The speed widget is anchored to the spacer, which is there because padding between items and
* their anchors in CoordinatorLayouts is finicky.
* @param res resource for view of which to anchor the spacer
*/
private void setSpeedWidgetAnchor(@IdRes int res) {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) spacer.getLayoutParams();
layoutParams.setAnchorId(res);
spacer.setLayoutParams(layoutParams);
}

@Override
public void onNavigationReady() {
NavigationViewOptions.Builder options = NavigationViewOptions.builder();
options.navigationListener(this);
options.origin(origin);
options.destination(destination);
options.shouldSimulateRoute(true);
options.progressChangeListener(this);
setBottomSheetCallback(options);

navigationView.startNavigation(options.build());
}

private void setBottomSheetCallback(NavigationViewOptions.Builder options) {
options.bottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch (newState) {
case BottomSheetBehavior.STATE_HIDDEN:
bottomSheetVisible = false;
setSpeedWidgetAnchor(R.id.recenterBtn);
break;
case BottomSheetBehavior.STATE_EXPANDED:
bottomSheetVisible = true;
break;
case BottomSheetBehavior.STATE_SETTLING:
if (!bottomSheetVisible) {
// View needs to be anchored to the bottom sheet before it is finished expanding
// because of the animation
setSpeedWidgetAnchor(R.id.summaryBottomSheet);
}
break;
default:
return;
}
}

@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
}

@Override
public void onLowMemory() {
super.onLowMemory();
navigationView.onLowMemory();
}

@Override
public void onBackPressed() {
// If the navigation view didn't need to do anything, call super
if (!navigationView.onBackPressed()) {
super.onBackPressed();
}
}

@Override
protected void onDestroy() {
super.onDestroy();
navigationView.onDestroy();
}

@Override
protected void onSaveInstanceState(Bundle outState) {
navigationView.onSaveInstanceState(outState);
super.onSaveInstanceState(outState);
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
navigationView.onRestoreInstanceState(savedInstanceState);
}

@Override
public void onCancelNavigation() {
// Navigation canceled, finish the activity
finish();
}

@Override
public void onNavigationFinished() {
// Intentionally empty
}

@Override
public void onNavigationRunning() {
// Intentionally empty
}

@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
setSpeed(location);
}

private void setSpeed(Location location) {
String string = String.format("%d\nMPH", (int) (location.getSpeed() * 2.2369));
int mphTextSize = getResources().getDimensionPixelSize(R.dimen.mph_text_size);
int speedTextSize = getResources().getDimensionPixelSize(R.dimen.speed_text_size);

SpannableString spannableString = new SpannableString(string);
spannableString.setSpan(new AbsoluteSizeSpan(mphTextSize),
string.length() - 4, string.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

spannableString.setSpan(new AbsoluteSizeSpan(speedTextSize),
0, string.length() - 3, Spanned.SPAN_INCLUSIVE_INCLUSIVE);

speedWidget.setText(spannableString);
speedWidget.setVisibility(View.VISIBLE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.mapbox.services.android.navigation.testapp.activity.RerouteActivity;
import com.mapbox.services.android.navigation.testapp.activity.navigationui.NavigationMapRouteActivity;
import com.mapbox.services.android.navigation.testapp.activity.navigationui.NavigationViewActivity;
import com.mapbox.services.android.navigation.ui.v5.WaypointNavigationActivity;
import com.mapbox.services.android.navigation.testapp.activity.WaypointNavigationActivity;
import com.mapbox.services.android.telemetry.permissions.PermissionsListener;
import com.mapbox.services.android.telemetry.permissions.PermissionsManager;

Expand Down Expand Up @@ -63,6 +63,11 @@ protected void onCreate(Bundle savedInstanceState) {
getString(R.string.title_waypoint_navigation),
getString(R.string.description_waypoint_navigation),
WaypointNavigationActivity.class
),
new SampleItem(
getString(R.string.title_embedded_navigation),
getString(R.string.description_embedded_navigation),
EmbeddedNavigationActivity.class
)
));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public class MockNavigationActivity extends AppCompatActivity implements OnMapRe
Button startRouteButton;

private MapboxMap mapboxMap;
private boolean running;

// Navigation related variables
private LocationEngine locationEngine;
Expand Down Expand Up @@ -234,7 +233,6 @@ public void onMilestoneEvent(RouteProgress routeProgress, String instruction, Mi

@Override
public void onRunning(boolean running) {
this.running = running;
if (running) {
Timber.d("onRunning: Started");
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mapbox.services.android.navigation.ui.v5;
package com.mapbox.services.android.navigation.testapp.activity;

import android.content.DialogInterface;
import android.location.Location;
Expand All @@ -8,6 +8,10 @@
import android.support.v7.app.AppCompatActivity;

import com.mapbox.geojson.Point;
import com.mapbox.services.android.navigation.testapp.R;
import com.mapbox.services.android.navigation.ui.v5.NavigationView;
import com.mapbox.services.android.navigation.ui.v5.NavigationViewOptions;
import com.mapbox.services.android.navigation.ui.v5.OnNavigationReadyCallback;
import com.mapbox.services.android.navigation.ui.v5.listeners.NavigationListener;
import com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener;
import com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress;
Expand Down
35 changes: 35 additions & 0 deletions app/src/main/res/layout/activity_embedded_navigation.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com.mapbox.services.android.navigation.ui.v5.NavigationView
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:navigationLightTheme="@style/NavigationViewLight"
app:navigationDarkTheme="@style/NavigationViewDark"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/speed_limit"
android:textSize="35sp"
android:padding="6dp"
app:layout_anchorGravity="top"
android:layout_gravity="top"
android:gravity="center"
android:layout_marginLeft="16dp"
android:elevation="3dp"
app:layout_anchor="@id/spacer"
android:textColor="@android:color/black"
android:background="@android:color/white"
android:visibility="gone"/>
<View
android:layout_width="wrap_content"
android:layout_height="6dp"
android:id="@+id/spacer"
android:background="@android:color/transparent"
app:layout_anchorGravity="top"
android:layout_gravity="top"/>
</android.support.design.widget.CoordinatorLayout>
Loading

0 comments on commit 5d92047

Please sign in to comment.