mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 04:16:49 +01:00
Improve background location permission request flow
This commit is contained in:
parent
01cdcc4b6f
commit
9877e24182
@ -57,7 +57,9 @@ public class PermissionsUtils {
|
||||
add(CUSTOM_PERM_NOTIFICATION_SERVICE);
|
||||
add(CUSTOM_PERM_DISPLAY_OVER);
|
||||
add(Manifest.permission.ACCESS_FINE_LOCATION);
|
||||
add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
add(Manifest.permission.ACCESS_BACKGROUND_LOCATION);
|
||||
}
|
||||
}};
|
||||
|
||||
public static ArrayList<PermissionDetails> getRequiredPermissionsList(Activity activity) {
|
||||
@ -205,6 +207,8 @@ public class PermissionsUtils {
|
||||
showNotifyPolicyPermissionsDialog(activity);
|
||||
} else if (permission.equals(CUSTOM_PERM_DISPLAY_OVER)) {
|
||||
showDisplayOverOthersPermissionsDialog(activity);
|
||||
} else if (permission.equals(Manifest.permission.ACCESS_BACKGROUND_LOCATION) && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)) {
|
||||
showBackgroundLocationPermissionsDialog(activity);
|
||||
} else {
|
||||
ActivityCompat.requestPermissions(activity, new String[]{permission}, 0);
|
||||
}
|
||||
@ -289,4 +293,16 @@ public class PermissionsUtils {
|
||||
})
|
||||
.show();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.R)
|
||||
private static void showBackgroundLocationPermissionsDialog(Activity activity) {
|
||||
new MaterialAlertDialogBuilder(activity)
|
||||
.setMessage(activity.getString(R.string.permission_location,
|
||||
activity.getString(R.string.app_name),
|
||||
activity.getPackageManager().getBackgroundPermissionOptionLabel()))
|
||||
.setPositiveButton(R.string.ok, (dialog, id) -> {
|
||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_BACKGROUND_LOCATION}, 0);
|
||||
})
|
||||
.show();
|
||||
}
|
||||
}
|
||||
|
@ -2124,7 +2124,7 @@
|
||||
<string name="permission_granting_mandatory">All these permissions are required and instability might occur if not granted</string>
|
||||
<string name="permission_notification_listener">%1$s needs access to Notifications in order to display them on your watch when your phone\'s screen is off.\n\nPlease tap \'%2$s\' then \'%1$s\' and enable \'Allow Notification Access\', then tap \'Back\' to return to %1$s.</string>
|
||||
<string name="permission_notification_policy_access">%1$s needs access to Do Not Disturb settings in order to honour them on your watch when your phone\'s screen is off.\n\nPlease tap \'%2$s\' then \'%1$s\' and enable \'Allow Do Not Disturb\', then tap \'Back\' to return to %1$s.</string>
|
||||
<string name="permission_location">%1$s needs access to your location in the background to allow it to stay connected to your watch even when your screen is off.\n\nPlease tap \'%2$s\' to agree.</string>
|
||||
<string name="permission_location">%1$s needs access to your location in the background to allow it to stay connected to your watch even when your screen is off.\n\nPlease choose \'%2$s\' in the following screen, then tap \'Back\' to return to %1$s.</string>
|
||||
<string name="permission_display_over_other_apps">%1$s needs permission to display over other apps in order to let Bangle.js watches start activities via intents when %1$s is in the background.\n\nThis can be used to start a music app and play a song, and many other things.\n\nPlease tap \'%2$s\' then \'%1$s\' and enable \'Allow display over other apps\', then tap \'Back\' to return to %1$s.\n\nTo stop %1$s asking for permissions go to \'Settings\' and uncheck \'Check permission status\'.\n\nMake sure to grant %1$s the permissions needed to function as you expect.</string>
|
||||
<string name="error_version_check_extreme_caution">CAUTION: Error when checking version information! You should not continue! Saw version name \"%s\"</string>
|
||||
<string name="require_location_provider">Location must be enabled</string>
|
||||
|
Loading…
Reference in New Issue
Block a user