diff --git a/build.gradle b/build.gradle index 7a3dee820..a43325925 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ allprojects { ext.issueUrl = 'https://github.com/' + githubRepoName + '/issues' ext.website = 'http://radar-base.org' - version = "1.2.4-SNAPSHOT" + version = "1.2.4" group = 'org.radarbase' ext.versionCode = 52 diff --git a/radar-commons-android/src/main/java/org/radarbase/android/util/PermissionHandler.kt b/radar-commons-android/src/main/java/org/radarbase/android/util/PermissionHandler.kt index 17c3e8e61..5530c2b8e 100644 --- a/radar-commons-android/src/main/java/org/radarbase/android/util/PermissionHandler.kt +++ b/radar-commons-android/src/main/java/org/radarbase/android/util/PermissionHandler.kt @@ -128,23 +128,10 @@ open class PermissionHandler( } private fun requestBackgroundLocationPermissions() { - alertDialog { - setTitle(R.string.enable_location_title) - setMessage(R.string.enable_location_background) - setPositiveButton(android.R.string.ok) { dialog, _ -> - dialog.dismiss() - requestPermissions(setOf(ACCESS_BACKGROUND_LOCATION_COMPAT)) - } - setNegativeButton(android.R.string.cancel) { dialog, _ -> - dialog.cancel() - requestPermissions() - } - show() - } + requestPermissions(setOf(ACCESS_BACKGROUND_LOCATION_COMPAT)) } private fun requestLocationPermissions(locationPermissions: Set) { - alertDialog { setView(R.layout.location_dialog) setPositiveButton(android.R.string.ok) { dialog, _ -> @@ -205,8 +192,7 @@ open class PermissionHandler( private fun requestLocationProvider() { alertDialog { - setTitle(R.string.enable_location_title) - setMessage(R.string.enable_location_instruction) + setView(R.layout.location_dialog) setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS) @@ -216,17 +202,26 @@ open class PermissionHandler( dialog.cancel() requestPermissions() } - setIcon(android.R.drawable.ic_dialog_alert) } } private fun requestSystemWindowPermissions() { // Show alert dialog to the user saying a separate permission is needed // Launch the settings activity if the user prefers - Intent( - Settings.ACTION_MANAGE_OVERLAY_PERMISSION, - Uri.parse("package:" + activity.packageName) - ).startActivityForResult(ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE) + alertDialog { + setView(R.layout.system_window_dialog) + setPositiveButton(android.R.string.ok) { dialog, _ -> + dialog.dismiss() + Intent( + Settings.ACTION_MANAGE_OVERLAY_PERMISSION, + Uri.parse("package:" + activity.packageName) + ).startActivityForResult(ACTION_MANAGE_OVERLAY_PERMISSION_REQUEST_CODE) + } + setNegativeButton(android.R.string.cancel) { dialog, _ -> + dialog.cancel() + requestPermissions() + } + } } private fun Intent.startActivityForResult(code: Int) { @@ -242,16 +237,25 @@ open class PermissionHandler( @SuppressLint("BatteryLife") private fun requestDisableBatteryOptimization() { - Intent( - Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, - Uri.parse("package:" + activity.packageName) - ).startActivityForResult(BATTERY_OPT_CODE) + alertDialog { + setView(R.layout.disable_battery_optimization_dialog) + setPositiveButton(android.R.string.ok) { dialog, _ -> + dialog.dismiss() + Intent( + Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, + Uri.parse("package:" + activity.packageName) + ).startActivityForResult(BATTERY_OPT_CODE) + } + setNegativeButton(android.R.string.cancel) { dialog, _ -> + dialog.cancel() + requestPermissions() + } + } } private fun requestPackageUsageStats() { alertDialog { - setTitle(R.string.enable_package_usage_title) - setMessage(R.string.enable_package_usage) + setView(R.layout.usage_tracking_dialog) setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() var intent = Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS) @@ -264,7 +268,6 @@ open class PermissionHandler( dialog.cancel() requestPermissions() } - setIcon(android.R.drawable.ic_dialog_alert) } } diff --git a/radar-commons-android/src/main/res/drawable/baseline_apps_green_700_48dp.xml b/radar-commons-android/src/main/res/drawable/baseline_apps_green_700_48dp.xml new file mode 100644 index 000000000..e9fdb61f4 --- /dev/null +++ b/radar-commons-android/src/main/res/drawable/baseline_apps_green_700_48dp.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/radar-commons-android/src/main/res/drawable/baseline_battery_alert_green_700_48dp.xml b/radar-commons-android/src/main/res/drawable/baseline_battery_alert_green_700_48dp.xml new file mode 100644 index 000000000..dda78069a --- /dev/null +++ b/radar-commons-android/src/main/res/drawable/baseline_battery_alert_green_700_48dp.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/radar-commons-android/src/main/res/drawable/baseline_warning_yellow_700_48dp.xml b/radar-commons-android/src/main/res/drawable/baseline_warning_yellow_700_48dp.xml new file mode 100644 index 000000000..81ed5dcb1 --- /dev/null +++ b/radar-commons-android/src/main/res/drawable/baseline_warning_yellow_700_48dp.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/radar-commons-android/src/main/res/layout/disable_battery_optimization_dialog.xml b/radar-commons-android/src/main/res/layout/disable_battery_optimization_dialog.xml new file mode 100644 index 000000000..7a4b03af2 --- /dev/null +++ b/radar-commons-android/src/main/res/layout/disable_battery_optimization_dialog.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/radar-commons-android/src/main/res/layout/location_dialog.xml b/radar-commons-android/src/main/res/layout/location_dialog.xml index 1185a72a2..835227439 100644 --- a/radar-commons-android/src/main/res/layout/location_dialog.xml +++ b/radar-commons-android/src/main/res/layout/location_dialog.xml @@ -16,8 +16,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="32dp" - android:layout_gravity="center" - android:text="@string/location_dialog_title" + android:text="@string/location_bg_dialog_title" + android:textAlignment="center" android:textSize="20sp" android:textStyle="bold" /> @@ -25,14 +25,14 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="32dp" - android:text="@string/location_dialog_message" + android:text="@string/location_bg_dialog_message" /> \ No newline at end of file diff --git a/radar-commons-android/src/main/res/layout/system_window_dialog.xml b/radar-commons-android/src/main/res/layout/system_window_dialog.xml new file mode 100644 index 000000000..783add06c --- /dev/null +++ b/radar-commons-android/src/main/res/layout/system_window_dialog.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/radar-commons-android/src/main/res/layout/usage_tracking_dialog.xml b/radar-commons-android/src/main/res/layout/usage_tracking_dialog.xml new file mode 100644 index 000000000..104d76640 --- /dev/null +++ b/radar-commons-android/src/main/res/layout/usage_tracking_dialog.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/radar-commons-android/src/main/res/values/strings.xml b/radar-commons-android/src/main/res/values/strings.xml index ed34978e0..0736c56b5 100644 --- a/radar-commons-android/src/main/res/values/strings.xml +++ b/radar-commons-android/src/main/res/values/strings.xml @@ -8,21 +8,37 @@ , Failed to login to authorization service, please retry Failed to log in - - Location information is needed to enable Bluetooth Low Energy and/or location tracking as - part of the study. - + + pRMT App uses your \"Location in Background\" + This app collects location data to enable Bluetooth Low Energy and/or location tracking as + part of the study even when the app is closed or not in use. + The researcher(s) only use the collected data in the study you consented to. + + pRMT App uses your \"Location\" + Location information is needed to enable Bluetooth Low Energy and/or location tracking as part of the study. + + Enable \"Usage tracking\" + Enable usage access to keep track of what kind of applications you use. + After click \"OK\", select RADAR pRMT from the list and enable \"Usage access\" + + Enable \"Display over other apps\" + Allow this app to display on top of other apps. + After click \"OK\", select RADAR pRMT from the list and enable \"Display over other apps\". + + + Enable \"No Restrictions\" for background apps + \"No Restrictions for background apps\" means that the battery saver does not restrict app\'s activity. + After click \"OK\", select \"No restrictions\". + + Location information is needed to enable Bluetooth Low Energy and/or location tracking as part of the study. Background location is needed to keep passively collecting data while the app is in the background, either for Bluetooth devices or for actual, relative location. - pRMT App uses your location - This app collects location data to enable Bluetooth Low Energy and/or location tracking as - part of the study even when the app is closed or not in use. - The researcher(s) only use the collected data in the study you consented to. Location]]> Enable usage access to keep track of what kind of applications you use. + Enable location tracking Enable usage tracking