From d97178dcb1fc913458784dea6de7f5013bd50c73 Mon Sep 17 00:00:00 2001 From: Quentin Hibon Date: Mon, 7 Aug 2023 20:04:28 +0200 Subject: [PATCH] Prompt for notification permission Preparation for the SDK upgrade from 32 to 33. --- uhabits-android/src/main/AndroidManifest.xml | 2 ++ .../activities/habits/edit/EditHabitActivity.kt | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/uhabits-android/src/main/AndroidManifest.xml b/uhabits-android/src/main/AndroidManifest.xml index 9377e42c0..394096470 100644 --- a/uhabits-android/src/main/AndroidManifest.xml +++ b/uhabits-android/src/main/AndroidManifest.xml @@ -22,6 +22,8 @@ + + { binding.nameInput.hint = getString(R.string.measurable_short_example) binding.questionInput.hint = getString(R.string.measurable_question_example) @@ -271,6 +273,14 @@ class EditHabitActivity : AppCompatActivity() { habit.description = binding.notesInput.text.trim().toString() habit.color = color if (reminderHour >= 0) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + requestPermissions( + arrayOf( + android.Manifest.permission.POST_NOTIFICATIONS + ), + 1 + ) + } habit.reminder = Reminder(reminderHour, reminderMin, reminderDays) } else { habit.reminder = null