From fb90dca6dba3ea8df0a41d62de03c62618396842 Mon Sep 17 00:00:00 2001 From: millanp Date: Mon, 19 Feb 2024 17:28:37 -0800 Subject: [PATCH] Ask for alarm and notification permissions to fix #1106 --- .../src/main/AndroidManifest.xml | 2 ++ .../android/ui/TripInfoActivity.java | 20 ++++++++++++++----- .../android/util/PermissionUtils.java | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/onebusaway-android/src/main/AndroidManifest.xml b/onebusaway-android/src/main/AndroidManifest.xml index 594a251c2..98ace5da4 100644 --- a/onebusaway-android/src/main/AndroidManifest.xml +++ b/onebusaway-android/src/main/AndroidManifest.xml @@ -45,6 +45,8 @@ + + = Build.VERSION_CODES.TIRAMISU) { + if (!TripService.canScheduleExactAlarms(getActivity())) { + showRequestAlarmsPermissionDialog(getActivity()); + return; + } + ActivityCompat.requestPermissions(this.getActivity(), + new String[] {Manifest.permission.POST_NOTIFICATIONS}, + NOTIFICATION_PERMISSION_REQUEST); } View view = getView(); diff --git a/onebusaway-android/src/main/java/org/onebusaway/android/util/PermissionUtils.java b/onebusaway-android/src/main/java/org/onebusaway/android/util/PermissionUtils.java index 2e4fc5182..b7a809cd7 100644 --- a/onebusaway-android/src/main/java/org/onebusaway/android/util/PermissionUtils.java +++ b/onebusaway-android/src/main/java/org/onebusaway/android/util/PermissionUtils.java @@ -30,6 +30,7 @@ public class PermissionUtils { public static final int SAVE_BACKUP_PERMISSION_REQUEST = 2; public static final int RESTORE_BACKUP_PERMISSION_REQUEST = 3; public static final int BACKGROUND_LOCATION_PERMISSION_REQUEST = 4; + public static final int NOTIFICATION_PERMISSION_REQUEST = 5; public static final String[] LOCATION_PERMISSIONS = { Manifest.permission.ACCESS_FINE_LOCATION,