Skip to content

Commit

Permalink
Merge pull request #5 from Yukams/master
Browse files Browse the repository at this point in the history
Update fork ( includes gradle upgrade )
  • Loading branch information
jo11yn authored Apr 21, 2023
2 parents aa5c410 + f174944 commit 8ba1c3c
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 13 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
## 2.0.6-dev.1
* Fix Type mismatch: inferred type is String? but Any was expected

## 2.0.6-dev.2
* Fixing iOS build
* Fixing memory leak on Android
* Fixing callbacks on older Android devices

## 2.0.6-dev.1
* Fix Type mismatch: inferred type is String? but Any was expected

## 2.0.5
* Fixing demo gif

Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ group 'yukams.app.background_locator_2'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.4.21'
ext.kotlin_version = '1.7.20'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath 'com.android.tools.build:gradle:4.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down Expand Up @@ -41,7 +41,7 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.google.android.gms:play-services-location:18.0.0"
implementation "com.google.android.gms:play-services-location:21.0.1"
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.google.android.material:material:1.0.0'
}
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GoogleLocationProviderClient(context: Context, override var listener: Loca
}

private class LocationListener(val listener: LocationUpdateListener?) : LocationCallback() {
override fun onLocationResult(location: LocationResult?) {
override fun onLocationResult(location: LocationResult) {
listener?.onLocationUpdated(LocationParserUtil.getLocationMapFromLocation(location))
}
}
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.4.31'
ext.kotlin_version = '1.7.20'
repositories {
google()
jcenter()
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
5 changes: 5 additions & 0 deletions example/lib/location_callback_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,30 @@ import 'package:background_locator_2/location_dto.dart';

import 'location_service_repository.dart';

@pragma('vm:entry-point')
class LocationCallbackHandler {
@pragma('vm:entry-point')
static Future<void> initCallback(Map<dynamic, dynamic> params) async {
LocationServiceRepository myLocationCallbackRepository =
LocationServiceRepository();
await myLocationCallbackRepository.init(params);
}

@pragma('vm:entry-point')
static Future<void> disposeCallback() async {
LocationServiceRepository myLocationCallbackRepository =
LocationServiceRepository();
await myLocationCallbackRepository.dispose();
}

@pragma('vm:entry-point')
static Future<void> callback(LocationDto locationDto) async {
LocationServiceRepository myLocationCallbackRepository =
LocationServiceRepository();
await myLocationCallbackRepository.callback(locationDto);
}

@pragma('vm:entry-point')
static Future<void> notificationCallback() async {
print('***notificationCallback');
}
Expand Down
2 changes: 1 addition & 1 deletion example/lib/location_service_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class LocationServiceRepository {
print('$_count location in dart: ${locationDto.toString()}');
await setLogPosition(_count, locationDto);
final SendPort send = IsolateNameServer.lookupPortByName(isolateName);
send?.send(locationDto);
send?.send(locationDto.toJson());
_count++;

}
Expand Down
7 changes: 4 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ class _MyAppState extends State<MyApp> {
super.dispose();
}

Future<void> updateUI(LocationDto data) async {
Future<void> updateUI(dynamic data) async {
final log = await FileManager.readLogFile();

await _updateNotificationText(data);
LocationDto locationDto = (data != null) ? LocationDto.fromJson(data) : null;
await _updateNotificationText(locationDto);

setState(() {
if (data != null) {
lastLocation = data;
lastLocation = locationDto;
}
logStr = log;
});
Expand Down
6 changes: 4 additions & 2 deletions lib/callback_dispatcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ void callbackDispatcher() {
_backgroundChannel.setMethodCallHandler((MethodCall call) async {
if (Keys.BCM_SEND_LOCATION == call.method) {
final Map<dynamic, dynamic> args = call.arguments;
final Function callback = PluginUtilities.getCallbackFromHandle(
final Function? callback = PluginUtilities.getCallbackFromHandle(
CallbackHandle.fromRawHandle(args[Keys.ARG_CALLBACK]))!;
final LocationDto location =
LocationDto.fromJson(args[Keys.ARG_LOCATION]);
callback(location);
if (callback != null) {
callback(location);
}
} else if (Keys.BCM_NOTIFICATION_CLICK == call.method) {
final Map<dynamic, dynamic> args = call.arguments;
final Function? notificationCallback =
Expand Down

0 comments on commit 8ba1c3c

Please sign in to comment.