Skip to content

Commit

Permalink
NAVAND-1298: add route notifications example
Browse files Browse the repository at this point in the history
  • Loading branch information
dzinad committed Apr 13, 2023
1 parent 9ec3d7a commit 14a79a2
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ android {

dependencies {
// Mapbox Navigation SDK
implementation "com.mapbox.navigation:android:2.10.1"
implementation "com.mapbox.navigation:ui-dropin:2.10.1"
implementation "com.mapbox.navigation:android:2.13.0-notifications"
implementation "com.mapbox.navigation:ui-dropin:2.13.0-notifications"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.21"
implementation "androidx.core:core-ktx:1.9.0"
implementation "com.google.android.material:material:1.7.0"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
android:exported="false"
/>

<activity android:name=".standalone.notifications.RouteNotificationsActivity"
android:exported="false"
/>

<activity
android:name=".dropinui.basic.NavigationViewActivity"
android:exported="true"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.mapbox.navigation.examples.standalone.fetchroute.FetchARouteActivity
import com.mapbox.navigation.examples.standalone.junctions.ShowJunctionsActivity
import com.mapbox.navigation.examples.standalone.location.ShowCurrentLocationActivity
import com.mapbox.navigation.examples.standalone.maneuvers.ShowManeuversActivity
import com.mapbox.navigation.examples.standalone.notifications.RouteNotificationsActivity
import com.mapbox.navigation.examples.standalone.preview.PreviewActivity
import com.mapbox.navigation.examples.standalone.replay.ReplayHistoryActivity
import com.mapbox.navigation.examples.standalone.routeline.RenderRouteLineActivity
Expand Down Expand Up @@ -56,7 +57,7 @@ fun Context.examplesList() = listOf(
ShowTripProgressActivity::class.java
),
MapboxExample(
ContextCompat.getDrawable(this, R.drawable.mapbox_screenshot_maneuvers),
ContextCompat.getDrawable(this, R.drawable.mapbox_screenshot_notifications),
getString(R.string.title_maneuver),
getString(R.string.description_maneuver),
ShowManeuversActivity::class.java
Expand Down Expand Up @@ -139,4 +140,10 @@ fun Context.examplesList() = listOf(
getString(R.string.description_replay),
ReplayHistoryActivity::class.java
),
MapboxExample(
ContextCompat.getDrawable(this, R.drawable.mapbox_screenshot_notifications), // TODO change screenshot
getString(R.string.title_notifications),
getString(R.string.description_notifications),
RouteNotificationsActivity::class.java
),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<com.mapbox.maps.MapView
android:id="@+id/mapView"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

<androidx.appcompat.widget.AppCompatButton
android:id="@+id/actionButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="12dp"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
android:textAllCaps="false"
android:visibility="gone"
android:background="@drawable/mapbox_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="notification_offset">16dp</dimen>
</resources>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="80dp"
android:height="80dp"
android:viewportWidth="80"
android:viewportHeight="80">
<path
android:fillColor="#FFFEFE"
android:pathData="M40.0007,40.0007m-33.8131,0a33.8131,33.8131 45,1 1,67.6263 0a33.8131,33.8131 135,1 1,-67.6263 0" />
<path
android:fillColor="#CE0000"
android:pathData="M40.2383,3.0119C57.1535,3.1734 73.0952,16.1597 76.3262,33.0046C80.3508,53.9894 63.2118,76.8418 40.2383,76.9883C22.6321,77.099 5.9891,63.0422 3.4041,45.3968C0.4868,25.4905 16.2105,4.5818 37.3937,3.1019C38.3408,3.0361 39.2901,3.0096 40.2383,3.0119ZM39.8023,9.3643C25.8447,9.497 12.7937,20.1186 9.9861,33.827C6.0503,53.0377 24.0948,74.251 45.7994,70.0879C58.2932,67.6921 68.6772,56.7221 70.3659,44.0945C72.6395,27.0789 58.442,9.5373 40.1979,9.3643C40.0664,9.3632 39.9338,9.3632 39.8023,9.3643Z" />
</vector>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/icon"
android:layout_width="32dp"
android:layout_height="32dp"
android:contentDescription="@null"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="4dp"
android:paddingEnd="4dp"
android:textColor="@android:color/black"
app:layout_constraintStart_toEndOf="@id/icon"
app:layout_constraintTop_toTopOf="@id/icon" />

</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<resources>

<string name="title_notifications">Display route notifications</string>
<string name="description_notifications">Handle route notifications using the Route Notifications API.</string>

</resources>
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ buildscript {

allprojects {
repositories {
mavenLocal()
google()
mavenCentral()
gradlePluginPortal()
Expand Down

0 comments on commit 14a79a2

Please sign in to comment.