Skip to content

Show next alert time in notification #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class Settings(context: Context) : PersistentStorageBase(context) {
val snoozePresetsRaw: String
get() = getString(SNOOZE_PRESET_KEY, DEFAULT_SNOOZE_PRESET)

val displayNextAlertTime: Boolean
get() = getBoolean(DISPLAY_NEXT_ALERT_TIME, false)

val snoozePresets: LongArray
get() {
var ret = PreferenceUtils.parseSnoozePresets(snoozePresetsRaw)
Expand Down Expand Up @@ -438,6 +441,7 @@ class Settings(context: Context) : PersistentStorageBase(context) {
private const val CALENDAR_IS_HANDLED_KEY_PREFIX = "calendar_handled_"

private const val SNOOZE_PRESET_KEY = "pref_snooze_presets" //"15m, 1h, 4h, 1d"
private const val DISPLAY_NEXT_ALERT_TIME = "pref_display_next_alert_time" //false
private const val VIEW_AFTER_EDIT_KEY = "show_event_after_reschedule" // true
private const val ENABLE_REMINDERS_KEY = "enable_reminding_key" // false
private const val REMINDER_INTERVAL_PATTERN_KEY = "remind_interval_key_pattern" // "10m"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,12 @@ fun EventRecord.nextAlarmTime(currentTime: Long): Long {
}

return ret
}
}

fun EventRecord.getNextAlertTimeAfter(anchor: Long): Long? {
val futureReminders = eventRecord
.reminders
.map { eventRecord.startTime - it.millisecondsBefore }
.filter { it > anchor }
return futureReminders.maxOrNull()
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ class EventFormatter(

sb.append(formatDateTimeOneLine(event, false))

if (Settings(ctx).displayNextAlertTime) {
val nextAlertTime = todo("need EventRecord here").getNextAlertTimeAfter(event.displayedStartTime)
if (nextAlertTime != null) {
val duration = nextAlertTime - clock.currentTimeMillis()
if (duration > 0) {
sb.append(" (")
sb.append(ctx.getString(R.string.next_alert_in))
Copy link
Owner

@williscool williscool Jun 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this R string exist yet?

sb.append(" ")
sb.append(formatTimeDuration(duration, 60))
sb.append(")")
}
}
}

if (event.location != "") {
sb.append("\n")
sb.append(ctx.resources.getString(R.string.location));
Expand Down
Loading