diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 0b8b7998..1032b29b 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -26,6 +26,9 @@
+
+
+
-
+
+
+
+
+
+
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceBroadcastReceiver.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceBroadcastReceiver.kt
index e9accb04..8fc1faae 100644
--- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceBroadcastReceiver.kt
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceBroadcastReceiver.kt
@@ -1,32 +1,4 @@
-/*
- * Copyright (c) 2018 Razeware LLC
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
- * distribute, sublicense, create a derivative work, and/or sell copies of the
- * Software in any work that is designed, intended, or marketed for pedagogical or
- * instructional purposes related to programming, coding, application development,
- * or information technology. Permission for such use, copying, modification,
- * merger, publication, distribution, sublicensing, creation of derivative works,
- * or sale is expressly withheld.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
+
package com.cloud.diplomaticquarterapp.geofence
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceErrorMessages.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceErrorMessages.kt
index e85c7ea3..4890f7cb 100755
--- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceErrorMessages.kt
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofenceErrorMessages.kt
@@ -1,32 +1,4 @@
-/*
- * Copyright (c) 2018 Razeware LLC
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * Notwithstanding the foregoing, you may not use, copy, modify, merge, publish,
- * distribute, sublicense, create a derivative work, and/or sell copies of the
- * Software in any work that is designed, intended, or marketed for pedagogical or
- * instructional purposes related to programming, coding, application development,
- * or information technology. Permission for such use, copying, modification,
- * merger, publication, distribution, sublicensing, creation of derivative works,
- * or sale is expressly withheld.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
+
package com.cloud.diplomaticquarterapp.geofence
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofencingRebootBroadcastReceiver.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofencingRebootBroadcastReceiver.kt
index 641e1522..08a0c93f 100644
--- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofencingRebootBroadcastReceiver.kt
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/GeofencingRebootBroadcastReceiver.kt
@@ -1,21 +1,27 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-package io.flutter.plugins.geofencing
+
+package com.cloud.diplomaticquarterapp.geofence
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
-import android.util.Log
+import android.os.Handler
+import android.os.Message
import com.cloud.diplomaticquarterapp.geofence.HMG_Geofence
+import com.cloud.diplomaticquarterapp.utils.HMGUtils
-class GeofencingRebootBroadcastReceiver : BroadcastReceiver() {
+class GeofencingRebootBroadcastReceiver : BroadcastReceiver(){
override fun onReceive(context: Context, intent: Intent) {
- if (intent.action.equals("android.intent.action.BOOT_COMPLETED")) {
+
+ if (Intent.ACTION_BOOT_COMPLETED.equals(intent.action)) {
+ val pref = context.getSharedPreferences(PREFS_STORAGE, Context.MODE_PRIVATE)
+ pref.edit().putString("REBOOT_DETECTED","YES").apply()
+
HMG_Geofence.shared(context).unRegisterAll { status, exception ->
- HMG_Geofence.shared(context).re
+ val geoZones = HMGUtils.getGeoZonesFromPreference(context)
+ HMG_Geofence.shared(context).register(geoZones)
}
}
}
+
}
\ No newline at end of file
diff --git a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/HMG_Geofence.kt b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/HMG_Geofence.kt
index fbef8749..4d2c48b3 100644
--- a/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/HMG_Geofence.kt
+++ b/android/app/src/main/kotlin/com/cloud/diplomaticquarterapp/geofence/HMG_Geofence.kt
@@ -36,6 +36,7 @@ enum class GeofenceTransition(val value: Int) {
const val PREFS_STORAGE = "FlutterSharedPreferences"
const val PREF_KEY_SUCCESS = "HMG_GEOFENCE_SUCCESS"
const val PREF_KEY_FAILED = "HMG_GEOFENCE_FAILED"
+const val PREF_KEY_HMG_ZONES = "flutter.hmg-geo-fences"
class HMG_Geofence {
// https://developer.android.com/training/location/geofencing#java
@@ -69,6 +70,8 @@ class HMG_Geofence {
}
fun register(geoZones: List){
+ if (geoZones.isEmpty())
+ return
fun buildGeofencingRequest(geofences: List): GeofencingRequest {
return GeofencingRequest.Builder()
@@ -92,7 +95,7 @@ class HMG_Geofence {
geofencingClient
.addGeofences(buildGeofencingRequest(geofences), geofencePendingIntent)
.addOnSuccessListener {
- saveGeofenceResults(geofences.map { it.requestId }, listOf())
+ saveActiveGeofence(geofences.map { it.requestId }, listOf())
}
.addOnFailureListener {
print(it.localizedMessage)
@@ -103,6 +106,8 @@ class HMG_Geofence {
fun unRegisterAll(completion: (status: Boolean, exception:Exception?) -> Unit){
getActiveGeofences({ success ->
+ val mList = success.toMutableList()
+ mList.add("12345")
geofencingClient
.removeGeofences(success)
.addOnSuccessListener {
@@ -111,17 +116,22 @@ class HMG_Geofence {
.addOnFailureListener {
completion(false, it)
}
+ removeActiveGeofences()
}, { failed ->
// Nothing to do with failed geofences.
})
}
- fun saveGeofenceResults(success: List, failed: List){
+ fun saveActiveGeofence(success: List, failed: List){
val jsonSuccess = gson.toJson(success)
val jsonFailure = gson.toJson(failed)
preferences.edit().putString(PREF_KEY_SUCCESS, jsonSuccess).apply()
preferences.edit().putString(PREF_KEY_FAILED, jsonFailure).apply()
+ }
+ fun removeActiveGeofences(){
+ preferences.edit().putString(PREF_KEY_SUCCESS,"[]").apply()
+ preferences.edit().putString(PREF_KEY_FAILED,"[]").apply()
}
fun getActiveGeofences(success: (success: List) -> Unit, failure: ((failed: List) -> Unit)?){
@@ -144,7 +154,7 @@ class HMG_Geofence {
}
fun getPatientID():Int?{
- val profileJson = preferences.getString("flutter.user-profile", "{}")
+ val profileJson = preferences.getString("flutter.imei-user-data", "{}")
val type = object : TypeToken