Skip to content

Commit 8ba1c3c

Browse files
authored
Merge pull request #5 from Yukams/master
Update fork ( includes gradle upgrade )
2 parents aa5c410 + f174944 commit 8ba1c3c

File tree

10 files changed

+29
-13
lines changed

10 files changed

+29
-13
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
## 2.0.6-dev.1
66
* Fix Type mismatch: inferred type is String? but Any was expected
77

8+
## 2.0.6-dev.2
9+
* Fixing iOS build
10+
* Fixing memory leak on Android
11+
* Fixing callbacks on older Android devices
12+
13+
## 2.0.6-dev.1
14+
* Fix Type mismatch: inferred type is String? but Any was expected
15+
816
## 2.0.5
917
* Fixing demo gif
1018

android/build.gradle

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ group 'yukams.app.background_locator_2'
22
version '1.0-SNAPSHOT'
33

44
buildscript {
5-
ext.kotlin_version = '1.4.21'
5+
ext.kotlin_version = '1.7.20'
66
repositories {
77
google()
88
jcenter()
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:4.1.1'
12+
classpath 'com.android.tools.build:gradle:4.1.3'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}
@@ -41,7 +41,7 @@ android {
4141

4242
dependencies {
4343
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
44-
implementation "com.google.android.gms:play-services-location:18.0.0"
44+
implementation "com.google.android.gms:play-services-location:21.0.1"
4545
implementation 'com.google.code.gson:gson:2.8.6'
4646
implementation 'com.google.android.material:material:1.0.0'
4747
}

android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip

android/src/main/kotlin/yukams/app/background_locator_2/provider/GoogleLocationProviderClient.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class GoogleLocationProviderClient(context: Context, override var listener: Loca
3131
}
3232

3333
private class LocationListener(val listener: LocationUpdateListener?) : LocationCallback() {
34-
override fun onLocationResult(location: LocationResult?) {
34+
override fun onLocationResult(location: LocationResult) {
3535
listener?.onLocationUpdated(LocationParserUtil.getLocationMapFromLocation(location))
3636
}
3737
}

example/android/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlin_version = '1.4.31'
2+
ext.kotlin_version = '1.7.20'
33
repositories {
44
google()
55
jcenter()

example/android/gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip

example/lib/location_callback_handler.dart

+5
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,30 @@ import 'package:background_locator_2/location_dto.dart';
44

55
import 'location_service_repository.dart';
66

7+
@pragma('vm:entry-point')
78
class LocationCallbackHandler {
9+
@pragma('vm:entry-point')
810
static Future<void> initCallback(Map<dynamic, dynamic> params) async {
911
LocationServiceRepository myLocationCallbackRepository =
1012
LocationServiceRepository();
1113
await myLocationCallbackRepository.init(params);
1214
}
1315

16+
@pragma('vm:entry-point')
1417
static Future<void> disposeCallback() async {
1518
LocationServiceRepository myLocationCallbackRepository =
1619
LocationServiceRepository();
1720
await myLocationCallbackRepository.dispose();
1821
}
1922

23+
@pragma('vm:entry-point')
2024
static Future<void> callback(LocationDto locationDto) async {
2125
LocationServiceRepository myLocationCallbackRepository =
2226
LocationServiceRepository();
2327
await myLocationCallbackRepository.callback(locationDto);
2428
}
2529

30+
@pragma('vm:entry-point')
2631
static Future<void> notificationCallback() async {
2732
print('***notificationCallback');
2833
}

example/lib/location_service_repository.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class LocationServiceRepository {
5555
print('$_count location in dart: ${locationDto.toString()}');
5656
await setLogPosition(_count, locationDto);
5757
final SendPort send = IsolateNameServer.lookupPortByName(isolateName);
58-
send?.send(locationDto);
58+
send?.send(locationDto.toJson());
5959
_count++;
6060

6161
}

example/lib/main.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ class _MyAppState extends State<MyApp> {
5555
super.dispose();
5656
}
5757

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

61-
await _updateNotificationText(data);
61+
LocationDto locationDto = (data != null) ? LocationDto.fromJson(data) : null;
62+
await _updateNotificationText(locationDto);
6263

6364
setState(() {
6465
if (data != null) {
65-
lastLocation = data;
66+
lastLocation = locationDto;
6667
}
6768
logStr = log;
6869
});

lib/callback_dispatcher.dart

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ void callbackDispatcher() {
1515
_backgroundChannel.setMethodCallHandler((MethodCall call) async {
1616
if (Keys.BCM_SEND_LOCATION == call.method) {
1717
final Map<dynamic, dynamic> args = call.arguments;
18-
final Function callback = PluginUtilities.getCallbackFromHandle(
18+
final Function? callback = PluginUtilities.getCallbackFromHandle(
1919
CallbackHandle.fromRawHandle(args[Keys.ARG_CALLBACK]))!;
2020
final LocationDto location =
2121
LocationDto.fromJson(args[Keys.ARG_LOCATION]);
22-
callback(location);
22+
if (callback != null) {
23+
callback(location);
24+
}
2325
} else if (Keys.BCM_NOTIFICATION_CLICK == call.method) {
2426
final Map<dynamic, dynamic> args = call.arguments;
2527
final Function? notificationCallback =

0 commit comments

Comments
 (0)