Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ jobs:
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
build-ios:
runs-on: macos-14
runs-on:
labels: macos-latest-xlarge
timeout-minutes: 45
env:
TURBO_CACHE_DIR: .turbo/ios
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Keys.plist
.idea
.project
.settings
.kotlin
local.properties
android.iml

Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
v22
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nodejs 18.20.1
nodejs 22.14.0
426 changes: 213 additions & 213 deletions .yarn/releases/yarn-3.6.1.cjs → .yarn/releases/yarn-3.6.4.cjs

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

nodeLinker: node-modules
nmHoistingLimits: workspaces

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
spec: '@yarnpkg/plugin-interactive-tools'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
spec: '@yarnpkg/plugin-workspace-tools'

yarnPath: .yarn/releases/yarn-3.6.1.cjs
yarnPath: .yarn/releases/yarn-3.6.4.cjs
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This repository contains a React Native plugin that provides a [Google Navigatio

| | Android | iOS |
| ------------------------------- | ------- | --------- |
| **Minimum mobile OS supported** | SDK 23+ | iOS 16.0+ |
| **Minimum mobile OS supported** | SDK 24+ | iOS 16.0+ |

* A React Native project
* A Google Cloud project
Expand Down Expand Up @@ -84,12 +84,12 @@ dependencies {

#### Minimum SDK Requirements for Android

The `minSdkVersion` for your Android project must be set to 23 or higher in `android/app/build.gradle`:
The `minSdkVersion` for your Android project must be set to 24 or higher in `android/app/build.gradle`:

```groovy
android {
defaultConfig {
minSdkVersion 23
minSdkVersion 24
}
}
```
Expand Down
84 changes: 45 additions & 39 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -15,16 +15,16 @@
import groovy.json.JsonSlurper

buildscript {
ext.kotlin_version = '2.1.21'
repositories {
google()
mavenCentral()
}
ext.kotlin_version = '2.1.21'
repositories {
google()
mavenCentral()
}

dependencies {
classpath("com.android.tools.build:gradle:8.4.0")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
dependencies {
classpath "com.android.tools.build:gradle:8.7.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

def isNewArchitectureEnabled() {
Expand All @@ -38,44 +38,50 @@ if (isNewArchitectureEnabled()) {
}

android {
namespace "com.google.android.react.navsdk"
compileSdkVersion 35
namespace "com.google.android.react.navsdk"
compileSdkVersion 35

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

defaultConfig {
minSdkVersion 24
targetSdkVersion 34
versionCode 1
// get version name from package.json version
versionName "1.0"
}
defaultConfig {
minSdkVersion 24
targetSdkVersion 34
}

buildTypes {
release {
minifyEnabled true
}
}
buildFeatures {
buildConfig true
}

lintOptions {
abortOnError false
disable "GradleCompatible"
buildTypes {
release {
minifyEnabled true
}
}

lintOptions {
abortOnError false
disable "GradleCompatible"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

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

dependencies {
implementation "androidx.car.app:app:1.4.0"
implementation "androidx.car.app:app-projected:1.4.0"
implementation 'com.facebook.react:react-native:+'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "com.google.android.libraries.navigation:navigation:6.3.1"
api 'com.google.guava:guava:31.0.1-android'
implementation 'com.facebook.react:react-native:+'
implementation "androidx.car.app:app:1.4.0"
implementation "androidx.car.app:app-projected:1.4.0"
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation "com.google.android.libraries.navigation:navigation:6.3.1"
api 'com.google.guava:guava:31.0.1-android'
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
package com.google.android.react.navsdk;

public class Constants {
public static final String NAV_JAVASCRIPT_FLAG = "NavJavascriptBridge";
public static final String NAV_AUTO_JAVASCRIPT_FLAG = "NavAutoJavascriptBridge";
public static final String LAT_FIELD_KEY = "lat";
public static final String LNG_FIELD_KEY = "lng";
}
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,10 @@ public GroundOverlay addGroundOverlay(Map<String, Object> map) {
Double lng = null;
if (map.containsKey("location")) {
Map<String, Object> latlng = (Map<String, Object>) map.get("location");
if (latlng.get("lat") != null) lat = Double.parseDouble(latlng.get("lat").toString());
if (latlng.get("lng") != null) lng = Double.parseDouble(latlng.get("lng").toString());
if (latlng.get(Constants.LAT_FIELD_KEY) != null)
lat = Double.parseDouble(latlng.get(Constants.LAT_FIELD_KEY).toString());
if (latlng.get(Constants.LNG_FIELD_KEY) != null)
lng = Double.parseDouble(latlng.get(Constants.LNG_FIELD_KEY).toString());
}

GroundOverlayOptions options = new GroundOverlayOptions();
Expand Down Expand Up @@ -568,9 +570,11 @@ private String fetchJsonFromUrl(String urlString) throws IOException {
private LatLng createLatLng(Map<String, Object> map) {
Double lat = null;
Double lng = null;
if (map.containsKey("lat") && map.containsKey("lng")) {
if (map.get("lat") != null) lat = Double.parseDouble(map.get("lat").toString());
if (map.get("lng") != null) lng = Double.parseDouble(map.get("lng").toString());
if (map.containsKey(Constants.LAT_FIELD_KEY) && map.containsKey(Constants.LNG_FIELD_KEY)) {
if (map.get(Constants.LAT_FIELD_KEY) != null)
lat = Double.parseDouble(map.get(Constants.LAT_FIELD_KEY).toString());
if (map.get(Constants.LNG_FIELD_KEY) != null)
lng = Double.parseDouble(map.get(Constants.LNG_FIELD_KEY).toString());
}

return new LatLng(lat, lng);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
package com.google.android.react.navsdk;

import android.location.Location;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.NativeArray;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.UiThreadUtil;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.google.android.gms.maps.UiSettings;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
Expand All @@ -34,15 +34,13 @@
import com.google.android.gms.maps.model.Polygon;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.libraries.navigation.StylingOptions;
import java.util.Map;

/**
* This exposes a series of methods that can be called diretly from the React Native code. They have
* been implemented using promises as it's not recommended for them to be synchronous.
* This exposes a series of methods that can be called directly from the React Native code. They
* have been implemented using promises as it's not recommended for them to be synchronous.
*/
public class NavAutoModule extends ReactContextBaseJavaModule implements INavigationAutoCallback {
public static final String REACT_CLASS = "NavAutoModule";
private static final String TAG = "AndroidAutoModule";
private static NavAutoModule instance;
private static ModuleReadyListener moduleReadyListener;

Expand All @@ -64,6 +62,7 @@ public NavAutoModule(ReactApplicationContext reactContext) {
}
}

@NonNull
@Override
public String getName() {
return REACT_CLASS;
Expand Down Expand Up @@ -100,13 +99,6 @@ public void androidAutoNavigationScreenDisposed() {
mNavigationViewController = null;
}

public void setStylingOptions(Map<String, Object> stylingOptions) {
mStylingOptions = new StylingOptionsBuilder.Builder(stylingOptions).build();
if (mStylingOptions != null && mNavigationViewController != null) {
mNavigationViewController.setStylingOptions(mStylingOptions);
}
}

@ReactMethod
public void setMapType(int jsValue) {
UiThreadUtil.runOnUiThread(
Expand Down Expand Up @@ -408,11 +400,6 @@ public void getCameraPosition(final Promise promise) {

CameraPosition cp = mMapViewController.getGoogleMap().getCameraPosition();

if (cp == null) {
promise.resolve(null);
return;
}

LatLng target = cp.target;
WritableMap map = Arguments.createMap();
map.putDouble("bearing", cp.bearing);
Expand All @@ -438,7 +425,6 @@ public void getMyLocation(final Promise promise) {
promise.resolve(ObjectTranslationUtil.getMapFromLocation(location));
} catch (Exception e) {
promise.resolve(null);
return;
}
});
}
Expand Down Expand Up @@ -539,12 +525,11 @@ public void onCustomNavigationAutoEvent(String type, ReadableMap data) {
}

/** Send command to react native. */
private void sendCommandToReactNative(String functionName, NativeArray params) {
ReactContext reactContext = getReactApplicationContext();

if (reactContext != null) {
CatalystInstance catalystInstance = reactContext.getCatalystInstance();
catalystInstance.callFunction(Constants.NAV_AUTO_JAVASCRIPT_FLAG, functionName, params);
private void sendCommandToReactNative(String functionName, @Nullable Object params) {
if (reactContext.hasActiveReactInstance()) {
reactContext
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
.emit(functionName, params);
}
}
}
Loading
Loading