100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Improvements for Background locations permission explanation
Michael Rademakercbf326fc835a
diff --git a/console/android/GenericApp/app/build.gradle b/console/android/GenericApp/app/build.gradleindex 1deb9ad02..afec78c5e 100644--- a/console/android/GenericApp/app/build.gradle+++ b/console/android/GenericApp/app/build.gradle@@ -4,13 +4,13 @@ apply plugin: 'com.google.gms.google-services'android {compileSdkVersion 30- buildToolsVersion "29.0.3"+ buildToolsVersion "30.0.3"defaultConfig {applicationId "io.openremote.app"minSdkVersion 25targetSdkVersion 30- versionCode 20+ versionCode 21versionName "1.0.3"testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"diff --git a/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.kt b/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.ktindex bfebe74cf..f2ecc1977 100644--- a/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.kt+++ b/console/android/GenericApp/app/src/main/java/io/openremote/app/service/GeofenceProvider.kt@@ -8,6 +8,7 @@ import android.content.Contextimport android.content.Intentimport android.content.pm.PackageManagerimport androidx.appcompat.app.AlertDialog+import androidx.core.app.ActivityCompatimport com.fasterxml.jackson.databind.ObjectMapperimport com.google.android.gms.location.*import io.openremote.app.R@@ -373,12 +374,26 @@ class GeofenceProvider(val context: Context) {LOG.info("Requesting geofence permissions")if (context.checkSelfPermission(ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.Q) {- activity.requestPermissions(- arrayOf(+ if (ActivityCompat.shouldShowRequestPermissionRationale(+ activity,ACCESS_BACKGROUND_LOCATION- ),- locationResponseCode- )+ )+ ) {+ AlertDialog.Builder(activity)+ .setIcon(R.mipmap.ic_launcher)+ .setTitle(R.string.location_background_disabled_title)+ .setMessage(R.string.background_location_alert_body)+ .setNegativeButton(R.string.background_location_decline, null)+ .setPositiveButton(R.string.background_location_accept) { dialog, which ->+ activity.requestPermissions(+ arrayOf(+ ACCESS_BACKGROUND_LOCATION+ ),+ locationResponseCode+ )+ }+ .show()+ }}} else {activity.requestPermissions(@@ -397,20 +412,26 @@ class GeofenceProvider(val context: Context) {if (context.checkSelfPermission(ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED &&context.checkSelfPermission(ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED) {- AlertDialog.Builder(activity)- .setIcon(R.mipmap.ic_launcher)- .setTitle(R.string.background_location_alert_title)- .setMessage(R.string.background_location_alert_body)- .setNegativeButton(R.string.background_location_decline, null)- .setPositiveButton(R.string.background_location_accept) { dialog, which ->- activity.requestPermissions(- arrayOf(- ACCESS_BACKGROUND_LOCATION- ),- locationResponseCode- )- }- .show()+ if (ActivityCompat.shouldShowRequestPermissionRationale(+ activity,+ ACCESS_BACKGROUND_LOCATION+ )+ ) {+ AlertDialog.Builder(activity)+ .setIcon(R.mipmap.ic_launcher)+ .setTitle(R.string.background_location_alert_title)+ .setMessage(R.string.background_location_alert_body)+ .setNegativeButton(R.string.background_location_decline, null)+ .setPositiveButton(R.string.background_location_accept) { dialog, which ->+ activity.requestPermissions(+ arrayOf(+ ACCESS_BACKGROUND_LOCATION+ ),+ locationResponseCode+ )+ }+ .show()+ }}}}diff --git a/console/android/GenericApp/app/src/main/res/values/strings.xml b/console/android/GenericApp/app/src/main/res/values/strings.xmlindex 1919bb167..80d4e5575 100644--- a/console/android/GenericApp/app/src/main/res/values/strings.xml+++ b/console/android/GenericApp/app/src/main/res/values/strings.xml@@ -16,7 +16,8 @@<string name="error_downloading">Error downloading file</string><string name="download_completed">Download completed</string><string name="background_location_alert_title">Background location needed</string>- <string name="background_location_alert_body">In order to signal the server whether the device has entered or exited a geofence, the app needs to get the device\'s location when the app is running in the background.</string>+ <string name="background_location_alert_body">Background location is needed in order to signal the server whether the device has entered or exited a certain location, the app needs to get the device\'s location when the app is running in the background.\nNo location history is stored, only the latest location is saved.\nDo you want to enabled it in the settings?</string>+ <string name="location_background_disabled_title">Background location disabled</string><string name="background_location_decline">No</string><string name="background_location_accept">Yes</string></resources>\ No newline at end of filediff --git a/console/android/GenericApp/build.gradle b/console/android/GenericApp/build.gradleindex 92d351395..efde564c6 100644--- a/console/android/GenericApp/build.gradle+++ b/console/android/GenericApp/build.gradle@@ -1,6 +1,6 @@// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript {- ext.kotlin_version = "1.4.31"+ ext.kotlin_version = "1.4.32"repositories {google()jcenter()