From 48ff63405cbbe7e40400f070f486157d21b97b18 Mon Sep 17 00:00:00 2001 From: MiMoHo <37556964+MiMoHo@users.noreply.github.com> Date: Fri, 3 Jul 2026 20:56:55 +0200 Subject: [PATCH] fix: show alarm label in upcoming alarm notification The upcoming-alarm notification only displayed the day and time from getClosestEnabledAlarmString, which is shared with the clock UI and digital widget and intentionally omits the label. Look up the specific alarm by its ALARM_ID (already passed via the PendingIntent) in UpcomingAlarmReceiver and append its label to the notification content text when present, leaving the shared helper untouched. Closes #183 --- CHANGELOG.md | 3 +++ .../fossify/clock/receivers/UpcomingAlarmReceiver.kt | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbc4a8614..fd88ad3ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed +- Added the alarm label to the upcoming alarm notification ([#183]) ## [1.6.0] - 2026-01-30 ### Added @@ -106,6 +108,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#107]: https://github.com/FossifyOrg/Clock/issues/107 [#144]: https://github.com/FossifyOrg/Clock/issues/144 [#158]: https://github.com/FossifyOrg/Clock/issues/158 +[#183]: https://github.com/FossifyOrg/Clock/issues/183 [#206]: https://github.com/FossifyOrg/Clock/issues/206 [#207]: https://github.com/FossifyOrg/Clock/issues/207 [#247]: https://github.com/FossifyOrg/Clock/issues/247 diff --git a/app/src/main/kotlin/org/fossify/clock/receivers/UpcomingAlarmReceiver.kt b/app/src/main/kotlin/org/fossify/clock/receivers/UpcomingAlarmReceiver.kt index fbc804b05..ae0ffb509 100644 --- a/app/src/main/kotlin/org/fossify/clock/receivers/UpcomingAlarmReceiver.kt +++ b/app/src/main/kotlin/org/fossify/clock/receivers/UpcomingAlarmReceiver.kt @@ -8,6 +8,7 @@ import android.content.Context import android.content.Intent import androidx.core.app.NotificationCompat import org.fossify.clock.R +import org.fossify.clock.extensions.dbHelper import org.fossify.clock.extensions.getClosestEnabledAlarmString import org.fossify.clock.extensions.getOpenAlarmTabIntent import org.fossify.clock.extensions.getSkipUpcomingAlarmPendingIntent @@ -35,6 +36,7 @@ class UpcomingAlarmReceiver : BroadcastReceiver() { } private fun showUpcomingAlarmNotification(context: Context, alarmId: Int) { + val label = context.dbHelper.getAlarmWithId(alarmId)?.label.orEmpty() context.getClosestEnabledAlarmString { alarmString -> val notificationManager = context.notificationManager NotificationChannel( @@ -52,9 +54,15 @@ class UpcomingAlarmReceiver : BroadcastReceiver() { alarmId = alarmId, notificationId = UPCOMING_ALARM_NOTIFICATION_ID ) + val contentText = if (label.isNotEmpty()) { + "$alarmString - $label" + } else { + alarmString + } + val notification = NotificationCompat.Builder(context, UPCOMING_ALARM_CHANNEL_ID) .setContentTitle(context.getString(R.string.upcoming_alarm)) - .setContentText(alarmString) + .setContentText(contentText) .setSmallIcon(R.drawable.ic_alarm_vector) .setPriority(Notification.PRIORITY_LOW) .addAction(