Skip to content

Commit

Permalink
Merge branch 'main' into feature/remove_optional-timestamp
Browse files Browse the repository at this point in the history
# Conflicts:
#	geolocator/CHANGELOG.md
  • Loading branch information
TimHoogstrate committed Oct 31, 2023
2 parents 740b576 + 524720d commit a494f09
Show file tree
Hide file tree
Showing 51 changed files with 589 additions and 281 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/geolocator_web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:

env:
source-directory: ./geolocator_web
example-directory: ./geolocator_web/example

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -51,5 +52,5 @@ jobs:

# Build Web version of the example App
- name: Run Web build
run: flutter build web --release --no-sound-null-safety
run: flutter build web --release
working-directory: ${{env.example-directory}}
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ The Flutter geolocator plugin is built following the federated plugin architectu

1. [`geolocator`][1]: the app facing package. This is the package users depend on to use the plugin in their project. For details on how to use the [`geolocator`][1] plugin you can refer to its [README.md][2] file.
2. [`geolocator_android`][3]: this package contains the endorsed Android implementation of the geolocator_platform_interface and adds Android support to the [`geolocator`][1] app facing package. More information can be found in its [README.md][4] file;
2. [`geolocator_apple`][5]: this package contains the endorsed iOS and macOS implementations of the geolocator_platform_interface and adds iOS and macOS support to the [`geolocator`][1] app facing package. More information can be found in its [README.md][6] file;
2. [`geolocator_web`][7]: this package contains the endorsed web implementation of the geolocator_platform_interface and adds web support to the [`geolocator`][1] app facing package. More information can be found in its [README.md][8] file;
2. [`geolocator_windows`][9]: this package contains the endorsed Windows implementation of the geolocator_platform_interface and adds Windows support to the [`geolocator`][1] app facing package. More information can be found in its [README.md][10] file;
3. [`geolocator_platform_interface`][11]: this package declares the interface which all platform packages must implement to support the app-facing package. Instructions on how to implement a platform package can be found in the [README.md][12] of the [`geolocator_platform_interface`][11] package.
3. [`geolocator_apple`][5]: this package contains the endorsed iOS and macOS implementations of the geolocator_platform_interface and adds iOS and macOS support to the [`geolocator`][1] app facing package. More information can be found in its [README.md][6] file;
4. [`geolocator_web`][7]: this package contains the endorsed web implementation of the geolocator_platform_interface and adds web support to the [`geolocator`][1] app facing package. More information can be found in its [README.md][8] file;
5. [`geolocator_windows`][9]: this package contains the endorsed Windows implementation of the geolocator_platform_interface and adds Windows support to the [`geolocator`][1] app facing package. More information can be found in its [README.md][10] file;
6. [`geolocator_platform_interface`][11]: this package declares the interface which all platform packages must implement to support the app-facing package. Instructions on how to implement a platform package can be found in the [README.md][12] of the [`geolocator_platform_interface`][11] package.

[1]: ./geolocator
[2]: ./geolocator/README.md
Expand Down
11 changes: 10 additions & 1 deletion geolocator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
## 10.1.1

- Replaced optional DateTime? `timestamp` in `Position` object for an NonNull DateTime `timestamp`.

## 10.1.0

- Includes `altitudeAccuracy` and `headingAccuracy` in `Position`.

## 10.0.1

- Optional timestamp in Position object is not optional anymore.
- Updates documentation for `getCurrentPosition()`, to clarify the behavior of location accuracy on Android devices.
- Updates README regarding the plugin interpretation of `LocationAccuracy`.

## 10.0.0

