Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I've made some enhancements and fixes that might address your concerns #121

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ea62b65
FIX: update mapbox navigation android to 2.17.8
saraf22 Dec 27, 2023
693334f
FIX: updated compile and target sdk versions
saraf22 Dec 27, 2023
6ca38f3
FIX: updated gradlew
saraf22 Dec 27, 2023
7e57549
FIX: compile -> implementation
saraf22 Dec 27, 2023
375e48d
FIX: build gradlew
saraf22 Dec 27, 2023
4a6cb33
FIX: build gradlew file
saraf22 Dec 27, 2023
9ef4010
fix reverted back to old build gradle with nav update
saraf22 Dec 27, 2023
f143d8e
FIX: update build gradle
saraf22 Dec 27, 2023
50f2623
FIX: upgraded gradle build
saraf22 Dec 27, 2023
9852ab3
FIX: build gradlew
saraf22 Jan 5, 2024
f7d5933
fix: update build gradlew
saraf22 Jan 5, 2024
0bae6e1
FIX: build gradle
saraf22 Jan 5, 2024
91cdaf7
Fix: update
saraf22 Jan 5, 2024
1cb1894
fix: add ndk version
saraf22 Jan 5, 2024
d0866f5
FEAT: add waypoints
saraf22 Jan 11, 2024
941d5be
FIX: waypoints type
saraf22 Jan 11, 2024
29b563b
FIX: waypoints typings.d.ts
saraf22 Jan 11, 2024
8051c98
FIX: updated mapbox nav ios
saraf22 Jan 12, 2024
ada8b9b
FIX: ios change minimum deployment target
saraf22 Jan 13, 2024
0171d93
FEAT: allow waypoints in ios
saraf22 Jan 25, 2024
aa3d07f
FEAT: add vehicle maxWeight and vehicle maxWidth in android
saraf22 Jan 29, 2024
96b4e7b
FEAT: vehicle width height options in ios
saraf22 Jan 29, 2024
e8239d7
FIX: vehicle options typo
saraf22 Jan 29, 2024
af494ed
FIX: double type in android
saraf22 Jan 29, 2024
4edc238
FIX: null check waypoints
saraf22 Jan 29, 2024
38eb160
FIX : float to double
saraf22 Jan 29, 2024
cbb524c
FIX: change pro fix android
saraf22 Jan 29, 2024
eea3582
FIX: android layout
saraf22 Feb 12, 2024
ae5c5b2
FIX: android layout
saraf22 Feb 12, 2024
5185688
FEAT: change vehicle height weight type android
saraf22 Feb 12, 2024
6f96245
Update README.md
sarafhbk Feb 13, 2024
bcf6a97
FEAT: update mapbox navigation sdk
saraf22 May 2, 2024
2061c9b
FIX: upgrade java version
saraf22 May 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ Array that contains the longitude and latitude for the starting point.<br>
Array that contains the longitude and latitude for the destination point.<br>
`[$longitude, $latitude]`

#### `waypoints`

Array that contains arrays of longitude and latitude for the waypoints (limit 25 as per the MapBox restrictions).<br>
`[[$longitude, $latitude], [$longitude, $latitude]]`

#### `shouldSimulateRoute`

Boolean that controls route simulation. Set this as `true` to auto navigate which is useful for testing or demo purposes. Defaults to `false`.
Expand All @@ -311,6 +316,18 @@ Boolean that toggles voice instructions. Defaults to `false`.

Boolean that controls showing the `StatusView` (iOS only). This is the transparent black bar with the "Simulating Navigation" text shown in the above screenshot. Defaults to `false`.

#### `vehicleMaxWidth`

Number that sets max width (in meters) of the vehicle. Defaults to `1.6`.

#### `vehicleMaxHeight`

Number that sets max height (in meters) of the vehicle. Defaults to `1.9`.

#### `mute`

Boolean that toggles voice instructions. Defaults to `false`.

#### `onLocationChange`

Function that is called frequently during route navigation. It receives `latitude` and `longitude` as parameters that represent the current location during navigation.
Expand Down
224 changes: 78 additions & 146 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,167 +1,99 @@
// android/build.gradle

// based on:
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
//
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
// original location:
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle

// https://www.cognizantsoftvision.com/blog/creating-an-android-native-module-for-react-native/

def DEFAULT_COMPILE_SDK_VERSION = 31
def DEFAULT_BUILD_TOOLS_VERSION = '30.0.2'
def DEFAULT_MIN_SDK_VERSION = 21
def DEFAULT_TARGET_SDK_VERSION = 31

def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven'

buildscript {
ext.kotlin_version = '1.5.21'
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
if (project == rootProject) {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
}
}
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["MapboxNavigation_kotlinVersion"]

repositories {
mavenCentral()
}
repositories {
google()
mavenCentral()
}

dependencies {
classpath "com.android.tools.build:gradle:7.2.2"
// noinspection DifferentKotlinGradleVersion
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
def isNewArchitectureEnabled() {
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven'
apply plugin: "com.android.library"
apply plugin: "kotlin-android"

android {
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding true
}
}

repositories {
// ref: https://www.baeldung.com/maven-local-repository
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
// Android JSC is installed from npm
url "$rootDir/../node_modules/jsc-android/dist"
}
google()
jcenter()
def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+' // From node_modules
implementation "com.mapbox.navigation:android:2.1.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.cardview:cardview:1.0.0'
def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["MapboxNavigation_" + name]
}

def configureReactNativePom(def pom) {
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)

pom.project {
name packageJson.title
artifactId packageJson.name
version = packageJson.version
group = "com.homee.mapboxnavigation"
description packageJson.description
url packageJson.repository.baseUrl

licenses {
license {
name packageJson.license
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
distribution 'repo'
}
}
}
def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["MapboxNavigation_" + name]).toInteger()
}

afterEvaluate { project ->
// some Gradle build hooks ref:
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
task androidJavadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += files(android.bootClasspath)
classpath += files(project.getConfigurations().getByName('compile').asList())
include '**/*.java'
}
android {
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
from androidJavadoc.destinationDir
defaultConfig {
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
}
buildTypes {
release {
minifyEnabled false
}
}

task androidSourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
include '**/*.java'
}
lintOptions {
disable "GradleCompatible"
}

android.libraryVariants.all { variant ->
def name = variant.name.capitalize()
def javaCompileTask = variant.javaCompileProvider.get()
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}

task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
from javaCompileTask.destinationDir
}
}
// Add the block below if you're using Kotlin
kotlinOptions {
jvmTarget = "17"
}

artifacts {
archives androidSourcesJar
archives androidJavadocJar
}
buildFeatures {
viewBinding true
}

task installArchives(type: Upload) {
configuration = configurations.archives
repositories.mavenDeployer {
// Deploy to react-native-event-bridge/maven, ready to publish to npm
repository url: "file://${projectDir}/../android/maven"
configureReactNativePom pom
}
}
}

repositories {
mavenCentral()
google()
}

def kotlin_version = getExtOrDefault("kotlinVersion")

dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

// mapbox dependencies
implementation "com.mapbox.navigation:android:2.19.0"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.cardview:cardview:1.0.0'
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "MapboxNavigationView"
codegenJavaPackageName = "com.homee.mapboxnavigation"
}
}
4 changes: 4 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MapboxNavigation_kotlinVersion=1.6.0
MapboxNavigation_compileSdkVersion=33
MapboxNavigation_minSdkVersion=21
MapboxNavigation_targetSdkVersion=33
Binary file added android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Mon Feb 12 09:11:13 IST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading