feat(android): add alarm sound and vibration to task reminders

Use default alarm ringtone with USAGE_ALARM audio attributes so
reminders play even when phone is on silent. Add vibration pattern
and change notification category from REMINDER to ALARM.

Fixes #5603
This commit is contained in:
Johannes Millan 2026-01-04 12:45:00 +01:00
parent 12e68cdb0e
commit b7cbef2f79

View file

@ -6,6 +6,8 @@ import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.media.AudioAttributes
import android.media.RingtoneManager
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
@ -26,6 +28,14 @@ object ReminderNotificationHelper {
fun createChannel(context: Context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val alarmSound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM)
?: RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
val audioAttributes = AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_ALARM)
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
.build()
val channel = NotificationChannel(
CHANNEL_ID,
"Reminders",
@ -34,6 +44,8 @@ object ReminderNotificationHelper {
description = "Task and note reminders"
setShowBadge(true)
enableVibration(true)
vibrationPattern = longArrayOf(0, 500, 200, 500, 200, 500)
setSound(alarmSound, audioAttributes)
}
val notificationManager = context.getSystemService(NotificationManager::class.java)
notificationManager.createNotificationChannel(channel)
@ -132,7 +144,7 @@ object ReminderNotificationHelper {
.setAutoCancel(true)
.addAction(0, "Snooze 10m", snoozePendingIntent)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setCategory(NotificationCompat.CATEGORY_REMINDER)
.setCategory(NotificationCompat.CATEGORY_ALARM)
.build()
try {