Skip to content

Commit

Permalink
nmea message clients both for gps and gnss added. Added nmea message …
Browse files Browse the repository at this point in the history
…functionality to example app
  • Loading branch information
Sempakonka committed Nov 24, 2020
1 parent 9333628 commit 5cf7d0d
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 69 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To use this plugin, add `geolocator` as a [dependency in your pubspec.yaml file]

```yaml
dependencies:
geolocator: ^6.1.7
geolocator: ^6.1.8
```
<details>
Expand Down
4 changes: 4 additions & 0 deletions geolocator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 6.1.8

- Added a functionality to receive NMEA messages.

## 6.1.7

- Resolved bug on Android where in some situations an IllegalArgumentException occures (see issue [#590](https://github.com/Baseflow/flutter-geolocator/issues/590)).
Expand Down
2 changes: 1 addition & 1 deletion geolocator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To use this plugin, add `geolocator` as a [dependency in your pubspec.yaml file]

```yaml
dependencies:
geolocator: ^6.1.7
geolocator: ^6.1.8
```
<details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public void onListen(Object arguments, EventChannel.EventSink events) {
geolocationManager.startNmeaUpdates(
context,
activity,
nmeaMessageaClient,
this.nmeaMessageaClient,
(String n, long l) -> events.success(toMap(n, l)),
(ErrorCodes errorCodes) ->
events.error(errorCodes.toString(), errorCodes.toDescription(), null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void startListening(Context context, BinaryMessenger messenger) {
stopListening();
}


channel = new EventChannel(messenger, "flutter.baseflow.com/geolocator_updates");
channel.setStreamHandler(this);
this.context = context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,6 @@ public void stopPositionUpdates() {
fusedLocationProviderClient.removeLocationUpdates(locationCallback);
}

@Override
public void startNmeaUpdates(
NmeaChangedCallback nmeaChangedCallback,
ErrorCallback errorCallback) {

}

private static LocationRequest buildLocationRequest(@Nullable LocationOptions options) {
LocationRequest locationRequest = new LocationRequest();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.OnNmeaMessageListener;
import android.os.Bundle;
import android.os.Looper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -53,7 +52,6 @@ public void stopNmeaUpdates() {

@Override
public void onNmeaMessage(String s, long l) {

if (this.nmeaChangedCallback != null) {
this.nmeaChangedCallback.onNmeaMessage(s, l);
}
Expand All @@ -64,15 +62,9 @@ public void onNmeaMessage(String s, long l) {
public void onLocationChanged(@NonNull Location location) {
}

@Override
public void onStatusChanged(String s, int i, Bundle bundle) {

}


@Override
public void onProviderEnabled(String s) {

}

@Override
Expand All @@ -85,7 +77,6 @@ public void onProviderDisabled(String s) {
if (this.errorCallback != null) {
errorCallback.onError(ErrorCodes.locationServicesDisabled);
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ public void onLocationChanged(@NonNull Location location) {

@Override
public void onProviderEnabled(String s) {

}

@Override
Expand All @@ -64,7 +63,6 @@ public void onProviderDisabled(String s) {
if (this.errorCallback != null) {
errorCallback.onError(ErrorCodes.locationServicesDisabled);
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ void startPositionUpdates(
ErrorCallback errorCallback);

void stopPositionUpdates();

}
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
package com.baseflow.geolocator.location;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.GpsStatus;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import android.location.OnNmeaMessageListener;
import android.os.Build.VERSION_CODES;
import android.os.Bundle;
import android.os.Looper;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import com.baseflow.geolocator.errors.ErrorCallback;
import com.baseflow.geolocator.errors.ErrorCodes;
import com.google.android.gms.common.util.Strings;

import java.util.List;


@SuppressLint("NewApi")
class LocationManagerClient implements LocationClient, LocationListener{
private static final long TWO_MINUTES = 120000;

Expand All @@ -41,15 +33,13 @@ class LocationManagerClient implements LocationClient, LocationListener{
@Nullable private String currentLocationProvider;
@Nullable private PositionChangedCallback positionChangedCallback;
@Nullable private ErrorCallback errorCallback;
@Nullable private NmeaChangedCallback nmeaChangedCallback;

public LocationManagerClient(
@NonNull Context context, @Nullable LocationOptions locationOptions) {
this.locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
this.locationOptions = locationOptions;
}


@Override
public void isLocationServiceEnabled(LocationServiceListener listener) {
if (locationManager == null) {
Expand Down Expand Up @@ -133,7 +123,6 @@ public void stopPositionUpdates() {
this.locationManager.removeUpdates(this);
}


@Override
public synchronized void onLocationChanged(Location location) {
float desiredAccuracy =
Expand Down Expand Up @@ -210,8 +199,6 @@ static boolean isBetterLocation(Location location, Location bestLocation) {
return false;
}



private static String getBestProvider(
LocationManager locationManager, LocationAccuracy accuracy) {
Criteria criteria = new Criteria();
Expand Down Expand Up @@ -267,4 +254,4 @@ private static float accuracyToFloat(LocationAccuracy accuracy) {
return 100;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public static Map<String, Object> toHashMap(Location location) {

Map<String, Object> position = new HashMap<>();

position.put("satellites", location.getExtras().getInt("satellites"));
position.put("latitude", location.getLatitude());
position.put("longitude", location.getLongitude());
position.put("timestamp", location.getTime());
Expand All @@ -31,6 +30,7 @@ public static Map<String, Object> toHashMap(Location location) {
} else {
position.put("is_mocked", false);
}

return position;
}
}

This file was deleted.

12 changes: 6 additions & 6 deletions geolocator/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import 'package:baseflow_plugin_template/baseflow_plugin_template.dart';
import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';

enum _PositionItemType {
permission,
position,
nmea,
}

/// Defines the main theme color.
final MaterialColor themeMaterialColor =
BaseflowPluginExample.createMaterialColor(
Expand Down Expand Up @@ -235,6 +229,12 @@ class _GeolocatorWidgetState extends State<GeolocatorWidget> {
}
}

enum _PositionItemType {
permission,
position,
nmea,
}

class _PositionItem {
_PositionItem(this.type, this.displayValue);

Expand Down
5 changes: 2 additions & 3 deletions geolocator/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: geolocator
description: Geolocation plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API for generic location (GPS etc.) functions.
version: 6.1.7
version: 6.1.8
homepage: https://github.com/Baseflow/flutter-geolocator/tree/master/geolocator

environment:
Expand All @@ -11,8 +11,7 @@ dependencies:
flutter:
sdk: flutter

geolocator_platform_interface:
path: ../geolocator_platform_interface
geolocator_platform_interface: ^1.0.9

dev_dependencies:
flutter_test:
Expand Down
4 changes: 4 additions & 0 deletions geolocator_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.9

- Added a functionality to receive NMEA messages. This can be done using the new nmea_message model.

## 1.0.8

- Added the optional floor property to the position model and can be used by implementations to specify the floor on which the device is located (see [#562](https://github.com/Baseflow/flutter-geolocator/issues/562)).
Expand Down
2 changes: 1 addition & 1 deletion geolocator_platform_interface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To use this plugin, add `geolocator` as a [dependency in your pubspec.yaml file]

```yaml
dependencies:
geolocator: ^6.1.7
geolocator: ^6.1.8
```
<details>
Expand Down
4 changes: 1 addition & 3 deletions geolocator_platform_interface/lib/src/models/position.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ class Position {
o.timestamp == timestamp &&
o.isMocked == isMocked;


return areEqual;
}

Expand All @@ -115,7 +114,6 @@ class Position {
if (message == null) {
return null;
}
print("using from map...");

final Map<dynamic, dynamic> positionMap = message;

Expand All @@ -131,7 +129,7 @@ class Position {

final timestamp = positionMap['timestamp'] != null
? DateTime.fromMillisecondsSinceEpoch(positionMap['timestamp'].toInt(),
isUtc: true)
isUtc: true)
: null;

return Position(
Expand Down

0 comments on commit 5cf7d0d

Please sign in to comment.