Expand Down
32 changes: 22 additions & 10 deletions geolocator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,28 @@ double bearing = Geolocator.bearingBetween(52.2165157, 6.9437819, 52.3546274, 4.

### Location accuracy

The table below outlines the accuracy options per platform:

| | Android | iOS |
|------------|-----------:|------:|
| **lowest** | 500m | 3000m |
| **low** | 500m | 1000m |
| **medium** | 100 - 500m | 100m |
| **high** | 0 - 100m | 10m |
| **best** | 0 - 100m | ~0m |
| **bestForNavigation** | 0 - 100m | [Optimized for navigation](https://developer.apple.com/documentation/corelocation/kcllocationaccuracybestfornavigation) |
#### Android
On Android, the `LocationAccuracy` enum controls the accuracy of the location data the app wants to receive. It also provides control over the [priority given to the location stream](https://developers.google.com/android/reference/com/google/android/gms/location/Priority). This can be confusing, as a priority of **lowest** might not return any location, while one might expect it to give the quickest responses. The table below outlines the priority and its meaning per accuracy option:

| Location accuracy | Android priority | Description |
|-------------------|------------------|-------------|
| **lowest** | [PRIORITY_PASSIVE](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_passive) | Ensures that no extra power will be used to derive locations. This enforces that the request will act as a passive listener that will only receive "free" locations calculated on behalf of other clients, and no locations will be calculated on behalf of only this request. |
| **low** | [PRIORITY_LOW_POWER](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_low_power) | Requests a tradeoff that favors low power usage at the possible expense of location accuracy. |
| **medium** | [PRIORITY_BALANCED_POWER_ACCURACY](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_balanced_power_accuracy) | Requests a tradeoff that is balanced between location accuracy and power usage. |
| **high**+ | [PRIORITY_HIGH_ACCURACY](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_high_accuracy) | Requests a tradeoff that favors highly accurate locations at the possible expense of additional power usage. |

#### iOS
On iOS, the `LocationAccuracy` enum controls the accuracy of the location data the app wants to receive. It also provides control on the battery consumption of the device: the more detailed data is requested, the larger the impact on the battery consumption. More details can be found on [Apple's documentation](https://developer.apple.com/documentation/corelocation/cllocationmanager/1423836-desiredaccuracy?language=objc). The table below shows how the `LocationAccuracy` values map to the native iOS accuracy settings.

| Location accuracy | iOS accuracy | Description |
|---|---|---|
| **lowest** | [kCLLocationAccuracyThreeKilometers](https://developer.apple.com/documentation/corelocation/kcllocationaccuracythreekilometers?language=objc) | Accurate to the nearest three kilometers. |
| **low** | [kCLLocationAccuracyKilometer](https://developer.apple.com/documentation/corelocation/kcllocationaccuracykilometer?language=objc) | Accurate to the nearest kilometer. |
| **medium** | [kCLLocationAccuracyHundredMeters](https://developer.apple.com/documentation/corelocation/kcllocationaccuracyhundredmeters?language=objc) | Accurate to within one hundred meters. |
| **high** | [kCLLocationAccuracyNearestTenMeters](https://developer.apple.com/documentation/corelocation/kcllocationaccuracynearesttenmeters?language=objc) | Accurate to within ten meters of the desired target. |
| **best** | [kCLLocationAccuracyBest](https://developer.apple.com/documentation/corelocation/kcllocationaccuracybest?language=objc) | The best level of accuracy available. |
| **bestForNavigation** | [kCLLocationAccuracyBestForNavigation](https://developer.apple.com/documentation/corelocation/kcllocationaccuracybestfornavigation?language=objc) | The highest possible accuracy that uses additional sensor data to facilitate navigation apps. |


## Issues

Expand Down
8 changes: 8 additions & 0 deletions geolocator/example/windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_windows
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
)

set(PLUGIN_BUNDLED_LIBRARIES)

foreach(plugin ${FLUTTER_PLUGIN_LIST})
Expand All @@ -15,3 +18,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)

foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)
38 changes: 33 additions & 5 deletions geolocator/lib/geolocator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,48 @@ class Geolocator {
GeolocatorPlatform.instance.getLastKnownPosition(
forceLocationManager: forceAndroidLocationManager);

/// Returns the current position taking the supplied [desiredAccuracy] into
/// account.
/// Returns the current position.
///
/// You can control the precision of the location updates by supplying the
/// [desiredAccuracy] parameter (defaults to "best"). On Android you can
/// force the use of the Android LocationManager instead of the
/// FusedLocationProvider by setting the [forceAndroidLocationManager]
/// [desiredAccuracy] parameter (defaults to "best").
/// On Android you can force the use of the Android LocationManager instead of
/// the FusedLocationProvider by setting the [forceAndroidLocationManager]
/// parameter to true. The [timeLimit] parameter allows you to specify a
/// timeout interval (by default no time limit is configured).
///
/// Calling the [getCurrentPosition] method will request the platform to
/// obtain a location fix. Depending on the availability of different location
/// services, this can take several seconds. The recommended use would be to
/// call the [getLastKnownPosition] method to receive a cached position and
/// update it with the result of the [getCurrentPosition] method.
///
/// Throws a [TimeoutException] when no location is received within the
/// supplied [timeLimit] duration.
/// Throws a [LocationServiceDisabledException] when the user allowed access,
/// but the location services of the device are disabled.
///
///
/// **Note**: On Android the location *accuracy* is interpreted as
/// [location *priority*](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#constants).
/// The interpretation works as follows:
///
/// [LocationAccuracy.lowest] -> [PRIORITY_PASSIVE](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_passive):
/// Ensures that no extra power will be used to derive locations. This
/// enforces that the request will act as a passive listener that will only
/// receive "free" locations calculated on behalf of other clients, and no
/// locations will be calculated on behalf of only this request.
///
/// [LocationAccuracy.low] -> [PRIORITY_LOW_POWER](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_low_power):
/// Requests a tradeoff that favors low power usage at the possible expense of
/// location accuracy.
///
/// [LocationAccuracy.medium] -> [PRIORITY_BALANCED_POWER_ACCURACY](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_balanced_power_accuracy):
/// Requests a tradeoff that is balanced between location accuracy and power
/// usage.
///
/// [LocationAccuracy.high]+ -> [PRIORITY_HIGH_ACCURACY](https://developers.google.com/android/reference/com/google/android/gms/location/Priority#public-static-final-int-priority_high_accuracy):
/// Requests a tradeoff that favors highly accurate locations at the possible
/// expense of additional power usage.
static Future<Position> getCurrentPosition({
LocationAccuracy desiredAccuracy = LocationAccuracy.best,
bool forceAndroidLocationManager = false,
Expand Down
12 changes: 6 additions & 6 deletions geolocator/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: geolocator
description: Geolocation plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API for generic location (GPS etc.) functions.
repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator
issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen
version: 10.0.0
version: 10.1.0

environment:
sdk: ">=2.15.0 <4.0.0"
Expand All @@ -26,11 +26,11 @@ dependencies:
flutter:
sdk: flutter

geolocator_platform_interface: ^4.0.3
geolocator_android: ^4.1.3
geolocator_apple: ^2.1.1+1
geolocator_web: ^2.1.3
geolocator_windows: ^0.2.0
geolocator_platform_interface: ^4.1.0
geolocator_android: ^4.3.0
geolocator_apple: ^2.3.0
geolocator_web: ^2.2.0
geolocator_windows: ^0.2.2

dev_dependencies:
flutter_test:
Expand Down
2 changes: 2 additions & 0 deletions geolocator/test/geolocator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ Position get mockPosition => Position(
isUtc: true,
),
altitude: 3000.0,
altitudeAccuracy: 0.0,
accuracy: 0.0,
heading: 0.0,
headingAccuracy: 0.0,
speed: 0.0,
speedAccuracy: 0.0);

Expand Down
27 changes: 27 additions & 0 deletions geolocator_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## 4.3.3

- Removes deprecated support for Android V1 embedding from the JAVA code base. Note that the geolocator's Flutter version restrictions already don't support V1 embedding anymore.
- Registers location services state change broadcast receiver with required exported flags

## 4.3.2

- Updates the following dependencies:
- uuid package from ^3.0.7 to ^4.1.0
- flutter_lints from ^2.0.0 to ^3.0.0

## 4.3.1

- Suppresses a deprecation warning for `LocationListenerCompat.onStatusChanged` when building for Android.

## 4.3.0

* Includes `altitudeAccuracy` and `headingAccuracy` in `Position`.

## 4.2.4

* Fixes a bug where location readings were very inaccurate when using `forceLocationManager: true`.

## 4.2.3

* Fixes a bug where the position stream was unnecessarily filtered when using `forceLocationManager: true`.

## 4.2.2

* Adds back the `applicationId` property of the AndroidManifest.xml file to keep backwardscompatibility with older applications that still rely on Gradle version <7.0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ public void onServiceDisconnected(ComponentName name) {
};
@Nullable private LocationServiceHandlerImpl locationServiceHandler;

@SuppressWarnings("deprecation")
@Nullable
private io.flutter.plugin.common.PluginRegistry.Registrar pluginRegistrar;

@Nullable private ActivityPluginBinding pluginBinding;

public GeolocatorPlugin() {
Expand All @@ -65,38 +61,6 @@ public GeolocatorPlugin() {
locationAccuracyManager = new LocationAccuracyManager();
}

// This static function is optional and equivalent to onAttachedToEngine. It supports the old
// pre-Flutter-1.12 Android projects. You are encouraged to continue supporting
// plugin registration via this function while apps migrate to use the new Android APIs
// post-flutter-1.12 via https://flutter.dev/go/android-project-migration.
//
// It is encouraged to share logic between onAttachedToEngine and registerWith to keep
// them functionally equivalent. Only one of onAttachedToEngine or registerWith will be called
// depending on the user's project. onAttachedToEngine or registerWith must both be defined
// in the same class.
@SuppressWarnings("deprecation")
public static void registerWith(io.flutter.plugin.common.PluginRegistry.Registrar registrar) {
GeolocatorPlugin geolocatorPlugin = new GeolocatorPlugin();
geolocatorPlugin.pluginRegistrar = registrar;
geolocatorPlugin.registerListeners();

MethodCallHandlerImpl methodCallHandler =
new MethodCallHandlerImpl(
geolocatorPlugin.permissionManager,
geolocatorPlugin.geolocationManager,
geolocatorPlugin.locationAccuracyManager);
methodCallHandler.startListening(registrar.context(), registrar.messenger());
methodCallHandler.setActivity(registrar.activity());

StreamHandlerImpl streamHandler = new StreamHandlerImpl(geolocatorPlugin.permissionManager);
streamHandler.startListening(registrar.context(), registrar.messenger());

LocationServiceHandlerImpl locationServiceHandler = new LocationServiceHandlerImpl();
locationServiceHandler.startListening(registrar.context(), registrar.messenger());
locationServiceHandler.setContext(registrar.activeContext());
geolocatorPlugin.bindForegroundService(registrar.activeContext());
}

@Override
public void onAttachedToEngine(@NonNull FlutterPluginBinding flutterPluginBinding) {
methodCallHandler =
Expand Down Expand Up @@ -168,10 +132,7 @@ public void onDetachedFromActivity() {
}

private void registerListeners() {
if (pluginRegistrar != null) {
pluginRegistrar.addActivityResultListener(this.geolocationManager);
pluginRegistrar.addRequestPermissionsResultListener(this.permissionManager);
} else if (pluginBinding != null) {
if (pluginBinding != null) {
pluginBinding.addActivityResultListener(this.geolocationManager);
pluginBinding.addRequestPermissionsResultListener(this.permissionManager);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.baseflow.geolocator;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.location.LocationManager;
import android.util.Log;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

import com.baseflow.geolocator.location.LocationServiceStatusReceiver;

Expand Down Expand Up @@ -55,7 +55,7 @@ public void onListen(Object arguments, EventChannel.EventSink events) {
IntentFilter filter = new IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION);
filter.addAction(Intent.ACTION_PROVIDER_CHANGED);
receiver = new LocationServiceStatusReceiver(events);
context.registerReceiver(receiver, filter);
ContextCompat.registerReceiver(context, receiver, filter, ContextCompat.RECEIVER_EXPORTED);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

@SuppressWarnings("deprecation")
public class GeolocationManager
implements io.flutter.plugin.common.PluginRegistry.ActivityResultListener {

Expand Down
Loading

0 comments on commit a494f09

Please sign in to comment.