fix: keep the dismiss challenge behind the notification's Dismiss
The ringing notification's Dismiss ended the alarm directly, so a heads-up or the lock screen got round a sum or hold challenge. With a challenge set, Dismiss now opens the ring screen. Snooze is shown only while snoozes are left, since a refused snooze dismisses.
This commit is contained in:
1 parent
4d29669222
commit
b883554dc4
2 files changed
+22
-9
No files matched your search
@@ -121,7 +121,7 @@ class AlarmRingService : Service() {
|
||||
startForeground(
|
||||
RingNotifications.ringing(
|
||||
context = this,
|
||||
alarm = session.alarm,
|
||||
session = session,
|
||||
presentation = presentation(),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -11,7 +11,9 @@ import de.jeanlucmakiola.clockula.R
|
||||
import de.jeanlucmakiola.clockula.alarm.AlarmIntents
|
||||
import de.jeanlucmakiola.clockula.alarm.receiver.AlarmActionReceiver
|
||||
import de.jeanlucmakiola.clockula.domain.Alarm
|
||||
import de.jeanlucmakiola.clockula.domain.DismissChallenge
|
||||
import de.jeanlucmakiola.clockula.domain.alarm.RingPresentation
|
||||
import de.jeanlucmakiola.clockula.domain.alarm.RingSession
|
||||
import de.jeanlucmakiola.clockula.ui.ring.AlarmRingActivity
|
||||
import java.time.Instant as JavaInstant
|
||||
import java.time.LocalTime
|
||||
@@ -95,12 +97,20 @@ object RingNotifications {
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
/** The ringing notification, presented as [presentation] says the platform allows. */
|
||||
/**
|
||||
* The ringing notification, presented as [presentation] says the platform allows.
|
||||
*
|
||||
* Its actions never get round the ring screen's rules. Snooze appears only
|
||||
* while snoozes are left, since a refused snooze dismisses; and an alarm
|
||||
* with a dismiss challenge has its Dismiss open the ring screen, where the
|
||||
* challenge is, rather than end the alarm from a heads-up or the lock screen.
|
||||
*/
|
||||
fun ringing(
|
||||
context: Context,
|
||||
alarm: Alarm,
|
||||
session: RingSession,
|
||||
presentation: RingPresentation,
|
||||
): Notification {
|
||||
val alarm = session.alarm
|
||||
val show = showPendingIntent(context)
|
||||
val builder = NotificationCompat.Builder(context, RING_CHANNEL_ID)
|
||||
.setSmallIcon(R.drawable.ic_notification)
|
||||
@@ -112,16 +122,19 @@ object RingNotifications {
|
||||
.setOngoing(true)
|
||||
.setAutoCancel(false)
|
||||
.setContentIntent(show)
|
||||
.addAction(
|
||||
if (session.canSnooze) {
|
||||
builder.addAction(
|
||||
R.drawable.ic_notification,
|
||||
context.getString(R.string.alarm_action_snooze),
|
||||
actionPendingIntent(context, AlarmIntents.ACTION_SNOOZE, AlarmIntents.REQUEST_SNOOZE, alarm.id),
|
||||
)
|
||||
.addAction(
|
||||
R.drawable.ic_notification,
|
||||
context.getString(R.string.alarm_action_dismiss),
|
||||
actionPendingIntent(context, AlarmIntents.ACTION_DISMISS, AlarmIntents.REQUEST_DISMISS, alarm.id),
|
||||
)
|
||||
}
|
||||
val dismiss = if (session.settings.dismissChallenge == DismissChallenge.NONE) {
|
||||
actionPendingIntent(context, AlarmIntents.ACTION_DISMISS, AlarmIntents.REQUEST_DISMISS, alarm.id)
|
||||
} else {
|
||||
show
|
||||
}
|
||||
builder.addAction(R.drawable.ic_notification, context.getString(R.string.alarm_action_dismiss), dismiss)
|
||||
|
||||
if (presentation.useFullScreenIntent) builder.setFullScreenIntent(show, true)
|
||||
return builder.build()
|
||||
|
||||
Reference in new issue
Block a user