mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-10 00:40:38 +01:00
delay notifications by 1 second to avoid glitches at rescheduling and triggering
This commit is contained in:
parent
295c5efe69
commit
d0e98c7e09
@ -107,15 +107,16 @@ fun Context.scheduleEventIn(notifTS: Long, event: Event, activity: SimpleActivit
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val newNotifTS = notifTS + 1000
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
val secondsTillNotification = (notifTS - System.currentTimeMillis()) / 1000
|
val secondsTillNotification = (newNotifTS - System.currentTimeMillis()) / 1000
|
||||||
val msg = String.format(getString(R.string.reminder_triggers_in), formatSecondsToTimeString(secondsTillNotification.toInt()))
|
val msg = String.format(getString(R.string.reminder_triggers_in), formatSecondsToTimeString(secondsTillNotification.toInt()))
|
||||||
activity.toast(msg)
|
activity.toast(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
val pendingIntent = getNotificationIntent(applicationContext, event)
|
val pendingIntent = getNotificationIntent(applicationContext, event)
|
||||||
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
val alarmManager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
|
||||||
AlarmManagerCompat.setExactAndAllowWhileIdle(alarmManager, AlarmManager.RTC_WAKEUP, notifTS, pendingIntent)
|
AlarmManagerCompat.setExactAndAllowWhileIdle(alarmManager, AlarmManager.RTC_WAKEUP, newNotifTS, pendingIntent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.cancelNotification(id: Int) {
|
fun Context.cancelNotification(id: Int) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user