From d2089131ad19c88717587850a314ea8beeda508a Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 08:08:16 -0300 Subject: [PATCH 01/18] correcaode bugs --- .../app/background_locator/BackgroundLocatorPlugin.kt | 8 ++++---- .../app/background_locator/pluggables/InitPluggable.kt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index 405b458b..73136adc 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -24,7 +24,7 @@ import rekab.app.background_locator.pluggables.InitPluggable class BackgroundLocatorPlugin : MethodCallHandler, FlutterPlugin, PluginRegistry.NewIntentListener, ActivityAware { - private var context: Context? = null + public var context: Context? = null private var activity: Activity? = null companion object { @@ -212,7 +212,7 @@ class BackgroundLocatorPlugin override fun onMethodCall(call: MethodCall, result: Result) { when (call.method) { Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { - val args: Map = call.arguments() + val args: Map? = call.arguments() // save callback dispatcher to use it when device reboots PreferencesManager.saveCallbackDispatcher(context!!, args) @@ -221,7 +221,7 @@ class BackgroundLocatorPlugin result.success(true) } Keys.METHOD_PLUGIN_REGISTER_LOCATION_UPDATE -> { - val args: Map = call.arguments() + val args: Map? = call.arguments() // save setting to use it when device reboots PreferencesManager.saveSettings(context!!, args) @@ -240,7 +240,7 @@ class BackgroundLocatorPlugin return } - val args: Map = call.arguments() + val args: Map? = call.arguments() updateNotificationText(context!!, args) result.success(true) } diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt index a33a7ecf..f0e01e75 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt @@ -19,7 +19,7 @@ class InitPluggable : Pluggable { if (!isInitCallbackCalled) { (PreferencesManager.getCallbackHandle(context, Keys.INIT_CALLBACK_HANDLE_KEY))?.let { initCallback -> val initialDataMap = PreferencesManager.getDataCallback(context, Keys.INIT_DATA_CALLBACK_KEY) - val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, + val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!, Keys.BACKGROUND_CHANNEL_ID) Handler(context.mainLooper) .post { From 222677f14a1cbe6da1071660b0768c2acca067c2 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 08:17:03 -0300 Subject: [PATCH 02/18] teste --- .../app/background_locator/BackgroundLocatorPlugin.kt | 10 +++++----- .../background_locator/pluggables/DisposePluggable.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index 73136adc..ab0d0a0e 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -215,19 +215,19 @@ class BackgroundLocatorPlugin val args: Map? = call.arguments() // save callback dispatcher to use it when device reboots - PreferencesManager.saveCallbackDispatcher(context!!, args) + PreferencesManager.saveCallbackDispatcher(context!!, args!) - initializeService(context!!, args) + initializeService(context!!, args!) result.success(true) } Keys.METHOD_PLUGIN_REGISTER_LOCATION_UPDATE -> { val args: Map? = call.arguments() // save setting to use it when device reboots - PreferencesManager.saveSettings(context!!, args) + PreferencesManager.saveSettings(context!!, args!) registerLocator(context!!, - args, + args!, result) } Keys.METHOD_PLUGIN_UN_REGISTER_LOCATION_UPDATE -> { @@ -241,7 +241,7 @@ class BackgroundLocatorPlugin } val args: Map? = call.arguments() - updateNotificationText(context!!, args) + updateNotificationText(context!!, args!) result.success(true) } else -> result.notImplemented() diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt index 69358109..5024e776 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt @@ -14,7 +14,7 @@ class DisposePluggable : Pluggable { override fun onServiceDispose(context: Context) { (PreferencesManager.getCallbackHandle(context, Keys.DISPOSE_CALLBACK_HANDLE_KEY))?.let { disposeCallback -> - val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, + val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!, Keys.BACKGROUND_CHANNEL_ID) Handler(context.mainLooper) .post { From b28c1dbcd2114fc22024fed5c7544f030e0f15dd Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 08:36:52 -0300 Subject: [PATCH 03/18] =?UTF-8?q?corre=C3=A7=C3=A3o=20de=20erros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rekab/app/background_locator/pluggables/DisposePluggable.kt | 2 +- .../rekab/app/background_locator/pluggables/InitPluggable.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt index 5024e776..69358109 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt @@ -14,7 +14,7 @@ class DisposePluggable : Pluggable { override fun onServiceDispose(context: Context) { (PreferencesManager.getCallbackHandle(context, Keys.DISPOSE_CALLBACK_HANDLE_KEY))?.let { disposeCallback -> - val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!, + val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, Keys.BACKGROUND_CHANNEL_ID) Handler(context.mainLooper) .post { diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt index f0e01e75..a33a7ecf 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt @@ -19,7 +19,7 @@ class InitPluggable : Pluggable { if (!isInitCallbackCalled) { (PreferencesManager.getCallbackHandle(context, Keys.INIT_CALLBACK_HANDLE_KEY))?.let { initCallback -> val initialDataMap = PreferencesManager.getDataCallback(context, Keys.INIT_DATA_CALLBACK_KEY) - val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!, + val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, Keys.BACKGROUND_CHANNEL_ID) Handler(context.mainLooper) .post { From eead0b7b3c04cf6d7b36c5a577aead0689edad9b Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 08:39:06 -0300 Subject: [PATCH 04/18] teste --- android/build.gradle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 82b8893c..4e83d68e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -43,4 +43,7 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "com.google.android.gms:play-services-location:18.0.0" implementation 'com.google.code.gson:gson:2.8.6' + implementation 'com.google.android.material:material:1.0.0' + + } From 8e8952768b40f3c03c42e34ba4ea79a9b00fdceb Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 08:57:33 -0300 Subject: [PATCH 05/18] =?UTF-8?q?corre=C3=A7=C3=A3o=20de=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BackgroundLocatorPlugin.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index ab0d0a0e..8d00779c 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -212,22 +212,22 @@ class BackgroundLocatorPlugin override fun onMethodCall(call: MethodCall, result: Result) { when (call.method) { Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { - val args: Map? = call.arguments() + val args: Map = call.arguments()! // save callback dispatcher to use it when device reboots - PreferencesManager.saveCallbackDispatcher(context!!, args!) + PreferencesManager.saveCallbackDispatcher(context!!, args) - initializeService(context!!, args!) + initializeService(context!!, args) result.success(true) } Keys.METHOD_PLUGIN_REGISTER_LOCATION_UPDATE -> { - val args: Map? = call.arguments() + val args: Map = call.arguments()! // save setting to use it when device reboots - PreferencesManager.saveSettings(context!!, args!) + PreferencesManager.saveSettings(context!!, args) registerLocator(context!!, - args!, + args, result) } Keys.METHOD_PLUGIN_UN_REGISTER_LOCATION_UPDATE -> { @@ -240,8 +240,8 @@ class BackgroundLocatorPlugin return } - val args: Map? = call.arguments() - updateNotificationText(context!!, args!) + val args: Map = call.arguments()! + updateNotificationText(context!!, args) result.success(true) } else -> result.notImplemented() From 1e71ad33aa6511d10be67e3618a6218d2e599132 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:00:46 -0300 Subject: [PATCH 06/18] teste --- .../rekab/app/background_locator/BackgroundLocatorPlugin.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index 8d00779c..d70b8448 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -212,7 +212,7 @@ class BackgroundLocatorPlugin override fun onMethodCall(call: MethodCall, result: Result) { when (call.method) { Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { - val args: Map = call.arguments()! + val args: Map = call.arguments(); // save callback dispatcher to use it when device reboots PreferencesManager.saveCallbackDispatcher(context!!, args) @@ -221,7 +221,7 @@ class BackgroundLocatorPlugin result.success(true) } Keys.METHOD_PLUGIN_REGISTER_LOCATION_UPDATE -> { - val args: Map = call.arguments()! + val args: Map = call.arguments(); // save setting to use it when device reboots PreferencesManager.saveSettings(context!!, args) @@ -240,7 +240,7 @@ class BackgroundLocatorPlugin return } - val args: Map = call.arguments()! + val args: Map = call.arguments(); updateNotificationText(context!!, args) result.success(true) } From a04ac75907128e30dd19025e703fc69e65ea4219 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:02:05 -0300 Subject: [PATCH 07/18] testes --- .../rekab/app/background_locator/BackgroundLocatorPlugin.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index d70b8448..c9e5c920 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -212,7 +212,7 @@ class BackgroundLocatorPlugin override fun onMethodCall(call: MethodCall, result: Result) { when (call.method) { Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { - val args: Map = call.arguments(); + val args: Map? = call.arguments() // save callback dispatcher to use it when device reboots PreferencesManager.saveCallbackDispatcher(context!!, args) @@ -221,7 +221,7 @@ class BackgroundLocatorPlugin result.success(true) } Keys.METHOD_PLUGIN_REGISTER_LOCATION_UPDATE -> { - val args: Map = call.arguments(); + val args: Map? = call.arguments(); // save setting to use it when device reboots PreferencesManager.saveSettings(context!!, args) @@ -240,7 +240,7 @@ class BackgroundLocatorPlugin return } - val args: Map = call.arguments(); + val args: Map? = call.arguments() updateNotificationText(context!!, args) result.success(true) } From 656170a83fec32910c1116639f8cff9795836d06 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:07:30 -0300 Subject: [PATCH 08/18] teste --- .../BackgroundLocatorPlugin.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index c9e5c920..c6d50316 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -214,8 +214,12 @@ class BackgroundLocatorPlugin Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { val args: Map? = call.arguments() - // save callback dispatcher to use it when device reboots - PreferencesManager.saveCallbackDispatcher(context!!, args) + if(args != null){ + // save callback dispatcher to use it when device reboots + PreferencesManager.saveCallbackDispatcher(context!!, args!) + } + + initializeService(context!!, args) result.success(true) @@ -224,7 +228,9 @@ class BackgroundLocatorPlugin val args: Map? = call.arguments(); // save setting to use it when device reboots - PreferencesManager.saveSettings(context!!, args) + if(args != null){ + PreferencesManager.saveSettings(context!!, args!) + } registerLocator(context!!, args, @@ -241,7 +247,10 @@ class BackgroundLocatorPlugin } val args: Map? = call.arguments() - updateNotificationText(context!!, args) + if(args != null){ + updateNotificationText(context!!, args!) + } + result.success(true) } else -> result.notImplemented() From eeda67f992754381c658a44768c6586e74ecddad Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:20:57 -0300 Subject: [PATCH 09/18] teste --- .../BackgroundLocatorPlugin.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index c6d50316..8ba67db6 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -212,29 +212,29 @@ class BackgroundLocatorPlugin override fun onMethodCall(call: MethodCall, result: Result) { when (call.method) { Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { - val args: Map? = call.arguments() + val args: Map? = call.arguments(), if(args != null){ // save callback dispatcher to use it when device reboots - PreferencesManager.saveCallbackDispatcher(context!!, args!) + PreferencesManager.saveCallbackDispatcher(context!!, args!), } - initializeService(context!!, args) - result.success(true) + initializeService(context!!, args), + result.success(true), } Keys.METHOD_PLUGIN_REGISTER_LOCATION_UPDATE -> { - val args: Map? = call.arguments(); + val args: Map? = call.arguments(), // save setting to use it when device reboots if(args != null){ - PreferencesManager.saveSettings(context!!, args!) + PreferencesManager.saveSettings(context!!, args!), } registerLocator(context!!, args, - result) + result), } Keys.METHOD_PLUGIN_UN_REGISTER_LOCATION_UPDATE -> { unRegisterPlugin(context!!, result) @@ -281,7 +281,7 @@ class BackgroundLocatorPlugin val notificationCallback = PreferencesManager.getCallbackHandle(activity!!, Keys.NOTIFICATION_CALLBACK_HANDLE_KEY) if (notificationCallback != null && IsolateHolderService.backgroundEngine != null) { val backgroundChannel = - MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, Keys.BACKGROUND_CHANNEL_ID) + MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!, Keys.BACKGROUND_CHANNEL_ID) activity?.mainLooper?.let { Handler(it) .post { From 40f355e6ce258b254dbccfde9b0aa7b5262d2bf5 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:28:29 -0300 Subject: [PATCH 10/18] =?UTF-8?q?teste=20corre=C3=A7=C3=A3o=20de=20erros?= =?UTF-8?q?=20initPluggable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/background_locator/pluggables/InitPluggable.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt index a33a7ecf..c4cc31d2 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt @@ -19,8 +19,14 @@ class InitPluggable : Pluggable { if (!isInitCallbackCalled) { (PreferencesManager.getCallbackHandle(context, Keys.INIT_CALLBACK_HANDLE_KEY))?.let { initCallback -> val initialDataMap = PreferencesManager.getDataCallback(context, Keys.INIT_DATA_CALLBACK_KEY) - val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, + + var binaryMessenger : BinaryMessenger? = IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger; + + if(binaryMessenger != null){ + val backgroundChannel = MethodChannel(binaryMessenger!, Keys.BACKGROUND_CHANNEL_ID) + } + Handler(context.mainLooper) .post { backgroundChannel.invokeMethod(Keys.BCM_INIT, From e7c5ffc912532a037a2e8ca70a900180afb2b3be Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:34:28 -0300 Subject: [PATCH 11/18] teste --- .../background_locator/BackgroundLocatorPlugin.kt | 14 +++++++------- .../background_locator/pluggables/InitPluggable.kt | 9 +++------ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index 8ba67db6..614d1323 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -212,29 +212,29 @@ class BackgroundLocatorPlugin override fun onMethodCall(call: MethodCall, result: Result) { when (call.method) { Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { - val args: Map? = call.arguments(), + val args: Map? = call.arguments() if(args != null){ // save callback dispatcher to use it when device reboots - PreferencesManager.saveCallbackDispatcher(context!!, args!), + PreferencesManager.saveCallbackDispatcher(context!!, args!) } - initializeService(context!!, args), - result.success(true), + initializeService(context!!, args) + result.success(true) } Keys.METHOD_PLUGIN_REGISTER_LOCATION_UPDATE -> { - val args: Map? = call.arguments(), + val args: Map? = call.arguments() // save setting to use it when device reboots if(args != null){ - PreferencesManager.saveSettings(context!!, args!), + PreferencesManager.saveSettings(context!!, args!) } registerLocator(context!!, args, - result), + result) } Keys.METHOD_PLUGIN_UN_REGISTER_LOCATION_UPDATE -> { unRegisterPlugin(context!!, result) diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt index c4cc31d2..7ad39ddd 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt @@ -20,13 +20,10 @@ class InitPluggable : Pluggable { (PreferencesManager.getCallbackHandle(context, Keys.INIT_CALLBACK_HANDLE_KEY))?.let { initCallback -> val initialDataMap = PreferencesManager.getDataCallback(context, Keys.INIT_DATA_CALLBACK_KEY) - var binaryMessenger : BinaryMessenger? = IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger; - - if(binaryMessenger != null){ - val backgroundChannel = MethodChannel(binaryMessenger!, + var binaryMessenger : BinaryMessenger? = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger; + + val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, Keys.BACKGROUND_CHANNEL_ID) - } - Handler(context.mainLooper) .post { backgroundChannel.invokeMethod(Keys.BCM_INIT, From 844e5ddbc47e9d11994b455f13a26653289dcfc0 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:39:51 -0300 Subject: [PATCH 12/18] teste --- .../app/background_locator/BackgroundLocatorPlugin.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index 614d1323..2b686e4e 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -216,7 +216,7 @@ class BackgroundLocatorPlugin if(args != null){ // save callback dispatcher to use it when device reboots - PreferencesManager.saveCallbackDispatcher(context!!, args!) + PreferencesManager.saveCallbackDispatcher(context!! , args!) } @@ -229,7 +229,7 @@ class BackgroundLocatorPlugin // save setting to use it when device reboots if(args != null){ - PreferencesManager.saveSettings(context!!, args!) + PreferencesManager.saveSettings(context!! , args!) } registerLocator(context!!, @@ -248,7 +248,7 @@ class BackgroundLocatorPlugin val args: Map? = call.arguments() if(args != null){ - updateNotificationText(context!!, args!) + updateNotificationText(context!! , args!) } result.success(true) @@ -281,7 +281,7 @@ class BackgroundLocatorPlugin val notificationCallback = PreferencesManager.getCallbackHandle(activity!!, Keys.NOTIFICATION_CALLBACK_HANDLE_KEY) if (notificationCallback != null && IsolateHolderService.backgroundEngine != null) { val backgroundChannel = - MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!, Keys.BACKGROUND_CHANNEL_ID) + MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger! , Keys.BACKGROUND_CHANNEL_ID) activity?.mainLooper?.let { Handler(it) .post { From cd44c3dd2c7599d9e8891cdb1690f68ab1ab9687 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:41:50 -0300 Subject: [PATCH 13/18] teste --- .../rekab/app/background_locator/BackgroundLocatorPlugin.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index 2b686e4e..23341651 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -248,7 +248,7 @@ class BackgroundLocatorPlugin val args: Map? = call.arguments() if(args != null){ - updateNotificationText(context!! , args!) + updateNotificationText(context! , args!) } result.success(true) From db235f76844ef206d5a00c9bda13d3309ea8bb9a Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:44:04 -0300 Subject: [PATCH 14/18] teste --- .../BackgroundLocatorPlugin.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index 23341651..cc1f92c0 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -214,10 +214,9 @@ class BackgroundLocatorPlugin Keys.METHOD_PLUGIN_INITIALIZE_SERVICE -> { val args: Map? = call.arguments() - if(args != null){ // save callback dispatcher to use it when device reboots - PreferencesManager.saveCallbackDispatcher(context!! , args!) - } + PreferencesManager.saveCallbackDispatcher(context!! , args!!) + @@ -228,9 +227,8 @@ class BackgroundLocatorPlugin val args: Map? = call.arguments() // save setting to use it when device reboots - if(args != null){ - PreferencesManager.saveSettings(context!! , args!) - } + + PreferencesManager.saveSettings(context!!, args!!) registerLocator(context!!, args, @@ -247,9 +245,9 @@ class BackgroundLocatorPlugin } val args: Map? = call.arguments() - if(args != null){ - updateNotificationText(context! , args!) - } + + updateNotificationText(context!!, args!!) + result.success(true) } From a5a1b9830fd0c3f086e0cd6211a122d72143c12b Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 09:47:00 -0300 Subject: [PATCH 15/18] =?UTF-8?q?corre=C3=A7=C3=A3o=20de=20erros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rekab/app/background_locator/BackgroundLocatorPlugin.kt | 2 +- .../app/background_locator/pluggables/DisposePluggable.kt | 2 +- .../rekab/app/background_locator/pluggables/InitPluggable.kt | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index cc1f92c0..fda78136 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -279,7 +279,7 @@ class BackgroundLocatorPlugin val notificationCallback = PreferencesManager.getCallbackHandle(activity!!, Keys.NOTIFICATION_CALLBACK_HANDLE_KEY) if (notificationCallback != null && IsolateHolderService.backgroundEngine != null) { val backgroundChannel = - MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger! , Keys.BACKGROUND_CHANNEL_ID) + MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!! , Keys.BACKGROUND_CHANNEL_ID) activity?.mainLooper?.let { Handler(it) .post { diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt index 69358109..e13e431d 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/DisposePluggable.kt @@ -14,7 +14,7 @@ class DisposePluggable : Pluggable { override fun onServiceDispose(context: Context) { (PreferencesManager.getCallbackHandle(context, Keys.DISPOSE_CALLBACK_HANDLE_KEY))?.let { disposeCallback -> - val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, + val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!!, Keys.BACKGROUND_CHANNEL_ID) Handler(context.mainLooper) .post { diff --git a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt index 7ad39ddd..a70b5cdd 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/pluggables/InitPluggable.kt @@ -20,9 +20,8 @@ class InitPluggable : Pluggable { (PreferencesManager.getCallbackHandle(context, Keys.INIT_CALLBACK_HANDLE_KEY))?.let { initCallback -> val initialDataMap = PreferencesManager.getDataCallback(context, Keys.INIT_DATA_CALLBACK_KEY) - var binaryMessenger : BinaryMessenger? = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger; - val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, + val backgroundChannel = MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!!, Keys.BACKGROUND_CHANNEL_ID) Handler(context.mainLooper) .post { From a0a9c2c0047dad1cde796ea3fd9f2608d163529a Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 10:04:07 -0300 Subject: [PATCH 16/18] =?UTF-8?q?corre=C3=A7=C3=A3o=20de=20erros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rekab/app/background_locator/BackgroundLocatorPlugin.kt | 2 +- .../kotlin/rekab/app/background_locator/IsolateHolderService.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt index fda78136..0c431a85 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/BackgroundLocatorPlugin.kt @@ -270,7 +270,7 @@ class BackgroundLocatorPlugin channel?.setMethodCallHandler(plugin) } - override fun onNewIntent(intent: Intent?): Boolean { + override fun onNewIntent(intent: Intent): Boolean { if (intent?.action != Keys.NOTIFICATION_ACTION) { // this is not our notification return false diff --git a/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderService.kt b/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderService.kt index a5dc9e41..dc6af79a 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderService.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderService.kt @@ -266,7 +266,7 @@ class IsolateHolderService : MethodChannel.MethodCallHandler, LocationUpdateList if (backgroundEngine != null) { val backgroundChannel = - MethodChannel(backgroundEngine?.dartExecutor?.binaryMessenger, Keys.BACKGROUND_CHANNEL_ID) + MethodChannel(backgroundEngine?.dartExecutor?.binaryMessenger!!, Keys.BACKGROUND_CHANNEL_ID) Handler(context.mainLooper) .post { Log.d("plugin", "sendLocationEvent $result") From 338ad7969ffc79942fe19dd226c534fab0cae89d Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 10:07:38 -0300 Subject: [PATCH 17/18] bug fixed for android sdk 31 --- .../rekab/app/background_locator/IsolateHolderExtension.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderExtension.kt b/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderExtension.kt index 9c0f65d0..58896a36 100644 --- a/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderExtension.kt +++ b/android/src/main/kotlin/rekab/app/background_locator/IsolateHolderExtension.kt @@ -39,7 +39,7 @@ internal fun IsolateHolderService.startLocatorService(context: Context) { } backgroundChannel = - MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger, + MethodChannel(IsolateHolderService.backgroundEngine?.dartExecutor?.binaryMessenger!!, Keys.BACKGROUND_CHANNEL_ID) backgroundChannel.setMethodCallHandler(this) } From 830989e338b2d7b789dc2ffa2bd407e7a1d92b19 Mon Sep 17 00:00:00 2001 From: caiobraga Date: Mon, 25 Apr 2022 11:53:29 -0300 Subject: [PATCH 18/18] =?UTF-8?q?corre=C3=A7=C3=A3o=20de=20erros?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/location_dto.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/location_dto.dart b/lib/location_dto.dart index c78022fe..512919fd 100644 --- a/lib/location_dto.dart +++ b/lib/location_dto.dart @@ -40,7 +40,7 @@ class LocationDto { json[Keys.ARG_HEADING], json[Keys.ARG_TIME], isLocationMocked, - json[Keys.ARG_PROVIDER], + json[Keys.ARG_PROVIDER] ?? '', ); }